diff --git a/src/engine/ai/MobileFSMManager.java b/src/engine/ai/MobileFSMManager.java index f0fdf7a3..1c52b11c 100644 --- a/src/engine/ai/MobileFSMManager.java +++ b/src/engine/ai/MobileFSMManager.java @@ -8,8 +8,6 @@ package engine.ai; - -import engine.gameManager.SessionManager; import engine.gameManager.ZoneManager; import engine.objects.Mob; import engine.objects.Zone; @@ -17,8 +15,6 @@ import engine.server.MBServerStatics; import engine.util.ThreadUtils; import org.pmw.tinylog.Logger; -import java.util.Random; - public class MobileFSMManager { @@ -68,17 +64,18 @@ public class MobileFSMManager { private void execution() { - //no players online means no mob action required + //Load zone threshold once. + long mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD; while (alive) { - //assign random range of delay between 1ms and 2000ms so mob actions don't appear synchronized - Random r = new Random(); - ThreadUtils.sleep(r.nextInt(2000-1) + 1); + + ThreadUtils.sleep(1); if (System.currentTimeMillis() > mobPulse) { for (Zone zone : ZoneManager.getAllZones()) { + for (Mob mob : zone.zoneMobSet) { try { diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 1e4dc342..10ca5136 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -13,7 +13,6 @@ import engine.Enum; import engine.InterestManagement.HeightMap; import engine.db.archive.DataWarehouse; import engine.gameManager.DbManager; -import engine.gameManager.SessionManager; import engine.gameManager.ZoneManager; import engine.math.Bounds; import engine.math.Vector2f; @@ -26,7 +25,6 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -511,15 +509,5 @@ public class Zone extends AbstractGameObject { public float getWorldAltitude() { return worldAltitude; } - public boolean hasPlayers(){ - for(PlayerCharacter pc : SessionManager.getAllActivePlayers()){ - for(Zone zone : ZoneManager.getAllZonesIn(pc.getLoc())) { - if(zone.equals(this)){ - return true; - } - } - } - return false; - } }