From 6a4ae0af31543fc5fed257eb32ebc25389077cea Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Thu, 27 Jul 2023 20:03:14 -0500 Subject: [PATCH] created respawnQue for mobs --- src/engine/ai/MobileFSM.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 2e01a8e0..03ef8ef9 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -32,6 +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; @@ -339,6 +341,13 @@ 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 + 1000 > System.currentTimeMillis()){ + respawnQue.get(0).respawn(); + respawnQue.remove(0); + lastRespawn = System.currentTimeMillis(); + } + if (mob == null) return; if (mob.despawned && mob.getMobBase().getLoadID() == 13171) { @@ -532,7 +541,8 @@ public class MobileFSM { } } } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { - aiAgent.respawn(); + //aiAgent.respawn(); + respawnQue.add(aiAgent); } }