This commit is contained in:
2023-11-07 22:55:34 -06:00
parent c426a84db0
commit f94648c5dd
4 changed files with 67 additions and 45 deletions
+19 -12
View File
@@ -914,7 +914,7 @@ public class MobAI {
switch (mob.getCombatTarget().getObjectType()) {
case PlayerCharacter:
case Mob:
mob.destination = GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
mob.destination = mob.combatTarget.loc;//GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
aiMove(mob, false,mob.getRange() + 1);
break;
case Building:
@@ -1345,18 +1345,16 @@ public class MobAI {
public static void aiMove(Mob mob, boolean isWalking, float offset) {
if(mob.navPath.size() < 1){
if(mob.navPath.isEmpty() || mob.navPath.size() == 1){
NavigationManager.pathfind(mob,mob.destination);
return;
}
if(mob.navPath.get(mob.navPath.size() -1).distanceSquared(mob.destination) > 100){ // goal has moved by at least 10 units, recalculate
NavigationManager.pathfind(mob,mob.destination);
if(mob.isMoving()) {
return;
}
if(mob.isMoving())
return;
Vector3fImmutable PathPoint = mob.navPath.get(0);
if(mob.loc.distanceSquared(mob.navPath.get(0)) < 25) {
if(mob.loc.distanceSquared(mob.destination) > mob.loc.distanceSquared2D(mob.destination)) {
mob.navPath.remove(0);
return;
}
@@ -1372,7 +1370,7 @@ public class MobAI {
if(offset > 0){
PathPoint= Vector3fImmutable.getRandomPointInCircle(PathPoint, offset);
}
mob.endLoc = PathPoint;
MoveToPointMsg msg = new MoveToPointMsg();
@@ -1380,10 +1378,19 @@ public class MobAI {
msg.setSourceID(mob.getObjectUUID());
msg.setStartCoord(mob.loc);
msg.setEndCoord(PathPoint);
msg.setInBuildingFloor(-1);
msg.setInBuilding(-1);
msg.setStartLocType(0);
msg.setInBuildingUUID(0);
Regions region = Regions.getRegionAtLocation(PathPoint);
if(region != null){
msg.setInBuildingFloor(region.room);
msg.setInBuilding(region.level);
msg.setStartLocType(0);
msg.setInBuildingUUID(region.parentBuildingID);
} else{
msg.setInBuildingFloor(-1);
msg.setInBuilding(-1);
msg.setStartLocType(0);
msg.setInBuildingUUID(0);
}
try {