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