panther75

LvlRates

Nov 13th, 2022
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.88 KB | Fixit | 0 0
  1. diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/config/Rates.ini b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/config/Rates.ini
  2. index efd2c30451..ba68eb87c0 100644
  3. --- a/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/config/Rates.ini
  4. +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/dist/game/config/Rates.ini
  5. @@ -30,6 +30,11 @@ RateInstancePartyXp = -1
  6.  # Instance Skill points multiplier (Party)
  7.  RateInstancePartySp = -1
  8.  
  9. +# XP/SP Rates based on player level
  10. +LvlRatesEnabled = false
  11. +# lv 0-61:3x ~ lv 62-76:2.5x ~ lv 77-83:2x
  12. +LvlRates = 61,3;76,2.5;83,2
  13. +
  14.  RateDropManor = 1
  15.  # Karma decreasing rate
  16.  # Note: -1 means RateXp so it means it will use retail rate for decreasing karma upon death or receiving exp by farming mobs.
  17. diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/Config.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/Config.java
  18. index 803238e615..cef40ff4ab 100644
  19. --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/Config.java
  20. +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/Config.java
  21. @@ -42,6 +42,7 @@ import java.util.HashMap;
  22.  import java.util.HashSet;
  23.  import java.util.List;
  24.  import java.util.Map;
  25. +import java.util.TreeMap;
  26.  import java.util.Properties;
  27.  import java.util.Set;
  28.  import java.util.logging.Level;
  29. @@ -718,6 +719,8 @@ public class Config
  30.     public static float RATE_INSTANCE_SP;
  31.     public static float RATE_INSTANCE_PARTY_XP;
  32.     public static float RATE_INSTANCE_PARTY_SP;
  33. +   public static boolean ENABLE_LVL_RATES;
  34. +   public static Map<Integer, Float> LVL_RATES;
  35.     public static float RATE_RAIDBOSS_POINTS;
  36.     public static float RATE_EXTRACTABLE;
  37.     public static int RATE_DROP_MANOR;
  38. @@ -2260,6 +2263,32 @@ public class Config
  39.             RATE_PARTY_XP = ratesConfig.getFloat("RatePartyXp", 1);
  40.             RATE_PARTY_SP = ratesConfig.getFloat("RatePartySp", 1);
  41.             RATE_INSTANCE_XP = ratesConfig.getFloat("RateInstanceXp", -1);
  42. +           ENABLE_LVL_RATES = ratesConfig.getBoolean("LvlRatesEnabled", false);
  43. +
  44. +           final String[] ratesLvlSplit = ratesConfig.getString("LvlRates", "").split(";");
  45. +           LVL_RATES = new HashMap<>(ratesLvlSplit.length);
  46. +           for (String rlvl : ratesLvlSplit)
  47. +           {
  48. +               final String[] raLvlSplit = rlvl.split(",");
  49. +               if (raLvlSplit.length != 2)
  50. +               {
  51. +                   LOGGER.warning(StringUtil.concat("[LvlRates]: invalid config property -> LvlRates \"", rlvl, "\""));
  52. +               }
  53. +               try
  54. +               {
  55. +                   LVL_RATES.put(Integer.parseInt(raLvlSplit[0]), Float.parseFloat(raLvlSplit[1]));
  56. +               }
  57. +               catch (NumberFormatException nfe)
  58. +               {
  59. +                   if (!rlvl.isEmpty())
  60. +                   {
  61. +                       LOGGER.warning(StringUtil.concat("[LvlRates]: invalid config property -> LvlRates \"", raLvlSplit[0], "\"", raLvlSplit[1]));
  62. +                   }
  63. +               }
  64. +           }
  65. +
  66. +           LVL_RATES = new TreeMap<>(LVL_RATES);
  67. +
  68.             if (RATE_INSTANCE_XP < 0)
  69.             {
  70.                 RATE_INSTANCE_XP = RATE_XP;
  71. diff --git a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java
  72. index 537ce5c5f5..910f2f2742 100644
  73. --- a/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java
  74. +++ b/L2J_Mobius_Essence_6.1_BattleChronicle/java/org/l2jmobius/gameserver/model/actor/stat/PlayerStat.java
  75. @@ -112,6 +112,21 @@ public class PlayerStat extends PlayableStat
  76.         double addToExp = addToExpValue;
  77.         double addToSp = addToSpValue;
  78.  
  79. +    if(Config.ENABLE_LVL_RATES)
  80. +    {
  81. +        Integer previous_lvl = 0;
  82. +        for (var entry : Config.LVL_RATES.entrySet())
  83. +        {
  84. +            if(player.getLevel() > previous_lvl && player.getLevel() <= entry.getKey())
  85. +            {
  86. +                       addToExp *= entry.getValue();
  87. +                       addToSp *= entry.getValue();
  88. +                       break;
  89. +               }
  90. +            previous_lvl = entry.getKey();
  91. +      }
  92. +     }
  93. +
  94.         // Premium rates
  95.         if (player.hasPremiumStatus())
  96.         {
Tags: LvlRates
Add Comment
Please, Sign In to add comment