Advertisement
iant06

Untitled

Nov 4th, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.91 KB | None | 0 0
  1. package scripts.clues;
  2.  
  3. import org.tribot.api.General;
  4. import org.tribot.api.Timing;
  5. import org.tribot.api.types.generic.Condition;
  6. import org.tribot.api.util.ABCUtil;
  7. import org.tribot.api2007.Equipment;
  8. import org.tribot.api2007.Interfaces;
  9. import org.tribot.api2007.Inventory;
  10. import org.tribot.api2007.Magic;
  11. import org.tribot.api2007.Player;
  12. import org.tribot.api2007.types.RSArea;
  13. import org.tribot.api2007.types.RSItem;
  14. import org.tribot.api2007.types.RSTile;
  15.  
  16. import scripts.clues.types.State;
  17. import scripts.clues.types.TeleportLocation;
  18. import scripts.clues.types.TeleportMethod;
  19. import scripts.methods.Methods;
  20.  
  21. public class Teleporting {
  22.  
  23. private Main main;
  24.  
  25. private final ABCUtil abc = new ABCUtil();
  26.  
  27. public final int ANIM = 714;
  28.  
  29. public Teleporting(Main main) {
  30. setMain(main);
  31. }
  32.  
  33. private long last_busy_time = 0L;
  34.  
  35. public boolean teleportTo(TeleportLocation loc) {
  36. Interfaces.closeAll();
  37. switch(loc) {
  38. case ARDOUGNE:
  39. return teleport(Constants.ARDOUGNE_TAB_ID, Locations.ARDOUGNE_TELEPORT_AREA, Constants.ARDOUGNE_TAB_PRICE, "Ardougne Teleport", loc);
  40. case BURTHORPE:
  41. return gamesNecklace();
  42. case CAMELOT:
  43. return teleport(Constants.CAMELOT_TAB_ID, Locations.CAMELOT_TELEPORT_AREA, Constants.CAMELOT_TAB_PRICE, "Camelot Teleport", loc);
  44. case CASTLEWARS:
  45. return duelRing("Castle Wars");
  46. case DUELARENA:
  47. return duelRing("Duel Arena");
  48. case FALADOR:
  49. return teleport(Constants.FALADOR_TAB_ID, Locations.FALADOR_TELEPORT_AREA, Constants.FALADOR_TAB_PRICE, "Falador Teleport", loc);
  50. case LUMBRIDGE:
  51. return teleport(Constants.LUMBRIDGE_TAB_ID, Locations.LUMBRIDGE_TELEPORT_AREA, Constants.LUMBRIDGE_TAB_PRICE, "Lumbridge Teleport", loc);
  52. case VARROCK:
  53. return teleport(Constants.VARROCK_TAB_ID, Locations.VARROCK_TELEPORT_AREA, Constants.VARROCK_TAB_PRICE, "Varrock Teleport", loc);
  54. }
  55. return false;
  56. }
  57.  
  58. public boolean duelRing(String location) {
  59.  
  60. if(!getMain().getEquipped().hasRing()) {
  61. getMain().setState(State.BANKING);
  62. return false;
  63. }
  64.  
  65. RSArea area = location.contains("Duel Arena") ?
  66. Locations.DUELARENA_TELEPORT_AREA : Locations.CASTLE_WARS_TELEPORT_AREA;
  67. RSTile tile = area.getRandomTile();
  68. int dist = Methods.distanceTo(getMain(), tile);
  69.  
  70. if(dist < 30 && Player.getPosition().getPlane() == 0
  71. || area.contains(Player.getPosition())) {
  72. return true;
  73. }
  74.  
  75. if(!Equipment.isEquipped(Constants.DUEL_RING_ID)
  76. && Inventory.getCount(Constants.DUEL_RING_ID) > 0)
  77. getMain().getEquipped().wearItem(Inventory.find(Constants.DUEL_RING_ID));
  78.  
  79. return jewellryTeleport(Equipment.find(Constants.DUEL_RING_ID), area, location);
  80. }
  81.  
  82. public boolean gamesNecklace() {
  83.  
  84. if(!getMain().getEquipped().hasNecklace()) {
  85. getMain().setState(State.BANKING);
  86. return false;
  87. }
  88.  
  89. RSArea area = Locations.BURTHORPE_TELEPORT_AREA;
  90. RSTile tile = area.getRandomTile();
  91. int dist = Methods.distanceTo(getMain(), tile);
  92.  
  93. if(dist < 30 && Player.getPosition().getPlane() == 0
  94. || area.contains(Player.getPosition())) {
  95. return true;
  96. }
  97.  
  98. if(!Equipment.isEquipped(Constants.GAMES_NECKLACE_ID)
  99. && Inventory.getCount(Constants.GAMES_NECKLACE_ID) > 0)
  100. getMain().getEquipped().wearItem(Inventory.find(Constants.GAMES_NECKLACE_ID));
  101.  
  102. return jewellryTeleport(Equipment.find(Constants.GAMES_NECKLACE_ID), Locations.BURTHORPE_TELEPORT_AREA, "Burthorpe");
  103. }
  104.  
  105. public boolean teleport(int id, RSArea area, int price, String teleportName, TeleportLocation loc) {
  106.  
  107. RSTile tile = area.getRandomTile();
  108. int dist = tile.distanceTo(Player.getPosition());
  109.  
  110. if(dist < 40 && Player.getPosition().getPlane() == 0
  111. || area.contains(Player.getPosition())) {
  112. return true;
  113. }
  114.  
  115. if(getMain().getState().equals(State.BANKING)
  116. && !Locations.MONASTERY_AREA.contains(Player.getPosition())
  117. && !Locations.CRAFTING_GUILD_AREA.contains(Player.getPosition())) {
  118. int bankdist = getMain().getBank().getClosestBankDistance();
  119. if(bankdist < dist && !Locations.inHamDungeon() && bankdist < 100) {
  120.  
  121. if(Player.getPosition().getPlane() > 0) {
  122. abc.waitNewOrSwitchDelay(last_busy_time, false);
  123. getMain().getClueScroll().climb(false);
  124. last_busy_time = System.currentTimeMillis();
  125. }
  126. getMain().println("Teleport Distance("+dist+") is greater than Closest Bank Distance("+bankdist+").");
  127. return true;
  128. }
  129. }
  130.  
  131. getMain().setStatus("Teleporting to " + Methods.correctCapitalization(loc.toString()));
  132.  
  133. if(getMain().getTeleportMethod().equals(TeleportMethod.TABS)) {
  134.  
  135. RSItem[] tab = Inventory.find(id);
  136.  
  137. if(tab.length > 0) {
  138.  
  139. if(area.contains(Player.getPosition()))
  140. return true;
  141.  
  142. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  143. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  144.  
  145. if(tab[0].click("Break")) {
  146.  
  147. final RSArea a = area;
  148.  
  149. if(Timing.waitCondition(new Condition() {
  150.  
  151. @Override
  152. public boolean active() {
  153. return a.contains(Player.getPosition());
  154. }
  155.  
  156. }, General.random(8000, 12000))) {
  157. getMain().setLoss(getMain().getLoss() + price);
  158. return true;
  159. }
  160. return false;
  161. }
  162.  
  163.  
  164. } else {
  165.  
  166. if(id == Constants.ARDOUGNE_TAB_ID) {
  167. getMain().getClueTask().setTeleLocation(TeleportLocation.CAMELOT);
  168. return teleport(Constants.CAMELOT_TAB_ID, Locations.CAMELOT_TELEPORT_AREA, Constants.CAMELOT_TAB_PRICE, "Camelot Teleport", loc);
  169. }
  170.  
  171. }
  172.  
  173. } else if(getMain().getTeleportMethod().equals(TeleportMethod.RUNES)) {
  174.  
  175. if(loc.equals(TeleportLocation.ARDOUGNE)) {
  176. loc = TeleportLocation.CAMELOT;
  177. teleportName = "Camelot Teleport";
  178. area = TeleportLocation.CAMELOT.getArea();
  179. }
  180.  
  181. if(area.contains(Player.getPosition()))
  182. return true;
  183.  
  184. abc.waitNewOrSwitchDelay(last_busy_time, false);
  185.  
  186. if(Magic.selectSpell(teleportName)) {
  187. last_busy_time = System.currentTimeMillis();
  188. final RSArea a = area;
  189.  
  190. if(Timing.waitCondition(new Condition() {
  191.  
  192. @Override
  193. public boolean active() {
  194. return a.contains(Player.getPosition());
  195. }
  196.  
  197. }, General.random(8000, 12000))) {
  198. getMain().setLoss(getMain().getLoss() + getRuneCost(loc));
  199. return true;
  200. }
  201. }
  202.  
  203. }
  204. return area.contains(Player.getPosition());
  205. }
  206.  
  207. public boolean jewellryTeleport(RSItem[] item, RSArea area, String option) {
  208.  
  209. if(area.contains(Player.getPosition()))
  210. return true;
  211.  
  212. if(item.length > 0) {
  213.  
  214. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  215. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  216.  
  217. if(item[0].click(option)) {
  218.  
  219. if(Timing.waitCondition(new Condition() {
  220.  
  221. @Override
  222. public boolean active() {
  223. return area.contains(Player.getPosition());
  224. }
  225.  
  226. }, General.random(8000, 12000))) {
  227. return true;
  228. }
  229.  
  230. }
  231. }
  232. return false;
  233. }
  234.  
  235. public int getRuneCost(TeleportLocation loc) {
  236. int[][] runes = getRunesRequired(loc);
  237. int cost = 0;
  238. for(int i = 0; i < runes.length; i++) {
  239. cost += Methods.getPrice(getMain(), runes[i][0]) * runes[i][1];
  240. }
  241. return cost;
  242. }
  243.  
  244. public int[][] getRunesRequired(TeleportLocation loc) {
  245. switch(loc) {
  246. case CAMELOT:
  247. return new int[][] {
  248. {Constants.LAW_RUNE_ID, 1},
  249. {Constants.AIR_RUNE_ID, 5}
  250. };
  251. case FALADOR:
  252. return new int[][] {
  253. {Constants.LAW_RUNE_ID, 1},
  254. {Constants.WATER_RUNE_ID, 1},
  255. {Constants.AIR_RUNE_ID, 3}
  256. };
  257. case LUMBRIDGE:
  258. return new int[][] {
  259. {Constants.LAW_RUNE_ID, 1},
  260. {Constants.EARTH_RUNE_ID, 1},
  261. {Constants.AIR_RUNE_ID, 3}
  262. };
  263. case VARROCK:
  264. return new int[][] {
  265. {Constants.LAW_RUNE_ID, 1},
  266. {Constants.FIRE_RUNE_ID, 1},
  267. {Constants.AIR_RUNE_ID, 3}
  268. };
  269. case ARDOUGNE:
  270. case BURTHORPE:
  271. case CASTLEWARS:
  272. case DUELARENA:
  273. return null;
  274. default:
  275. break;
  276. }
  277. return null;
  278. }
  279.  
  280. public Main getMain() {
  281. return main;
  282. }
  283.  
  284. public void setMain(Main m) {
  285. this.main = m;
  286. }
  287.  
  288. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement