L2JMobius

Crusader Rates based on character level

Paiplayer · 5 · 1341

Offline Paiplayer

  • Knight
  • ***
    • Posts: 74
It's pretty simple: it allows admins to config specific XP and SP rates to level ranges. If the config is empty or the level is missing inside the ranges the default RateXp or RateSp will be used to calc.

The code could be a little messy and be improved, but it's working as is.

Once more my Eclipse have some problems to create patches, then there's the instructions:

Code: [Select]
### Eclipse Workspace Patch 1.0
#P L2J_Mobius_Essence_6.3_Crusader
diff --git dist/game/config/Rates.ini dist/game/config/Rates.ini
index ed2da11..8a03bb5 100644
--- dist/game/config/Rates.ini
+++ dist/game/config/Rates.ini
@@ -18,6 +18,12 @@
 # Skill points multiplier (Party)
 RatePartySp = 10
 
+# Experience and Skill Points multipliers by level range
+# Format: start,end,rate;start2,end2,rate2;
+# Defatult: empty
+RateXpByLevelRange = 1,39,10;40,75,5;76,99,2;
+RateSpByLevelRange = 1,39,10;40,75,5;76,99,2;
+
 # Instance rates
 # Those rates are used as absolute rate within instances, does not applies on top of RateXp for example!
 # Default: -1 (Uses the rates above)

On /L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/Config.java set

Code: [Select]
public static String RATE_XP_BY_LEVEL;
public static String RATE_SP_BY_LEVEL;

Then pull the configs @ line 2425:

Code: [Select]
RATE_XP_BY_LEVEL = ratesConfig.getString("RateXpByLevelRange", "");
RATE_SP_BY_LEVEL = ratesConfig.getString("RateSpByLevelRange", "");


On /L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/actor/Npc.java find and replace the following methods starting at line 878:

Code: [Select]
/**
* @param charLevel
* @return the Exp Reward of this Npc (modified by RATE_XP or RATE_XP_BY_LEVEL).
*/
public double getExpReward(int charLevel)
{
final Instance instance = getInstanceWorld();
final float rateMul = instance != null ? instance.getExpRate() : Config.RATE_XP;
for (String listOfXpRate : Config.RATE_XP_BY_LEVEL.split(";"))
{
final String[] rateSplit = listOfXpRate.split(",");
if (rateSplit.length == 3)
{
if ((charLevel >= Integer.parseInt(rateSplit[0])) && (charLevel <= Integer.parseInt(rateSplit[1])))
{
return getTemplate().getExp() * Integer.parseInt(rateSplit[2]);
}
}
}
return getTemplate().getExp() * rateMul;
}

Code: [Select]
/**
* @param charLevel
* @return the SP Reward of this Npc (modified by RATE_SP or RATE_SP_BY_LEVEL).
*/
public double getSpReward(int charLevel)
{
final Instance instance = getInstanceWorld();
final float rateMul = instance != null ? instance.getSPRate() : Config.RATE_SP;
for (String listOfSpRate : Config.RATE_SP_BY_LEVEL.split(";"))
{
final String[] rateSplit = listOfSpRate.split(",");
if (rateSplit.length == 3)
{
if ((charLevel >= Integer.parseInt(rateSplit[0])) && (charLevel <= Integer.parseInt(rateSplit[1])))
{
return getTemplate().getSP() * Integer.parseInt(rateSplit[2]);
}
}
}
return getTemplate().getSP() * rateMul;
}



On /L2J_Mobius_Essence_6.3_Crusader/java/org/l2jmobius/gameserver/model/actor/Attackable.java at line 1787 replace as follow:

From:
Code: [Select]
if ((getLevel() <= 0) || (getExpReward() <= 0) || (isBoss && (Config.VITALITY_CONSUME_BY_BOSS == 0)))
To:
Code: [Select]
if ((getLevel() <= 0) || (getExpReward(level) <= 0) || (isBoss && (Config.VITALITY_CONSUME_BY_BOSS == 0)))
Want a developer? Check here or call me on Discord: PaiPlayer#5051


Online CostyKiller

  • Distinguished King
  • *****
    • Posts: 969
Nice! I use something similar but with fixed player level intervals like this:

Code: [Select]
# Experience multiplier for level 90 till 99 included
RateXp_90_100 = 4

# Experience multiplier for level 100 till 109 included
RateXp_100_110 = 3


Offline Paiplayer

  • Knight
  • ***
    • Posts: 74
Nice! I use something similar but with fixed player level intervals like this:

Code: [Select]
# Experience multiplier for level 90 till 99 included
RateXp_90_100 = 4

# Experience multiplier for level 100 till 109 included
RateXp_100_110 = 3

It's a valid approach, but my method focuses on the premise that the admin can opt to chamge the rate just on specific ranges. For instance: I can set
RateXp = 10

RateXpByLevelRange = 76,99,5;

This will make only 76~99 range players get RateXp x5
Want a developer? Check here or call me on Discord: PaiPlayer#5051


Offline Mystogan

  • Knight
  • ***
    • Posts: 55
  • I apologize for my English, I write through Google
Could you update the code to the latest DataPack version?


Offline Bru7aLMike

  • Vassal
  • *
    • Posts: 6
It would be more efficient to populate a couple of hashmaps (or even sorted lists) on server launch with the values from the config, and do the lookup in these maps(lists) as opposed to doing all of the string splitting and integer extraction every time a player is ought to receive EXP.