method to check if zone has players inside it

mob ai check if zone has no players mobs need not perform actions
This commit is contained in:
2023-03-15 17:17:22 -05:00
parent db71635f16
commit 113d74cffe
2 changed files with 22 additions and 2 deletions
+10 -2
View File
@@ -9,6 +9,7 @@
package engine.ai;
import engine.gameManager.SessionManager;
import engine.gameManager.ZoneManager;
import engine.objects.Mob;
import engine.objects.Zone;
@@ -67,7 +68,10 @@ public class MobileFSMManager {
private void execution() {
//Load zone threshold once.
//no players online means no mob action required
if(SessionManager.getActivePlayerCharacterCount() <= 0){
return;
}
long mobPulse = System.currentTimeMillis() + MBServerStatics.AI_PULSE_MOB_THRESHOLD;
@@ -79,7 +83,11 @@ public class MobileFSMManager {
if (System.currentTimeMillis() > mobPulse) {
for (Zone zone : ZoneManager.getAllZones()) {
//check if any players are in the zone
if(zone.hasPlayers() == false){
//if zone has no players no need for mobs to do anything
return;
}
for (Mob mob : zone.zoneMobSet) {
try {