armark1ng

Untitled

Jun 25th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.02 KB | None | 0 0
  1. package com.rs.game.npc;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import com.rs.cache.loaders.ItemDefinitions;
  7. import com.rs.game.player.Player;
  8. import com.rs.game.player.content.Combat;
  9. import com.rs.utils.Utils;
  10.  
  11. public class Drops {
  12.  
  13. public static final int ALWAYS = 0, COMMOM = 1, UNCOMMON = 2, RARE = 3, VERY_RARE = 4;
  14. //100% always, 100% commum, 75% uncommum, 2% rare, 1% very rare
  15. // public static final double[] DROP_RATES = { 100.0, 100.0, 75.0, 2.0, 1.0 };
  16.  
  17. //2nd eco
  18. /* public static final double[] DROP_RATES =
  19. { 100.0, 90.0, 70.0, 0.5, 0.3 };*/
  20. //boosted 20%
  21. public static final double[] DROP_RATES =
  22. { 100.0, 90.0, 70.0, 0.6, 0.36 };
  23.  
  24. public static final int[] CHARMS =
  25. { 12158, 12159, 12160, 12163 };
  26. public static final Drop[] RARE_DROP_TABLE =
  27. {
  28. new Drop(1623, 1, 1),
  29. new Drop(1621, 1, 1),
  30. new Drop(1619, 1, 1),
  31. new Drop(1617, 1, 1),
  32. new Drop(1453, 1, 1),
  33. new Drop(1462, 1, 1),
  34. new Drop(987, 1, 1),
  35. new Drop(985, 1, 1),
  36. new Drop(995, 250, 1200),
  37. new Drop(1247, 1, 1),
  38. new Drop(830, 5, 5),
  39. new Drop(1201, 1, 1),
  40. new Drop(1319, 1, 1),
  41. new Drop(1373, 1, 1),
  42. new Drop(2366, 1, 1),
  43. new Drop(1249, 1, 1),
  44. new Drop(1149, 1, 1),
  45. new Drop(563, 45, 45),
  46. new Drop(563, 5, 50),
  47. new Drop(561, 47, 77),
  48. new Drop(566, 20, 20),
  49. new Drop(565, 50, 50),
  50. new Drop(892, 150, 150),
  51. new Drop(443, 100, 100),
  52. new Drop(995, 250, 1200) // again
  53. ,
  54. new Drop(1215, 1, 1),
  55. new Drop(892, 150, 500) // again
  56. ,
  57. new Drop(9143, 200, 200),
  58. new Drop(533, 151, 500),
  59. new Drop(2999, 25, 250),
  60. new Drop(258, 33, 33),
  61. new Drop(3001, 30, 120),
  62. new Drop(270, 10, 100),
  63. new Drop(454, 150, 7500),
  64. new Drop(450, 150, 800),
  65. new Drop(7937, 100, 14500),
  66. new Drop(1441, 25, 35),
  67. new Drop(1443, 25, 36),
  68. new Drop(1444, 1, 1),
  69. new Drop(372, 125, 1000),
  70. new Drop(383, 250, 500),
  71. new Drop(5321, 3, 3),
  72. new Drop(1631, 1, 1),
  73. new Drop(1615, 1, 1),
  74. new Drop(1391, 200, 200),
  75. new Drop(574, 1000, 1000),
  76. new Drop(570, 1000, 1000),
  77. new Drop(451, 1, 100),
  78. new Drop(2362, 1450, 7000),
  79. new Drop(2364, 1, 150),
  80. new Drop(5315, 1, 50),
  81. new Drop(5316, 1, 6),
  82. new Drop(5289, 10, 10),
  83. new Drop(5304, 1, 31),
  84. new Drop(5300, 1, 1),
  85. new Drop(1516, 100, 4500),
  86. new Drop(21620, 4, 4),
  87. new Drop(9342, 150, 150),
  88. new Drop(1216, 50, 50),
  89. new Drop(20667, 1, 1),
  90. new Drop(6686, 250, 250) };
  91.  
  92. private boolean acessRareTable;
  93. private Drop[][] drops;
  94. private Drop[][] gearRareDrops;
  95.  
  96. public Drops(boolean acessRareTable) {
  97. this.acessRareTable = acessRareTable;
  98. drops = new Drop[VERY_RARE + 1][];
  99. gearRareDrops = new Drop[VERY_RARE - RARE + 1][];
  100.  
  101. }
  102.  
  103. public List<Drop> generateDrops(Player killer, double e) {
  104. List<Drop> d = new ArrayList<Drop>();
  105. boolean ringOfRecoil = Combat.hasRingOfWealth(killer);
  106. if (ringOfRecoil)
  107. e *= 1.01; //1% extra chance
  108. if (drops[ALWAYS] != null) {
  109. for (Drop drop : drops[ALWAYS])
  110. d.add(drop);
  111. }
  112. for (int i = COMMOM; i <= VERY_RARE; i++) {
  113. Drop drop = getDrop(i, e);
  114. if (drop != null) {
  115. if (i >= RARE && ringOfRecoil) {
  116. killer.getPackets().sendGameMessage("<col=ff7000>Your ring of wealth shines more brightly!", true);
  117. ringOfRecoil = false;
  118. }
  119. d.add(drop);
  120. }
  121. }
  122. if (acessRareTable && Utils.random((int) (3000 / e)) == 0) {
  123. Drop drop = getRareDropTable();
  124. if (drop.getItemId() != 20667 || ringOfRecoil)
  125. d.add(drop);
  126. }
  127. return d;
  128. }
  129.  
  130. public void setAcessRareTable(boolean t) {
  131. acessRareTable = t;
  132. }
  133.  
  134. public void addCharms(List<Drop> d, int size) {
  135. if (!d.isEmpty() && Utils.random(8 / size) == 0)
  136. d.add(new Drop(CHARMS[Utils.random(CHARMS.length)], 1, size));
  137. }
  138.  
  139. public Drop getRareDropTable() {
  140. return RARE_DROP_TABLE[Utils.random(RARE_DROP_TABLE.length)];
  141. }
  142. public Drop[] getDrops(int rarity) {
  143. return drops[rarity];
  144. }
  145.  
  146. public Drop getDrop(int rarity, double e) {
  147. if (rarity >= RARE) {
  148. if (gearRareDrops[rarity - RARE] != null && gearRareDrops[rarity - RARE].length != 0 && Math.random() * 100 <= (DROP_RATES[rarity] * e))
  149. return gearRareDrops[rarity - RARE][Utils.random(gearRareDrops[rarity - RARE].length)];
  150. }
  151. if (drops[rarity] != null && drops[rarity].length != 0 && Math.random() * 100 <= (DROP_RATES[rarity] * e))
  152. return drops[rarity][Utils.random(drops[rarity].length)];
  153. return null;
  154. }
  155.  
  156. public static boolean countsAsGear(int id) {
  157. return id == 13754 || id == 11286 || id == 21369 || id == 13746 || id == 13748 || id == 13750 || id == 13752;
  158. }
  159.  
  160. public void addDrops(List<Drop>[] dList) {
  161. for (int i = 0; i < dList.length; i++) {
  162. if (dList[i] == null)
  163. continue;
  164. if (i >= RARE) {
  165. ArrayList<Drop> cleanedGear = new ArrayList<Drop>();
  166. for (Drop drop : dList[i].toArray(new Drop[dList[i].size()])) {
  167. if (countsAsGear(drop.getItemId()) || ItemDefinitions.getItemDefinitions(drop.getItemId()).isWearItem()) {
  168. cleanedGear.add(drop);
  169. dList[i].remove(drop);
  170. }
  171. }
  172. if (cleanedGear.size() > 0)
  173. gearRareDrops[i - RARE] = cleanedGear.toArray(new Drop[cleanedGear.size()]);
  174. }
  175. drops[i] = dList[i].toArray(new Drop[dList[i].size()]);
  176. }
  177. }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment