Browse Source

new chase logic for mobs

master
FatBoy-DOTC 2 years ago
parent
commit
0ee7507467
  1. 35
      src/engine/ai/MobileFSM.java

35
src/engine/ai/MobileFSM.java

@ -5,21 +5,15 @@ @@ -5,21 +5,15 @@
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.ai;
import engine.Enum;
import engine.Enum.DispatchChannel;
import engine.ai.utilities.CombatUtilities;
import engine.ai.utilities.MovementUtilities;
import engine.gameManager.*;
import engine.math.Vector3fImmutable;
import engine.net.DispatchMessage;
import engine.net.client.msg.PerformActionMsg;
import engine.net.client.msg.PowerProjectileMsg;
import engine.net.client.msg.UpdateStateMsg;
import engine.net.client.msg.chat.ChatSystemMsg;
import engine.objects.*;
import engine.powers.ActionsBase;
import engine.powers.PowersBase;
@ -602,7 +596,12 @@ public class MobileFSM { @@ -602,7 +596,12 @@ public class MobileFSM {
private static void CheckMobMovement(Mob mob) {
mob.updateLocation();
if (mob.isPet() == false && mob.isSummonedPet() == false && mob.isNecroPet() == false) {
if (mob.getCombatTarget() == null) {
patrol(mob);
} else {
chaseTarget(mob);
}
} else {
//pet logic
if (mob.playerAgroMap.containsKey(mob.getOwner().getObjectUUID()) == false) {
@ -614,18 +613,8 @@ public class MobileFSM { @@ -614,18 +613,8 @@ public class MobileFSM {
if (CombatUtilities.inRange2D(mob, mob.getOwner(), 10) == false) {
mob.destination = mob.getOwner().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 5);
}
} else {
//chase target
mob.updateMovementState();
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
if (mob.getRange() > 15) {
mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0);
} else {
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange());
}
chaseTarget(mob);
}
}
}
@ -735,4 +724,16 @@ public class MobileFSM { @@ -735,4 +724,16 @@ public class MobileFSM {
aiAgent.setCombatTarget(null);
}
}
private static void chaseTarget(Mob mob) {
mob.updateMovementState();
if (CombatUtilities.inRange2D(mob, mob.getCombatTarget(), mob.getRange()) == false) {
if (mob.getRange() > 15) {
mob.destination = mob.getCombatTarget().getLoc();
MovementUtilities.moveToLocation(mob, mob.destination, 0);
} else {
mob.destination = MovementUtilities.GetDestinationToCharacter(mob, (AbstractCharacter) mob.getCombatTarget());
MovementUtilities.moveToLocation(mob, mob.destination, mob.getRange());
}
}
}
}
Loading…
Cancel
Save