Advertisement
Nik

Category drop rework

Nik
Apr 20th, 2011
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 21.85 KB | None | 0 0
  1. Index: java/com/l2jserver/gameserver/model/L2DropCategory.java
  2. ===================================================================
  3. --- java/com/l2jserver/gameserver/model/L2DropCategory.java (revision 4580)
  4. +++ java/com/l2jserver/gameserver/model/L2DropCategory.java (working copy)
  5. @@ -14,6 +14,8 @@
  6.   */
  7.  package com.l2jserver.gameserver.model;
  8.  
  9. +import java.util.List;
  10. +
  11.  import javolution.util.FastList;
  12.  
  13.  import com.l2jserver.Config;
  14. @@ -21,105 +23,72 @@
  15.  
  16.  /**
  17.   *
  18. - * @author  Fulminus
  19. + * @author Nik
  20.   */
  21.  public class L2DropCategory
  22.  {
  23. -   private FastList<L2DropData> _drops;
  24. -   private int _categoryChance; // a sum of chances for calculating if an item will be dropped from this category
  25. -   private int _categoryBalancedChance; // sum for balancing drop selection inside categories in high rate servers
  26. -   private int _categoryType;
  27. -  
  28. -   public L2DropCategory(int categoryType)
  29. +   public enum CategoryType
  30.     {
  31. -       _categoryType = categoryType;
  32. -       _drops = new FastList<L2DropData>(0);
  33. -       _categoryChance = 0;
  34. -       _categoryBalancedChance = 0;
  35. +       NORMAL, SWEEP, HERB, RAID, VITALITY_HERBS, HP_HERBS, MP_HERBS, SPECIAL_HERBS, COMMON_HERBS
  36.     }
  37.    
  38. -   public void addDropData(L2DropData drop, boolean raid)
  39. -   {
  40. -       boolean found = false;
  41. -      
  42. -       if (drop.isQuestDrop()) {
  43. -           //if (_questDrops == null)
  44. -           //  _questDrops = new FastList<L2DropData>(0);
  45. -           //_questDrops.add(drop);
  46. -       }
  47. -       else
  48. -       {
  49. -           if (Config.CUSTOM_DROPLIST_TABLE)
  50. -           {
  51. -               // If the drop exists is replaced
  52. -               for (L2DropData d : _drops)
  53. -               {
  54. -                   if (d.getItemId() == drop.getItemId())
  55. -                   {
  56. -                       d.setMinDrop(drop.getMinDrop());
  57. -                       d.setMaxDrop(drop.getMaxDrop());
  58. -                       if (d.getChance() != drop.getChance())
  59. -                       {
  60. -                           // Re-calculate Chance
  61. -                           _categoryChance -= d.getChance();
  62. -                           _categoryBalancedChance -= Math.min((d.getChance() * Config.RATE_DROP_ITEMS), L2DropData.MAX_CHANCE);
  63. -                           d.setChance(drop.getChance());
  64. -                           _categoryChance += d.getChance();
  65. -                           _categoryBalancedChance += Math.min((d.getChance() * Config.RATE_DROP_ITEMS), L2DropData.MAX_CHANCE);
  66. -                       }
  67. -                       found = true;
  68. -                       break;
  69. -                   }
  70. -               }
  71. -           }
  72. -          
  73. -           if (!found)
  74. -           {
  75. -               _drops.add(drop);
  76. -               _categoryChance += drop.getChance();
  77. -               // for drop selection inside a category: max 100 % chance for getting an item, scaling all values to that.
  78. -               _categoryBalancedChance += Math.min((drop.getChance()*(raid?Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS)),L2DropData.MAX_CHANCE);
  79. -           }
  80. -       }
  81. -   }
  82. +   private final FastList<L2DropData> _drops;
  83. +   private final int _categoryChance; // The chance that items are dropped from this category
  84. +   private final CategoryType _categoryType;
  85.    
  86. -   public FastList<L2DropData> getAllDrops()
  87. +   public L2DropCategory(CategoryType ct, int categoryChance)
  88.     {
  89. -       return _drops;
  90. -   }
  91. -  
  92. -   public void clearAllDrops()
  93. -   {
  94. -       _drops.clear();
  95. -   }
  96. -  
  97. -   public boolean isSweep()
  98. -   {
  99. -       return (getCategoryType()==-1);
  100. -   }
  101. -  
  102. -   // this returns the chance for the category to be visited in order to check if
  103. -   // drops might come from it.  Category -1 (spoil) must always be visited
  104. -   // (but may return 0 or many drops)
  105. -   public int getCategoryChance()
  106. -   {
  107. -       if (getCategoryType() >= 0)
  108. -           return _categoryChance;
  109. -       else
  110. -           return L2DropData.MAX_CHANCE;
  111. -   }
  112. -  
  113. -   public int getCategoryBalancedChance()
  114. -   {
  115. -       if (getCategoryType() >= 0)
  116. -           return _categoryBalancedChance;
  117. -       else
  118. -           return L2DropData.MAX_CHANCE;
  119. +       _drops = new FastList<L2DropData>(0);
  120. +       _categoryChance = categoryChance;
  121. +       _categoryType = ct;
  122.     }
  123.    
  124. -   public int getCategoryType()
  125. +   /**
  126. +    * Modifies the param's drop chance with the config values of the corresponding category type
  127. +    * then the item is added to the _drops, with a modified chance, which can exceed L2DropData.MAX_CHANCE
  128. +    * @param drop
  129. +    */
  130. +   public void addDrop(L2DropData drop)
  131.     {
  132. -       return _categoryType;
  133. +       int newDropChance = drop.getChance();
  134. +       switch(_categoryType)
  135. +       {
  136. +           case NORMAL:
  137. +               if (Config.RATE_DROP_ITEMS_ID.get(drop.getItemId()) != 0)
  138. +                   newDropChance *= Config.RATE_DROP_ITEMS_ID.get(drop.getItemId());
  139. +               else
  140. +                   newDropChance *= Config.RATE_DROP_ITEMS;
  141. +               break;
  142. +           case SWEEP:
  143. +               if (Config.RATE_DROP_ITEMS_ID.get(drop.getItemId()) != 0)
  144. +                   newDropChance *= Config.RATE_DROP_ITEMS_ID.get(drop.getItemId());
  145. +               else
  146. +                   newDropChance *= Config.RATE_DROP_SPOIL;
  147. +               break;
  148. +           case RAID:
  149. +               if (Config.RATE_DROP_ITEMS_ID.get(drop.getItemId()) != 0)
  150. +                   newDropChance *= Config.RATE_DROP_ITEMS_ID.get(drop.getItemId());
  151. +               else
  152. +                   newDropChance *= Config.RATE_DROP_ITEMS_BY_RAID;
  153. +               break;
  154. +           case VITALITY_HERBS:
  155. +               newDropChance *= Config.RATE_DROP_VITALITY_HERBS;
  156. +               break;
  157. +           case HP_HERBS:
  158. +               newDropChance *= Config.RATE_DROP_HP_HERBS;
  159. +               break;
  160. +           case MP_HERBS:
  161. +               newDropChance *= Config.RATE_DROP_MP_HERBS;
  162. +               break;
  163. +           case SPECIAL_HERBS:
  164. +               newDropChance *= Config.RATE_DROP_SPECIAL_HERBS;
  165. +               break;
  166. +           case COMMON_HERBS:
  167. +               newDropChance *= Config.RATE_DROP_COMMON_HERBS;
  168. +       }
  169. +      
  170. +       drop.setChance(newDropChance);
  171. +       _drops.add(drop);
  172.     }
  173.    
  174.     /**
  175. @@ -136,28 +105,26 @@
  176.     public synchronized L2DropData dropSeedAllowedDropsOnly()
  177.     {
  178.         FastList<L2DropData> drops = new FastList<L2DropData>();
  179. -       int subCatChance = 0;
  180. -       for (L2DropData drop : getAllDrops())
  181. +       for (L2DropData drop : _drops)
  182.         {
  183. -           if ((drop.getItemId() == 57) || (drop.getItemId() == 6360)|| (drop.getItemId() == 6361)|| (drop.getItemId() == 6362))
  184. -           {
  185. +           if ((drop.getItemId() == 57) || (drop.getItemId() == 6360) || (drop.getItemId() == 6361) || (drop.getItemId() == 6362))
  186.                 drops.add(drop);
  187. -               subCatChance += drop.getChance();
  188. -           }
  189.         }
  190.        
  191. -       // among the results choose one.
  192. -       int randomIndex = Rnd.get(subCatChance);
  193. -       int sum = 0;
  194. -       for (L2DropData drop : drops)
  195. +       while (!drops.isEmpty())
  196.         {
  197. -           sum += drop.getChance();
  198. -          
  199. -           if (sum > randomIndex)       // drop this item and exit the function
  200. +           // Get drop data from a random index
  201. +           L2DropData dd = drops.get(Rnd.get(drops.size()));
  202. +           if (dd.getChance() >= Rnd.get(L2DropData.MAX_CHANCE))
  203. +           {
  204. +               // This is the lucky drop :)
  205. +               return dd;
  206. +           }
  207. +           else
  208.             {
  209. -               drops.clear();
  210. -               drops=null;
  211. -               return drop;
  212. +               // This drop is unlucky :( so it wont drop.
  213. +               // Remove this drop, since it already got checked
  214. +               drops.remove(dd);
  215.             }
  216.         }
  217.         // since it is still within category, only drop one of the acceptable drops from the results.
  218. @@ -165,43 +132,49 @@
  219.     }
  220.    
  221.     /**
  222. -    * ONE of the drops in this category is to be dropped now.
  223. -    * to see which one will be dropped, weight all items' chances such that
  224. -    * their sum of chances equals MAX_CHANCE.
  225. -    * since the individual drops have their base chance, we also ought to use the
  226. -    * base category chance for the weight.  So weight = MAX_CHANCE/basecategoryDropChance.
  227. -    * Then get a single random number within this range.  The first item
  228. -    * (in order of the list) whose contribution to the sum makes the
  229. -    * sum greater than the random number, will be dropped.
  230. -    *
  231. -    * Edited: How _categoryBalancedChance works in high rate servers:
  232. -    * Let's say item1 has a drop chance (when considered alone, without category) of
  233. -    * 1 % * RATE_DROP_ITEMS and item2 has 20 % * RATE_DROP_ITEMS, and the server's
  234. -    * RATE_DROP_ITEMS is for example 50x. Without this balancer, the relative chance inside
  235. -    * the category to select item1 to be dropped would be 1/26 and item2 25/26, no matter
  236. -    * what rates are used. In high rate servers people usually consider the 1 % individual
  237. -    * drop chance should become higher than this relative chance (1/26) inside the category,
  238. -    * since having the both items for example in their own categories would result in having
  239. -    * a drop chance for item1 50 % and item2 1000 %. _categoryBalancedChance limits the
  240. -    * individual chances to 100 % max, making the chance for item1 to be selected from this
  241. -    * category 50/(50+100) = 1/3 and item2 100/150 = 2/3.
  242. -    * This change doesn't affect calculation when drop_chance * RATE_DROP_ITEMS < 100 %,
  243. -    * meaning there are no big changes for low rate servers and no changes at all for 1x
  244. -    * servers.
  245. -    *
  246. -    * @return selected drop from category, or null if nothing is dropped.
  247. +    * Gets a random index from the drop list, checks if the chance of the L2DropData
  248. +    * corresponding to the index if bigger than Rnd.get(L2DropData.MAX_CHANCE)
  249. +    * if so, this L2DropData will be returned, if not, it will go through the same
  250. +    * loop with another L2DropData (not the same, since it gets removed).
  251. +    * If no L2DropData gets chosen, it will return null.
  252. +    * @return Lucky L2DropData or null if there is no lucky hit :)
  253.      */
  254. -   public synchronized L2DropData dropOne(boolean raid)
  255. +   public synchronized L2DropData dropOne()
  256.     {
  257. -       int randomIndex = Rnd.get(getCategoryBalancedChance());
  258. -       int sum = 0;
  259. -       for (L2DropData drop : getAllDrops())
  260. +       List<L2DropData> tmp = new FastList<L2DropData>();
  261. +       tmp.addAll(_drops);
  262. +       while (!tmp.isEmpty())
  263.         {
  264. -           sum += Math.min((drop.getChance()*(raid?Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS)),L2DropData.MAX_CHANCE);
  265. -          
  266. -           if (sum >= randomIndex)       // drop this item and exit the function
  267. -               return drop;
  268. +           // Get drop data from a random index
  269. +           L2DropData dd = tmp.get(Rnd.get(tmp.size()));
  270. +           if (dd.getChance() >= Rnd.get(L2DropData.MAX_CHANCE))
  271. +           {
  272. +               // This is the lucky drop :)
  273. +               return dd;
  274. +           }
  275. +           else
  276. +           {
  277. +               // This drop is unlucky :( so it wont drop.
  278. +               // Remove this drop, since it already got checked
  279. +               tmp.remove(dd);
  280. +           }
  281.         }
  282. +      
  283.         return null;
  284.     }
  285. +  
  286. +   public FastList<L2DropData> getDrops()
  287. +   {
  288. +       return _drops;
  289. +   }
  290. +  
  291. +   public int getCategoryChance()
  292. +   {
  293. +       return _categoryChance;
  294. +   }
  295. +  
  296. +   public CategoryType getCategoryType()
  297. +   {
  298. +       return _categoryType;
  299. +   }
  300.  }
  301. Index: java/com/l2jserver/gameserver/model/L2Skill.java
  302. ===================================================================
  303. --- java/com/l2jserver/gameserver/model/L2Skill.java    (revision 4580)
  304. +++ java/com/l2jserver/gameserver/model/L2Skill.java    (working copy)
  305. @@ -464,8 +464,8 @@
  306.         _magicLevel = set.getInteger("magicLvl", SkillTreeTable.getInstance().getMinSkillLevel(_id, _level));
  307.         _levelDepend = set.getInteger("lvlDepend", 0);
  308.         _ignoreResists = set.getBool("ignoreResists", false);
  309. -       _minChance = set.getInteger("minChance", 1);
  310. -       _maxChance = set.getInteger("maxChance", 99);
  311. +       _minChance = set.getInteger("minChance", 10);
  312. +       _maxChance = set.getInteger("maxChance", 90);
  313.         _stat = set.getEnum("stat", Stats.class, null);
  314.         _ignoreShield = set.getBool("ignoreShld", false);
  315.         _skillType = set.getEnum("skillType", L2SkillType.class);
  316. Index: java/com/l2jserver/gameserver/model/actor/L2Attackable.java
  317. ===================================================================
  318. --- java/com/l2jserver/gameserver/model/actor/L2Attackable.java (revision 4580)
  319. +++ java/com/l2jserver/gameserver/model/actor/L2Attackable.java (working copy)
  320. @@ -32,7 +32,6 @@
  321.  import com.l2jserver.gameserver.ai.L2SiegeGuardAI;
  322.  import com.l2jserver.gameserver.datatables.EventDroplist;
  323.  import com.l2jserver.gameserver.datatables.EventDroplist.DateDrop;
  324. -import com.l2jserver.gameserver.datatables.HerbDropTable;
  325.  import com.l2jserver.gameserver.datatables.ItemTable;
  326.  import com.l2jserver.gameserver.datatables.SkillTable;
  327.  import com.l2jserver.gameserver.instancemanager.CursedWeaponsManager;
  328. @@ -247,7 +246,7 @@
  329.         public int getCount() { return _count;}
  330.     }
  331.    
  332. -   private FastMap<L2Character, AggroInfo> _aggroList = new FastMap<L2Character, AggroInfo>().shared();
  333. +   private final FastMap<L2Character, AggroInfo> _aggroList = new FastMap<L2Character, AggroInfo>().shared();
  334.    
  335.     public final FastMap<L2Character, AggroInfo> getAggroList()
  336.     {
  337. @@ -301,7 +300,7 @@
  338.    
  339.     private boolean _absorbed;
  340.    
  341. -   private FastMap<Integer, AbsorberInfo> _absorbersList = new FastMap<Integer, AbsorberInfo>().shared();
  342. +   private final FastMap<Integer, AbsorberInfo> _absorbersList = new FastMap<Integer, AbsorberInfo>().shared();
  343.    
  344.     private boolean _mustGiveExpSp;
  345.    
  346. @@ -555,10 +554,10 @@
  347.    
  348.     private static class OnKillNotifyTask implements Runnable
  349.     {
  350. -       private L2Attackable _attackable;
  351. -       private Quest _quest;
  352. -       private L2PcInstance _killer;
  353. -       private boolean _isPet;
  354. +       private final L2Attackable _attackable;
  355. +       private final Quest _quest;
  356. +       private final L2PcInstance _killer;
  357. +       private final boolean _isPet;
  358.        
  359.         public OnKillNotifyTask(L2Attackable attackable, Quest quest, L2PcInstance killer, boolean isPet)
  360.         {
  361. @@ -1331,38 +1330,13 @@
  362.         // Check if an Item from this category must be dropped
  363.         if (Rnd.get(L2DropData.MAX_CHANCE) < categoryDropChance)
  364.         {
  365. -           L2DropData drop = categoryDrops.dropOne(isRaid() && !isRaidMinion());
  366. +           // Drop's chance (increased by configs) is calculated inside L2DropCategory
  367. +           // this chance can exceed L2DropData.MAX_CHANCE;
  368. +           L2DropData drop = categoryDrops.dropOne();
  369.            
  370.             if (drop == null)
  371.                 return null;
  372.            
  373. -           // Now decide the quantity to drop based on the rates and penalties.    To get this value
  374. -           // simply divide the modified categoryDropChance by the base category chance.   This
  375. -           // results in a chance that will dictate the drops amounts: for each amount over 100
  376. -           // that it is, it will give another chance to add to the min/max quantities.
  377. -          
  378. -           // For example, If the final chance is 120%, then the item should drop between
  379. -           // its min and max one time, and then have 20% chance to drop again.    If the final
  380. -           // chance is 330%, it will similarly give 3 times the min and max, and have a 30%
  381. -           // chance to give a 4th time.
  382. -           // At least 1 item will be dropped for sure.    So the chance will be adjusted to 100%
  383. -           // if smaller.
  384. -          
  385. -           int dropChance = drop.getChance();
  386. -          
  387. -           if (Config.RATE_DROP_ITEMS_ID.get(drop.getItemId()) != 0)
  388. -               dropChance *= Config.RATE_DROP_ITEMS_ID.get(drop.getItemId());
  389. -           else
  390. -               dropChance *= isRaid() && !isRaidMinion() ? Config.RATE_DROP_ITEMS_BY_RAID : Config.RATE_DROP_ITEMS;
  391. -          
  392. -           if (Config.L2JMOD_CHAMPION_ENABLE && isChampion())
  393. -               dropChance *= Config.L2JMOD_CHAMPION_REWARDS;
  394. -          
  395. -           dropChance = Math.round(dropChance);
  396. -          
  397. -           if (dropChance < L2DropData.MAX_CHANCE)
  398. -               dropChance = L2DropData.MAX_CHANCE;
  399. -          
  400.             // Get min and max Item quantity that can be dropped in one time
  401.             int min = drop.getMinDrop();
  402.             int max = drop.getMaxDrop();
  403. @@ -1371,9 +1345,9 @@
  404.             int itemCount = 0;
  405.            
  406.             // Count and chance adjustment for high rate servers
  407. -           if (dropChance > L2DropData.MAX_CHANCE && !Config.PRECISE_DROP_CALCULATION)
  408. +           if (drop.getChance() > L2DropData.MAX_CHANCE && !Config.PRECISE_DROP_CALCULATION)
  409.             {
  410. -               int multiplier = dropChance / L2DropData.MAX_CHANCE;
  411. +               int multiplier = drop.getChance() / L2DropData.MAX_CHANCE;
  412.                
  413.                 if (min < max)
  414.                     itemCount += Rnd.get(min * multiplier, max * multiplier);
  415. @@ -1382,12 +1356,12 @@
  416.                 else
  417.                     itemCount += multiplier;
  418.                
  419. -               dropChance = dropChance % L2DropData.MAX_CHANCE;
  420. +               drop.setChance(drop.getChance() % L2DropData.MAX_CHANCE);
  421.             }
  422.            
  423.             // Check if the Item must be dropped
  424.             int random = Rnd.get(L2DropData.MAX_CHANCE);
  425. -           while (random < dropChance)
  426. +           while (random < drop.getChance())
  427.             {
  428.                 // Get the item quantity dropped
  429.                 if (min < max)
  430. @@ -1397,8 +1371,8 @@
  431.                 else
  432.                     itemCount++;
  433.                
  434. -               // Prepare for next iteration if dropChance > L2DropData.MAX_CHANCE
  435. -               dropChance -= L2DropData.MAX_CHANCE;
  436. +               // Prepare for next iteration if drop.getChance() > L2DropData.MAX_CHANCE
  437. +               drop.setChance(drop.getChance() - L2DropData.MAX_CHANCE);
  438.             }
  439.             if (Config.L2JMOD_CHAMPION_ENABLE)
  440.                 // TODO (April 11, 2009): Find a way not to hardcode these values.
  441. @@ -1443,138 +1417,6 @@
  442.         return 0;
  443.     }
  444.    
  445. -   private RewardItem calculateCategorizedHerbItem(L2PcInstance lastAttacker, L2DropCategory categoryDrops)
  446. -   {
  447. -       if (categoryDrops == null)
  448. -           return null;
  449. -      
  450. -       // Get default drop chance for the category (that's the sum of chances for all items in the category)
  451. -       // keep track of the base category chance as it'll be used later, if an item is drop from the category.
  452. -       // for everything else, use the total "categoryDropChance"
  453. -       int basecategoryDropChance = categoryDrops.getCategoryChance() ;
  454. -       int categoryDropChance = basecategoryDropChance;
  455. -      
  456. -       // Applies Drop rates
  457. -       switch(categoryDrops.getCategoryType())
  458. -       {
  459. -           case 0:
  460. -               if (Config.ENABLE_DROP_VITALITY_HERBS)
  461. -                   categoryDropChance *= Config.RATE_DROP_VITALITY_HERBS;
  462. -               else
  463. -                   return null;
  464. -               break;
  465. -           case 1:
  466. -               categoryDropChance *= Config.RATE_DROP_HP_HERBS;
  467. -               break;
  468. -           case 2:
  469. -               categoryDropChance *= Config.RATE_DROP_MP_HERBS;
  470. -               break;
  471. -           case 3:
  472. -               categoryDropChance *= Config.RATE_DROP_SPECIAL_HERBS;
  473. -               break;
  474. -           default:
  475. -               categoryDropChance *= Config.RATE_DROP_COMMON_HERBS;
  476. -       }
  477. -      
  478. -       // Round drop chance
  479. -       categoryDropChance = Math.round(categoryDropChance);
  480. -      
  481. -       // Set our limits for chance of drop
  482. -       if (categoryDropChance < 1)
  483. -           categoryDropChance = 1;
  484. -      
  485. -       // Check if an Item from this category must be dropped
  486. -       if (Rnd.get(L2DropData.MAX_CHANCE) < categoryDropChance)
  487. -       {
  488. -           L2DropData drop = categoryDrops.dropOne(false);
  489. -          
  490. -           if (drop == null)
  491. -               return null;
  492. -          
  493. -           // Now decide the quantity to drop based on the rates and penalties.    To get this value
  494. -           // simply divide the modified categoryDropChance by the base category chance.   This
  495. -           // results in a chance that will dictate the drops amounts: for each amount over 100
  496. -           // that it is, it will give another chance to add to the min/max quantities.
  497. -          
  498. -           // For example, If the final chance is 120%, then the item should drop between
  499. -           // its min and max one time, and then have 20% chance to drop again.    If the final
  500. -           // chance is 330%, it will similarly give 3 times the min and max, and have a 30%
  501. -           // chance to give a 4th time.
  502. -           // At least 1 item will be dropped for sure.    So the chance will be adjusted to 100%
  503. -           // if smaller.
  504. -          
  505. -           int dropChance = drop.getChance();
  506. -          
  507. -           switch(categoryDrops.getCategoryType())
  508. -           {
  509. -               case 0:
  510. -                   dropChance *= Config.RATE_DROP_VITALITY_HERBS;
  511. -                   break;
  512. -               case 1:
  513. -                   dropChance *= Config.RATE_DROP_HP_HERBS;
  514. -                   break;
  515. -               case 2:
  516. -                   dropChance *= Config.RATE_DROP_MP_HERBS;
  517. -                   break;
  518. -               case 3:
  519. -                   dropChance *= Config.RATE_DROP_SPECIAL_HERBS;
  520. -                   break;
  521. -               default:
  522. -                   dropChance *= Config.RATE_DROP_COMMON_HERBS;
  523. -           }
  524. -          
  525. -          
  526. -           dropChance = Math.round(dropChance);
  527. -          
  528. -           if (dropChance < L2DropData.MAX_CHANCE)
  529. -               dropChance = L2DropData.MAX_CHANCE;
  530. -          
  531. -           // Get min and max Item quantity that can be dropped in one time
  532. -           int min = drop.getMinDrop();
  533. -           int max = drop.getMaxDrop();
  534. -          
  535. -           // Get the item quantity dropped
  536. -           int itemCount = 0;
  537. -          
  538. -           // Count and chance adjustment for high rate servers
  539. -           if (dropChance > L2DropData.MAX_CHANCE && !Config.PRECISE_DROP_CALCULATION)
  540. -           {
  541. -               int multiplier = dropChance / L2DropData.MAX_CHANCE;
  542. -              
  543. -               if (min < max)
  544. -                   itemCount += Rnd.get(min * multiplier, max * multiplier);
  545. -               else if (min == max)
  546. -                   itemCount += min * multiplier;
  547. -               else
  548. -                   itemCount += multiplier;
  549. -              
  550. -               dropChance = dropChance % L2DropData.MAX_CHANCE;
  551. -           }
  552. -          
  553. -           // Check if the Item must be dropped
  554. -           int random = Rnd.get(L2DropData.MAX_CHANCE);
  555. -           while (random < dropChance)
  556. -           {
  557. -               // Get the item quantity dropped
  558. -               if (min < max)
  559. -                   itemCount += Rnd.get(min, max);
  560. -               else if (min == max)
  561. -                   itemCount += min;
  562. -               else
  563. -                   itemCount++;
  564. -              
  565. -               // Prepare for next iteration if dropChance > L2DropData.MAX_CHANCE
  566. -               dropChance -= L2DropData.MAX_CHANCE;
  567. -           }
  568. -          
  569. -           if (itemCount > 0)
  570. -               return new RewardItem(drop.getItemId(), itemCount);
  571. -           else if (itemCount == 0 && Config.DEBUG)
  572. -               _log.fine("Roll produced no drops.");
  573. -       }
  574. -       return null;
  575. -   }
  576. -  
  577.     public void doItemDrop(L2Character lastAttacker)
  578.     {
  579.         doItemDrop(getTemplate(),lastAttacker);
  580. @@ -1621,14 +1463,14 @@
  581.             for(L2DropCategory cat:npcTemplate.getDropData())
  582.             {
  583.                 RewardItem item = null;
  584. -               if (cat.isSweep())
  585. +               if (cat.getCategoryType() == L2DropCategory.CategoryType.SWEEP)
  586.                 {
  587.                     // according to sh1ny, seeded mobs CAN be spoiled and swept.
  588.                     if ( isSpoil()/* && !isSeeded() */)
  589.                     {
  590.                         FastList<RewardItem> sweepList = new FastList<RewardItem>();
  591.                        
  592. -                       for(L2DropData drop: cat.getAllDrops() )
  593. +                       for(L2DropData drop: cat.getDrops() )
  594.                         {
  595.                             item = calculateRewardItem(player, drop, levelModifier, true);
  596.                             if (item == null)
  597. @@ -1705,30 +1547,6 @@
  598.                     dropItem(player, item);
  599.             }
  600.         }
  601. -      
  602. -       //Instant Item Drop :>
  603. -       if (getTemplate().dropherbgroup > 0)
  604. -       {
  605. -           for(L2DropCategory cat : HerbDropTable.getInstance().getHerbDroplist(getTemplate().dropherbgroup))
  606. -           {
  607. -               RewardItem item = calculateCategorizedHerbItem(player, cat);
  608. -               if (item != null)
  609. -               {
  610. -                   // more than one herb cant be auto looted!
  611. -                   int count = item.getCount();
  612. -                   if (count > 1)
  613. -                   {
  614. -                       item._count = 1;
  615. -                       for(int i = 0; i < count; i++)
  616. -                           dropItem(player, item);
  617. -                   }
  618. -                   else if (isFlying() || Config.AUTO_LOOT_HERBS)
  619. -                       player.addItem("Loot", item.getItemId(), count, this, true);
  620. -                   else
  621. -                       dropItem(player, item);
  622. -               }
  623. -           }
  624. -       }
  625.     }
  626.    
  627.     /**
  628. @@ -2297,7 +2115,7 @@
  629.    
  630.     private static class CommandChannelTimer implements Runnable
  631.     {
  632. -       private L2Attackable _monster;
  633. +       private final L2Attackable _monster;
  634.        
  635.         public CommandChannelTimer(L2Attackable monster)
  636.         {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement