From d5c219897d6ffc2c8e1b321998c5ef74b62722c6 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Fri, 24 Feb 2023 10:45:46 -0500 Subject: [PATCH] Experience Modifiers added to ConfigManager --- src/engine/Enum.java | 30 -------------- src/engine/gameManager/ConfigManager.java | 12 ++---- src/engine/objects/Experience.java | 50 +++++++++++------------ src/engine/objects/LootTable.java | 3 +- src/engine/objects/Mob.java | 9 ++-- 5 files changed, 32 insertions(+), 72 deletions(-) diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 6c82024c..d2718ab9 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -2643,36 +2643,6 @@ public class Enum { MAGE; } - public enum DropRateType { - EXP_RATE_MOD, - GOLD_RATE_MOD, - DROP_RATE_MOD, - HOT_EXP_RATE_MOD, - HOT_GOLD_RATE_MOD, - HOT_DROP_RATE_MOD; - - public float rate; - - public static void init() { - - for (DropRateType rateType : DropRateType.values()) { - - switch (rateType) { - case EXP_RATE_MOD: - case GOLD_RATE_MOD: - case DROP_RATE_MOD: - rateType.rate = Float.parseFloat(ConfigManager.MB_NORMAL_RATE.getValue()); - break; - case HOT_EXP_RATE_MOD: - case HOT_GOLD_RATE_MOD: - case HOT_DROP_RATE_MOD: - rateType.rate = Float.parseFloat(ConfigManager.MB_HOTZONE_RATE.getValue()); - break; - } - } - } - } - public enum MinionType { AELFBORNGUARD(951,1637, MinionClass.MELEE, "Guard","Aelfborn"), AELFBORNMAGE(952, 1635, MinionClass.MAGE,"Adept","Aelfborn"), diff --git a/src/engine/gameManager/ConfigManager.java b/src/engine/gameManager/ConfigManager.java index f3de52ec..b23ca660 100644 --- a/src/engine/gameManager/ConfigManager.java +++ b/src/engine/gameManager/ConfigManager.java @@ -14,7 +14,6 @@ package engine.gameManager; import engine.Enum; import engine.net.NetMsgHandler; -import engine.server.MBServerStatics; import engine.server.login.LoginServer; import engine.server.world.WorldServer; import org.pmw.tinylog.Logger; @@ -67,8 +66,10 @@ public enum ConfigManager { MB_WORLD_KEYCLONE_MAX, //drop rates - MB_NORMAL_RATE, - MB_HOTZONE_RATE, + MB_NORMAL_EXP_RATE, + MB_NORMAL_DROP_RATE, + MB_HOTZONE_EXP_RATE, + MB_HOTZONE_DROP_RATE, MB_HOTZONE_DURATION, MB_HOTZONE_MIN_LEVEL, @@ -117,11 +118,6 @@ public enum ConfigManager { return false; } - // Setting drop rates - - Logger.info("Setting drop rates..."); - Enum.DropRateType.init(); - // compile regex here Logger.info("Compiling regex"); diff --git a/src/engine/objects/Experience.java b/src/engine/objects/Experience.java index d828c24b..32653186 100644 --- a/src/engine/objects/Experience.java +++ b/src/engine/objects/Experience.java @@ -11,6 +11,7 @@ package engine.objects; import engine.Enum; import engine.Enum.TargetColor; +import engine.gameManager.ConfigManager; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; import engine.server.MBServerStatics; @@ -332,12 +333,7 @@ public class Experience { if (killer == null || mob == null) return; - double xp = 0.0; - - //Get the xp modifier for the world - float xpMod = Enum.DropRateType.EXP_RATE_MOD.rate; - - + double grantedExperience = 0.0; if (g != null) { // Do group EXP stuff @@ -374,18 +370,18 @@ public class Experience { } // Process every player in the group getting XP - for (PlayerCharacter pc : giveEXPTo) { - if (pc.getLevel() >= MBServerStatics.LEVELCAP) + for (PlayerCharacter playerCharacter : giveEXPTo) { + if (playerCharacter.getLevel() >= MBServerStatics.LEVELCAP) continue; // Sets Max XP with server exp mod taken into account. - xp = (double) xpMod * maxXPPerKill(pc.getLevel()); + grantedExperience = (double) Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()) * maxXPPerKill(playerCharacter.getLevel()); // Adjust XP for Mob Level - xp *= getConMod(pc, mob); + grantedExperience *= getConMod(playerCharacter, mob); // Process XP for this member - penalty = getGroupMemberPenalty(leadership, pc, giveEXPTo, + penalty = getGroupMemberPenalty(leadership, playerCharacter, giveEXPTo, highestLevel); // Leadership Penalty Reduction @@ -393,27 +389,27 @@ public class Experience { penalty -= ((leadership) * 0.01) * penalty; // Modify for hotzone - if (xp != 0) + if (grantedExperience != 0) if (ZoneManager.inHotZone(mob.getLoc())) - xp *= Enum.DropRateType.HOT_EXP_RATE_MOD.rate; + grantedExperience *= Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue()); // Check for 0 XP due to white mob, otherwise subtract penalty // xp - if (xp == 0) { - xp = 1; + if (grantedExperience == 0) { + grantedExperience = 1; } else { - xp -= (penalty * 0.01) * xp; + grantedExperience -= (penalty * 0.01) * grantedExperience; // Errant Penalty Calculation - if (pc.getGuild().isEmptyGuild()) - xp *= 0.6; + if (playerCharacter.getGuild().isEmptyGuild()) + grantedExperience *= 0.6; } - if (xp == 0) - xp = 1; + if (grantedExperience == 0) + grantedExperience = 1; // Grant the player the EXP - pc.grantXP((int) Math.floor(xp)); + playerCharacter.grantXP((int) Math.floor(grantedExperience)); } } else { // Give EXP to a single character @@ -424,20 +420,20 @@ public class Experience { return; // Get XP and adjust for Mob Level with world xp modifier taken into account - xp = (double) xpMod * maxXPPerKill(killer.getLevel()); - xp *= getConMod(killer, mob); + grantedExperience = (double) Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()) * maxXPPerKill(killer.getLevel()); + grantedExperience *= getConMod(killer, mob); // Modify for hotzone if (ZoneManager.inHotZone(mob.getLoc())) - xp *= Enum.DropRateType.HOT_EXP_RATE_MOD.rate; + grantedExperience *= Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue()); // Errant penalty - if (xp != 1) + if (grantedExperience != 1) if (killer.getGuild().isEmptyGuild()) - xp *= .6; + grantedExperience *= .6; // Grant XP - killer.grantXP((int) Math.floor(xp)); + killer.grantXP((int) Math.floor(grantedExperience)); } } } diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index acdc033d..c9c5fb9d 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -13,6 +13,7 @@ import engine.Enum; import engine.Enum.ItemContainerType; import engine.Enum.ItemType; import engine.Enum.OwnerType; +import engine.gameManager.ConfigManager; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; import engine.server.MBServerStatics; @@ -210,7 +211,7 @@ public class LootTable { float chance = mlb.getChance() *.01f; - chance *= Enum.DropRateType.DROP_RATE_MOD.rate; + chance *= Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); calculatedLootTable = mlb.getLootTableID(); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 9c28ec9f..1bd41d53 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1506,17 +1506,14 @@ public class Mob extends AbstractIntelligenceAgent { double gold = (ThreadLocalRandom.current().nextDouble() * (maxGold - minGold) + minGold); - //server specific gold multiplier - double goldMod = DropRateType.GOLD_RATE_MOD.rate; - gold *= goldMod; + + gold *= Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue()); //modify for hotzone if (ZoneManager.inHotZone(mob.getLoc())) - gold *= DropRateType.HOT_GOLD_RATE_MOD.rate; - - gold *= DropRateType.GOLD_RATE_MOD.rate; + gold *= Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue()); return (int) gold; }