Browse Source

ranged mobs attack at range again

master
FatBoy-DOTC 1 year ago
parent
commit
0e78902ff6
  1. 15
      src/engine/mobileAI/MobAI.java

15
src/engine/mobileAI/MobAI.java

@ -956,10 +956,12 @@ public class MobAI {
try { try {
mob.updateMovementState(); float rangeSquared = mob.getRange() * mob.getRange();
mob.updateLocation(); float distanceSquared = mob.getLoc().distanceSquared2D(mob.getCombatTarget().getLoc());
if(mob.isMoving() == true && distanceSquared < rangeSquared - 50) {
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) { mob.destination = mob.getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0);
} else if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
if (mob.getRange() > 15) { if (mob.getRange() > 15) {
mob.destination = mob.getCombatTarget().getLoc(); mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0); MovementUtilities.moveToLocation(mob, mob.destination, 0);
@ -978,11 +980,10 @@ public class MobAI {
MovementUtilities.moveToLocation(mob, mob.getCombatTarget().getLoc(), 0); MovementUtilities.moveToLocation(mob, mob.getCombatTarget().getLoc(), 0);
break; break;
} }
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == true) {
mob.stopMovement(mob.getLoc());
}
} }
} }
mob.updateMovementState();
mob.updateLocation();
} catch (Exception e) { } catch (Exception e) {
Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget" + " " + e.getMessage()); Logger.info(mob.getObjectUUID() + " " + mob.getName() + " Failed At: chaseTarget" + " " + e.getMessage());
} }

Loading…
Cancel
Save