Browse Source

Experience Modifiers added to ConfigManager

master
MagicBot 2 years ago
parent
commit
d5c219897d
  1. 30
      src/engine/Enum.java
  2. 12
      src/engine/gameManager/ConfigManager.java
  3. 50
      src/engine/objects/Experience.java
  4. 3
      src/engine/objects/LootTable.java
  5. 9
      src/engine/objects/Mob.java

30
src/engine/Enum.java

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

12
src/engine/gameManager/ConfigManager.java

@ -14,7 +14,6 @@ package engine.gameManager;
import engine.Enum; import engine.Enum;
import engine.net.NetMsgHandler; import engine.net.NetMsgHandler;
import engine.server.MBServerStatics;
import engine.server.login.LoginServer; import engine.server.login.LoginServer;
import engine.server.world.WorldServer; import engine.server.world.WorldServer;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -67,8 +66,10 @@ public enum ConfigManager {
MB_WORLD_KEYCLONE_MAX, MB_WORLD_KEYCLONE_MAX,
//drop rates //drop rates
MB_NORMAL_RATE, MB_NORMAL_EXP_RATE,
MB_HOTZONE_RATE, MB_NORMAL_DROP_RATE,
MB_HOTZONE_EXP_RATE,
MB_HOTZONE_DROP_RATE,
MB_HOTZONE_DURATION, MB_HOTZONE_DURATION,
MB_HOTZONE_MIN_LEVEL, MB_HOTZONE_MIN_LEVEL,
@ -117,11 +118,6 @@ public enum ConfigManager {
return false; return false;
} }
// Setting drop rates
Logger.info("Setting drop rates...");
Enum.DropRateType.init();
// compile regex here // compile regex here
Logger.info("Compiling regex"); Logger.info("Compiling regex");

50
src/engine/objects/Experience.java

@ -11,6 +11,7 @@ package engine.objects;
import engine.Enum; import engine.Enum;
import engine.Enum.TargetColor; import engine.Enum.TargetColor;
import engine.gameManager.ConfigManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
@ -332,12 +333,7 @@ public class Experience {
if (killer == null || mob == null) if (killer == null || mob == null)
return; return;
double xp = 0.0; double grantedExperience = 0.0;
//Get the xp modifier for the world
float xpMod = Enum.DropRateType.EXP_RATE_MOD.rate;
if (g != null) { // Do group EXP stuff if (g != null) { // Do group EXP stuff
@ -374,18 +370,18 @@ public class Experience {
} }
// Process every player in the group getting XP // Process every player in the group getting XP
for (PlayerCharacter pc : giveEXPTo) { for (PlayerCharacter playerCharacter : giveEXPTo) {
if (pc.getLevel() >= MBServerStatics.LEVELCAP) if (playerCharacter.getLevel() >= MBServerStatics.LEVELCAP)
continue; continue;
// Sets Max XP with server exp mod taken into account. // 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 // Adjust XP for Mob Level
xp *= getConMod(pc, mob); grantedExperience *= getConMod(playerCharacter, mob);
// Process XP for this member // Process XP for this member
penalty = getGroupMemberPenalty(leadership, pc, giveEXPTo, penalty = getGroupMemberPenalty(leadership, playerCharacter, giveEXPTo,
highestLevel); highestLevel);
// Leadership Penalty Reduction // Leadership Penalty Reduction
@ -393,27 +389,27 @@ public class Experience {
penalty -= ((leadership) * 0.01) * penalty; penalty -= ((leadership) * 0.01) * penalty;
// Modify for hotzone // Modify for hotzone
if (xp != 0) if (grantedExperience != 0)
if (ZoneManager.inHotZone(mob.getLoc())) 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 // Check for 0 XP due to white mob, otherwise subtract penalty
// xp // xp
if (xp == 0) { if (grantedExperience == 0) {
xp = 1; grantedExperience = 1;
} else { } else {
xp -= (penalty * 0.01) * xp; grantedExperience -= (penalty * 0.01) * grantedExperience;
// Errant Penalty Calculation // Errant Penalty Calculation
if (pc.getGuild().isEmptyGuild()) if (playerCharacter.getGuild().isEmptyGuild())
xp *= 0.6; grantedExperience *= 0.6;
} }
if (xp == 0) if (grantedExperience == 0)
xp = 1; grantedExperience = 1;
// Grant the player the EXP // Grant the player the EXP
pc.grantXP((int) Math.floor(xp)); playerCharacter.grantXP((int) Math.floor(grantedExperience));
} }
} else { // Give EXP to a single character } else { // Give EXP to a single character
@ -424,20 +420,20 @@ public class Experience {
return; return;
// Get XP and adjust for Mob Level with world xp modifier taken into account // Get XP and adjust for Mob Level with world xp modifier taken into account
xp = (double) xpMod * maxXPPerKill(killer.getLevel()); grantedExperience = (double) Float.parseFloat(ConfigManager.MB_NORMAL_EXP_RATE.getValue()) * maxXPPerKill(killer.getLevel());
xp *= getConMod(killer, mob); grantedExperience *= getConMod(killer, mob);
// Modify for hotzone // Modify for hotzone
if (ZoneManager.inHotZone(mob.getLoc())) if (ZoneManager.inHotZone(mob.getLoc()))
xp *= Enum.DropRateType.HOT_EXP_RATE_MOD.rate; grantedExperience *= Float.parseFloat(ConfigManager.MB_HOTZONE_EXP_RATE.getValue());
// Errant penalty // Errant penalty
if (xp != 1) if (grantedExperience != 1)
if (killer.getGuild().isEmptyGuild()) if (killer.getGuild().isEmptyGuild())
xp *= .6; grantedExperience *= .6;
// Grant XP // Grant XP
killer.grantXP((int) Math.floor(xp)); killer.grantXP((int) Math.floor(grantedExperience));
} }
} }
} }

3
src/engine/objects/LootTable.java

@ -13,6 +13,7 @@ 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.ConfigManager;
import engine.gameManager.DbManager; import engine.gameManager.DbManager;
import engine.gameManager.ZoneManager; import engine.gameManager.ZoneManager;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
@ -210,7 +211,7 @@ public class LootTable {
float chance = mlb.getChance() *.01f; float chance = mlb.getChance() *.01f;
chance *= Enum.DropRateType.DROP_RATE_MOD.rate; chance *= Float.parseFloat(ConfigManager.MB_NORMAL_DROP_RATE.getValue());
calculatedLootTable = mlb.getLootTableID(); calculatedLootTable = mlb.getLootTableID();

9
src/engine/objects/Mob.java

@ -1506,17 +1506,14 @@ public class Mob extends AbstractIntelligenceAgent {
double gold = (ThreadLocalRandom.current().nextDouble() * (maxGold - minGold) + minGold); double gold = (ThreadLocalRandom.current().nextDouble() * (maxGold - minGold) + minGold);
//server specific gold multiplier //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 //modify for hotzone
if (ZoneManager.inHotZone(mob.getLoc())) if (ZoneManager.inHotZone(mob.getLoc()))
gold *= DropRateType.HOT_GOLD_RATE_MOD.rate; gold *= Float.parseFloat(ConfigManager.MB_HOTZONE_DROP_RATE.getValue());
gold *= DropRateType.GOLD_RATE_MOD.rate;
return (int) gold; return (int) gold;
} }

Loading…
Cancel
Save