diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 087110d4..6c82024c 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -9,6 +9,7 @@ package engine; import ch.claude_martin.enumbitset.EnumBitSetHelper; +import engine.gameManager.ConfigManager; import engine.gameManager.PowersManager; import engine.gameManager.ZoneManager; import engine.math.Vector2f; @@ -2641,7 +2642,37 @@ public class Enum { ARCHER, 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/devcmd/cmds/SetRateCmd.java b/src/engine/devcmd/cmds/SetRateCmd.java index b73c0d92..f40c627b 100644 --- a/src/engine/devcmd/cmds/SetRateCmd.java +++ b/src/engine/devcmd/cmds/SetRateCmd.java @@ -9,11 +9,12 @@ package engine.devcmd.cmds; +import engine.Enum.DropRateType; import engine.devcmd.AbstractDevCmd; import engine.objects.AbstractGameObject; import engine.objects.PlayerCharacter; import engine.server.MBServerStatics; - +import engine.server.world.WorldServer; /** * @@ -46,32 +47,32 @@ public class SetRateCmd extends AbstractDevCmd { if (args[0].equals("exp")){ - MBServerStatics.EXP_RATE_MOD = mod; + DropRateType.EXP_RATE_MOD.rate = mod; throwbackInfo(pc, "Experience Rate set to: " + mod); } else if (args[0].equals("gold")){ - MBServerStatics.GOLD_RATE_MOD = mod; + DropRateType.GOLD_RATE_MOD.rate = mod; throwbackInfo(pc, "Gold Rate set to: " + mod); } else if (args[0].equals("drop")){ - MBServerStatics.DROP_RATE_MOD = mod; + DropRateType.DROP_RATE_MOD.rate = mod; throwbackInfo(pc, "Drop Multiplier Rate set to: " + mod); } else if (args[0].equals("hotexp")){ - MBServerStatics.HOT_EXP_RATE_MOD = mod; + DropRateType.HOT_EXP_RATE_MOD.rate = mod; throwbackInfo(pc, "HOTZONE Experience Rate set to: " + mod); } else if (args[0].equals("hotgold")){ - MBServerStatics.HOT_GOLD_RATE_MOD = mod; + DropRateType.HOT_GOLD_RATE_MOD.rate = mod; throwbackInfo(pc, "HOTZONE Gold Rate set to: " + mod); } else if (args[0].equals("hotdrop")){ - MBServerStatics.HOT_DROP_RATE_MOD = mod; + DropRateType.HOT_DROP_RATE_MOD.rate = mod; throwbackInfo(pc, "HOTZONE Drop Multiplier Rate set to: " + mod); } else if (args[0].equals("production")){ diff --git a/src/engine/objects/Experience.java b/src/engine/objects/Experience.java index ab5c2789..d828c24b 100644 --- a/src/engine/objects/Experience.java +++ b/src/engine/objects/Experience.java @@ -9,10 +9,12 @@ package engine.objects; +import engine.Enum; import engine.Enum.TargetColor; import engine.gameManager.ZoneManager; import engine.math.Vector3fImmutable; import engine.server.MBServerStatics; +import engine.server.world.WorldServer; import java.util.ArrayList; import java.util.TreeMap; @@ -333,7 +335,7 @@ public class Experience { double xp = 0.0; //Get the xp modifier for the world - float xpMod = MBServerStatics.EXP_RATE_MOD; + float xpMod = Enum.DropRateType.EXP_RATE_MOD.rate; @@ -393,7 +395,7 @@ public class Experience { // Modify for hotzone if (xp != 0) if (ZoneManager.inHotZone(mob.getLoc())) - xp *= MBServerStatics.HOT_EXP_RATE_MOD; + xp *= Enum.DropRateType.HOT_EXP_RATE_MOD.rate; // Check for 0 XP due to white mob, otherwise subtract penalty // xp @@ -427,7 +429,7 @@ public class Experience { // Modify for hotzone if (ZoneManager.inHotZone(mob.getLoc())) - xp *= MBServerStatics.HOT_EXP_RATE_MOD; + xp *= Enum.DropRateType.HOT_EXP_RATE_MOD.rate; // Errant penalty if (xp != 1) diff --git a/src/engine/objects/LootTable.java b/src/engine/objects/LootTable.java index 16a9523a..acdc033d 100644 --- a/src/engine/objects/LootTable.java +++ b/src/engine/objects/LootTable.java @@ -9,12 +9,14 @@ package engine.objects; +import engine.Enum; import engine.Enum.ItemContainerType; import engine.Enum.ItemType; import engine.Enum.OwnerType; import engine.gameManager.DbManager; import engine.gameManager.ZoneManager; import engine.server.MBServerStatics; +import engine.server.world.WorldServer; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -208,7 +210,7 @@ public class LootTable { float chance = mlb.getChance() *.01f; - chance *= MBServerStatics.DROP_RATE_MOD; + chance *= Enum.DropRateType.DROP_RATE_MOD.rate; calculatedLootTable = mlb.getLootTableID(); diff --git a/src/engine/objects/Mob.java b/src/engine/objects/Mob.java index 4f0979bd..9c28ec9f 100644 --- a/src/engine/objects/Mob.java +++ b/src/engine/objects/Mob.java @@ -1508,15 +1508,15 @@ public class Mob extends AbstractIntelligenceAgent { //server specific gold multiplier - double goldMod = MBServerStatics.GOLD_RATE_MOD; + double goldMod = DropRateType.GOLD_RATE_MOD.rate; gold *= goldMod; //modify for hotzone if (ZoneManager.inHotZone(mob.getLoc())) - gold *= MBServerStatics.HOT_GOLD_RATE_MOD; + gold *= DropRateType.HOT_GOLD_RATE_MOD.rate; - gold *= MBServerStatics.GOLD_RATE_MOD; + gold *= DropRateType.GOLD_RATE_MOD.rate; return (int) gold; } diff --git a/src/engine/server/MBServerStatics.java b/src/engine/server/MBServerStatics.java index 03f83b2a..a986901b 100644 --- a/src/engine/server/MBServerStatics.java +++ b/src/engine/server/MBServerStatics.java @@ -406,26 +406,6 @@ public class MBServerStatics { public static int SPATIAL_HASH_BUCKETSY = 12288; public static float MAX_PLAYER_X_LOC = 129999; public static float MAX_PLAYER_Y_LOC = -97000; - public static String NO_DELETE_COMBAT = "Can't delete items when in Combat with another player."; - - /* - * Rates - */ - - public static float EXP_RATE_MOD = 2f; // Probably don't want to declare - // as final. - public static float GOLD_RATE_MOD = 1.0f; // Probably don't want to declare - // as final. - public static float DROP_RATE_MOD = 1.0f; // Probably don't want to declare - // as final. - - // Hotzones - public static float HOT_EXP_RATE_MOD = 2.0f; // Probably don't want to - // declare as final. - public static float HOT_GOLD_RATE_MOD = 1.5f; // Probably don't want to - // declare as final. - public static float HOT_DROP_RATE_MOD = 1.8f; // Probably don't want to - // declare as final. /* * Ranges diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index d261cb25..dc675f45 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -483,14 +483,10 @@ public class WorldServer { Logger.info("Running garbage collection..."); System.gc(); - //set rates from config file - Logger.info("Setting rates based on conf file..."); - MBServerStatics.EXP_RATE_MOD = Float.parseFloat(ConfigManager.MB_NORMAL_RATE.getValue()); - MBServerStatics.GOLD_RATE_MOD = Float.parseFloat(ConfigManager.MB_NORMAL_RATE.getValue()); - MBServerStatics.DROP_RATE_MOD = Float.parseFloat(ConfigManager.MB_NORMAL_RATE.getValue()); - MBServerStatics.HOT_EXP_RATE_MOD = Float.parseFloat(ConfigManager.MB_HOTZONE_RATE.getValue()); - MBServerStatics.HOT_GOLD_RATE_MOD = Float.parseFloat(ConfigManager.MB_HOTZONE_RATE.getValue()); - MBServerStatics.HOT_DROP_RATE_MOD = Float.parseFloat(ConfigManager.MB_HOTZONE_RATE.getValue()); + //set drop rates from config file + + Logger.info("Setting drop rates..."); + Enum.DropRateType.init(); return true; }