diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index d091a047..d4a7180e 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -32,8 +32,8 @@ import java.util.concurrent.ThreadLocalRandom; import static engine.math.FastMath.sqr; public class MobileFSM { - public static ArrayList respawnQue = new ArrayList<>(); - public static long lastRespawn = 0; + + private static void AttackTarget(Mob mob, AbstractWorldObject target) { if (mob == null) return; @@ -342,11 +342,7 @@ public class MobileFSM { public static void DetermineAction(Mob mob) { //always check the respawn que, respawn 1 mob max per second to not flood the client - if(respawnQue.size() > 0 && lastRespawn + 100 < System.currentTimeMillis()){ - respawnQue.get(0).respawn(); - respawnQue.remove(0); - lastRespawn = System.currentTimeMillis(); - } + if (mob == null) return; if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { @@ -555,7 +551,7 @@ public class MobileFSM { } } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { //aiAgent.respawn(); - respawnQue.add(aiAgent); + aiAgent.getParentZone().respawnQue.add(aiAgent); } } diff --git a/src/engine/ai/MobileFSMManager.java b/src/engine/ai/MobileFSMManager.java index 4733567e..6e2accf9 100644 --- a/src/engine/ai/MobileFSMManager.java +++ b/src/engine/ai/MobileFSMManager.java @@ -98,6 +98,11 @@ public class MobileFSMManager { for (Zone zone : ZoneManager.getAllZones()) { + if(zone.respawnQue.size() > 0 && zone.lastRespawn + 100 < System.currentTimeMillis()){ + zone.respawnQue.get(0).respawn(); + zone.respawnQue.remove(0); + zone.lastRespawn = System.currentTimeMillis(); + } for (Mob mob : zone.zoneMobSet) { try { diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index f3a8a8fc..8fbd4990 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -58,7 +58,8 @@ public class Zone extends AbstractGameObject { private String hash; private float worldAltitude = 0; private float seaLevel = 0; - + public static ArrayList respawnQue = new ArrayList<>(); + public static long lastRespawn = 0; /** * ResultSet Constructor */