Advertisement
VANPER

Global Drop

Feb 9th, 2020
1,250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.81 KB | None | 0 0
  1. Index: java/net/sf/l2j/Config.java
  2. ===================================================================
  3. --- java/net/sf/l2j/Config.java (revision 84)
  4. +++ java/net/sf/l2j/Config.java (working copy)
  5. @@ -1281,6 +1281,10 @@
  6.  
  7. +   public static boolean GLOBAL_DROP;
  8. +   public static Map<Integer, List<Integer>> DROP_LIST = new HashMap<>();
  9.  
  10.  
  11.  
  12.  
  13. +   GLOBAL_DROP = server.getProperty("DropSystem", false);
  14. +   String[] temp = server.getProperty("DropList", "").split(";");
  15. +   for (String s : temp)
  16. +   {
  17. +       List<Integer> list = new ArrayList<>();
  18. +       String[] t = s.split(",");
  19. +       list.add(Integer.parseInt(t[1]));
  20. +       list.add(Integer.parseInt(t[2]));
  21. +       list.add(Integer.parseInt(t[3]));
  22. +       DROP_LIST.put(Integer.parseInt(t[0]), list);
  23. +   }
  24.  
  25.  
  26. Index: gameserver/config/server.properties
  27. ===================================================================
  28. --- gameserver/config/server.properties (revision 84)
  29. +++ gameserver/config/server.properties (working copy)
  30. @@ -1281,6 +1281,10 @@
  31.  
  32. +# =================================================================
  33. +#                   Global Drop
  34. +# =================================================================
  35.  
  36.  
  37. +   # Specified drop items.
  38. +   DropSystem = True
  39. +   # itemId,chance,min,max;itemId2,chance2,min2,max2;...
  40. +   DropList = 3470,10,1,2
  41.  
  42.  
  43.  
  44. Index: net.sf.l2j.gameserver.model.actor.instance/Monster.java
  45. ===================================================================
  46. --- net.sf.l2j.gameserver.model.actor.instance/Monster.java (revision 84)
  47. +++ net.sf.l2j.gameserver.model.actor.instance/Monster.java (working copy)
  48. @@ -1281,6 +1281,10 @@
  49.        
  50.     public void doItemDrop(NpcTemplate npcTemplate, Creature mainDamageDealer)
  51.     {
  52.         if (mainDamageDealer == null)
  53.             return;
  54.        
  55.         // Don't drop anything if the last attacker or owner isn't Player
  56.         final Player player = mainDamageDealer.getActingPlayer();
  57.         if (player == null)
  58.             return;
  59.        
  60.         // level modifier in %'s (will be subtracted from drop chance)
  61.         final int levelModifier = calculateLevelModifierForDrop(player);
  62.        
  63.         CursedWeaponManager.getInstance().checkDrop(this, player);
  64.        
  65.         // now throw all categorized drops and handle spoil.
  66.         for (DropCategory cat : npcTemplate.getDropData())
  67.         {
  68.             IntIntHolder item = null;
  69.             if (cat.isSweep())
  70.             {
  71.                 if (getSpoilState().isSpoiled())
  72.                 {
  73.                     for (DropData drop : cat.getAllDrops())
  74.                     {
  75.                         item = calculateRewardItem(drop, levelModifier, true, player);
  76.                         if (item == null)
  77.                             continue;
  78.                        
  79.                         getSpoilState().getSweepItems().add(item);
  80.                     }
  81.                 }
  82.             }
  83.             else
  84.             {
  85.                 if (getSeedState().isSeeded())
  86.                 {
  87.                     DropData drop = cat.dropSeedAllowedDropsOnly();
  88.                     if (drop == null)
  89.                         continue;
  90.                    
  91.                     item = calculateRewardItem(drop, levelModifier, false, player);
  92.                 }
  93.                 else
  94.                     item = calculateCategorizedRewardItem(cat, levelModifier, player);
  95.                
  96.                 if (item != null)
  97.                 {
  98.                     // Check if the autoLoot mode is active
  99.                     if ((isRaidBoss() && Config.AUTO_LOOT_RAID) || (!isRaidBoss() && Config.AUTO_LOOT))
  100.                         player.doAutoLoot(this, item);
  101.                     else
  102.                         dropItem(player, item);
  103.                    
  104.                     // Broadcast message if RaidBoss was defeated
  105.                     if (isRaidBoss())
  106.                         broadcastPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_DIED_DROPPED_S3_S2).addCharName(this).addItemName(item.getId()).addNumber(item.getValue()));
  107.                 }
  108.             }
  109.         }
  110.  
  111. +       if (Config.GLOBAL_DROP)
  112. +       {      
  113. +           for (Entry<Integer, List<Integer>> entry : Config.DROP_LIST.entrySet())
  114. +           {
  115. +               int rewardItem = Rnd.get(entry.getValue().get(1), entry.getValue().get(2));
  116. +               int dropChance = entry.getValue().get(0);
  117. +              
  118. +              
  119. +               // Apply level modifier, if any/wanted.
  120. +               if (Config.DEEPBLUE_DROP_RULES)
  121. +               {
  122. +                   int deepBlueDrop = (levelModifier > 0) ? 3 : 1;
  123. +                  
  124. +                   // Check if we should apply our maths so deep blue mobs will not drop that easy.
  125. +                   dropChance = ((entry.getValue().get(0) - ((entry.getValue().get(0) * levelModifier) / 100)) / deepBlueDrop);
  126. +               }
  127. +              
  128. +               if (Rnd.get(100) < dropChance)
  129. +               {
  130. +                   final IntIntHolder item = new IntIntHolder(entry.getKey(), rewardItem);
  131. +                   if (Config.AUTO_LOOT)
  132. +                       player.addItem("dropCustom", item.getId(), item.getValue(), this, true);
  133. +                   else
  134. +                       dropItem(player, item);
  135. +               }
  136. +           }
  137. +       }
  138.        
  139.         // Apply special item drop for champions.
  140.         if (isChampion() && Config.CHAMPION_REWARD > 0)
  141.         {
  142.             int dropChance = Config.CHAMPION_REWARD;
  143.            
  144.             // Apply level modifier, if any/wanted.
  145.             if (Config.DEEPBLUE_DROP_RULES)
  146.             {
  147.                 int deepBlueDrop = (levelModifier > 0) ? 3 : 1;
  148.                
  149.                 // Check if we should apply our maths so deep blue mobs will not drop that easy.
  150.                 dropChance = ((Config.CHAMPION_REWARD - ((Config.CHAMPION_REWARD * levelModifier) / 100)) / deepBlueDrop);
  151.             }
  152.            
  153.             if (Rnd.get(100) < dropChance)
  154.             {
  155.                 final IntIntHolder item = new IntIntHolder(Config.CHAMPION_REWARD_ID, Math.max(1, Rnd.get(1, Config.CHAMPION_REWARD_QTY)));
  156.                 if (Config.AUTO_LOOT)
  157.                     player.addItem("ChampionLoot", item.getId(), item.getValue(), this, true);
  158.                 else
  159.                     dropItem(player, item);
  160.             }
  161.         }
  162.        
  163.         // Herbs.
  164.         if (getTemplate().getDropHerbGroup() > 0)
  165.         {
  166.             for (DropCategory cat : HerbDropData.getInstance().getHerbDroplist(getTemplate().getDropHerbGroup()))
  167.             {
  168.                 final IntIntHolder item = calculateCategorizedHerbItem(cat, levelModifier);
  169.                 if (item != null)
  170.                 {
  171.                     if (Config.AUTO_LOOT_HERBS)
  172.                         player.addItem("Loot", item.getId(), 1, this, true);
  173.                     else
  174.                     {
  175.                         // If multiple similar herbs drop, split them and make a unique drop per item.
  176.                         final int count = item.getValue();
  177.                         if (count > 1)
  178.                         {
  179.                             item.setValue(1);
  180.                             for (int i = 0; i < count; i++)
  181.                                 dropItem(player, item);
  182.                         }
  183.                         else
  184.                             dropItem(player, item);
  185.                     }
  186.                 }
  187.             }
  188.         }
  189.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement