Browse Source

Refactored caching of drop rates. Whittling away at MBServerStatics.

master
MagicBot 2 years ago
parent
commit
70ca0a1df3
  1. 31
      src/engine/Enum.java
  2. 15
      src/engine/devcmd/cmds/SetRateCmd.java
  3. 8
      src/engine/objects/Experience.java
  4. 4
      src/engine/objects/LootTable.java
  5. 6
      src/engine/objects/Mob.java
  6. 20
      src/engine/server/MBServerStatics.java
  7. 12
      src/engine/server/world/WorldServer.java

31
src/engine/Enum.java

@ -9,6 +9,7 @@ @@ -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;
@ -2642,6 +2643,36 @@ public class Enum { @@ -2642,6 +2643,36 @@ 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"),

15
src/engine/devcmd/cmds/SetRateCmd.java

@ -9,11 +9,12 @@ @@ -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 { @@ -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")){

8
src/engine/objects/Experience.java

@ -9,10 +9,12 @@ @@ -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 { @@ -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 { @@ -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 { @@ -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)

4
src/engine/objects/LootTable.java

@ -9,12 +9,14 @@ @@ -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 { @@ -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();

6
src/engine/objects/Mob.java

@ -1508,15 +1508,15 @@ public class Mob extends AbstractIntelligenceAgent { @@ -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;
}

20
src/engine/server/MBServerStatics.java

@ -406,26 +406,6 @@ public class MBServerStatics { @@ -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

12
src/engine/server/world/WorldServer.java

@ -483,14 +483,10 @@ public class WorldServer { @@ -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;
}

Loading…
Cancel
Save