|
|
@ -26,7 +26,6 @@ import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
public class MobRespawnThread implements Runnable { |
|
|
|
public class MobRespawnThread implements Runnable { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MobRespawnThread() { |
|
|
|
public MobRespawnThread() { |
|
|
|
Logger.info(" MobRespawnThread thread has started!"); |
|
|
|
Logger.info(" MobRespawnThread thread has started!"); |
|
|
|
|
|
|
|
|
|
|
@ -35,9 +34,14 @@ public class MobRespawnThread implements Runnable { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long startTime = System.currentTimeMillis(); |
|
|
|
|
|
|
|
long rollingKeepFraction = (Zone.rollingAvgMobsAliveDepth - 1) / Zone.rollingAvgMobsAliveDepth; |
|
|
|
|
|
|
|
long rollingAddFraction = 1 / Zone.rollingAvgMobsAliveDepth; |
|
|
|
|
|
|
|
|
|
|
|
while (true) { |
|
|
|
while (true) { |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
for (Zone zone : ZoneManager.getAllZones()) { |
|
|
|
for (Zone zone : ZoneManager.getAllZones()) { |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -51,53 +55,64 @@ public class MobRespawnThread implements Runnable { |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int aliveCount = 0; |
|
|
|
int deadCount = 0; |
|
|
|
int deadCount = 0; |
|
|
|
for (Mob mob : zone.zoneMobSet) { |
|
|
|
for (Mob mob : zone.zoneMobSet) { |
|
|
|
if (!mob.isAlive()) { |
|
|
|
if (mob.isAlive()) { |
|
|
|
|
|
|
|
aliveCount = aliveCount + 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
deadCount = deadCount + 1; |
|
|
|
deadCount = deadCount + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (deadCount > Math.floor(zone.zoneMobSet.size() / 2.0)) { |
|
|
|
zone.rollingAvgMobsAlive = |
|
|
|
|
|
|
|
((zone.rollingAvgMobsAlive * (Zone.rollingAvgMobsAliveDepth - 1) + aliveCount) / Zone.rollingAvgMobsAliveDepth); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
if (startTime + ZoneLevel.msDelayToCampLevel < System.currentTimeMillis()) { |
|
|
|
|
|
|
|
if (aliveCount > Math.floor(zone.zoneMobSet.size() / 2.0)) { |
|
|
|
if (zone.levelUpTimer == 0) { |
|
|
|
if (zone.levelUpTimer == 0) { |
|
|
|
zone.levelUpTimer = System.currentTimeMillis(); |
|
|
|
zone.levelUpTimer = System.currentTimeMillis(); |
|
|
|
} |
|
|
|
} else if (zone.levelUpTimer + ZoneLevel.msTolevelUp < System.currentTimeMillis()) { |
|
|
|
else if (zone.levelUpTimer + ZoneLevel.msTolevelUp < System.currentTimeMillis()) { |
|
|
|
|
|
|
|
zone.setCampLvl(zone.getCampLvl() + 1); |
|
|
|
zone.setCampLvl(zone.getCampLvl() + 1); |
|
|
|
|
|
|
|
|
|
|
|
zone.levelUpTimer = 0; |
|
|
|
zone.levelUpTimer = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (aliveCount == 0) { |
|
|
|
else if (deadCount == 0) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (zone.levelDownTimer == 0) { |
|
|
|
if (zone.levelDownTimer == 0) { |
|
|
|
zone.levelDownTimer = System.currentTimeMillis(); |
|
|
|
zone.levelDownTimer = System.currentTimeMillis(); |
|
|
|
} |
|
|
|
} else if (zone.levelDownTimer + ZoneLevel.msToLevelDown < System.currentTimeMillis()) { |
|
|
|
else if (zone.levelDownTimer + ZoneLevel.msToLevelDown < System.currentTimeMillis()) { |
|
|
|
|
|
|
|
if (zone.getCampLvl() > 0) { |
|
|
|
if (zone.getCampLvl() > 0) { |
|
|
|
zone.setCampLvl(zone.getCampLvl() + 1); |
|
|
|
zone.setCampLvl(zone.getCampLvl() + 1); |
|
|
|
|
|
|
|
|
|
|
|
zone.levelDownTimer = 0; |
|
|
|
zone.levelDownTimer = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
|
|
|
|
zone.levelUpTimer = 0; |
|
|
|
zone.levelUpTimer = 0; |
|
|
|
zone.levelDownTimer = 0; |
|
|
|
zone.levelDownTimer = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { |
|
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Manage mob respawn
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if (!Zone.respawnQue.isEmpty() && Zone.lastRespawn + 100 < System.currentTimeMillis()) { |
|
|
|
|
|
|
|
|
|
|
|
Mob respawner = zone.respawnQue.iterator().next(); |
|
|
|
Mob respawner = Zone.respawnQue.iterator().next(); |
|
|
|
|
|
|
|
|
|
|
|
if (respawner == null) |
|
|
|
if (respawner == null) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
respawner.respawn(); |
|
|
|
respawner.respawn(); |
|
|
|
zone.respawnQue.remove(respawner); |
|
|
|
Zone.respawnQue.remove(respawner); |
|
|
|
zone.lastRespawn = System.currentTimeMillis(); |
|
|
|
Zone.lastRespawn = System.currentTimeMillis(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
Logger.error(e); |
|
|
|
Logger.error(e); |
|
|
|
} |
|
|
|
} |
|
|
|