forked from MagicBane/Server
Refactored caching of drop rates. Whittling away at MBServerStatics.
This commit is contained in:
+32
-1
@@ -9,6 +9,7 @@
|
|||||||
package engine;
|
package engine;
|
||||||
|
|
||||||
import ch.claude_martin.enumbitset.EnumBitSetHelper;
|
import ch.claude_martin.enumbitset.EnumBitSetHelper;
|
||||||
|
import engine.gameManager.ConfigManager;
|
||||||
import engine.gameManager.PowersManager;
|
import engine.gameManager.PowersManager;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector2f;
|
import engine.math.Vector2f;
|
||||||
@@ -2641,7 +2642,37 @@ public class Enum {
|
|||||||
ARCHER,
|
ARCHER,
|
||||||
MAGE;
|
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 {
|
public enum MinionType {
|
||||||
AELFBORNGUARD(951,1637, MinionClass.MELEE, "Guard","Aelfborn"),
|
AELFBORNGUARD(951,1637, MinionClass.MELEE, "Guard","Aelfborn"),
|
||||||
AELFBORNMAGE(952, 1635, MinionClass.MAGE,"Adept","Aelfborn"),
|
AELFBORNMAGE(952, 1635, MinionClass.MAGE,"Adept","Aelfborn"),
|
||||||
|
|||||||
@@ -9,11 +9,12 @@
|
|||||||
|
|
||||||
package engine.devcmd.cmds;
|
package engine.devcmd.cmds;
|
||||||
|
|
||||||
|
import engine.Enum.DropRateType;
|
||||||
import engine.devcmd.AbstractDevCmd;
|
import engine.devcmd.AbstractDevCmd;
|
||||||
import engine.objects.AbstractGameObject;
|
import engine.objects.AbstractGameObject;
|
||||||
import engine.objects.PlayerCharacter;
|
import engine.objects.PlayerCharacter;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
|
import engine.server.world.WorldServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -46,32 +47,32 @@ public class SetRateCmd extends AbstractDevCmd {
|
|||||||
|
|
||||||
if (args[0].equals("exp")){
|
if (args[0].equals("exp")){
|
||||||
|
|
||||||
MBServerStatics.EXP_RATE_MOD = mod;
|
DropRateType.EXP_RATE_MOD.rate = mod;
|
||||||
throwbackInfo(pc, "Experience Rate set to: " + mod);
|
throwbackInfo(pc, "Experience Rate set to: " + mod);
|
||||||
|
|
||||||
} else if (args[0].equals("gold")){
|
} else if (args[0].equals("gold")){
|
||||||
|
|
||||||
MBServerStatics.GOLD_RATE_MOD = mod;
|
DropRateType.GOLD_RATE_MOD.rate = mod;
|
||||||
throwbackInfo(pc, "Gold Rate set to: " + mod);
|
throwbackInfo(pc, "Gold Rate set to: " + mod);
|
||||||
|
|
||||||
} else if (args[0].equals("drop")){
|
} 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);
|
throwbackInfo(pc, "Drop Multiplier Rate set to: " + mod);
|
||||||
|
|
||||||
} else if (args[0].equals("hotexp")){
|
} 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);
|
throwbackInfo(pc, "HOTZONE Experience Rate set to: " + mod);
|
||||||
|
|
||||||
} else if (args[0].equals("hotgold")){
|
} 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);
|
throwbackInfo(pc, "HOTZONE Gold Rate set to: " + mod);
|
||||||
|
|
||||||
} else if (args[0].equals("hotdrop")){
|
} 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);
|
throwbackInfo(pc, "HOTZONE Drop Multiplier Rate set to: " + mod);
|
||||||
|
|
||||||
} else if (args[0].equals("production")){
|
} else if (args[0].equals("production")){
|
||||||
|
|||||||
@@ -9,10 +9,12 @@
|
|||||||
|
|
||||||
package engine.objects;
|
package engine.objects;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
import engine.Enum.TargetColor;
|
import engine.Enum.TargetColor;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.math.Vector3fImmutable;
|
import engine.math.Vector3fImmutable;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
|
import engine.server.world.WorldServer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -333,7 +335,7 @@ public class Experience {
|
|||||||
double xp = 0.0;
|
double xp = 0.0;
|
||||||
|
|
||||||
//Get the xp modifier for the world
|
//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
|
// Modify for hotzone
|
||||||
if (xp != 0)
|
if (xp != 0)
|
||||||
if (ZoneManager.inHotZone(mob.getLoc()))
|
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
|
// Check for 0 XP due to white mob, otherwise subtract penalty
|
||||||
// xp
|
// xp
|
||||||
@@ -427,7 +429,7 @@ public class Experience {
|
|||||||
|
|
||||||
// Modify for hotzone
|
// Modify for hotzone
|
||||||
if (ZoneManager.inHotZone(mob.getLoc()))
|
if (ZoneManager.inHotZone(mob.getLoc()))
|
||||||
xp *= MBServerStatics.HOT_EXP_RATE_MOD;
|
xp *= Enum.DropRateType.HOT_EXP_RATE_MOD.rate;
|
||||||
|
|
||||||
// Errant penalty
|
// Errant penalty
|
||||||
if (xp != 1)
|
if (xp != 1)
|
||||||
|
|||||||
@@ -9,12 +9,14 @@
|
|||||||
|
|
||||||
package engine.objects;
|
package engine.objects;
|
||||||
|
|
||||||
|
import engine.Enum;
|
||||||
import engine.Enum.ItemContainerType;
|
import engine.Enum.ItemContainerType;
|
||||||
import engine.Enum.ItemType;
|
import engine.Enum.ItemType;
|
||||||
import engine.Enum.OwnerType;
|
import engine.Enum.OwnerType;
|
||||||
import engine.gameManager.DbManager;
|
import engine.gameManager.DbManager;
|
||||||
import engine.gameManager.ZoneManager;
|
import engine.gameManager.ZoneManager;
|
||||||
import engine.server.MBServerStatics;
|
import engine.server.MBServerStatics;
|
||||||
|
import engine.server.world.WorldServer;
|
||||||
import org.pmw.tinylog.Logger;
|
import org.pmw.tinylog.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -208,7 +210,7 @@ public class LootTable {
|
|||||||
|
|
||||||
float chance = mlb.getChance() *.01f;
|
float chance = mlb.getChance() *.01f;
|
||||||
|
|
||||||
chance *= MBServerStatics.DROP_RATE_MOD;
|
chance *= Enum.DropRateType.DROP_RATE_MOD.rate;
|
||||||
|
|
||||||
calculatedLootTable = mlb.getLootTableID();
|
calculatedLootTable = mlb.getLootTableID();
|
||||||
|
|
||||||
|
|||||||
@@ -1508,15 +1508,15 @@ public class Mob extends AbstractIntelligenceAgent {
|
|||||||
|
|
||||||
|
|
||||||
//server specific gold multiplier
|
//server specific gold multiplier
|
||||||
double goldMod = MBServerStatics.GOLD_RATE_MOD;
|
double goldMod = DropRateType.GOLD_RATE_MOD.rate;
|
||||||
gold *= goldMod;
|
gold *= goldMod;
|
||||||
|
|
||||||
//modify for hotzone
|
//modify for hotzone
|
||||||
|
|
||||||
if (ZoneManager.inHotZone(mob.getLoc()))
|
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;
|
return (int) gold;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -406,26 +406,6 @@ public class MBServerStatics {
|
|||||||
public static int SPATIAL_HASH_BUCKETSY = 12288;
|
public static int SPATIAL_HASH_BUCKETSY = 12288;
|
||||||
public static float MAX_PLAYER_X_LOC = 129999;
|
public static float MAX_PLAYER_X_LOC = 129999;
|
||||||
public static float MAX_PLAYER_Y_LOC = -97000;
|
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
|
* Ranges
|
||||||
|
|||||||
@@ -483,14 +483,10 @@ public class WorldServer {
|
|||||||
Logger.info("Running garbage collection...");
|
Logger.info("Running garbage collection...");
|
||||||
System.gc();
|
System.gc();
|
||||||
|
|
||||||
//set rates from config file
|
//set drop rates from config file
|
||||||
Logger.info("Setting rates based on conf file...");
|
|
||||||
MBServerStatics.EXP_RATE_MOD = Float.parseFloat(ConfigManager.MB_NORMAL_RATE.getValue());
|
Logger.info("Setting drop rates...");
|
||||||
MBServerStatics.GOLD_RATE_MOD = Float.parseFloat(ConfigManager.MB_NORMAL_RATE.getValue());
|
Enum.DropRateType.init();
|
||||||
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());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user