Advertisement
Guest User

Untitled

a guest
Mar 13th, 2019
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.28 KB | None | 0 0
  1. Index: dist/game/config/Custom/MonsterSpawnMultiplier.ini
  2. ===================================================================
  3. --- dist/game/config/Custom/MonsterSpawnMultiplier.ini  (nonexistent)
  4. +++ dist/game/config/Custom/MonsterSpawnMultiplier.ini  (working copy)
  5. @@ -0,0 +1,16 @@
  6. +# ---------------------------------------------------------------------------
  7. +# Monster Spawn Multiplier
  8. +# ---------------------------------------------------------------------------
  9. +
  10. +# Enable/Disable monster spawn multiplier.
  11. +# Default: False
  12. +MonsterSpawnMultiplierEnable = False
  13. +
  14. +# Monster spawn count will be multiplied with this number.
  15. +# Default: 1
  16. +MonsterSpawnMultiplierRate = 1
  17.  
  18. +# Monster spawn mode
  19. +# 0 : static (fixed rate MonsterSpawnMultiplierRate)
  20. +# 1 : dynamic (random from 1..MonsterSpawnMultiplierRate)
  21. +# Default: 0
  22. +MonsterSpawnMultiplierMode = 0
  23.  
  24. +# Specify ids of monsters to be affected, or leave empty to affect all monsters.
  25. +# Example:
  26. +# MonsterMultiplierList = 1045, 2019
  27. +MonsterSpawnMultiplierList =
  28.  
  29. Index: java/com/l2jmobius/Config.java
  30. ===================================================================
  31. --- java/com/l2jmobius/Config.java  (revision 5007)
  32. +++ java/com/l2jmobius/Config.java  (working copy)
  33. @@ -118,6 +118,7 @@
  34.     private static final String CUSTOM_FACTION_SYSTEM_CONFIG_FILE = "./config/Custom/FactionSystem.ini";
  35.     private static final String CUSTOM_FAKE_PLAYERS_CONFIG_FILE = "./config/Custom/FakePlayers.ini";
  36.     private static final String CUSTOM_FIND_PVP_CONFIG_FILE = "./config/Custom/FindPvP.ini";
  37. +   private static final String CUSTOM_MONSTER_MULTIPLIER_CONFIG_FILE = "./config/Custom/MonsterSpawnMultiplier.ini";
  38.     private static final String CUSTOM_MULTILANGUAL_SUPPORT_CONFIG_FILE = "./config/Custom/MultilingualSupport.ini";
  39.     private static final String CUSTOM_NPC_STAT_MULTIPIERS_CONFIG_FILE = "./config/Custom/NpcStatMultipliers.ini";
  40.     private static final String CUSTOM_OFFLINE_TRADE_CONFIG_FILE = "./config/Custom/OfflineTrade.ini";
  41. @@ -1076,6 +1077,9 @@
  42.     public static boolean FAKE_PLAYER_CAN_DROP_ITEMS;
  43.     public static boolean FAKE_PLAYER_CAN_PICKUP;
  44.     public static boolean ENABLE_FIND_PVP;
  45. +   public static boolean MONSTER_SPAWN_MULTIPLIER_ENABLED;
  46. +   public static float MONSTER_SPAWN_MULTIPLIER_RATE;
  47. +   public static float MONSTER_SPAWN_MULTIPLIER_MODE;
  48. +   public static List<Integer> MONSTER_SPAWN_MULTIPLIER_LIST;
  49.     public static boolean PREMIUM_SYSTEM_ENABLED;
  50.     public static float PREMIUM_RATE_XP;
  51.     public static float PREMIUM_RATE_SP;
  52. @@ -2430,6 +2434,22 @@
  53.             final PropertiesParser FindPvP = new PropertiesParser(CUSTOM_FIND_PVP_CONFIG_FILE);
  54.             ENABLE_FIND_PVP = FindPvP.getBoolean("EnableFindPvP", false);
  55.            
  56. +           // Load MonsterSpawnMultiplier config file (if exists)
  57. +           final PropertiesParser MonsterSpawnMultiplier = new PropertiesParser(CUSTOM_MONSTER_MULTIPLIER_CONFIG_FILE);
  58. +          
  59. +           MONSTER_SPAWN_MULTIPLIER_ENABLED = MonsterSpawnMultiplier.getBoolean("MonsterSpawnMultiplierEnable", false);
  60. +           MONSTER_SPAWN_MULTIPLIER_RATE = MonsterSpawnMultiplier.getFloat("MonsterSpawnMultiplierRate", 1);
  61. +           MONSTER_SPAWN_MULTIPLIER_MODE = MonsterSpawnMultiplier.getInt("MonsterSpawnMultiplierMode", 0);
  62. +           final String[] monsterSpawnMultiplierList = MonsterSpawnMultiplier.getString("MonsterSpawnMultiplierList", "").split(",");
  63. +           MONSTER_SPAWN_MULTIPLIER_LIST = new ArrayList<>(monsterSpawnMultiplierList.length);
  64. +           for (String monsterId : monsterSpawnMultiplierList)
  65. +           {
  66. +               monsterId = monsterId.trim();
  67. +               if (!monsterId.equals("0") && Util.isDigit(monsterId))
  68. +               {
  69. +                   MONSTER_SPAWN_MULTIPLIER_LIST.add(Integer.parseInt(monsterId));
  70. +               }
  71. +           }
  72. +          
  73.             // Load MultilingualSupport config file (if exists)
  74.             final PropertiesParser MultilingualSupport = new PropertiesParser(CUSTOM_MULTILANGUAL_SUPPORT_CONFIG_FILE);
  75.            
  76. Index: java/com/l2jmobius/gameserver/model/spawns/NpcSpawnTemplate.java
  77. ===================================================================
  78. --- java/com/l2jmobius/gameserver/model/spawns/NpcSpawnTemplate.java    (revision 5007)
  79. +++ java/com/l2jmobius/gameserver/model/spawns/NpcSpawnTemplate.java    (working copy)
  80. @@ -25,6 +25,7 @@
  81.  import java.util.logging.Level;
  82.  import java.util.logging.Logger;
  83. +import java.util.Random;
  84.  
  85. +import com.l2jmobius.Config;
  86.  import com.l2jmobius.commons.util.Rnd;
  87.  import com.l2jmobius.gameserver.data.xml.impl.NpcData;
  88.  import com.l2jmobius.gameserver.datatables.SpawnTable;
  89. @@ -87,7 +88,7 @@
  90.         _spawnTemplate = spawnTemplate;
  91.         _group = group;
  92.         _id = set.getInt("id");
  93. -       _count = set.getInt("count", 1);
  94. +       _count = getSpawnMultiplier(_id, set);
  95.         _respawnTime = set.getDuration("respawnTime", null);
  96.         _respawnTimeRandom = set.getDuration("respawnRandom", null);
  97.         _spawnAnimation = set.getBoolean("spawnAnimation", false);
  98. @@ -128,6 +129,21 @@
  99.         mergeParameters(spawnTemplate, group);
  100.     }
  101.    
  102. +       private int getSpawnMultiplier(int id, StatsSet set)
  103. +       {
  104. +               final int originalCount = set.getInt("count", 1);
  105. +               if (Config.MONSTER_SPAWN_MULTIPLIER_ENABLED && NpcData.getInstance().getTemplate(id).isType("L2Monster"))
  106. +               {
  107. +                       int newSpawnCount = originalCount;
  108. +                       if (Config.MONSTER_SPAWN_MULTIPLIER_MODE == 1)
  109. +                       {
  110. +                               newSpawnCount = newSpawnCount * (new Random().nextInt((int) ((Config.MONSTER_SPAWN_MULTIPLIER_RATE - 1) + 1)) + 1);
  111. +                       }
  112. +                       else
  113. +                       {
  114. +                               newSpawnCount = (int) (newSpawnCount * Config.MONSTER_SPAWN_MULTIPLIER_RATE);
  115. +                       }
  116. +
  117. +                       if (!Config.MONSTER_SPAWN_MULTIPLIER_LIST.isEmpty())
  118. +                       {
  119. +                               return Config.MONSTER_SPAWN_MULTIPLIER_LIST.contains(id) ? newSpawnCount : originalCount;
  120. +                       }
  121. +                       return newSpawnCount;
  122. +               }
  123. +               return originalCount;
  124. +       }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement