armark1ng

Untitled

Sep 11th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.89 KB | None | 0 0
  1. package com.rs.game.player.content;
  2.  
  3. import com.rs.game.WorldTile;
  4. import com.rs.game.item.Item;
  5. import com.rs.game.player.Equipment;
  6. import com.rs.game.player.Player;
  7.  
  8. public class ItemTransportation {
  9.  
  10. private static final WorldTile[][] COORDINATES = new WorldTile[][] {
  11. { new WorldTile(3316, 3232, 0), new WorldTile(2443, 3089, 0), new WorldTile(2416, 2836, 0),
  12. new WorldTile(1701, 5600, 0) },
  13. { new WorldTile(2880, 3559, 0), new WorldTile(2519, 3571, 0), new WorldTile(2970, 9679, 0),
  14. new WorldTile(2886, 4377, 0), },
  15. { new WorldTile(3087, 3496, 0), new WorldTile(2918, 3176, 0), new WorldTile(3105, 3251, 0),
  16. new WorldTile(3293, 3163, 0) },
  17. { new WorldTile(3087, 3496, 0), new WorldTile(2918, 3176, 0), new WorldTile(3105, 3251, 0),
  18. new WorldTile(3293, 3163, 0) },
  19. { new WorldTile(2614, 3386, 0), new WorldTile(3032, 3337, 0), new WorldTile(2933, 3291, 0),
  20. new WorldTile(3143, 3442, 0) },
  21. { new WorldTile(2878, 3542, 0), new WorldTile(3191, 3363, 0), new WorldTile(2606, 3220, 0),
  22. new WorldTile(2657, 3238, 0) },
  23. { new WorldTile(3356, 3421, 0) }, { new WorldTile(3167, 3492, 0), new WorldTile(2527, 3860, 0) },
  24. { new WorldTile(3353, 3006, 0), new WorldTile(3427, 3538, 0), new WorldTile(2787, 3616, 0),
  25. new WorldTile(3150, 4666, 0) },
  26. { new WorldTile(4744, 5156, 0), new WorldTile(4599, 5062, 0), new WorldTile(4613, 5128, 0),
  27. new WorldTile(4744, 5170, 0) },
  28. { new WorldTile(2339, 3171, 0) }, { new WorldTile(3305, 3489, 0) }, { new WorldTile(3423, 2914, 0) },
  29. { new WorldTile(2796, 3082, 0) }, { new WorldTile(3170, 2982, 0) }, { new WorldTile(2294, 3626, 0) },
  30. { new WorldTile(2519, 3860, 0) }, { new WorldTile(3054, 3295, 0) },
  31. { new WorldTile(3565, 3312, 0), new WorldTile(3491, 3199, 0), new WorldTile(3626, 9618, 0),
  32. new WorldTile(3628, 3364, 0), new WorldTile(3633, 9696, 0) } };
  33. private static final String[] ITEM_NAMES = new String[] { "ring of duelling", "games necklace",
  34. "amulet of glory (t", "amulet of glory", "skills necklace", "combat bracelet", "digsite", "ring of wealth",
  35. "ring of slaying", "tokkul-zo (charged)", "teleport crystal", "lumber yard", "nardah", "tai bwo wannai",
  36. "bandit camp", "phoenix lair", "miscellania", "explorer's ring", "drakan's medallion" };
  37. private static final String[][] TELEPORT_NAMES = new String[][] {
  38. { "Al Kharid Duel Arena", "Castle Wars Arena", "Mobilizing Armies Command Centre", "Fist Of Guthix",
  39. "Nowhere" },
  40. { "Burthrope Games Room", "Barbarian Outpost", "Gamers' Grotto", "Corporeal Beast", "Nowhere" },
  41. { "Edgeville", "Karamja", "Draynor Village", "Al Kharid", "Nowhere" },
  42. { "Edgeville", "Karamja", "Draynor Village", "Al Kharid", "Nowhere" },
  43. { "Fishing Guild", "Mining Guild", "Crafting Guild", "Cooking Guild", "Nowhere" },
  44. { "Warrior's Guild", "Champions Guild", "Monastery", "Ranging Guild", "Nowhere" }, { "Digsite", "Nowhere" },
  45. { "Grand Exchange", "Miscellania", "Nowhere" },
  46. { "Sumona's Lair", "Slayer Tower", "Freminek Slayer Dungeon", "Tarn's Lair", "Nowhere" },
  47. { "Main Plaza", "Fight Pits", "Fight Caves", "Fight Kiln", "Nowhere" }, { "Lletya", "Nowhere" },
  48. { "Lumber Yard", "Nowhere" }, { "Nardah", "Nowhere" }, { "Tai Bwo Wannai", "Nowhere" },
  49. { "Bandit camp", "Nowhere" }, { "Phoenix lair", "Nowhere" }, { "Miscellania", "Nowhere" },
  50. { "Cabbage Port", "Nowhere" },
  51. { "Barrows", "Burgh de Rott", "Meiyerditch", "Darkmeyer", "Meiyerditch Labritories" } };
  52. private static final int[] LOWEST_AMOUNT = new int[] { 2566, 3867, 1706, 10362, 11113, 11126, 11190, 20651, 13288,
  53. 23643, 6102, 19480, 19475, 19479, 19476, 19478, 19477, 19760, -1 };
  54. public static final int EMOTE = 9603, GFX = 1684, SCROLL_EMOTE = 14293, SCROLL_GFX = 94, FIRST_CABBAGE_EMOTE = 804,
  55. SECOND_CABBAGE_EMOTE = 803, FIRST_CABBAGE_GFX = 1731, SECOND_CABBAGE_GFX = 1732;
  56.  
  57. public static boolean transportationDialogue(Player player, Item item, boolean removeCharge) {
  58. int index = getIndex(item);
  59. if (!checkAll(player, item, index, 0, 1))
  60. return false;
  61. player.getDialogueManager().startDialogue("Transportation", TELEPORT_NAMES[index], item.getId(), removeCharge);
  62. return true;
  63. }
  64.  
  65. private static boolean checkAll(Player player, Item item, int index, int optionsIndex, int optionsLength) {
  66. if (index == -1)
  67. return false;
  68. if (optionsIndex >= optionsLength) {
  69. player.stopAll(); // nowhere option
  70. return false;
  71. } else if (hasCharges(index) && !isScrollTeleport(index)
  72. && (item.getId() == 10362 || !item.getName().toLowerCase().contains("("))) {
  73. player.getPackets().sendGameMessage("Your " + item.getName().toLowerCase()
  74. + " has ran out of charges. You need to recharge it if you wish it use it once more.");
  75. return false;
  76. }
  77. return true;
  78. }
  79.  
  80. public static void sendTeleport(Player player, Item item, int optionIndex, boolean equipmentTeleport,
  81. boolean removeCharge) {
  82. sendTeleport(player, item, optionIndex, equipmentTeleport, 4, removeCharge);
  83. }
  84.  
  85. public static void sendTeleport(Player player, Item item, int optionIndex, boolean equipmentTeleport) {
  86. sendTeleport(player, item, optionIndex, equipmentTeleport, 4, true);
  87. }
  88.  
  89. public static void sendTeleport(Player player, Item item, int optionIndex, boolean equipmentTeleport,
  90. int optionslength, boolean removeCharge) {
  91. int index = getIndex(item);
  92. if (!checkAll(player, item, index, optionIndex, optionslength))
  93. return;
  94. if (Magic.sendTeleportSpell(player, getFirstEmote(index), getSecondEmote(index), getFirstGFX(index),
  95. getSecondGFX(index), 0, 0, COORDINATES[index][optionIndex], 4, true, Magic.ITEM_TELEPORT)) {
  96. if (hasCharges(index) && removeCharge) {
  97. int newItemId = item.getId() + ((isNegative(index) ? -1 : 1) * (isIncremented(index) ? 2 : 1)),
  98. slot = equipmentTeleport ? Equipment.getItemSlot(item.getId())
  99. : player.getInventory().getItems().getThisItemSlot(item);
  100. if (item.getId() == LOWEST_AMOUNT[index] && destroyOnEmpty(index)) {
  101. if (equipmentTeleport)
  102. player.getEquipment().deleteItem(item.getId(), item.getAmount());
  103. else
  104. player.getInventory().deleteItem(slot, item);
  105. player.getPackets().sendGameMessage(
  106. "Your " + item.getName().toLowerCase().replace(" (1)", "") + " has crumbled to dust.");
  107. } else {
  108. if (newItemId == 20652)
  109. newItemId = 2572;
  110. item.setId(newItemId);
  111. if (equipmentTeleport)
  112. player.getEquipment().refresh(slot);
  113. else
  114. player.getInventory().refresh(slot);
  115. }
  116. } else
  117. return;
  118. }
  119. }
  120.  
  121. private static boolean isScrollTeleport(int index) {
  122. return index >= 11 && index <= 16;
  123. }
  124.  
  125. public static int getFirstEmote(int index) {
  126. if (isScrollTeleport(index))
  127. return SCROLL_EMOTE;
  128. else if (index == 17)
  129. return FIRST_CABBAGE_EMOTE;
  130. else if (index == 18)
  131. return 8939;
  132. return EMOTE;
  133. }
  134.  
  135. public static int getFirstGFX(int index) {
  136. if (isScrollTeleport(index))
  137. return SCROLL_GFX;
  138. else if (index == 17)
  139. return FIRST_CABBAGE_GFX;
  140. else if (index == 18)
  141. return 1864;
  142. return GFX;
  143. }
  144.  
  145. public static int getSecondEmote(int index) {
  146. if (index == 17)
  147. return SECOND_CABBAGE_EMOTE;
  148. else if (index == 18)
  149. return 8941;
  150. return -1;
  151. }
  152.  
  153. public static int getSecondGFX(int index) {
  154. if (index == 17)
  155. return SECOND_CABBAGE_GFX;
  156. else if (index == 18)
  157. return 1864;
  158. return -1;
  159. }
  160.  
  161. private static int getIndex(Item item) {
  162. for (int i = 0; i < ITEM_NAMES.length; i++) {
  163. if (item.getName().toLowerCase().contains(ITEM_NAMES[i]))
  164. return i;
  165. }
  166. return -1;
  167. }
  168.  
  169. private static boolean hasCharges(int index) {
  170. if (index == 9 || index == 17 || index == 18)
  171. return false;
  172. return true;
  173. }
  174.  
  175. private static boolean isNegative(int index) {
  176. return index == 3 || index == 6 || index == 7;
  177. }
  178.  
  179. private static boolean isIncremented(int index) {
  180. return index == 0 || index == 1 || index == 2 || index == 3 || index == 4 || index == 5 || index == 7;
  181. }
  182.  
  183. private static boolean destroyOnEmpty(int index) {
  184. return index == 0 || index == 1 || index == 6 || index == 8 || isScrollTeleport(index);
  185. }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment