Advertisement
iant06

Untitled

Nov 4th, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 43.12 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.Camera;
  12. import org.tribot.api2007.Equipment;
  13. import org.tribot.api2007.Game;
  14. import org.tribot.api2007.GameTab;
  15. import org.tribot.api2007.GameTab.TABS;
  16. import org.tribot.api2007.GroundItems;
  17. import org.tribot.api2007.Interfaces;
  18. import org.tribot.api2007.Inventory;
  19. import org.tribot.api2007.NPCChat;
  20. import org.tribot.api2007.NPCs;
  21. import org.tribot.api2007.Objects;
  22. import org.tribot.api2007.Player;
  23. import org.tribot.api2007.Skills;
  24. import org.tribot.api2007.Skills.SKILLS;
  25. import org.tribot.api2007.Walking;
  26. import org.tribot.api2007.WebWalking;
  27. import org.tribot.api2007.ext.Doors;
  28. import org.tribot.api2007.types.RSArea;
  29. import org.tribot.api2007.types.RSGroundItem;
  30. import org.tribot.api2007.types.RSInterface;
  31. import org.tribot.api2007.types.RSInterfaceChild;
  32. import org.tribot.api2007.types.RSInterfaceComponent;
  33. import org.tribot.api2007.types.RSItem;
  34. import org.tribot.api2007.types.RSNPC;
  35. import org.tribot.api2007.types.RSObject;
  36. import org.tribot.api2007.types.RSObjectDefinition;
  37. import org.tribot.api2007.types.RSTile;
  38.  
  39. import scripts.clues.types.AcquiringMethod;
  40. import scripts.clues.types.CrypticClue;
  41. import scripts.clues.types.EmoteClue;
  42. import scripts.clues.types.State;
  43. import scripts.clues.types.TeleportLocation;
  44. import scripts.methods.Methods;
  45.  
  46. public class ClueScroll {
  47.  
  48. private Main main;
  49. private Teleporting teleporting;
  50.  
  51. private int emoteClicks = 0;
  52. private int npcClicks = 0;
  53. private int tries = 0;
  54.  
  55. private boolean teleported = false;
  56. private boolean emoteTeleport = false;
  57. private boolean npcClicked = false;
  58.  
  59. private long last_busy_time = 0L;
  60.  
  61. private final ABCUtil abc = new ABCUtil();
  62.  
  63. public ClueScroll(Main m) {
  64. setMain(m);
  65. setTeleporting(getMain().getTeleporting());
  66. }
  67.  
  68. public boolean solveMapScroll(ClueTask task) {
  69.  
  70. if(getMain().getState().equals(State.BANKING)) {
  71. return true;
  72. }
  73.  
  74. if(hasCasket()) {
  75. getMain().setClueTask(null);
  76. return true;
  77. }
  78.  
  79. getMain().setStatus("Solving Map Scroll");
  80. RSTile digTile = task.getDigLocation().getTile();
  81. int dist = Methods.distanceTo(getMain(), digTile);
  82.  
  83. if(!Player.getPosition().equals(digTile))
  84. walkMapObjective(task, digTile, dist);
  85. else
  86. dig(digTile);
  87.  
  88. return false;
  89. }
  90.  
  91. public boolean solveCrypticScroll(ClueTask task) {
  92.  
  93. if(getMain().getState().equals(State.BANKING)) {
  94. return true;
  95. }
  96.  
  97. if(isRewardInterface()) {
  98. getMain().setClueTask(null);
  99. getMain().setState(State.BANKING);
  100. return true;
  101. }
  102.  
  103. if(isItemInterface()) {
  104. getMain().setClueTask(null);
  105. return true;
  106. }
  107. getMain().setStatus("Solving Cryptic Scroll");
  108.  
  109. int height = getCrypticHeight(task.getCrypticClue());
  110. RSTile walk = task.getCrypticClue().getWalkLocation();
  111. RSArea area = task.getCrypticClue().getWalkLocationArea();
  112. String npcName = task.getCrypticClue().getNpcName();
  113. String objectName = task.getCrypticClue().getObjectName();
  114.  
  115. if(inDungeonArea(task) || task.getCrypticClue().isUpstairs()) {
  116. walk = task.getCrypticClue().getSecondaryWalkLocation();
  117. area = task.getCrypticClue().getSecondaryWalkArea();
  118. }
  119.  
  120. int distance = Player.getPosition().distanceTo(walk);
  121.  
  122. if(distance <= task.getCrypticClue().getDistance()) {
  123.  
  124. if(!npcName.equals("null")) {
  125. if(interactNpc(task, npcName, walk)) {
  126. return true;
  127. }
  128. }
  129.  
  130. if(!objectName.equals("null")) {
  131. if(interactObject(task, objectName, walk, area)) {
  132. return true;
  133. }
  134. }
  135.  
  136. }
  137.  
  138. if(npcName.equals("null") && objectName.equals("null")) {
  139. if(dig(walk)) {
  140. return true;
  141. }
  142. }
  143.  
  144. walkCrypticObjective(task, height, task.getCrypticClue().getWalkLocation(), task.getCrypticClue().getWalkLocationArea(), distance);
  145. return false;
  146. }
  147.  
  148. public boolean solveEmoteScroll(ClueTask task) {
  149.  
  150. if(getMain().getState().equals(State.BANKING)) {
  151. return true;
  152. }
  153.  
  154. if(isRewardInterface()) {
  155. getMain().setClueTask(null);
  156. getMain().setState(State.BANKING);
  157. return true;
  158. }
  159.  
  160. if(isItemInterface()) {
  161. getMain().setClueTask(null);
  162. return true;
  163. }
  164.  
  165. getMain().setStatus("Solving Emote Scroll");
  166.  
  167. String[] requiredItems = task.getEmoteClue().getItems();
  168. RSArea area = task.getEmoteClue().getWalkLocationArea();
  169. RSTile tile = task.getEmoteClue().getWalkLocation();
  170. int emoteId = task.getEmoteClue().getEmote();
  171. String emoteName = task.getEmoteClue().getEmoteName();
  172. int height = getEmoteHeight(task.getEmoteClue());
  173.  
  174. if(!hasAllItems(task)) {
  175.  
  176. getMain().getBank().bankForEquipment(task, requiredItems);
  177. return false;
  178.  
  179. } else if(!getMain().getEquipped().isWearingRequiredEquipment(task)) {
  180.  
  181. if(!requiredItems[0].equals(""))
  182. getMain().getEquipped().wearRequiredEquipment(requiredItems);
  183. else
  184. getMain().getEquipped().unequipAllItems();
  185.  
  186. }
  187.  
  188. if(getMain().getEquipped().isWearingRequiredEquipment(task)) {
  189.  
  190. if(task.getEmoteClue().isUpstairs()) {
  191. tile = task.getEmoteClue().getSecondLocation();
  192. area = task.getEmoteClue().getSecondLocationArea();
  193. }
  194.  
  195. int dist = tile.distanceTo(Player.getPosition());
  196. getMain().println("Emote Tile: " + tile.toString());
  197.  
  198. if(tile.getPosition().equals(Player.getPosition())
  199. || area.contains(Player.getPosition()) && Player.getPosition().getPlane() == tile.getPlane()) {
  200.  
  201. getMain().setStatus("Inside Emote Area");
  202.  
  203. if(hasCasket()) {
  204. getMain().setClueTask(null);
  205. return true;
  206. }
  207.  
  208. RSNPC[] uri = NPCs.find("Uri");
  209. if(uri.length > 0) {
  210.  
  211. getMain().setStatus("Talking to Uri");
  212.  
  213. abc.waitNewOrSwitchDelay(last_busy_time, false);
  214.  
  215. if(uri[0].click("Talk-to Uri")) {
  216. last_busy_time = System.currentTimeMillis();
  217. if(Timing.waitCondition(new Condition() {
  218.  
  219. @Override
  220. public boolean active() {
  221. return isItemInterface() || isRewardInterface();
  222. }
  223.  
  224. }, General.random(4000, 6000))) {
  225. return true;
  226. }
  227. }
  228.  
  229. } else {
  230.  
  231. if(dist > task.getEmoteClue().getDistance()) {
  232.  
  233. getMain().println(dist + " tiles from " + tile.toString());
  234.  
  235. walkEmoteObjective(task, height, task.getEmoteClue().getWalkLocation(), task.getEmoteClue().getWalkLocationArea(), dist);
  236. return false;
  237. }
  238.  
  239. abc.waitNewOrSwitchDelay(last_busy_time, false);
  240.  
  241. if(performEmote(emoteName, emoteId)) {
  242.  
  243. last_busy_time = System.currentTimeMillis();
  244.  
  245. if(Timing.waitCondition(new Condition() {
  246.  
  247. @Override
  248. public boolean active() {
  249. return NPCs.find("Uri").length > 0;
  250. }
  251.  
  252. }, General.random(4000, 6000))) {
  253. return solveEmoteScroll(task);
  254. }
  255.  
  256. }
  257.  
  258. }
  259. } else {
  260. walkEmoteObjective(task, height, task.getEmoteClue().getWalkLocation(), task.getEmoteClue().getWalkLocationArea(), dist);
  261. }
  262.  
  263. }
  264. return false;
  265. }
  266.  
  267. public boolean walkCrypticObjective(ClueTask task, int height, RSTile walk, RSArea area, int walkDist) {
  268.  
  269. if(isRewardInterface()) {
  270. getMain().setClueTask(null);
  271. getMain().setState(State.BANKING);
  272. return true;
  273. }
  274.  
  275. if(isItemInterface()) {
  276. getMain().setClueTask(null);
  277. return true;
  278. }
  279.  
  280. // teleport
  281. if(!teleported && walkDist > 30) {
  282. teleportObjective(task, walkDist);
  283. }
  284.  
  285. // climb
  286. if(walk.distanceTo(Player.getPosition()) <= task.getCrypticClue().getDistance()) {
  287. if((height == -1 && !inDungeonArea(task) // dungeons
  288. || (Player.getPosition().getPlane() != height && height != -1)) // correct height
  289. || ((height == 2 && Player.getPosition().getPlane() == 1) // second floor
  290. || (height == 1 && Player.getPosition().getPlane() == 0)) // first floor
  291. && area.contains(Player.getPosition())) {
  292.  
  293. getMain().println("Player Height: " + Player.getPosition().getPlane() + " , Desired Height: " + height);
  294.  
  295. abc.waitNewOrSwitchDelay(last_busy_time, false);
  296.  
  297. climb((height - Player.getPosition().getPlane()) > 0 ? true : false);
  298.  
  299. last_busy_time = System.currentTimeMillis();
  300.  
  301. return solveCrypticScroll(task);
  302. }
  303. }
  304.  
  305. // second walk
  306. int walkX = task.getCrypticClue().getWalkLocation().getX();
  307. int walkY = task.getCrypticClue().getWalkLocation().getY();
  308. RSTile climbTile = new RSTile(walkX, walkY, height);
  309.  
  310. if(height == -1 && inDungeonArea(task) // reg dungeon
  311. || (Player.getPosition().getPlane() == height && height != 0
  312. && climbTile.distanceTo(Player.getPosition()) < 30)) { // reg stairs
  313.  
  314. getMain().println("Using secondary area.");
  315. area = task.getCrypticClue().getSecondaryWalkArea();
  316. walk = task.getCrypticClue().getSecondaryWalkLocation();
  317.  
  318. if(!Player.isMoving()) {
  319. getMain().setStatus("Walking to Second Location");
  320. RSTile secondWalk = task.getCrypticClue().getSecondaryWalkLocation();
  321.  
  322. if(!Player.getPosition().equals(secondWalk)) {
  323.  
  324. if(Game.getDestination() == null || !Game.getDestination().equals(secondWalk)) {
  325.  
  326. if(!task.getCrypticClue().equals(CrypticClue.AMBASSADOR_SPANFIPPLE)
  327. && !task.getCrypticClue().equals(CrypticClue.DUKE_OF_LUMBRIDGE_CHEST)) {
  328.  
  329. RSTile[] path = Walking.generateStraightPath(secondWalk);
  330.  
  331. return Methods.walkPath(path);
  332.  
  333. } else {
  334.  
  335. return WebWalking.walkTo(secondWalk);
  336.  
  337. }
  338. }
  339. }
  340. }
  341. return false;
  342. }
  343.  
  344. if(Player.getPosition().getPlane() == 0 && !Player.getPosition().equals(walk) && !inDungeonArea(task)) { // no stairs/before stairs
  345.  
  346. if(task.getCrypticClue().equals(CrypticClue.SINCLAIR_MANSION_STAFF)) {
  347.  
  348. openDoor(Locations.SINCLAIR_GATE_TILE);
  349.  
  350. }
  351.  
  352. if(!Player.isMoving()) {
  353.  
  354. if(Locations.inHamDungeon()) {
  355. getMain().getTeleporting().teleportTo(task.getTeleLocation());
  356. return false;
  357. }
  358.  
  359. getMain().setStatus("Walking to Location");
  360. RSTile tile = task.getCrypticClue().getWalkLocation();
  361. if(Game.getDestination() == null || !Game.getDestination().equals(tile)) {
  362. if(task.getCrypticClue().equals(CrypticClue.DIGSITE_CENTRE_BUSH)) {
  363.  
  364. //handle gate
  365. openDoor(Locations.DIGSITE_GATE_TILE);
  366.  
  367. Methods.walkPath(Locations.DIGSITE_BUSH_PATH);
  368.  
  369. } else {
  370. WebWalking.walkTo(tile, new Condition() {
  371.  
  372. @Override
  373. public boolean active() {
  374. if(tile.equals(Player.getPosition())) {
  375. return true;
  376. }
  377. return false;
  378. }
  379.  
  380. }, getMain().getProfile().getRandomGeneralSleep());
  381. }
  382. }
  383. }
  384. }
  385. return false;
  386.  
  387. }
  388.  
  389. public boolean teleportObjective(ClueTask task, int walkDist) {
  390.  
  391. if(!teleported && walkDist > 30) {
  392.  
  393.  
  394. RSTile tile = Locations.inHamDungeon() ? Locations.TRAPDOOR_TILE : Player.getPosition();
  395.  
  396. int teleDest = task.getTeleLocation().getArea().getRandomTile().distanceTo(tile);
  397.  
  398. if(teleDest > walkDist && walkDist < 100 || teleDest < 100) {
  399. Interfaces.closeAll();
  400.  
  401. if(Locations.inHamDungeon())
  402. getMain().getHamDungeon().leaveDungeon();
  403.  
  404. checkPlane(task);
  405.  
  406. getMain().println("Teleport Distance("+teleDest+") is greater than the Walking Distance("+walkDist+").");
  407. teleported = true;
  408. return false;
  409.  
  410. }
  411.  
  412. // teleport
  413. getMain().setStatus("Teleporting to " + Methods.correctCapitalization(task.getTeleLocation().toString()));
  414.  
  415. if(getTeleporting().teleportTo(task.getTeleLocation())) {
  416. teleported = true;
  417. return true;
  418. }
  419.  
  420. }
  421.  
  422. return false;
  423. }
  424.  
  425. public boolean walkMapObjective(ClueTask task, RSTile walk, int walkDist) {
  426.  
  427. if(isRewardInterface()) {
  428. getMain().setClueTask(null);
  429. getMain().setState(State.BANKING);
  430. return true;
  431. }
  432.  
  433. if(isItemInterface()) {
  434. getMain().setClueTask(null);
  435. return true;
  436. }
  437.  
  438. if (!teleported && walkDist > 30) {
  439. teleportObjective(task, walkDist);
  440. }
  441.  
  442. if(!Player.getPosition().equals(walk)) {
  443. if(!Player.isMoving()) {
  444. if(Locations.inHamDungeon()) {
  445. getMain().getTeleporting().teleportTo(task.getTeleLocation());
  446. return false;
  447. }
  448. getMain().setStatus("Walking to Location");
  449. if(Game.getDestination() == null || !Game.getDestination().equals(walk)) {
  450. WebWalking.walkTo(walk, new Condition() {
  451.  
  452. @Override
  453. public boolean active() {
  454. if(Player.getPosition().equals(walk)) {
  455. return true;
  456. }
  457. return false;
  458. }
  459.  
  460. }, getMain().getProfile().getRandomGeneralSleep());
  461. }
  462. }
  463. } else {
  464. return dig(walk);
  465. }
  466. return true;
  467. }
  468.  
  469. public boolean walkEmoteObjective(ClueTask task, int height, RSTile walk, RSArea area, int walkDist) {
  470.  
  471. if(isRewardInterface()) {
  472. getMain().setClueTask(null);
  473. getMain().setState(State.BANKING);
  474. return true;
  475. }
  476.  
  477. if(isItemInterface()) {
  478. getMain().setClueTask(null);
  479. return true;
  480. }
  481.  
  482. //teleport
  483. if(!teleported && walkDist > 30 && !Locations.inGamesRoom())
  484. teleportObjective(task, walkDist);
  485.  
  486. // climb
  487. int dist = Methods.distanceTo(getMain(), task.getEmoteClue().getWalkLocation());
  488. int playerHeight = Player.getPosition().getPlane();
  489. if(dist <= task.getEmoteClue().getDistance() || Locations.inGamesRoom() && playerHeight == 1) {
  490. if((height == -1 && !inDungeonArea(task)) // dungeon
  491. || (playerHeight != height && height != -1) // correct level
  492. || (playerHeight == 2 && height == 1) // level 2
  493. || (playerHeight == 1 && height == 0) // level 1
  494. || (!Locations.inGamesRoom() && height == -2) // games room
  495. || (Locations.inGamesRoom() && playerHeight == 1)) { // games room
  496.  
  497. getMain().println("Player Height: " + playerHeight + " , Desired Height: " + height);
  498. abc.waitNewOrSwitchDelay(last_busy_time, false);
  499. climb((height - Player.getPosition().getPlane()) > 0 ? true : false);
  500. last_busy_time = System.currentTimeMillis();
  501. return true;
  502. }
  503. }
  504.  
  505. // second location
  506. if((playerHeight == height && height != 0) // on correct level
  507. || (playerHeight == 1 && height == 1) // on first level
  508. || (playerHeight == 0 && height == -2 && Locations.inGamesRoom()) // games room
  509. || (inDungeonArea(task) && height == -1)
  510. && !Locations.inGamesRoom()) { // in dungeon
  511.  
  512. if(!Player.isMoving()) {
  513.  
  514. getMain().setStatus("Walking to Second Location");
  515.  
  516. RSTile secondWalk = task.getEmoteClue().getSecondLocation();
  517. if(!Player.getPosition().equals(secondWalk)) {
  518.  
  519. if(Game.getDestination() == null || !Game.getDestination().equals(secondWalk)) {
  520. if(Locations.inGamesRoom()) {
  521. if(WebWalking.walkTo(secondWalk))
  522. return true;
  523. } else {
  524.  
  525. RSTile[] path = Walking.generateStraightPath(secondWalk);
  526. if(Methods.walkPath(path))
  527. return true;
  528.  
  529. }
  530. }
  531.  
  532. }
  533. }
  534. return false;
  535. }
  536.  
  537. walk = task.getEmoteClue().getWalkLocation();
  538.  
  539. // first walk
  540. if(!Player.getPosition().equals(walk)) {
  541.  
  542. if(task.getEmoteClue().equals(EmoteClue.GAMES_ROOM_CHEER)) {
  543. dist = Player.getPosition().distanceTo(walk);
  544. if(dist > 100 && Player.getPosition().getPlane() == 0) {
  545. getMain().getTeleporting().teleportTo(task.getTeleLocation());
  546. return false;
  547. }
  548. }
  549.  
  550. if(Locations.inHamDungeon()) {
  551. if(getMain().getTeleporting().teleportTo(task.getTeleLocation())) {
  552. return true;
  553. }
  554. return false;
  555. }
  556.  
  557. if(!Player.isMoving()) {
  558.  
  559. getMain().setStatus("Walking to Location");
  560.  
  561. if(Game.getDestination() == null || !Game.getDestination().equals(walk)) {
  562.  
  563. RSTile tile = task.getEmoteClue().getWalkLocation();
  564.  
  565. if(task.getEmoteClue().equals(EmoteClue.FALADOR_GEM_STORE_WAVE)) {
  566. abc.waitNewOrSwitchDelay(last_busy_time, false);
  567.  
  568. RSTile[] path = Walking.generateStraightPath(tile);
  569. Methods.walkPath(path);
  570.  
  571. last_busy_time = System.currentTimeMillis();
  572. } else if(task.getEmoteClue().equals(EmoteClue.FISHING_TRAWLER_PIER_PANIC)) {
  573.  
  574. // first yanille doors
  575. openDoor(Locations.YANILLE_FIRST_DOOR_TILE);
  576.  
  577. // second yanille doors
  578. openDoor(Locations.YANILLE_SECOND_DOOR_TILE);
  579.  
  580. Methods.walkPath(Locations.FISH_TRAWLER_PATH);
  581.  
  582. } else if(task.getEmoteClue().equals(EmoteClue.EXAM_ROOM_CLAP)) {
  583.  
  584. //gate
  585. openDoor(Locations.DIGSITE_GATE_TILE);
  586.  
  587. //door
  588. openDoor(Locations.EXAM_ROOM_DOOR_TILE);
  589.  
  590. Methods.walkPath(Locations.EXAM_ROOM_PATH);
  591.  
  592. } else {
  593. abc.waitNewOrSwitchDelay(last_busy_time, false);
  594. WebWalking.walkTo(tile, new Condition() {
  595.  
  596. @Override
  597. public boolean active() {
  598. return Player.getPosition().equals(tile);
  599. }
  600.  
  601. }, abc.DELAY_TRACKER.NEW_OBJECT.next());
  602. abc.DELAY_TRACKER.NEW_OBJECT.reset();
  603. last_busy_time = System.currentTimeMillis();
  604. }
  605.  
  606. }
  607. }
  608. }
  609.  
  610. return false;
  611. }
  612.  
  613. public boolean interactObject(ClueTask task, String objectName, RSTile walk, RSArea area) {
  614.  
  615. if(!getMain().getState().equals(State.SOLVING_CLUE)) {
  616. return false;
  617. }
  618.  
  619. if(Player.getPosition().getPlane() != walk.getPlane()) {
  620. return false;
  621. }
  622.  
  623. int walkdist = walk.distanceTo(Player.getPosition());
  624. if(walkdist <= 2) {
  625.  
  626. getMain().setStatus("Interacting with " + objectName);
  627.  
  628. if(!objectName.equals("null")) {
  629.  
  630. if(isRewardInterface()) {
  631. getMain().setClueTask(null);
  632. getMain().setState(State.BANKING);
  633. return true;
  634. }
  635.  
  636. if(isItemInterface()) {
  637. getMain().setClueTask(null);
  638. return true;
  639. }
  640.  
  641. if(walk.getPlane() == Player.getPosition().getPlane()) {
  642. getMain().println("Searching for " + objectName + "...");
  643. RSObject[] object = Objects.findNearest(64, objectName, "Open chest");
  644.  
  645. if(object.length > 0) {
  646. for(int i = 0; i < object.length; i++) {
  647. if(object[i] != null) {
  648.  
  649. int dist = object[i].getPosition().distanceTo(walk);
  650. if(dist > 4) {
  651. continue;
  652. }
  653.  
  654. getMain().println("Found " + objectName + "!");
  655.  
  656. RSObjectDefinition objectDef = object[i].getDefinition();
  657.  
  658. if(objectDef == null)
  659. continue;
  660.  
  661. String objectAction = getObjectAction(objectDef);
  662.  
  663. if(objectAction == null)
  664. continue;
  665.  
  666. if(!object[i].isOnScreen()) {
  667. abc.waitNewOrSwitchDelay(last_busy_time, false);
  668. Camera.turnToTile(object[i]);
  669. last_busy_time = System.currentTimeMillis();
  670. }
  671.  
  672. abc.waitNewOrSwitchDelay(last_busy_time, false);
  673.  
  674. if(object[i].click(objectAction)) {
  675.  
  676. last_busy_time = System.currentTimeMillis();
  677.  
  678. if(npcClicks > General.random(2, 3)) {
  679. getMain().setClueTask(null);
  680. return true;
  681. }
  682.  
  683. npcClicks++;
  684.  
  685. if(Timing.waitCondition(new Condition() {
  686.  
  687. @Override
  688. public boolean active() {
  689. return isItemInterface() || isRewardInterface();
  690. }
  691.  
  692. }, General.random(4000, 6000))) {
  693.  
  694. if(isRewardInterface())
  695. getMain().setState(State.BANKING);
  696.  
  697. getMain().setClueTask(null);
  698. return true;
  699.  
  700.  
  701. }
  702.  
  703. if(objectName.contains("chest") || objectName.contains("Chest"))
  704. i--;
  705. }
  706. }
  707. }
  708. } else {
  709. getMain().println("Cant find object: " + objectName);
  710. }
  711. }
  712. }
  713. }
  714. return false;
  715. }
  716.  
  717. public boolean interactNpc(ClueTask task, String npcName, RSTile walk) {
  718.  
  719. if(!getMain().getState().equals(State.SOLVING_CLUE)
  720. || Player.getPosition().getPlane() != walk.getPlane()) {
  721. return false;
  722. }
  723.  
  724. if(isRewardInterface()) {
  725. getMain().setClueTask(null);
  726. getMain().setState(State.BANKING);
  727. return true;
  728. }
  729.  
  730. if(isItemInterface()) {
  731. getMain().setClueTask(null);
  732. return true;
  733. }
  734.  
  735. if(!npcName.equals("null")) {
  736.  
  737. RSNPC[] npc = NPCs.findNearest(npcName);
  738. if(npc.length > 0) {
  739. getMain().setStatus("Interacting with " + npcName);
  740.  
  741. int dist = Methods.distanceTo(getMain(), npc[0].getPosition());
  742. if(dist > 4 && !task.getCrypticClue().equals(CrypticClue.FALADOR_PARTYGOER) && !task.getCrypticClue().equals(CrypticClue.HANS_IN_LUMBRIDGE)) {
  743.  
  744. if(!Player.isMoving()) {
  745. if(Game.getDestination() == null || !Game.getDestination().equals(npc[0].getPosition())) {
  746. abc.waitNewOrSwitchDelay(last_busy_time, false);
  747. Methods.walkPath(Walking.generateStraightPath(npc[0].getPosition()));
  748. last_busy_time = System.currentTimeMillis();
  749. }
  750. }
  751. }
  752.  
  753. if(!npc[0].isOnScreen()) {
  754. abc.waitNewOrSwitchDelay(last_busy_time, false);
  755. Camera.turnToTile(npc[0]);
  756. last_busy_time = System.currentTimeMillis();
  757. }
  758.  
  759. if(!npc[0].isOnScreen()) {
  760. if(!task.getCrypticClue().equals(CrypticClue.HANS_IN_LUMBRIDGE)) {
  761. abc.waitNewOrSwitchDelay(last_busy_time, false);
  762. Methods.walkPath(Walking.generateStraightPath(npc[0].getPosition()));
  763. last_busy_time = System.currentTimeMillis();
  764. }
  765. }
  766.  
  767. if(task.getCrypticClue().equals(CrypticClue.SINCLAIR_MANSION_STAFF)) {
  768.  
  769. if(npc.length > 0 && npc[0] != null
  770. && npc[0].getPosition().distanceTo(Player.getPosition()) > 1) {
  771.  
  772. abc.waitNewOrSwitchDelay(last_busy_time, false);
  773.  
  774. WebWalking.walkTo(npc[0]);
  775.  
  776. last_busy_time = System.currentTimeMillis();
  777.  
  778. }
  779. }
  780.  
  781. abc.waitNewOrSwitchDelay(last_busy_time, false);
  782.  
  783. if(npc[0].click("Talk-to " + npc[0].getName())) {
  784.  
  785. last_busy_time = System.currentTimeMillis();
  786.  
  787. if(tooManyTries(npcClicks)) {
  788. getMain().setClueTask(null);
  789. return true;
  790. }
  791.  
  792. npcClicks++;
  793.  
  794. if(Timing.waitCondition(new Condition() {
  795.  
  796. @Override
  797. public boolean active() {
  798. return NPCChat.getClickContinueInterface() != null
  799. || isItemInterface()
  800. || isRewardInterface();
  801. }
  802.  
  803. }, General.random(4000, 6000))) {
  804.  
  805. if(NPCChat.getClickContinueInterface() != null) {
  806.  
  807. abc.waitNewOrSwitchDelay(last_busy_time, false);
  808.  
  809. if(NPCChat.clickContinue(true)) {
  810.  
  811. last_busy_time = System.currentTimeMillis();
  812.  
  813. if(Timing.waitCondition(new Condition() {
  814.  
  815. @Override
  816. public boolean active() {
  817. return isRewardInterface() || isItemInterface();
  818. }
  819.  
  820. }, General.random(4000, 6000))) {
  821. getMain().setClueTask(null);
  822.  
  823. if(isRewardInterface())
  824. getMain().setState(State.BANKING);
  825.  
  826. return true;
  827. }
  828.  
  829. }
  830. }
  831.  
  832. }
  833. }
  834.  
  835. }
  836. }
  837. return false;
  838. }
  839.  
  840. public boolean calculateGpMade(RSItem[] all) {
  841. getMain().setStatus("Calculating Reward");
  842. int[][] newItems = new int[10][2];
  843. String[] newNames = new String[10];
  844. int index = 0;
  845. RSItem[] inv = Inventory.getAll();
  846. boolean foundItem = false;
  847.  
  848. for(RSItem newItem : inv) {
  849.  
  850. for(RSItem oldItem : all) {
  851. if(newItem.getID() == oldItem.getID()) {
  852. foundItem = true;
  853. break;
  854. }
  855. }
  856.  
  857. if(!foundItem) {
  858. newItems[index][0] = newItem.getID();
  859. newItems[index][1] = newItem.getStack();
  860. newNames[index] = newItem.getDefinition().getName();
  861. index++;
  862. } else {
  863. foundItem = false;
  864. }
  865.  
  866. }
  867.  
  868. int made = 0;
  869.  
  870. for(int i = 0; i < newItems.length; i++) {
  871. int id = newItems[i][0];
  872. int amt = newItems[i][1];
  873. String name = newNames[i];
  874.  
  875. if(amt > 0) {
  876.  
  877. int price = Methods.getPrice(getMain(), id);
  878. int profit = (price * amt);
  879. HashMap<Integer, Reward> map = getMain().getItemsWon();
  880. Reward r = (Reward) map.get(id);
  881.  
  882. if(r == null)
  883. getMain().getItemsWon().put(id, new Reward(id, amt, price, name));
  884. else {
  885. int oldAmount = r.getAmount();
  886. getMain().getItemsWon().put(id, new Reward(id, amt + oldAmount, price, name));
  887. }
  888.  
  889. made += profit;
  890. getMain().println("Found " + amt + " x " + name + " for a total of " + Methods.setInMoneyFormat(profit) + ".");
  891. }
  892. }
  893.  
  894. getMain().setMade(getMain().getMade() + made);
  895.  
  896. if(getMain().getRewardGui() != null)
  897. getMain().getRewardGui().dispose();
  898.  
  899. getMain().setRewardGui(null);
  900. getMain().setRewardGui(new RewardGUI(getMain()));
  901. return false;
  902. }
  903.  
  904. public boolean climb(boolean up) {
  905. if(isRewardInterface()) {
  906. getMain().setClueTask(null);
  907. getMain().setState(State.BANKING);
  908. return true;
  909. }
  910.  
  911. if(isItemInterface()) {
  912. getMain().setClueTask(null);
  913. return true;
  914. }
  915.  
  916. String[] objects = {
  917. "Ladder", "Staircase", "Stairs", "Stile", "Gate"
  918. };
  919.  
  920. RSTile pos = Player.getPosition();
  921. int plane = pos.getPlane();
  922. RSObject[] object = Objects.findNearest(64, objects);
  923. if(object.length > 0) {
  924. for(int i = 0; i < object.length; i++) {
  925. if(object[i] != null) {
  926.  
  927. RSObjectDefinition def = object[i].getDefinition();
  928.  
  929. if(def != null) {
  930.  
  931. String action = up ? "Climb-up" : "Climb-down";
  932.  
  933. if(!hasAction(def, action)) {
  934. continue;
  935. }
  936.  
  937. getMain().setStatus(action + " " + def.getName());
  938.  
  939. if(plane == Player.getPosition().getPlane()) {
  940.  
  941. if(!object[i].isOnScreen()) {
  942. abc.waitNewOrSwitchDelay(last_busy_time, false);
  943. Camera.turnToTile(object[i]);
  944. last_busy_time = System.currentTimeMillis();
  945. }
  946.  
  947. if(!object[i].isOnScreen()) {
  948. abc.waitNewOrSwitchDelay(last_busy_time, false);
  949. if(plane > 0)
  950. WebWalking.walkTo(object[i]);
  951. else {
  952. RSTile[] path = Walking.generateStraightPath(object[i]);
  953. Methods.walkPath(path);
  954. }
  955. last_busy_time = System.currentTimeMillis();
  956. }
  957.  
  958. if(object[i].getPosition().distanceTo(Player.getPosition()) > 3) {
  959. if(Game.getDestination() == null || !Game.getDestination().equals(object[i])) {
  960. if(!Player.isMoving()) {
  961. abc.waitNewOrSwitchDelay(last_busy_time, false);
  962. if(plane > 0)
  963. WebWalking.walkTo(object[i]);
  964. else {
  965. RSTile[] path = Walking.generateStraightPath(object[i]);
  966. Methods.walkPath(path);
  967. }
  968. last_busy_time = System.currentTimeMillis();
  969. }
  970. }
  971. }
  972.  
  973. if(object[i].getPosition().distanceTo(Player.getPosition()) <= 10) {
  974.  
  975.  
  976. abc.waitNewOrSwitchDelay(last_busy_time, false);
  977.  
  978. if(object[i].click(action)) {
  979.  
  980. last_busy_time = System.currentTimeMillis();
  981.  
  982. if(Timing.waitCondition(new Condition() {
  983.  
  984. @Override
  985. public boolean active() {
  986. return Player.getPosition().getPlane() != plane;
  987. }
  988.  
  989. }, General.random(4000, 6000))) {
  990. return true;
  991. }
  992. }
  993.  
  994. }
  995. break;
  996. }
  997. }
  998. }
  999. }
  1000. } else {
  1001. getMain().println("Can't find object to climb.");
  1002. }
  1003. return Player.getPosition().getPlane() != plane || inDungeonArea(getMain().getClueTask());
  1004. }
  1005.  
  1006. public boolean dig(RSTile digTile) {
  1007.  
  1008. if(digTile.equals(Player.getPosition())) {
  1009.  
  1010. getMain().setStatus("Digging");
  1011.  
  1012. RSItem[] spade = Inventory.find(Constants.SPADE);
  1013. if(spade.length > 0) {
  1014.  
  1015. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  1016. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  1017.  
  1018. if(spade[0].click("Dig")) {
  1019.  
  1020. if(Timing.waitCondition(new Condition() {
  1021.  
  1022. @Override
  1023. public boolean active() {
  1024. return NPCChat.getMessage() != null;
  1025. }
  1026.  
  1027. }, General.random(4000, 6000))) {
  1028.  
  1029. if(NPCChat.getMessage().contains("casket")) {
  1030. getMain().setClueTask(null);
  1031. return true;
  1032. }
  1033.  
  1034. }
  1035. }
  1036. }
  1037. }
  1038. return false;
  1039. }
  1040.  
  1041. public boolean performEmote(String emoteName, int emote) {
  1042.  
  1043. if(tooManyTries(emoteClicks)) {
  1044. getMain().setClueTask(null);
  1045. return true;
  1046. }
  1047.  
  1048. getMain().setStatus("Performing " + emoteName + " Emote");
  1049.  
  1050. if(GameTab.open(TABS.EMOTES)) {
  1051.  
  1052. RSInterfaceChild child = Interfaces.get(Constants.EMOTE_INTERFACE_ID, Constants.EMOTE_CHILD_ID);
  1053. if(child == null) {
  1054. return false;
  1055. }
  1056.  
  1057. RSInterfaceComponent[] emotes = child.getChildren();
  1058. if(emotes.length > 0) {
  1059. for(int i = 0; i < emotes.length; i++) {
  1060.  
  1061. if(emotes[i] == null) {
  1062. continue;
  1063. }
  1064.  
  1065. String[] actions = emotes[i].getActions();
  1066. if(actions.length > 0) {
  1067. if(!actions[0].equals(emoteName)) {
  1068. continue;
  1069. }
  1070.  
  1071. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1072.  
  1073. if(emoteName.equals("Clap")) {
  1074. //Mouse.clickBox(new Rectangle(587, 464, 549, 458), 1);
  1075. Mouse.click(new Point(570 + General.random(-10, 10), 460 + General.random(-5, 5)), 1);
  1076.  
  1077. } else {
  1078.  
  1079. emotes[i].click(emoteName);
  1080. }
  1081.  
  1082.  
  1083. if(Timing.waitCondition(new Condition() {
  1084.  
  1085. @Override
  1086. public boolean active() {
  1087. return Player.getAnimation() != -1;
  1088. }
  1089.  
  1090. }, General.random(4000, 6000))) {
  1091. last_busy_time = System.currentTimeMillis();
  1092. emoteClicks++;
  1093. return true;
  1094. }
  1095.  
  1096.  
  1097. return false;
  1098. }
  1099. }
  1100. }
  1101. }
  1102. return false;
  1103. }
  1104.  
  1105. public boolean foundClueScroll() {
  1106.  
  1107. if(hasClue()) {
  1108. if(getMain().getAcquiringMethod().equals(AcquiringMethod.THIEVING)) {
  1109. getMain().getHamDungeon().dropJunk();
  1110. }
  1111. getMain().setState(State.SOLVING_CLUE);
  1112. return true;
  1113. }
  1114.  
  1115. if(Inventory.isFull()) {
  1116. if(getMain().getAcquiringMethod().equals(AcquiringMethod.THIEVING))
  1117. getMain().getHamDungeon().dropJunk();
  1118.  
  1119. if(Inventory.isFull())
  1120. getMain().getHamDungeon().eatFood();
  1121. }
  1122.  
  1123. RSGroundItem[] clue = GroundItems.find("Clue scroll (easy)");
  1124. if(clue.length > 0) {
  1125.  
  1126. getMain().setStatus("Found Clue Scroll");
  1127. getMain().setClueTask(null);
  1128.  
  1129. if(!clue[0].isOnScreen()) {
  1130.  
  1131. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1132. Camera.turnToTile(clue[0]);
  1133. last_busy_time = System.currentTimeMillis();
  1134.  
  1135. if(!clue[0].isOnScreen()) {
  1136. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1137. WebWalking.walkTo(clue[0], new Condition() {
  1138.  
  1139. @Override
  1140. public boolean active() {
  1141. return clue[0].isOnScreen();
  1142. }
  1143.  
  1144. }, getMain().getProfile().getRandomGeneralSleep());
  1145. last_busy_time = System.currentTimeMillis();
  1146. }
  1147.  
  1148. }
  1149.  
  1150. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1151.  
  1152. if(clue[0].click("Take Clue scroll (easy)")) {
  1153.  
  1154. last_busy_time = System.currentTimeMillis();
  1155.  
  1156. if(Timing.waitCondition(new Condition() {
  1157.  
  1158. @Override
  1159. public boolean active() {
  1160. return hasClue();
  1161. }
  1162.  
  1163. }, General.random(8000, 12000))) {
  1164. getMain().setState(State.SOLVING_CLUE);
  1165. return true;
  1166. }
  1167.  
  1168. }
  1169. }
  1170. return false;
  1171. }
  1172.  
  1173. public boolean readClue() {
  1174.  
  1175. if(!hasClue()) {
  1176. return false;
  1177. }
  1178.  
  1179. if(getMain().getClueTask() != null) {
  1180. solveClue();
  1181. return false;
  1182. }
  1183.  
  1184. getMain().setStatus("Reading Clue Scroll");
  1185.  
  1186. RSItem[] invClue = Inventory.find("Clue scroll (easy)");
  1187.  
  1188. if(invClue.length > 0) {
  1189.  
  1190. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  1191. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  1192.  
  1193. if(invClue[0].click("Read")) {
  1194.  
  1195. int[] maps = {
  1196. Constants.ALKHARID_MINE_DIG_INTERFACE,
  1197. Constants.VARROCK_MINE_DIG_INTERFACE,
  1198. Constants.VARROCK_SOUTH_DIG_INTERFACE,
  1199. Constants.GALAHAD_DIG_INTERFACE,
  1200. Constants.FALADOR_ROCKS_DIG_INTERFACE,
  1201. Constants.FALADOR_CROSSROADS_DIG_INTERFACE,
  1202. Constants.WIZARD_TOWER_DIG_INTERFACE
  1203. };
  1204.  
  1205.  
  1206. if(Timing.waitCondition(new Condition() {
  1207.  
  1208. @Override
  1209. public boolean active() {
  1210. for(int mapId : maps) {
  1211. RSInterface map = Interfaces.get(mapId);
  1212. if(map != null) {
  1213. return true;
  1214. }
  1215. }
  1216.  
  1217. RSInterface textInterface = Interfaces.get(Constants.TEXT_INTERFACE);
  1218.  
  1219. if(textInterface != null) {
  1220. return true;
  1221. }
  1222.  
  1223. return false;
  1224. }
  1225.  
  1226. }, General.random(4000, 6000))) {
  1227.  
  1228. getMain().setClueTask(ClueTask.newClueTask(getMain()));
  1229.  
  1230. //text interface close
  1231. RSInterface textInterface = Interfaces.get(Constants.TEXT_INTERFACE);
  1232.  
  1233. if(textInterface != null) {
  1234.  
  1235. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1236.  
  1237. RSInterface close = textInterface.getChild(1);
  1238. if(close != null) {
  1239. if(close.click("Close")) {
  1240. last_busy_time = System.currentTimeMillis();
  1241. return true;
  1242. }
  1243. }
  1244. }
  1245.  
  1246. //map interface close
  1247. for(int mapId : maps) {
  1248. RSInterface map = Interfaces.get(mapId);
  1249. if(map != null) {
  1250. int length = map.getChildren().length;
  1251.  
  1252. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1253.  
  1254. RSInterface close = map.getChild(length - 1);
  1255. if(close != null) {
  1256. if(close.click("Close")) {
  1257. last_busy_time = System.currentTimeMillis();
  1258. return true;
  1259. }
  1260. }
  1261. }
  1262. }
  1263. }
  1264.  
  1265. }
  1266. }
  1267. return false;
  1268. }
  1269.  
  1270. public boolean solveClue() {
  1271. if(getMain().getClueTask() != null) {
  1272.  
  1273. if(badClue(getMain().getClueTask())) {
  1274. getMain().println("Found bad clue");
  1275. dropClue();
  1276. return false;
  1277. }
  1278.  
  1279. if(getMain().getClueTask().getDigLocation() != null) {
  1280. if(solveMapScroll(getMain().getClueTask())) {
  1281. getMain().setClueTask(null);
  1282. getMain().setState(State.SOLVING_CLUE);
  1283. return true;
  1284. }
  1285. return false;
  1286. }
  1287.  
  1288. if(getMain().getClueTask().getCrypticClue() != null) {
  1289. if(solveCrypticScroll(getMain().getClueTask())) {
  1290. getMain().setClueTask(null);
  1291. getMain().setState(State.SOLVING_CLUE);
  1292. return true;
  1293. }
  1294. return false;
  1295. }
  1296.  
  1297. if(getMain().getClueTask().getEmoteClue() != null) {
  1298. if(solveEmoteScroll(getMain().getClueTask())) {
  1299. getMain().setClueTask(null);
  1300. getMain().setState(State.SOLVING_CLUE);
  1301. return true;
  1302. }
  1303. return false;
  1304. }
  1305. }
  1306. return false;
  1307. }
  1308.  
  1309. public boolean dropClue() {
  1310. if(hasClue()) {
  1311. if(Locations.inHamDungeon()) {
  1312. if(getMain().getTeleporting().teleportTo(TeleportLocation.LUMBRIDGE)) {
  1313. Inventory.drop(new String[] { "Clue scroll (easy)"} );
  1314. getMain().setClueTask(null);
  1315. getMain().setState(State.WALKING_TO_CLUE_LOCATION);
  1316. return true;
  1317. }
  1318. } else {
  1319. Inventory.drop(new String[] { "Clue scroll (easy)"} );
  1320. getMain().setClueTask(null);
  1321. getMain().setState(State.BANKING);
  1322. }
  1323. }
  1324. return false;
  1325. }
  1326.  
  1327. public boolean openCasket() {
  1328.  
  1329. getMain().getEquipped().checkEquipment();
  1330.  
  1331. if(hasCasket()) {
  1332. getMain().setStatus("Opening Casket");
  1333. RSItem[] casket = Inventory.find("Casket (easy)");
  1334. if(casket.length > 0) {
  1335.  
  1336. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  1337. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  1338.  
  1339. if(casket[0].click("Open Casket (easy)")) {
  1340.  
  1341. if(Timing.waitCondition(new Condition() {
  1342.  
  1343. @Override
  1344. public boolean active() {
  1345. return isRewardInterface()
  1346. || Inventory.getCount("Casket (easy)") <= 0;
  1347. }
  1348.  
  1349. }, General.random(4000, 6000))) {
  1350. getMain().setClueTask(null);
  1351.  
  1352. if(isRewardInterface())
  1353. getMain().setState(State.BANKING);
  1354.  
  1355. return true;
  1356. }
  1357. }
  1358. }
  1359. }
  1360. return false;
  1361. }
  1362.  
  1363. public boolean openDoor(RSTile doorTile) {
  1364.  
  1365. RSObject door = Doors.getDoorAt(doorTile);
  1366.  
  1367. if(door != null) {
  1368. if(!door.isOnScreen()) {
  1369. if(doorTile.distanceTo(Player.getPosition()) > 5) {
  1370.  
  1371. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1372.  
  1373. Walking.walkTo(door);
  1374.  
  1375. last_busy_time = System.currentTimeMillis();
  1376. }
  1377. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1378.  
  1379. Camera.turnToTile(door);
  1380.  
  1381. last_busy_time = System.currentTimeMillis();
  1382. }
  1383.  
  1384. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1385.  
  1386. if(Doors.handleDoor(door, true)) {
  1387. last_busy_time = System.currentTimeMillis();
  1388. if(Timing.waitCondition(new Condition() {
  1389.  
  1390. @Override
  1391. public boolean active() {
  1392. return Doors.isDoorAt(doorTile, true);
  1393. }
  1394.  
  1395. }, General.random(4000, 6000))) {
  1396. return true;
  1397. }
  1398. }
  1399. }
  1400. return false;
  1401. }
  1402.  
  1403. public boolean inDungeonArea(ClueTask task) {
  1404. if(task != null) {
  1405. if(task.getCrypticClue() != null) {
  1406. if(task.getCrypticClue().equals(CrypticClue.VARROCK_BANK_CRATE)) {
  1407. if(Locations.VARROCK_BANK_DUNGEON.contains(Player.getPosition())) {
  1408. return true;
  1409. }
  1410. }
  1411. }
  1412. if(task.getEmoteClue() != null) {
  1413. if(task.getEmoteClue().equals(EmoteClue.GAMES_ROOM_CHEER)) {
  1414. if(Player.getPosition().getY() > 4900 && Player.getPosition().getY() < 5100) {
  1415. return true;
  1416. }
  1417. }
  1418. }
  1419. }
  1420. return false;
  1421. }
  1422.  
  1423. public boolean hasAllItems(ClueTask task) {
  1424. if(task.getEmoteClue() != null) {
  1425. String[] items = task.getEmoteClue().getItems();
  1426. if(items[0].equals("")) {
  1427. return true;
  1428. }
  1429. boolean hasItems = true;
  1430.  
  1431. for(int i = 0; i < items.length; i++) {
  1432. if(Inventory.getCount(items[i]) <= 0
  1433. && !Equipment.isEquipped(items[i])) {
  1434. hasItems = false;
  1435. }
  1436. }
  1437. return hasItems;
  1438. }
  1439. return false;
  1440. }
  1441.  
  1442. public boolean hasRequiredEquipment(ClueTask task) {
  1443. if(task.getEmoteClue() != null) {
  1444. String[] items = task.getEmoteClue().getItems();
  1445.  
  1446. boolean hasItems = true;
  1447.  
  1448. for(int i = 0; i < items.length; i++) {
  1449. if(Inventory.getCount(items[i]) <= 0) {
  1450. hasItems = false;
  1451. }
  1452. }
  1453. return hasItems;
  1454. }
  1455. return false;
  1456. }
  1457.  
  1458.  
  1459. public boolean hasAction(RSObjectDefinition def, String action) {
  1460.  
  1461. if(def == null)
  1462. return false;
  1463.  
  1464. String[] actions = def.getActions();
  1465. if(actions == null || actions.length <= 0)
  1466. return false;
  1467.  
  1468. for(int j = 0; j < def.getActions().length; j++) {
  1469. if(def.getActions()[j].contains(action)) {
  1470. return true;
  1471. }
  1472. }
  1473.  
  1474. return false;
  1475. }
  1476.  
  1477. public String getObjectAction(RSObjectDefinition def) {
  1478.  
  1479. String[] actions = def.getActions();
  1480. if(actions == null || actions.length <= 0)
  1481. return "";
  1482.  
  1483. for(String action : actions) {
  1484. if(action.equals("Open")
  1485. || action.equals("Search")) {
  1486. return action;
  1487. }
  1488. }
  1489.  
  1490. return "";
  1491. }
  1492.  
  1493. public boolean checkPlane(ClueTask task) {
  1494. if(Player.getPosition().getPlane() > 0) {
  1495.  
  1496. if(tooManyTries(tries)) {
  1497. getTeleporting().teleportTo(task.getTeleLocation());
  1498. return true;
  1499. }
  1500.  
  1501. tries++;
  1502.  
  1503. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1504.  
  1505. if(climb(false)) {
  1506.  
  1507. last_busy_time = System.currentTimeMillis();
  1508. return true;
  1509. }
  1510. }
  1511. return false;
  1512. }
  1513.  
  1514. public boolean tooManyTries(int tries) {
  1515. return tries > General.random(1, 2);
  1516. }
  1517.  
  1518. public boolean isItemInterface() {
  1519. RSInterface itemInterface = Interfaces.get(Constants.ITEM_INTERFACE);
  1520. if(itemInterface != null) {
  1521. int childId = Constants.ITEM_INTERFACE_TEXT_CHILD;
  1522. RSInterface rsChild = itemInterface.getChild(childId);
  1523. if(rsChild == null)
  1524. return false;
  1525. String text = rsChild.getText();
  1526. getMain().println(text);
  1527. getMain().setClueTask(null);
  1528. return true;
  1529. }
  1530. return false;
  1531. }
  1532.  
  1533. public boolean isRewardInterface() {
  1534. RSItem[] all = Inventory.getAll();
  1535. if(Interfaces.get(Constants.REWARD_INTERFACE) != null) {
  1536. RSInterface reward = Interfaces.get(Constants.REWARD_INTERFACE);
  1537. getMain().setStatus("Solved Clue");
  1538. getMain().setClueTask(null);
  1539. int child = Constants.REWARD_INTERFACE_CLOSE_CHILD;
  1540.  
  1541. RSInterface close = reward.getChild(child);
  1542. if(close != null) {
  1543.  
  1544. abc.waitNewOrSwitchDelay(last_busy_time, false);
  1545.  
  1546. if(close.click("Close")) {
  1547.  
  1548. last_busy_time = System.currentTimeMillis();
  1549.  
  1550. }
  1551. }
  1552.  
  1553. if(Timing.waitCondition(new Condition() {
  1554.  
  1555. @Override
  1556. public boolean active() {
  1557. return Inventory.getAll().length != all.length;
  1558. }
  1559.  
  1560. }, General.random(8000, 12000))) {
  1561. last_busy_time = System.currentTimeMillis();
  1562. getMain().setCluesSolved(getMain().getCluesSolved() + 1);
  1563. calculateGpMade(all);
  1564. return true;
  1565. }
  1566. }
  1567. return false;
  1568. }
  1569.  
  1570. public boolean badClue(ClueTask task) {
  1571. if(task.getCrypticClue() != null) {
  1572. CrypticClue clue = task.getCrypticClue();
  1573. if(clue.equals(CrypticClue.DRAYNOR_MANOR_CRATE)
  1574. || clue.equals(CrypticClue.TAVERLY_OUTHOUSE_CRATE)
  1575. || clue.equals(CrypticClue.PORT_SARIM_JAIL_BUCKET)) {
  1576. getMain().setStatus("Found Bad Clue");
  1577. return true;
  1578. }
  1579. if(clue.equals(CrypticClue.CANIFIS_CRATE)) {
  1580. RSInterface questTab = Interfaces.get(274);
  1581. if(questTab != null) {
  1582. if(questTab.getChild(100).getTextColour() != 65280) { // priest in peril
  1583. getMain().setStatus("Found Bad Clue: Need Priest in Peril");
  1584. return true;
  1585. }
  1586. }
  1587. }
  1588. }
  1589. if(task.getEmoteClue() != null) {
  1590. EmoteClue e = task.getEmoteClue();
  1591. Object[][] req = getMain().getEquipped().getItemRequirements(e.getItems());
  1592. for(Object[] o : req) {
  1593. if(o != null && o.length >= 2) {
  1594. if(o[0] != null && o[1] != null) {
  1595. SKILLS skill = (SKILLS) o[0];
  1596. int lvl = (Integer) o[1];
  1597. if(Skills.getActualLevel(skill) < lvl) {
  1598. getMain().setStatus("Bad Clue: Need " + lvl + " " + Methods.correctCapitalization(skill.toString()));
  1599. return true;
  1600. }
  1601. }
  1602. }
  1603. }
  1604. }
  1605. return false;
  1606. }
  1607.  
  1608. public int getCrypticHeight(CrypticClue clue) {
  1609.  
  1610. if(clue.equals(CrypticClue.VARROCK_BANK_CRATE)) {
  1611. return -1;
  1612. }
  1613. if(clue.equals(CrypticClue.TAVERLY_OUTHOUSE_CRATE)) {
  1614. return 10;
  1615. }
  1616. if(clue.equals(CrypticClue.YANILLE_SHOP_DRAWERS)
  1617. || clue.equals(CrypticClue.WIZARD_TOWER_BOOKCASE)
  1618. || clue.equals(CrypticClue.DRAYNOR_WARDROBE)
  1619. || clue.equals(CrypticClue.DIGSITE_CENTRE_BUSH)) {
  1620. return 0;
  1621. }
  1622. if(clue.equals(CrypticClue.CAMELOT_CASTLE_CHEST)
  1623. || clue.equals(CrypticClue.DRAYNOR_MANOR_CRATE)) {
  1624. return 2;
  1625. }
  1626. if(clue.isUpstairs()) {
  1627. return 1;
  1628. }
  1629. return 0;
  1630. }
  1631.  
  1632. public int getEmoteHeight(EmoteClue clue) {
  1633. if(clue.equals(EmoteClue.ARDOUGNE_MILL_CLAP)) {
  1634. return 2;
  1635. }
  1636. if(clue.equals(EmoteClue.GAMES_ROOM_CHEER)) {
  1637. return -2;
  1638. }
  1639. if(clue.equals(EmoteClue.EXAM_ROOM_CLAP)) {
  1640. return 0;
  1641. }
  1642. if(clue.isUpstairs()) {
  1643. return 1;
  1644. }
  1645. return 0;
  1646. }
  1647.  
  1648. public boolean hasClue() {
  1649. return Inventory.getCount("Clue scroll (easy)") > 0;
  1650. }
  1651.  
  1652. public boolean hasCasket() {
  1653. return Inventory.getCount("Casket (easy)") > 0;
  1654. }
  1655.  
  1656. public int getNpcClicks() {
  1657. return npcClicks;
  1658. }
  1659.  
  1660. public void setNpcClicks(int npcClicks) {
  1661. this.npcClicks = npcClicks;
  1662. }
  1663.  
  1664. public Main getMain() {
  1665. return main;
  1666. }
  1667.  
  1668. public void setMain(Main main) {
  1669. this.main = main;
  1670. }
  1671.  
  1672. public boolean isTeleported() {
  1673. return teleported;
  1674. }
  1675.  
  1676. public void setTeleported(boolean teleported) {
  1677. this.teleported = teleported;
  1678. }
  1679.  
  1680. public Teleporting getTeleporting() {
  1681. return teleporting;
  1682. }
  1683.  
  1684. public void setTeleporting(Teleporting teleporting) {
  1685. this.teleporting = teleporting;
  1686. }
  1687.  
  1688. public boolean isEmoteTeleport() {
  1689. return emoteTeleport;
  1690. }
  1691.  
  1692. public void setEmoteTeleport(boolean emoteTeleport) {
  1693. this.emoteTeleport = emoteTeleport;
  1694. }
  1695.  
  1696. public boolean isNpcClicked() {
  1697. return npcClicked;
  1698. }
  1699.  
  1700. public void setNpcClicked(boolean npcClicked) {
  1701. this.npcClicked = npcClicked;
  1702. }
  1703.  
  1704. public int getEmoteClicks() {
  1705. return emoteClicks;
  1706. }
  1707.  
  1708. public void setEmoteClicks(int emoteClicks) {
  1709. this.emoteClicks = emoteClicks;
  1710. }
  1711.  
  1712.  
  1713. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement