From 785a5eb7364483d7e802867f765fab6c0cef6aa8 Mon Sep 17 00:00:00 2001 From: kevin Date: Mon, 19 Aug 2024 06:56:44 -0400 Subject: [PATCH] Auto-leveling camp modifications --- .../mobileAI/Threads/MobRespawnThread.java | 37 +++++++++++++++++++ src/engine/objects/Zone.java | 6 ++- src/engine/util/ZoneLevel.java | 5 ++- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/engine/mobileAI/Threads/MobRespawnThread.java b/src/engine/mobileAI/Threads/MobRespawnThread.java index f9714a56..1d0b72fb 100644 --- a/src/engine/mobileAI/Threads/MobRespawnThread.java +++ b/src/engine/mobileAI/Threads/MobRespawnThread.java @@ -40,6 +40,7 @@ public class MobRespawnThread implements Runnable { try { for (Zone zone : ZoneManager.getAllZones()) { + /* if (zone.respawnQue.size() > ZoneLevel.queueLengthToLevelUp) { zone.setCampLvl(zone.getCamplvl() + 1); } @@ -48,6 +49,42 @@ public class MobRespawnThread implements Runnable { zone.getCamplvl() > 0) { zone.setCampLvl(zone.getCamplvl() - 1); } + */ + + int deadCount = 0; + for (Mob mob : zone.zoneMobSet) { + if (!mob.isAlive()) { + deadCount = deadCount + 1; + } + } + + if (deadCount > Math.floor(zone.zoneMobSet.size() / 2.0)) { + if (zone.levelUpTimer == 0) { + zone.levelUpTimer = System.currentTimeMillis(); + } + else if (zone.levelUpTimer + ZoneLevel.msTolevelUp < System.currentTimeMillis()) { + zone.setCampLvl(zone.getCampLvl() + 1); + + zone.levelUpTimer = 0; + } + } + else if (deadCount == 0) { + + if (zone.levelDownTimer == 0) { + zone.levelDownTimer = System.currentTimeMillis(); + } + else if (zone.levelDownTimer + ZoneLevel.msToLevelDown < System.currentTimeMillis()) { + if (zone.getCampLvl() > 0) { + zone.setCampLvl(zone.getCampLvl() + 1); + + zone.levelDownTimer = 0; + } + } + } + else { + zone.levelUpTimer = 0; + zone.levelDownTimer = 0; + } if (zone.respawnQue.isEmpty() == false && zone.lastRespawn + 100 < System.currentTimeMillis()) { diff --git a/src/engine/objects/Zone.java b/src/engine/objects/Zone.java index 89986848..6f37660c 100644 --- a/src/engine/objects/Zone.java +++ b/src/engine/objects/Zone.java @@ -66,6 +66,8 @@ public class Zone extends AbstractGameObject { public static long lastRespawn = 0; private int campLvl = 0; + public long levelUpTimer = 0; + public long levelDownTimer = 0; /** * ResultSet Constructor @@ -121,7 +123,7 @@ public class Zone extends AbstractGameObject { this.campLvl = 0; } - if (this.campLvl > ZoneLevel.campLvlAnnounceThreshold) + //if (this.campLvl > ZoneLevel.campLvlAnnounceThreshold) { ChatSystemMsg chatMsg = new ChatSystemMsg(null, this.getName() + " has reached camp level " + this.campLvl + "! Will anyone contest?!"); chatMsg.setMessageType(2); @@ -130,7 +132,7 @@ public class Zone extends AbstractGameObject { } } - public int getCamplvl() + public int getCampLvl() { return this.campLvl; } diff --git a/src/engine/util/ZoneLevel.java b/src/engine/util/ZoneLevel.java index a8e69890..884f3c2f 100644 --- a/src/engine/util/ZoneLevel.java +++ b/src/engine/util/ZoneLevel.java @@ -15,6 +15,7 @@ public class ZoneLevel { public static final int queueLengthToLevelUp = 5; public static final int msToLevelDown = 60 * 1000; + public static final int msTolevelUp = 60 * 1000; private static final String[] nameMap = { @@ -34,7 +35,7 @@ public class ZoneLevel { public static String getNameSuffix(Zone zone) { try { - return nameMap[zone.getCamplvl()]; + return nameMap[zone.getCampLvl()]; } catch (Exception ignored) { @@ -74,7 +75,7 @@ public class ZoneLevel { if (zone != null) { - modifier += zone.getCamplvl() * modifierPerLevel; + modifier += zone.getCampLvl() * modifierPerLevel; } return modifier;