Advertisement
iant06

Untitled

Nov 4th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.82 KB | None | 0 0
  1. package scripts.clues;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Point;
  8. import java.text.DecimalFormat;
  9. import java.util.HashMap;
  10.  
  11. import org.tribot.api.General;
  12. import org.tribot.api.Timing;
  13. import org.tribot.api.util.ABCUtil;
  14. import org.tribot.api2007.Banking;
  15. import org.tribot.api2007.Game;
  16. import org.tribot.api2007.Inventory;
  17. import org.tribot.api2007.NPCChat;
  18. import org.tribot.api2007.Options;
  19. import org.tribot.api2007.Player;
  20. import org.tribot.api2007.WebWalking;
  21. import org.tribot.api2007.util.ThreadSettings;
  22. import org.tribot.script.EnumScript;
  23. import org.tribot.script.ScriptManifest;
  24. import org.tribot.script.interfaces.MouseActions;
  25. import org.tribot.script.interfaces.Painting;
  26.  
  27. import scripts.clues.types.AcquiringMethod;
  28. import scripts.clues.types.State;
  29. import scripts.clues.types.TeleportLocation;
  30. import scripts.clues.types.TeleportMethod;
  31. import scripts.methods.Methods;
  32.  
  33. @ScriptManifest(authors = { "iant06" }, category = "Money Making", name = "iClueSolver")
  34.  
  35. public class Main extends EnumScript<State> implements Painting, MouseActions {
  36.  
  37. private final ABCUtil abc = new ABCUtil();
  38. private final DecimalFormat decimalFormat = new DecimalFormat("#.##");
  39.  
  40. private State state;
  41. private AcquiringMethod acquiringMethod;
  42. private TeleportMethod teleportMethod;
  43. private ClueTask clueTask;
  44. private ClueScroll clueScroll;
  45. private Teleporting teleporting;
  46. private Bank bank;
  47. private GUI gui;
  48. private Profile profile;
  49. private HamDungeon hamDungeon;
  50. private Equipped equipped;
  51. private RewardGUI rewardGui;
  52.  
  53. private int foodAmount;
  54. private int cluesSolved = 0;
  55. private int made;
  56. private int loss;
  57.  
  58. private boolean clueSolved;
  59. private boolean paintHidden = false;
  60. private boolean isEndScript = false;
  61.  
  62. private String foodName = "Lobster";
  63. private String status;
  64. private String name;
  65.  
  66. private HashMap<Integer, Reward> itemsWon = new HashMap<Integer, Reward>();
  67.  
  68. @Override
  69. public State getInitialState() {
  70. setName(Player.getRSPlayer().getName());
  71. setStatus("Initializing");
  72.  
  73. println("Starting script for: " + getName());
  74.  
  75. if(gui == null) {
  76. setGui(new GUI(this));
  77. }
  78.  
  79. while(gui.isVisible()) {
  80. sleep(40, 80);
  81. }
  82.  
  83. println("Hunting Clues using: " + Methods.correctCapitalization(getAcquiringMethod().toString()));
  84. println("Teleporting using: " + Methods.correctCapitalization(getTeleportMethod().toString()));
  85. println("Bringing " + getFoodAmount() + " " + getFoodName() + " for food.");
  86. println("Eating food if HP is below " + abc.INT_TRACKER.NEXT_EAT_AT.next() + "%");
  87.  
  88. if(teleporting == null) {
  89. setTeleporting(new Teleporting(this));
  90. }
  91.  
  92. if(clueScroll == null) {
  93. setClueScroll(new ClueScroll(this));
  94. }
  95.  
  96. if(bank == null) {
  97. setBank(new Bank(this));
  98. }
  99.  
  100. if(hamDungeon == null) {
  101. setHamDungeon(new HamDungeon(this));
  102. }
  103.  
  104. if(equipped == null) {
  105. setEquipped(new Equipped(this));
  106. }
  107.  
  108. ThreadSettings.get().setClickingAPIUseDynamic(true);
  109. General.useAntiBanCompliance(true);
  110. getEquipped().setEquipment();
  111.  
  112. if(getClueScroll().hasClue()) {
  113. setState(State.SOLVING_CLUE);
  114. return State.SOLVING_CLUE;
  115. }
  116.  
  117. if(Locations.inHamDungeon()) {
  118. setState(State.AQUIRING_CLUE);
  119. return State.AQUIRING_CLUE;
  120. }
  121.  
  122. if(getBank().canPerform()) {
  123. setState(State.WALKING_TO_CLUE_LOCATION);
  124. return State.WALKING_TO_CLUE_LOCATION;
  125. }
  126.  
  127. setState(State.BANKING);
  128. return State.BANKING;
  129. }
  130.  
  131. @Override
  132. public State handleState(State state) {
  133.  
  134. if(getHamDungeon().canEatFood()) {
  135. getHamDungeon().eatFood();
  136. }
  137.  
  138. if(getClueScroll().isItemInterface()) {
  139. NPCChat.clickContinue(true);
  140. General.sleep(abc.DELAY_TRACKER.ITEM_INTERACTION.next());
  141. abc.DELAY_TRACKER.ITEM_INTERACTION.reset();
  142. setClueTask(null);
  143. setState(State.SOLVING_CLUE);
  144. return State.SOLVING_CLUE;
  145. }
  146.  
  147. if(getClueScroll().isRewardInterface()) {
  148. setState(State.BANKING);
  149. return State.BANKING;
  150. }
  151.  
  152. if(!getEquipped().hasNecklace() || !getEquipped().hasRing()) {
  153. println("Out of Duel ring or Games necklace.");
  154. setState(State.BANKING);
  155. }
  156.  
  157. if(Game.getRunEnergy() >= abc.INT_TRACKER.NEXT_RUN_AT.next()) {
  158. Options.setRunOn(true);
  159. abc.INT_TRACKER.NEXT_RUN_AT.reset();
  160. }
  161.  
  162. state = getState() != null ? getState() : getInitialState();
  163.  
  164. switch(state) {
  165.  
  166. case AQUIRING_CLUE:
  167.  
  168. getEquipped().checkEquipment();
  169. getBank().setBankTeleport(false);
  170.  
  171. if(getClueScroll().hasClue()) {
  172.  
  173. if(getAcquiringMethod().equals(AcquiringMethod.THIEVING)) {
  174. getHamDungeon().dropJunk();
  175. }
  176.  
  177. setState(State.SOLVING_CLUE);
  178. return State.SOLVING_CLUE;
  179.  
  180. }
  181.  
  182. if(!Locations.inHamDungeon()) {
  183.  
  184. setState(State.WALKING_TO_CLUE_LOCATION);
  185. return State.WALKING_TO_CLUE_LOCATION;
  186.  
  187. }
  188.  
  189. if (Player.getPosition().getX() > 3182 && Player.getPosition().getY() < 9614) {
  190.  
  191. getHamDungeon().openJailDoor();
  192. return State.AQUIRING_CLUE;
  193.  
  194. }
  195.  
  196. if(Inventory.isFull()) {
  197.  
  198. if(getAcquiringMethod().equals(AcquiringMethod.THIEVING)) {
  199. getHamDungeon().dropJunk();
  200. } else {
  201. getHamDungeon().eatFood();
  202. }
  203.  
  204. return State.AQUIRING_CLUE;
  205.  
  206. }
  207.  
  208. if(!getClueScroll().foundClueScroll()) {
  209. if(getAcquiringMethod().equals(AcquiringMethod.COMBAT))
  210. getHamDungeon().attackHamGuard();
  211. else
  212. getHamDungeon().pickpocketHamMember();
  213. }
  214.  
  215. return State.AQUIRING_CLUE;
  216.  
  217. case BANKING:
  218.  
  219. getEquipped().checkEquipment();
  220.  
  221. if(Locations.CRAFTING_GUILD_AREA.contains(Player.getPosition())
  222. || Locations.MONASTERY_AREA.contains(Player.getPosition())) {
  223.  
  224. getBank().setBankTeleport(true);
  225. getTeleporting().teleportTo(TeleportLocation.FALADOR);
  226. return State.BANKING;
  227.  
  228. }
  229.  
  230. if(getBank().checkPlane()) {
  231. return State.BANKING;
  232. }
  233.  
  234. if(!getBank().isBankTeleport()) {
  235.  
  236. if(Locations.inHamDungeon()) {
  237. getHamDungeon().leaveDungeon();
  238. return State.BANKING;
  239. }
  240.  
  241. int bankdist = Locations.FALADOR_TELEPORT_AREA.getRandomTile().distanceTo(Player.getPosition());
  242. int closest = getBank().getClosestBankDistance();
  243.  
  244. if(closest < bankdist && closest < 100) {
  245. println("Teleport Distance("+bankdist+") is greater than Closest Bank Distance("+closest+").");
  246. getBank().setBankTeleport(true);
  247. return State.BANKING;
  248. }
  249.  
  250. if(bankdist > 30 && !Banking.isInBank()
  251. || Player.getPosition().getPlane() > 0) {
  252. getBank().setBankTeleport(true);
  253. getTeleporting().teleportTo(TeleportLocation.FALADOR);
  254. return State.BANKING;
  255. }
  256. }
  257.  
  258. if(!Banking.isInBank()) {
  259. setStatus("Walking to Bank");
  260. WebWalking.walkToBank();
  261. return State.BANKING;
  262. }
  263.  
  264. if(getBank().openBank()) {
  265.  
  266. if(getBank().performBankTask()) {
  267.  
  268. Banking.close();
  269.  
  270. if(!getClueScroll().hasClue() && !getClueScroll().hasCasket()) {
  271.  
  272. setState(State.WALKING_TO_CLUE_LOCATION);
  273. return State.WALKING_TO_CLUE_LOCATION;
  274.  
  275. } else {
  276.  
  277. setState(State.SOLVING_CLUE);
  278. return State.SOLVING_CLUE;
  279. }
  280.  
  281. }
  282. }
  283.  
  284. return State.BANKING;
  285.  
  286. case SOLVING_CLUE:
  287. getBank().setBankTeleport(false);
  288. if(!getClueScroll().hasClue() && !getClueScroll().hasCasket()) {
  289. setState(State.BANKING);
  290. return State.BANKING;
  291. }
  292. if(Player.getRSPlayer().isInCombat() && Locations.inHamDungeon()) {
  293. return State.SOLVING_CLUE;
  294. }
  295. if(getClueScroll().isItemInterface()) {
  296. NPCChat.clickContinue(true);
  297. General.sleep(abc.DELAY_TRACKER.NEW_OBJECT_COMBAT.next());
  298. abc.DELAY_TRACKER.NEW_OBJECT_COMBAT.reset();
  299. setClueTask(null);
  300. setState(State.SOLVING_CLUE);
  301. return State.SOLVING_CLUE;
  302. }
  303. if(getClueScroll().isRewardInterface()) {
  304. setClueTask(null);
  305. getEquipped().checkEquipment();
  306. setState(State.BANKING);
  307. return State.BANKING;
  308. }
  309. if(getClueScroll().hasCasket()) {
  310. getClueScroll().openCasket();
  311. return State.SOLVING_CLUE;
  312. }
  313. if(getClueScroll().hasClue()) {
  314. getClueScroll().readClue();
  315. return State.SOLVING_CLUE;
  316. }
  317. return State.SOLVING_CLUE;
  318.  
  319. case WALKING_TO_CLUE_LOCATION:
  320. getEquipped().checkEquipment();
  321. getBank().setBankTeleport(false);
  322.  
  323. if(Banking.isBankScreenOpen()) {
  324. Banking.close();
  325. return State.WALKING_TO_CLUE_LOCATION;
  326. }
  327.  
  328. if(Locations.inHamDungeon()) {
  329. setState(State.AQUIRING_CLUE);
  330. return State.AQUIRING_CLUE;
  331. }
  332.  
  333. int dist = Methods.distanceTo(this, Locations.TRAPDOOR_TILE);
  334. if(dist > 100) {
  335. getTeleporting().teleportTo(TeleportLocation.LUMBRIDGE);
  336. return State.WALKING_TO_CLUE_LOCATION;
  337. }
  338.  
  339. if(dist > 4) {
  340. setStatus("Walking to Trapdoor");
  341. WebWalking.walkTo(Locations.TRAPDOOR_TILE);
  342. }
  343.  
  344. if(getHamDungeon().pickLock()) {
  345. setState(State.AQUIRING_CLUE);
  346. return State.AQUIRING_CLUE;
  347. }
  348.  
  349. return State.WALKING_TO_CLUE_LOCATION;
  350.  
  351. }
  352. return getState();
  353. }
  354.  
  355. @Override
  356. public void onPaint(Graphics g) {
  357. if(!isPaintHidden()) {
  358. int solved = (int) getCluesSolved();
  359. double solveHr = (double) (solved / ((getRunningTime()) / 3600000D));
  360. ((Graphics2D)g).drawImage(Constants.PAINT_IMG, 7, 330, null);
  361. g.setColor(Color.WHITE);
  362. g.setFont(new Font("Arial", Font.BOLD, 14));
  363. g.drawString(Timing.msToString(getRunningTime()), 125, 404);
  364. g.drawString(solved + " (" + (decimalFormat.format(solveHr)) + ")", 125, 426);
  365. g.drawString(getStatus(), 125, 451);
  366. String type = "None";
  367. String taskName = "None";
  368. if(getClueTask() != null) {
  369. if(getClueTask().getCrypticClue() != null) {
  370. type = "Cryptic";
  371. taskName = getClueTask().getCrypticClue().toString();
  372. } else if(getClueTask().getEmoteClue() != null) {
  373. type = "Emote";
  374. taskName = getClueTask().getEmoteClue().toString();
  375. } else if(getClueTask().getDigLocation() != null) {
  376. type = "Map";
  377. taskName = getClueTask().getDigLocation().toString();
  378. }
  379. }
  380. g.drawString(type, 411, 432);
  381. g.drawString(Methods.correctCapitalization(taskName), 411, 408);
  382. g.setFont(new Font("Arial", Font.PLAIN, 10));
  383. g.drawString("HIDE PAINT", 292, 465);
  384. g.drawString("SHOW REWARDS", 370, 465);
  385. g.drawString("CHANGE ACQUIRING METHOD", 120, 465);
  386. g.drawString(Constants.VERSION, 345, 365);
  387. } else {
  388. g.setFont(new Font("Arial", Font.PLAIN, 10));
  389. g.drawString("SHOW PAINT", 292, 465);
  390. }
  391. }
  392.  
  393. public State getState() {
  394. return state;
  395. }
  396.  
  397. public void setState(State state) {
  398. this.state = state;
  399. }
  400.  
  401. public ClueTask getClueTask() {
  402. return clueTask;
  403. }
  404.  
  405. public void setClueTask(ClueTask clueTask) {
  406. if(clueTask == null) {
  407. getClueScroll().setTeleported(false);
  408. getClueScroll().setEmoteTeleport(false);
  409. getClueScroll().setNpcClicks(0);
  410. getClueScroll().setEmoteClicks(0);
  411. getBank().setBankTeleport(false);
  412. getEquipped().checkEquipment();
  413. }
  414. this.clueTask = clueTask;
  415. }
  416.  
  417. public ClueScroll getClueScroll() {
  418. return clueScroll;
  419. }
  420.  
  421. public void setClueScroll(ClueScroll clueScroll) {
  422. this.clueScroll = clueScroll;
  423. }
  424.  
  425. public boolean isClueSolved() {
  426. return clueSolved;
  427. }
  428.  
  429. public void setClueSolved(boolean solvedClue) {
  430. this.clueSolved = solvedClue;
  431. }
  432.  
  433. public Teleporting getTeleporting() {
  434. return teleporting;
  435. }
  436.  
  437. public void setTeleporting(Teleporting teleporting) {
  438. this.teleporting = teleporting;
  439. }
  440.  
  441. public int getCluesSolved() {
  442. return cluesSolved;
  443. }
  444.  
  445. public void setCluesSolved(int cluesSolved) {
  446. this.cluesSolved = cluesSolved;
  447. }
  448.  
  449. public String getStatus() {
  450. return status;
  451. }
  452.  
  453. public void setStatus(String status) {
  454. this.status = status;
  455. }
  456.  
  457. public Bank getBank() {
  458. return bank;
  459. }
  460.  
  461. public void setBank(Bank bank) {
  462. this.bank = bank;
  463. }
  464.  
  465. public int getMade() {
  466. return made;
  467. }
  468.  
  469. public void setMade(int made) {
  470. this.made = made;
  471. }
  472.  
  473. public int getLoss() {
  474. return loss;
  475. }
  476.  
  477. public void setLoss(int loss) {
  478. this.loss = loss;
  479. }
  480.  
  481. public HashMap<Integer, Reward> getItemsWon() {
  482. return itemsWon;
  483. }
  484.  
  485. public void setItemsWon(HashMap<Integer, Reward> itemsWon) {
  486. this.itemsWon = itemsWon;
  487. }
  488.  
  489. public AcquiringMethod getAcquiringMethod() {
  490. return acquiringMethod;
  491. }
  492.  
  493. public void setAcquiringMethod(AcquiringMethod acquiringMethod) {
  494. this.acquiringMethod = acquiringMethod;
  495. }
  496.  
  497. public TeleportMethod getTeleportMethod() {
  498. return teleportMethod;
  499. }
  500.  
  501. public void setTeleportMethod(TeleportMethod teleportMethod) {
  502. this.teleportMethod = teleportMethod;
  503. }
  504.  
  505. public String getFoodName() {
  506. return foodName;
  507. }
  508.  
  509. public void setFoodName(String foodName) {
  510. this.foodName = foodName;
  511. }
  512.  
  513. public int getFoodAmount() {
  514. return foodAmount;
  515. }
  516.  
  517. public void setFoodAmount(int foodAmount) {
  518. this.foodAmount = foodAmount;
  519. }
  520.  
  521. public GUI getGui() {
  522. return gui;
  523. }
  524.  
  525. public void setGui(GUI gui) {
  526. this.gui = gui;
  527. }
  528.  
  529. public Profile getProfile() {
  530. return profile;
  531. }
  532.  
  533. public void setProfile(Profile profile) {
  534. this.profile = profile;
  535. }
  536.  
  537. public HamDungeon getHamDungeon() {
  538. return hamDungeon;
  539. }
  540.  
  541. public void setHamDungeon(HamDungeon hamDungeon) {
  542. this.hamDungeon = hamDungeon;
  543. }
  544.  
  545. public Equipped getEquipped() {
  546. return equipped;
  547. }
  548.  
  549. public void setEquipped(Equipped equipped) {
  550. this.equipped = equipped;
  551. }
  552.  
  553. public RewardGUI getRewardGui() {
  554. return rewardGui;
  555. }
  556.  
  557. public void setRewardGui(RewardGUI rewardGui) {
  558. this.rewardGui = rewardGui;
  559. }
  560.  
  561. public String getName() {
  562. return name;
  563. }
  564.  
  565. public void setName(String name) {
  566. this.name = name;
  567. }
  568.  
  569. public boolean isPaintHidden() {
  570. return paintHidden;
  571. }
  572.  
  573. public void setPaintHidden(boolean paintHidden) {
  574. this.paintHidden = paintHidden;
  575. }
  576.  
  577. @Override
  578. public void mouseClicked(Point e, int button, boolean isBot) {
  579. // hide paint
  580. if(e.getX() >= Constants.PAINT_CLICK_X[0] && e.getX() <= Constants.PAINT_CLICK_X[1]
  581. && e.getY() >= Constants.PAINT_CLICK_Y[0] && e.getY() <= Constants.PAINT_CLICK_Y[1]) {
  582. if(button == 1 && !isBot) {
  583. if(isPaintHidden()) {
  584. println("Showing Paint!");
  585. setPaintHidden(false);
  586. } else {
  587. println("Hiding Paint!");
  588. setPaintHidden(true);
  589. }
  590. }
  591. }
  592.  
  593. // show rewards
  594. if(e.getX() >= Constants.PAINT_CLICK_X[2] && e.getX() <= Constants.PAINT_CLICK_X[3]
  595. && e.getY() >= Constants.PAINT_CLICK_Y[2] && e.getY() <= Constants.PAINT_CLICK_Y[3]) {
  596. if(button == 1 && !isBot) {
  597. if(getRewardGui() != null) {
  598. getRewardGui().dispose();
  599. setRewardGui(null);
  600. }
  601. setRewardGui(new RewardGUI(this));
  602. println("Showing Rewards List!");
  603. }
  604. }
  605.  
  606. // change acquiring method
  607. if(e.getX() >= Constants.PAINT_CLICK_X[4] && e.getX() <= Constants.PAINT_CLICK_X[5]
  608. && e.getY() >= Constants.PAINT_CLICK_Y[4] && e.getY() <= Constants.PAINT_CLICK_Y[5]) {
  609. if(button == 1 && !isBot) {
  610. if(getAcquiringMethod().equals(AcquiringMethod.COMBAT)) {
  611. println("Changing Acquiring Method to Thieving!");
  612. setAcquiringMethod(AcquiringMethod.THIEVING);
  613. } else {
  614. println("Changing Acquiring Method to Combat!");
  615. setAcquiringMethod(AcquiringMethod.COMBAT);
  616. }
  617. }
  618. }
  619.  
  620. }
  621.  
  622. @Override
  623. public void mouseDragged(Point arg0, int arg1, boolean arg2) {
  624. }
  625.  
  626. @Override
  627. public void mouseMoved(Point arg0, boolean arg1) {
  628. }
  629.  
  630. @Override
  631. public void mouseReleased(Point arg0, int arg1, boolean arg2) {
  632. }
  633.  
  634. public String[] getTribotUsers() {
  635. return tribotUsers;
  636. }
  637.  
  638. public void setTribotUsers(String[] tribotUsers) {
  639. this.tribotUsers = tribotUsers;
  640. }
  641.  
  642. public boolean isEndScript() {
  643. return isEndScript;
  644. }
  645.  
  646. public void setEndScript(boolean isEndScript) {
  647. this.isEndScript = isEndScript;
  648. }
  649.  
  650. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement