armark1ng

Untitled

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