Browse Source

respawn while loop addition

master
FatBoy-DOTC 1 year ago
parent
commit
5e0b4ad763
  1. 4
      src/engine/ai/MobileFSM.java
  2. 20
      src/engine/workthreads/MobRespawnThread.java

4
src/engine/ai/MobileFSM.java

@ -604,7 +604,9 @@ public class MobileFSM {
} }
} else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) { } else if (System.currentTimeMillis() > (aiAgent.deathTime + (aiAgent.spawnTime * 1000))) {
//aiAgent.respawn(); //aiAgent.respawn();
aiAgent.getParentZone().respawnQue.add(aiAgent); if(aiAgent.getParentZone().respawnQue.contains(aiAgent) == false) {
aiAgent.getParentZone().respawnQue.add(aiAgent);
}
} }
} catch(Exception e){ } catch(Exception e){
Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage()); Logger.info(aiAgent.getObjectUUID() + " " + aiAgent.getName() + " Failed At: CheckForRespawn" + " " + e.getMessage());

20
src/engine/workthreads/MobRespawnThread.java

@ -26,6 +26,7 @@ import engine.objects.Zone;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.LongAdder;
/** /**
* Thread blocks until MagicBane dispatch messages are * Thread blocks until MagicBane dispatch messages are
@ -41,24 +42,25 @@ public class MobRespawnThread implements Runnable {
// Instance variables // Instance variables
// Thread constructor // Thread constructor
public MobRespawnThread() { public MobRespawnThread() {
Boolean isAlive = false;
Logger.info(" MobRespawnThread thread has started!"); Logger.info(" MobRespawnThread thread has started!");
} }
@Override @Override
public void run() { public void run() {
for (Zone zone : ZoneManager.getAllZones()) { while(true) {
if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { for (Zone zone : ZoneManager.getAllZones()) {
if (zone.respawnQue.iterator().next() != null) { if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) {
Mob respawner = zone.respawnQue.iterator().next(); if (zone.respawnQue.iterator().next() != null) {
respawner.respawn(); Mob respawner = zone.respawnQue.iterator().next();
zone.respawnQue.remove(respawner); respawner.respawn();
zone.lastRespawn = System.currentTimeMillis(); zone.respawnQue.remove(respawner);
zone.lastRespawn = System.currentTimeMillis();
}
} }
} }
} }

Loading…
Cancel
Save