Advertisement
iant06

Untitled

Nov 13th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.08 KB | None | 0 0
  1. package scripts.clues;
  2.  
  3. import java.awt.Point;
  4. import java.util.HashMap;
  5.  
  6. import org.tribot.api.General;
  7. import org.tribot.api.Timing;
  8. import org.tribot.api.input.Mouse;
  9. import org.tribot.api.types.generic.Condition;
  10. import org.tribot.api.util.ABCUtil;
  11. import org.tribot.api2007.GameTab;
  12. import org.tribot.api2007.GameTab.TABS;
  13. import org.tribot.api2007.GroundItems;
  14. import org.tribot.api2007.Interfaces;
  15. import org.tribot.api2007.Inventory;
  16. import org.tribot.api2007.NPCChat;
  17. import org.tribot.api2007.NPCs;
  18. import org.tribot.api2007.Objects;
  19. import org.tribot.api2007.Player;
  20. import org.tribot.api2007.Skills;
  21. import org.tribot.api2007.Skills.SKILLS;
  22. import org.tribot.api2007.ext.Doors;
  23. import org.tribot.api2007.types.RSArea;
  24. import org.tribot.api2007.types.RSGroundItem;
  25. import org.tribot.api2007.types.RSInterface;
  26. import org.tribot.api2007.types.RSInterfaceChild;
  27. import org.tribot.api2007.types.RSInterfaceComponent;
  28. import org.tribot.api2007.types.RSItem;
  29. import org.tribot.api2007.types.RSNPC;
  30. import org.tribot.api2007.types.RSObject;
  31. import org.tribot.api2007.types.RSObjectDefinition;
  32. import org.tribot.api2007.types.RSTile;
  33.  
  34. import scripts.clues.types.AcquiringMethod;
  35. import scripts.clues.types.CrypticClue;
  36. import scripts.clues.types.EmoteClue;
  37. import scripts.clues.types.State;
  38. import scripts.clues.types.TeleportLocation;
  39. import scripts.methods.Methods;
  40.  
  41. public class ClueScroll {
  42.  
  43. private Main main;
  44. private Teleporting teleporting;
  45.  
  46. private int emoteClicks = 0;
  47. private int npcClicks = 0;
  48. private int climbTries = 0;
  49.  
  50. private boolean teleported = false;
  51. private boolean emoteTeleport = false;
  52. private boolean npcClicked = false;
  53.  
  54. private long last_busy_time = 0L;
  55.  
  56. private final ABCUtil abc = new ABCUtil();
  57.  
  58. public ClueScroll(Main m) {
  59. setMain(m);
  60. setTeleporting(getMain().getTeleporting());
  61. }
  62.  
  63. public boolean solveMapScroll(ClueTask task) {
  64.  
  65. if(getMain().getState().equals(State.BANKING))
  66. return true;
  67.  
  68. if(hasCasket()) {
  69. getMain().setClueTask(null);
  70. return true;
  71. }
  72.  
  73. getMain().setStatus("Solving Map Scroll");
  74. RSTile digTile = task.getDigLocation().getTile();
  75. RSTile pos = Player.getPosition();
  76.  
  77. if(!pos.equals(digTile)) {
  78. walkMapObjective(task, digTile);
  79. return false;
  80. }
  81.  
  82. return dig(digTile);
  83. }
  84.  
  85. public boolean solveCrypticScroll(ClueTask task) {
  86.  
  87. if(getMain().getState().equals(State.BANKING))
  88. return true;
  89.  
  90. if(isRewardInterface()) {
  91. getMain().setClueTask(null);
  92. getMain().setState(State.BANKING);
  93. return true;
  94. }
  95.  
  96. if(isItemInterface()) {
  97. getMain().setClueTask(null);
  98. return true;
  99. }
  100.  
  101. getMain().setStatus("Solving Cryptic Scroll");
  102.  
  103. CrypticClue cryptic = task.getCrypticClue();
  104. RSTile pos = Player.getPosition();
  105. int height = getCrypticHeight(cryptic);
  106. RSTile walk = cryptic.getWalkLocation();
  107. RSArea area = cryptic.getWalkLocationArea();
  108. String npcName = cryptic.getNpcName();
  109. String objectName = cryptic.getObjectName();
  110. int requiredDistance = cryptic.getDistance();
  111.  
  112. if(Locations.inDungeonArea(task) || cryptic.isUpstairs()) {
  113. walk = cryptic.getSecondaryWalkLocation();
  114. area = cryptic.getSecondaryWalkArea();
  115. }
  116.  
  117. int distanceToWalkTile = pos.distanceTo(walk);
  118.  
  119. if(distanceToWalkTile <= requiredDistance) {
  120.  
  121. if(!npcName.equals("null"))
  122. if(interactNpc(task, npcName, walk))
  123. return true;
  124.  
  125. if(!objectName.equals("null"))
  126. if(interactObject(task, objectName, walk, area))
  127. return true;
  128.  
  129. }
  130.  
  131. if(npcName.equals("null") && objectName.equals("null"))
  132. if(dig(walk))
  133. return true;
  134.  
  135. walkCrypticObjective(task, height, cryptic.getWalkLocation(), cryptic.getWalkLocationArea());
  136. return false;
  137. }
  138.  
  139. public boolean solveEmoteScroll(ClueTask task) {
  140.  
  141. if(getMain().getState().equals(State.BANKING))
  142. return true;
  143.  
  144. if(isRewardInterface()) {
  145. getMain().setClueTask(null);
  146. getMain().setState(State.BANKING);
  147. return true;
  148. }
  149.  
  150. if(isItemInterface() || hasCasket()) {
  151. getMain().setClueTask(null);
  152. return true;
  153. }
  154.  
  155. getMain().setStatus("Solving Emote Scroll");
  156.  
  157. EmoteClue emote = task.getEmoteClue();
  158. String[] requiredItems = emote.getItems();
  159. RSArea area = emote.getWalkLocationArea();
  160. RSTile tile = emote.getWalkLocation();
  161. int emoteId = emote.getEmote();
  162. String emoteName = emote.getEmoteName();
  163. int height = getEmoteHeight(emote);
  164. RSTile pos = Player.getPosition();
  165. int currentPlane = pos.getPlane();
  166. int requiredDistance = emote.getDistance();
  167.  
  168. if(!getMain().getEquipped().hasEmoteEquipment(requiredItems)) {
  169. getMain().getBank().walkBankAndWithdrawEquipment(task, requiredItems);
  170. return false;
  171. }
  172.  
  173. if(!getMain().getEquipped().isWearingRequiredEquipment(task)
  174. && getMain().getEquipped().hasEmoteEquipment(requiredItems)) {
  175.  
  176. if(!requiredItems[0].equals(""))
  177. getMain().getEquipped().wearRequiredEquipment(requiredItems);
  178. else
  179. getMain().getEquipped().unequipAllItems();
  180.  
  181. }
  182.  
  183. if(getMain().getEquipped().isWearingRequiredEquipment(task)) {
  184.  
  185. if(emote.isUpstairs()) {
  186. tile = emote.getSecondLocation();
  187. area = emote.getSecondLocationArea();
  188. }
  189.  
  190. int distanceToWalkTile = tile.distanceTo(pos);
  191. getMain().println("Emote Tile: " + tile.toString());
  192.  
  193. if(distanceToWalkTile > requiredDistance) {
  194. getMain().println(distanceToWalkTile + " tiles from " + tile.toString());
  195. walkEmoteObjective(task, height, emote.getWalkLocation(), emote.getWalkLocationArea());
  196. return false;
  197. }
  198.  
  199. if(tile.getPosition().equals(pos)
  200. || area.contains(pos) && currentPlane == tile.getPlane()) {
  201. getMain().setStatus("Inside Emote Area");
  202.  
  203. RSNPC[] npcs = NPCs.find("Uri");
  204. if(npcs.length > 0)
  205. return interactNpc(task, "Uri", npcs[0].getPosition());
  206.  
  207. if(performEmote(emoteName, emoteId)) {
  208.  
  209. if(Timing.waitCondition(new Condition() {
  210.  
  211. @Override
  212. public boolean active() {
  213. return NPCs.find("Uri").length > 0;
  214. }
  215.  
  216. }, General.random(4000, 6000)))
  217. return solveEmoteScroll(task);
  218.  
  219. }
  220. }
  221. }
  222. return false;
  223. }
  224.  
  225. public boolean walkCrypticObjective(ClueTask task, int desiredHeight, RSTile walk, RSArea area) {
  226.  
  227. if(isRewardInterface()) {
  228. getMain().setClueTask(null);
  229. getMain().setState(State.BANKING);
  230. return true;
  231. }
  232.  
  233. if(isItemInterface()) {
  234. getMain().setClueTask(null);
  235. return true;
  236. }
  237.  
  238. if(Player.isMoving() || Player.getPosition().equals(walk))
  239. return false;
  240.  
  241. CrypticClue cryptic = task.getCrypticClue();
  242. RSTile pos = Player.getPosition();
  243. int distanceToWalkTile = walk.distanceTo(pos);
  244. int currentPlane = pos.getPlane();
  245. int requiredDistance = cryptic.getDistance();
  246.  
  247. // teleport
  248. if(!hasTeleported() && distanceToWalkTile > 30)
  249. teleportObjective(task, distanceToWalkTile);
  250.  
  251. // climb
  252. if(distanceToWalkTile <= requiredDistance && desiredHeight != 0) {
  253.  
  254. if((desiredHeight == -1 && !Locations.inDungeonArea(task) // dungeons
  255. || (currentPlane != desiredHeight && desiredHeight != -1)) // correct height
  256. && area.contains(pos)) {
  257.  
  258. getMain().println("Player Height: " + currentPlane + " , Desired Height: " + desiredHeight);
  259.  
  260. getMain().climb((desiredHeight - currentPlane) > 0 ? true : false);
  261. return solveCrypticScroll(task);
  262. }
  263.  
  264. }
  265.  
  266. // second walk
  267. RSTile climbTile = new RSTile(cryptic.getWalkLocation().getX(), cryptic.getWalkLocation().getY(), desiredHeight);
  268. int distanceToClimbTile = climbTile.distanceTo(pos);
  269.  
  270. if(desiredHeight == -1 && Locations.inDungeonArea(task) // reg dungeon
  271. || (currentPlane == desiredHeight && desiredHeight != 0
  272. && distanceToClimbTile < 30)) { // reg stairs
  273.  
  274. getMain().println("Using secondary area.");
  275. getMain().setStatus("Walking to Second Location");
  276.  
  277. if(!pos.equals(walk))
  278. getMain().walkObjective(task, cryptic.getSecondaryWalkLocation(), false);
  279.  
  280. return false;
  281. }
  282.  
  283. if(currentPlane == 0 && !pos.equals(walk)
  284. && !Locations.inDungeonArea(task)) { // no stairs/before stairs
  285.  
  286. getMain().setStatus("Walking to Location");
  287.  
  288. if(cryptic.equals(CrypticClue.SINCLAIR_MANSION_STAFF))
  289. openDoor(Locations.SINCLAIR_GATE_TILE);
  290. else if(cryptic.equals(CrypticClue.DIGSITE_CENTRE_BUSH))
  291. openDoor(Locations.DIGSITE_GATE_TILE);
  292.  
  293. getMain().walkObjective(task, walk, true);
  294. }
  295.  
  296. return false;
  297. }
  298.  
  299. public boolean walkMapObjective(ClueTask task, RSTile walk) {
  300.  
  301. if(Player.isMoving())
  302. return false;
  303.  
  304. if(isRewardInterface()) {
  305. getMain().setClueTask(null);
  306. getMain().setState(State.BANKING);
  307. return true;
  308. }
  309.  
  310. if(isItemInterface()) {
  311. getMain().setClueTask(null);
  312. return true;
  313. }
  314.  
  315. RSTile pos = Player.getPosition();
  316.  
  317. if(pos.equals(walk))
  318. return true;
  319.  
  320. int distanceToWalkTile = walk.distanceTo(pos);
  321.  
  322. if (!hasTeleported() && distanceToWalkTile > 30)
  323. teleportObjective(task, distanceToWalkTile);
  324.  
  325. getMain().setStatus("Walking to Location");
  326. getMain().walkObjective(task, walk, true);
  327. return false;
  328. }
  329.  
  330.  
  331. public boolean walkEmoteObjective(ClueTask task, int desiredHeight, RSTile walk, RSArea area) {
  332.  
  333. if(isRewardInterface()) {
  334. getMain().setClueTask(null);
  335. getMain().setState(State.BANKING);
  336. return true;
  337. }
  338.  
  339. if(isItemInterface()) {
  340. getMain().setClueTask(null);
  341. return true;
  342. }
  343.  
  344. if(Player.isMoving() || Player.getPosition().equals(walk))
  345. return false;
  346.  
  347. EmoteClue emote = task.getEmoteClue();
  348. RSTile pos = Player.getPosition();
  349. int distanceToWalkTile = walk.distanceTo(pos);
  350. int requiredDistance = emote.getDistance();
  351. int currentPlane = pos.getPlane();
  352.  
  353. //teleport
  354. if(!hasTeleported() && distanceToWalkTile > 30 && !Locations.inGamesRoom())
  355. teleportObjective(task, distanceToWalkTile);
  356.  
  357. // climb
  358. if(distanceToWalkTile <= requiredDistance || Locations.inGamesRoom() && currentPlane == 1) {
  359. if((desiredHeight == -1 && !Locations.inDungeonArea(task)) // dungeon
  360. || (currentPlane != desiredHeight && desiredHeight != -1) // correct level
  361. || (!Locations.inGamesRoom() && desiredHeight == -2) // games room
  362. || (Locations.inGamesRoom() && currentPlane == 1)) { // games room
  363.  
  364. getMain().println("Player Height: " + currentPlane + " , Desired Height: " + desiredHeight);
  365. getMain().climb((desiredHeight - currentPlane) > 0 ? true : false);
  366. return true;
  367. }
  368. }
  369.  
  370. // second location
  371. if((currentPlane == desiredHeight && desiredHeight != 0) // on correct level
  372. || (currentPlane == 0 && desiredHeight == -2 && Locations.inGamesRoom()) // games room
  373. || (Locations.inDungeonArea(task) && desiredHeight == -1) && !Locations.inGamesRoom()) { // in dungeon
  374.  
  375. getMain().setStatus("Walking to Second Location");
  376.  
  377. getMain().walkObjective(task, emote.getSecondLocation(), false);
  378. return false;
  379. }
  380.  
  381. // first walk
  382. getMain().setStatus("Walking to Location");
  383.  
  384. if(emote.equals(EmoteClue.FISHING_TRAWLER_PIER_PANIC)) {
  385. openDoor(Locations.YANILLE_FIRST_DOOR_TILE);
  386. openDoor(Locations.YANILLE_SECOND_DOOR_TILE);
  387. } else if(emote.equals(EmoteClue.EXAM_ROOM_CLAP)) {
  388. openDoor(Locations.DIGSITE_GATE_TILE);
  389. openDoor(Locations.EXAM_ROOM_DOOR_TILE);
  390. }
  391.  
  392. getMain().walkObjective(task, walk, true);
  393. return false;
  394. }
  395.  
  396. public boolean teleportObjective(ClueTask task, int distanceToWalkTile) {
  397.  
  398. if(!hasTeleported() && distanceToWalkTile > 30) {
  399.  
  400. RSArea teleLoc = task.getTeleLocationArea();
  401. RSTile pos = Player.getPosition();
  402. RSTile tile = Locations.inHamDungeon() ? Locations.TRAPDOOR_TILE : pos;
  403. int distanceToTeleLoc = teleLoc.getRandomTile().distanceTo(tile);
  404.  
  405. if((distanceToTeleLoc > distanceToWalkTile
  406. && distanceToWalkTile < 100) || distanceToTeleLoc < 100) {
  407.  
  408. Interfaces.closeAll();
  409. checkPlane(task.getTeleLocation());
  410. setTeleported(true);
  411. getMain().println("Teleport Distance("+distanceToTeleLoc+") is greater than the Walking Distance("+distanceToWalkTile+").");
  412. return false;
  413.  
  414. }
  415. // teleport
  416. getMain().setStatus("Teleporting to " + Methods.correctCapitalization(task.getTeleLocation().toString()));
  417.  
  418. if(getTeleporting().teleportTo(task.getTeleLocation())) {
  419. setTeleported(true);
  420. return true;
  421. }
  422. }
  423. return false;
  424. }
  425.  
  426. public boolean interactObject(ClueTask task, String objectName, RSTile walk, RSArea area) {
  427.  
  428. RSTile pos = Player.getPosition();
  429. int currentPlane = pos.getPlane();
  430.  
  431. if(!getMain().getState().equals(State.SOLVING_CLUE)
  432. || currentPlane != walk.getPlane()
  433. || objectName.equals("null"))
  434. return false;
  435.  
  436. if(isRewardInterface()) {
  437. getMain().setClueTask(null);
  438. getMain().setState(State.BANKING);
  439. return true;
  440. }
  441.  
  442. if(isItemInterface()) {
  443. getMain().setClueTask(null);
  444. return true;
  445. }
  446.  
  447. int walkdist = walk.distanceTo(pos);
  448. int interactDist = task.getCrypticClue().getDistance();
  449.  
  450. if(walkdist <= interactDist) {
  451.  
  452. getMain().setStatus("Interacting with " + objectName);
  453. getMain().println("Searching for " + objectName + "...");
  454. RSObject[] objects = Objects.findNearest(64, objectName, "Open chest");
  455.  
  456. if(objects.length == 0) {
  457. getMain().println("Cant find object: " + objectName);
  458. return false;
  459. }
  460.  
  461. for(int i = 0; i < objects.length; i++) {
  462.  
  463. RSObject object = objects[i];
  464. getMain().println("Found " + objectName + "!");
  465.  
  466. RSObjectDefinition objectDef = object.getDefinition();
  467.  
  468. if(objectDef == null)
  469. continue;
  470.  
  471. String objectAction = getObjectInteractAction(objectDef);
  472.  
  473. if(objectAction == null)
  474. continue;
  475.  
  476. getMain().moveCamera(object.getPosition());
  477.  
  478. abc.waitNewOrSwitchDelay(last_busy_time, false);
  479.  
  480. if(object.click(objectAction)) {
  481.  
  482. setNpcClicks(getNpcClicks() + 1);
  483.  
  484. if(Timing.waitCondition(new Condition() {
  485.  
  486. @Override
  487. public boolean active() {
  488. return isItemInterface() || isRewardInterface();
  489. }
  490.  
  491. }, General.random(4000, 6000))) {
  492. last_busy_time = System.currentTimeMillis();
  493.  
  494. if(isRewardInterface())
  495. getMain().setState(State.BANKING);
  496.  
  497. getMain().setClueTask(null);
  498. return true;
  499. }
  500.  
  501. if(getNpcClicks() > General.random(2, 3)) {
  502. setNpcClicks(0);
  503. getMain().setClueTask(null);
  504. return false;
  505. }
  506.  
  507. }
  508.  
  509. if(objectName.contains("chest") || objectName.contains("Chest")
  510. || objectName.contains("drawers") || objectName.contains("Drawers"))
  511. i--;
  512. }
  513. }
  514.  
  515. return false;
  516. }
  517.  
  518. public boolean interactNpc(ClueTask task, String npcName, RSTile walk) {
  519.  
  520. if(!getMain().getState().equals(State.SOLVING_CLUE)
  521. || Player.getPosition().getPlane() != walk.getPlane()
  522. || Player.isMoving()
  523. || npcName.equals("null"))
  524. return false;
  525.  
  526. if(isRewardInterface()) {
  527. getMain().setClueTask(null);
  528. getMain().setState(State.BANKING);
  529. return true;
  530. }
  531.  
  532. if(isItemInterface() || hasCasket()) {
  533. getMain().setClueTask(null);
  534. return true;
  535. }
  536.  
  537. CrypticClue cryptic = task.getCrypticClue();
  538. RSTile pos = Player.getPosition();
  539. RSNPC[] npcs = NPCs.findNearest(npcName);
  540.  
  541. if(npcs.length == 0)
  542. return false;
  543.  
  544. getMain().setStatus("Interacting with " + npcName);
  545.  
  546. RSNPC npc = npcs[0];
  547. RSTile npcPos = npc.getPosition();
  548. int distanceToNpc = npcPos.distanceTo(pos);
  549.  
  550. if((cryptic.equals(CrypticClue.SINCLAIR_MANSION_STAFF) && distanceToNpc > 1)
  551. || (!cryptic.equals(CrypticClue.FALADOR_PARTYGOER) && !cryptic.equals(CrypticClue.HANS_IN_LUMBRIDGE)
  552. && distanceToNpc > 4))
  553. getMain().walkObjective(task, npcPos, true);
  554.  
  555. getMain().moveCamera(npcPos);
  556.  
  557. if(!npc.isOnScreen()) {
  558. if(!cryptic.equals(CrypticClue.HANS_IN_LUMBRIDGE)) {
  559. abc.waitNewOrSwitchDelay(last_busy_time, false);
  560. getMain().walkObjective(task, npcPos, false);
  561. last_busy_time = System.currentTimeMillis();
  562. }
  563. }
  564.  
  565. abc.waitNewOrSwitchDelay(last_busy_time, false);
  566.  
  567. if(npc.click("Talk-to " + npc.getName())) {
  568.  
  569. setNpcClicks(getNpcClicks() + 1);
  570.  
  571. if(Timing.waitCondition(new Condition() {
  572.  
  573. @Override
  574. public boolean active() {
  575. return NPCChat.getClickContinueInterface() != null
  576. || isItemInterface()
  577. || isRewardInterface()
  578. || hasCasket();
  579. }
  580.  
  581. }, General.random(4000, 6000))) {
  582. last_busy_time = System.currentTimeMillis();
  583. if(NPCChat.clickContinue(true)) {
  584.  
  585. if(Timing.waitCondition(new Condition() {
  586.  
  587. @Override
  588. public boolean active() {
  589. return isRewardInterface() || isItemInterface() || hasCasket();
  590. }
  591.  
  592. }, General.random(4000, 6000))) {
  593. getMain().setClueTask(null);
  594.  
  595. if(isRewardInterface())
  596. getMain().setState(State.BANKING);
  597.  
  598. return true;
  599. }
  600.  
  601. if(tooManyTries(getNpcClicks())) {
  602. setNpcClicks(0);
  603. getMain().setClueTask(null);
  604. return false;
  605. }
  606. }
  607. }
  608. }
  609. return false;
  610. }
  611.  
  612. public boolean calculateGpMade(RSItem[] oldInventoryItems) {
  613.  
  614. getMain().setStatus("Calculating Reward");
  615.  
  616. int[][] rewardItems = new int[10][2];
  617. String[] rewardNames = new String[10];
  618. RSItem[] newInventoryItems = Inventory.getAll();
  619. boolean foundItem = false;
  620. int oldStack = 0;
  621. int index = 0;
  622.  
  623. for(RSItem newItem : newInventoryItems) {
  624.  
  625. for(RSItem oldItem : oldInventoryItems) {
  626.  
  627. if(newItem.getID() == oldItem.getID()) {
  628.  
  629. if(newItem.getStack() == oldItem.getStack()) {
  630. foundItem = true;
  631. break;
  632. }
  633.  
  634. oldStack = oldItem.getStack();
  635. break;
  636. }
  637.  
  638. }
  639.  
  640. if(!foundItem) {
  641. rewardItems[index][0] = newItem.getID();
  642. rewardItems[index][1] = newItem.getStack() - oldStack;
  643. rewardNames[index] = newItem.getDefinition().getName();
  644. oldStack = 0;
  645. index++;
  646. }
  647.  
  648. foundItem = false;
  649.  
  650. }
  651.  
  652. int totalGp = 0;
  653.  
  654. for(int i = 0; i < rewardItems.length; i++) {
  655. int itemId = rewardItems[i][0];
  656. int stack = rewardItems[i][1];
  657. String name = rewardNames[i];
  658.  
  659. if(stack > 0) {
  660.  
  661. int price = Methods.getPrice(itemId);
  662. int profit = (price * stack);
  663.  
  664. HashMap<Integer, Reward> map = getMain().getItemsWon();
  665. Reward r = (Reward) map.get(itemId);
  666.  
  667. if(r == null)
  668. getMain().getItemsWon().put(itemId, new Reward(itemId, stack, price, name));
  669. else
  670. getMain().getItemsWon().put(itemId, new Reward(itemId, stack + r.getAmount(), price, name));
  671.  
  672. totalGp += profit;
  673. getMain().println("Found " + stack + " x " + name + " for a total of " + Methods.setInMoneyFormat(profit) + ".");
  674. }
  675. }
  676.  
  677. getMain().setMade(getMain().getMade() + totalGp);
  678.  
  679. if(getMain().getRewardGui() != null)
  680. getMain().getRewardGui().dispose();
  681.  
  682. getMain().setRewardGui(null);
  683. getMain().setRewardGui(new RewardGUI(getMain()));
  684. return false;
  685. }
  686.  
  687. public boolean dig(RSTile digTile) {
  688.  
  689. if(!digTile.equals(Player.getPosition()))
  690. return false;
  691.  
  692. getMain().setStatus("Digging");
  693.  
  694. RSItem[] items = Inventory.find(Constants.SPADE);
  695. if(items.length == 0)
  696. return false;
  697.  
  698. RSItem spade = items[0];
  699.  
  700. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  701. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  702.  
  703. if(spade.click("Dig")) {
  704.  
  705. if(Timing.waitCondition(new Condition() {
  706.  
  707. @Override
  708. public boolean active() {
  709. return NPCChat.getMessage() != null;
  710. }
  711.  
  712. }, General.random(4000, 6000))) {
  713.  
  714. if(NPCChat.getMessage().contains("casket")) {
  715. getMain().setClueTask(null);
  716. return true;
  717. }
  718.  
  719. }
  720. }
  721. return false;
  722. }
  723.  
  724. public boolean performEmote(String emoteName, int emote) {
  725. getMain().setStatus("Performing " + emoteName + " Emote");
  726.  
  727. if(GameTab.open(TABS.EMOTES)) {
  728.  
  729. RSInterfaceChild child = Interfaces.get(Constants.EMOTE_INTERFACE_ID, Constants.EMOTE_CHILD_ID);
  730. if(child == null)
  731. return false;
  732.  
  733. RSInterfaceComponent[] emotes = child.getChildren();
  734. if(emotes.length == 0)
  735. return false;
  736.  
  737. for(int i = 0; i < emotes.length; i++) {
  738.  
  739. RSInterfaceComponent emoteComponent = emotes[i];
  740.  
  741. if(emoteComponent == null)
  742. continue;
  743.  
  744. String[] actions = emoteComponent.getActions();
  745. if(actions.length == 0)
  746. continue;
  747.  
  748. String action = actions[0];
  749. if(!action.equals(emoteName))
  750. continue;
  751.  
  752. if(emoteName.equals("Clap")) {
  753. //Mouse.clickBox(new Rectangle(587, 464, 549, 458), 1);
  754. Mouse.click(new Point(570 + General.random(-10, 10), 460 + General.random(-5, 5)), 1);
  755. } else
  756. emoteComponent.click(emoteName);
  757.  
  758. setEmoteClicks(getEmoteClicks() + 1);
  759.  
  760. if(Timing.waitCondition(new Condition() {
  761.  
  762. @Override
  763. public boolean active() {
  764. return Player.getAnimation() != -1;
  765. }
  766.  
  767. }, General.random(4000, 6000)))
  768. return true;
  769.  
  770. if(tooManyTries(getEmoteClicks())) {
  771. setEmoteClicks(0);
  772. getMain().setClueTask(null);
  773. return false;
  774. }
  775. }
  776. }
  777.  
  778. return false;
  779. }
  780.  
  781. public boolean foundClueScroll() {
  782. if(hasClue()) {
  783. if(getMain().getAcquiringMethod().equals(AcquiringMethod.THIEVING))
  784. getMain().dropJunk();
  785.  
  786. getMain().setState(State.SOLVING_CLUE);
  787. return true;
  788. }
  789.  
  790. if(Inventory.isFull()) {
  791. if(getMain().getAcquiringMethod().equals(AcquiringMethod.THIEVING))
  792. getMain().dropJunk();
  793.  
  794. if(Inventory.isFull())
  795. getMain().eatFood();
  796. }
  797.  
  798. RSGroundItem[] clues = GroundItems.find("Clue scroll (easy)");
  799. if(clues.length == 0)
  800. return false;
  801.  
  802. RSGroundItem clue = clues[0];
  803. RSTile cluePos = clue.getPosition();
  804.  
  805. getMain().setStatus("Found Clue Scroll");
  806. getMain().setClueTask(null);
  807.  
  808. getMain().moveCamera(cluePos);
  809.  
  810. if(!clue.isOnScreen())
  811. getMain().walkObjective(getMain().getClueTask(), cluePos, true);
  812.  
  813. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  814. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  815.  
  816. if(clue.click("Take Clue scroll (easy)")) {
  817.  
  818. if(Timing.waitCondition(new Condition() {
  819.  
  820. @Override
  821. public boolean active() {
  822. return hasClue();
  823. }
  824.  
  825. }, General.random(8000, 12000))) {
  826. getMain().setState(State.SOLVING_CLUE);
  827. return true;
  828. }
  829.  
  830. }
  831. return false;
  832. }
  833.  
  834. public boolean readClue() {
  835.  
  836. if(!hasClue())
  837. return false;
  838.  
  839. if(getMain().getClueTask() != null) {
  840. solveClue();
  841. return false;
  842. }
  843.  
  844. getMain().setStatus("Reading Clue Scroll");
  845.  
  846. RSItem[] invClue = Inventory.find("Clue scroll (easy)");
  847.  
  848. if(invClue.length == 0)
  849. return false;
  850.  
  851. RSItem clue = invClue[0];
  852.  
  853. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  854. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  855.  
  856. if(clue.click("Read")) {
  857.  
  858.  
  859. if(Timing.waitCondition(new Condition() {
  860.  
  861. @Override
  862. public boolean active() {
  863. return isClueInterface();
  864. }
  865.  
  866. }, General.random(4000, 6000))) {
  867.  
  868. getMain().setClueTask(ClueTask.newClueTask(getMain()));
  869. closeClueInterface();
  870. }
  871.  
  872. }
  873. return false;
  874. }
  875.  
  876. public boolean solveClue() {
  877. if(getMain().getClueTask() == null)
  878. return false;
  879.  
  880. if(badClue(getMain().getClueTask())) {
  881. getMain().println("Found bad clue");
  882. dropClue();
  883. return false;
  884. }
  885.  
  886. if(getMain().getClueTask().getDigLocation() != null) {
  887. if(solveMapScroll(getMain().getClueTask())) {
  888. getMain().setClueTask(null);
  889. getMain().setState(State.SOLVING_CLUE);
  890. return true;
  891. }
  892. return false;
  893. }
  894.  
  895. if(getMain().getClueTask().getCrypticClue() != null) {
  896. if(solveCrypticScroll(getMain().getClueTask())) {
  897. getMain().setClueTask(null);
  898. getMain().setState(State.SOLVING_CLUE);
  899. return true;
  900. }
  901. return false;
  902. }
  903.  
  904. if(getMain().getClueTask().getEmoteClue() != null) {
  905. if(solveEmoteScroll(getMain().getClueTask())) {
  906. getMain().setClueTask(null);
  907. getMain().setState(State.SOLVING_CLUE);
  908. return true;
  909. }
  910. return false;
  911. }
  912. return false;
  913. }
  914.  
  915. public boolean dropClue() {
  916. if(hasClue()) {
  917.  
  918. String[] clue = new String[] { "Clue scroll (easy)"};
  919. getMain().setClueTask(null);
  920.  
  921. if(Locations.inHamDungeon()) {
  922. getMain().getHamDungeon().leaveDungeon();
  923. getMain().setState(State.WALKING_TO_CLUE_LOCATION);
  924. } else
  925. getMain().setState(State.BANKING);
  926.  
  927. Inventory.drop(clue);
  928. }
  929. return !hasClue();
  930. }
  931.  
  932. public boolean openCasket() {
  933.  
  934. getMain().getEquipped().checkEquipment();
  935.  
  936. if(hasCasket()) {
  937. getMain().setStatus("Opening Casket");
  938. RSItem[] items = Inventory.find("Casket (easy)");
  939. if(items.length == 0)
  940. return false;
  941.  
  942. RSItem casket = items[0];
  943.  
  944. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  945. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  946.  
  947. if(casket.click("Open Casket (easy)")) {
  948. if(Timing.waitCondition(new Condition() {
  949.  
  950. @Override
  951. public boolean active() {
  952. return isRewardInterface()
  953. || Inventory.getCount("Casket (easy)") == 0;
  954. }
  955.  
  956. }, General.random(4000, 6000))) {
  957. getMain().setClueTask(null);
  958.  
  959. if(isRewardInterface())
  960. getMain().setState(State.BANKING);
  961.  
  962. return true;
  963. }
  964. }
  965. }
  966. return false;
  967. }
  968.  
  969. public boolean openDoor(RSTile doorTile) {
  970.  
  971. RSObject door = Doors.getDoorAt(doorTile);
  972.  
  973. if(door == null)
  974. return false;
  975.  
  976. if(!door.isOnScreen()) {
  977.  
  978. if(doorTile.distanceTo(Player.getPosition()) > 5) {
  979. abc.waitNewOrSwitchDelay(last_busy_time, false);
  980. getMain().walkObjective(null, doorTile, false);
  981. last_busy_time = System.currentTimeMillis();
  982. }
  983.  
  984. getMain().moveCamera(doorTile);
  985. }
  986.  
  987. abc.waitNewOrSwitchDelay(last_busy_time, false);
  988.  
  989. if(Doors.handleDoor(door, true)) {
  990. if(Timing.waitCondition(new Condition() {
  991.  
  992. @Override
  993. public boolean active() {
  994. return Doors.isDoorAt(doorTile, true);
  995. }
  996.  
  997. }, General.random(4000, 6000))) {
  998. last_busy_time = System.currentTimeMillis();
  999. return true;
  1000. }
  1001. }
  1002. return false;
  1003. }
  1004.  
  1005. public String getObjectInteractAction(RSObjectDefinition def) {
  1006.  
  1007. String[] actions = def.getActions();
  1008. if(actions.length == 0)
  1009. return "";
  1010.  
  1011. for(String action : actions)
  1012. if(action.equals("Open")
  1013. || action.equals("Search"))
  1014. return action;
  1015.  
  1016. return "";
  1017. }
  1018.  
  1019. public boolean checkPlane(TeleportLocation loc) {
  1020.  
  1021. if(Locations.inHamDungeon())
  1022. getMain().getHamDungeon().leaveDungeon();
  1023.  
  1024. if(Player.getPosition().getPlane() > 0) {
  1025.  
  1026. if(tooManyTries(getClimbTries())) {
  1027. setClimbTries(0);
  1028. getTeleporting().teleportTo(loc);
  1029. return true;
  1030. }
  1031.  
  1032. setClimbTries(getClimbTries() + 1);
  1033. return getMain().climb(false);
  1034. }
  1035. return false;
  1036. }
  1037.  
  1038. public boolean tooManyTries(int tries) {
  1039. return tries > General.random(1, 2);
  1040. }
  1041.  
  1042. public boolean isItemInterface() {
  1043. RSInterface itemInterface = Interfaces.get(Constants.ITEM_INTERFACE);
  1044. if(itemInterface != null) {
  1045.  
  1046. int childId = Constants.ITEM_INTERFACE_TEXT_CHILD;
  1047. RSInterface rsChild = itemInterface.getChild(childId);
  1048.  
  1049. if(rsChild == null)
  1050. return false;
  1051.  
  1052. String text = rsChild.getText();
  1053. if(text != null)
  1054. getMain().println(text);
  1055.  
  1056. getMain().setClueTask(null);
  1057. return true;
  1058. }
  1059. return false;
  1060. }
  1061.  
  1062. public boolean isRewardInterface() {
  1063. RSItem[] all = Inventory.getAll();
  1064.  
  1065. RSInterface reward = Interfaces.get(Constants.REWARD_INTERFACE);
  1066. if(reward == null)
  1067. return false;
  1068.  
  1069. getMain().setStatus("Solved Clue");
  1070. getMain().setClueTask(null);
  1071. int child = Constants.REWARD_INTERFACE_CLOSE_CHILD;
  1072.  
  1073. RSInterface close = reward.getChild(child);
  1074. if(close != null)
  1075. close.click("Close");
  1076.  
  1077. if(Timing.waitCondition(new Condition() {
  1078.  
  1079. @Override
  1080. public boolean active() {
  1081. return Inventory.getAll().length != all.length;
  1082. }
  1083.  
  1084. }, General.random(8000, 12000))) {
  1085. getMain().setCluesSolved(getMain().getCluesSolved() + 1);
  1086. calculateGpMade(all);
  1087. return true;
  1088. }
  1089.  
  1090. return false;
  1091. }
  1092.  
  1093. public boolean badClue(ClueTask task) {
  1094.  
  1095. CrypticClue cryptic = task.getCrypticClue();
  1096.  
  1097. if(cryptic != null) {
  1098.  
  1099. if(cryptic.equals(CrypticClue.DRAYNOR_MANOR_CRATE)
  1100. || cryptic.equals(CrypticClue.TAVERLY_OUTHOUSE_CRATE)
  1101. || cryptic.equals(CrypticClue.PORT_SARIM_JAIL_BUCKET)) {
  1102. getMain().setStatus("Found Bad Clue");
  1103. return true;
  1104. }
  1105.  
  1106. if(cryptic.equals(CrypticClue.CANIFIS_CRATE)) {
  1107. RSInterface questTab = Interfaces.get(274);
  1108. if(questTab == null)
  1109. return false;
  1110.  
  1111. RSInterface priestInPeril = questTab.getChild(100);
  1112. if(priestInPeril == null)
  1113. return false;
  1114.  
  1115. if(priestInPeril.getTextColour() != 65280) { // priest in peril
  1116. getMain().setStatus("Found Bad Clue: Need Priest in Peril");
  1117. return true;
  1118. }
  1119. }
  1120. }
  1121.  
  1122. EmoteClue emote = task.getEmoteClue();
  1123. if(emote != null) {
  1124. Object[][] req = getMain().getEquipped().getItemRequirements(emote.getItems());
  1125. for(Object[] o : req) {
  1126.  
  1127. if(o == null || o.length < 2)
  1128. continue;
  1129.  
  1130. if(o[0] == null || o[1] == null)
  1131. continue;
  1132.  
  1133. SKILLS skill = (SKILLS) o[0];
  1134. int lvl = (Integer) o[1];
  1135.  
  1136. if(Skills.getActualLevel(skill) < lvl) {
  1137. getMain().setStatus("Bad Clue: Need " + lvl + " " + Methods.correctCapitalization(skill.toString()));
  1138. return true;
  1139. }
  1140. }
  1141. }
  1142. return false;
  1143. }
  1144.  
  1145. public boolean isClueInterface() {
  1146. for(int mapId : Constants.MAP_INTERFACES)
  1147. if(Interfaces.get(mapId) != null)
  1148. return true;
  1149.  
  1150. RSInterface textInterface = Interfaces.get(Constants.TEXT_INTERFACE);
  1151.  
  1152. if(textInterface != null)
  1153. return true;
  1154.  
  1155. return false;
  1156. }
  1157.  
  1158. public boolean closeClueInterface() {
  1159. //text interface close
  1160. RSInterface textInterface = Interfaces.get(Constants.TEXT_INTERFACE);
  1161. RSInterface close = null;
  1162. if(textInterface != null) {
  1163.  
  1164. close = textInterface.getChild(1);
  1165. if(close != null)
  1166. if(close.click("Close"))
  1167. return true;
  1168. }
  1169. //map interface close
  1170. for(int mapId : Constants.MAP_INTERFACES) {
  1171. RSInterface map = Interfaces.get(mapId);
  1172. if(map != null) {
  1173. int length = map.getChildren().length;
  1174.  
  1175. close = map.getChild(length - 1);
  1176. if(close != null)
  1177. if(close.click("Close"))
  1178. return true;
  1179.  
  1180. }
  1181. }
  1182. return false;
  1183. }
  1184.  
  1185. public int getCrypticHeight(CrypticClue clue) {
  1186.  
  1187. if(clue.equals(CrypticClue.VARROCK_BANK_CRATE))
  1188. return -1;
  1189.  
  1190. if(clue.equals(CrypticClue.TAVERLY_OUTHOUSE_CRATE))
  1191. return 10;
  1192.  
  1193. if(clue.equals(CrypticClue.YANILLE_SHOP_DRAWERS)
  1194. || clue.equals(CrypticClue.WIZARD_TOWER_BOOKCASE)
  1195. || clue.equals(CrypticClue.DRAYNOR_WARDROBE)
  1196. || clue.equals(CrypticClue.DIGSITE_CENTRE_BUSH))
  1197. return 0;
  1198.  
  1199. if(clue.equals(CrypticClue.CAMELOT_CASTLE_CHEST)
  1200. || clue.equals(CrypticClue.DRAYNOR_MANOR_CRATE))
  1201. return 2;
  1202.  
  1203. if(clue.isUpstairs())
  1204. return 1;
  1205.  
  1206. return 0;
  1207. }
  1208.  
  1209. public int getEmoteHeight(EmoteClue clue) {
  1210.  
  1211. if(clue.equals(EmoteClue.ARDOUGNE_MILL_CLAP))
  1212. return 2;
  1213.  
  1214. if(clue.equals(EmoteClue.GAMES_ROOM_CHEER))
  1215. return -2;
  1216.  
  1217. if(clue.equals(EmoteClue.EXAM_ROOM_CLAP))
  1218. return 0;
  1219.  
  1220. if(clue.isUpstairs())
  1221. return 1;
  1222.  
  1223. return 0;
  1224. }
  1225.  
  1226. public boolean hasClue() {
  1227. return Inventory.getCount("Clue scroll (easy)") > 0;
  1228. }
  1229.  
  1230. public boolean hasCasket() {
  1231. return Inventory.getCount("Casket (easy)") > 0;
  1232. }
  1233.  
  1234. public int getNpcClicks() {
  1235. return npcClicks;
  1236. }
  1237.  
  1238. public void setNpcClicks(int npcClicks) {
  1239. this.npcClicks = npcClicks;
  1240. }
  1241.  
  1242. public Main getMain() {
  1243. return main;
  1244. }
  1245.  
  1246. public void setMain(Main main) {
  1247. this.main = main;
  1248. }
  1249.  
  1250. public boolean hasTeleported() {
  1251. return teleported;
  1252. }
  1253.  
  1254. public void setTeleported(boolean teleported) {
  1255. this.teleported = teleported;
  1256. }
  1257.  
  1258. public Teleporting getTeleporting() {
  1259. return teleporting;
  1260. }
  1261.  
  1262. public void setTeleporting(Teleporting teleporting) {
  1263. this.teleporting = teleporting;
  1264. }
  1265.  
  1266. public boolean isEmoteTeleport() {
  1267. return emoteTeleport;
  1268. }
  1269.  
  1270. public void setEmoteTeleport(boolean emoteTeleport) {
  1271. this.emoteTeleport = emoteTeleport;
  1272. }
  1273.  
  1274. public boolean isNpcClicked() {
  1275. return npcClicked;
  1276. }
  1277.  
  1278. public void setNpcClicked(boolean npcClicked) {
  1279. this.npcClicked = npcClicked;
  1280. }
  1281.  
  1282. public int getEmoteClicks() {
  1283. return emoteClicks;
  1284. }
  1285.  
  1286. public void setEmoteClicks(int emoteClicks) {
  1287. this.emoteClicks = emoteClicks;
  1288. }
  1289.  
  1290. public int getClimbTries() {
  1291. return climbTries;
  1292. }
  1293.  
  1294. public void setClimbTries(int climbTries) {
  1295. this.climbTries = climbTries;
  1296. }
  1297.  
  1298. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement