Advertisement
iant06

Untitled

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