Advertisement
Guest User

Untitled

a guest
Oct 28th, 2013
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.96 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Graphics;
  4. import java.awt.Point;
  5. import java.awt.Polygon;
  6. import java.util.ArrayList;
  7.  
  8. import org.tribot.api2007.Camera;
  9. import org.tribot.api2007.Login;
  10. import org.tribot.api2007.Banking;
  11. import org.tribot.api2007.ChooseOption;
  12. import org.tribot.api2007.Interfaces;
  13. import org.tribot.api2007.Objects;
  14. import org.tribot.api2007.Player;
  15. import org.tribot.api2007.Screen;
  16. import org.tribot.api2007.Walking;
  17. import org.tribot.api2007.types.RSNPC;
  18. import org.tribot.api2007.types.RSObject;
  19. import org.tribot.api2007.types.RSTile;
  20. import org.tribot.api2007.types.RSItem;
  21. import org.tribot.api2007.Inventory;
  22. import org.tribot.api2007.types.RSInterface;
  23. import org.tribot.api2007.NPCs;
  24. import org.tribot.api.DynamicClicking;
  25. import org.tribot.api.General;
  26. import org.tribot.api.Timing;
  27. import org.tribot.api.input.Mouse;
  28. import org.tribot.api.types.generic.Condition;
  29. import org.tribot.script.Script;
  30. import org.tribot.script.ScriptManifest;
  31. import org.tribot.script.interfaces.Painting;
  32. import java.awt.Color; //to get different colors
  33. import java.awt.Font; //to change font
  34. import java.awt.Graphics2D; //needed for the image
  35. import java.awt.Image; //same as above
  36. import java.io.IOException; //this is needed for the loading of the image
  37. import java.net.URL; //same as above
  38. import javax.imageio.ImageIO; //same as above
  39.  
  40. @ScriptManifest(authors = { "Okokokok" }, category = "Money Making", name = "Ok_oreBuyer")
  41. public class Ok_oreBuyer extends Script implements Painting {
  42.  
  43. private final int ORDAN_ID = 594,
  44. COAL_ID = 453,
  45. FRONT_CLOSED_DOOR_ID = 6977,
  46. HALF_CLOSED_DOOR_ID = 6102,
  47. HALF_OPEN_DOOR_ID = 6103,
  48. LAST_CLOSED_DOOR_ID = 6975,
  49. UP_STAIRS_ID = 9084,
  50. DOWN_STAIRS_ID = 9138;
  51.  
  52. private final RSTile SHOPTILE_DOWNSTAIRS = new RSTile(1936, 4965, 0);
  53.  
  54. private final Polygon frontShopArea = new Polygon(
  55. new int[]{2928, 2933, 2933, 2928},
  56. new int[]{10190, 10189, 10186, 10186},
  57. 4),
  58. frontShopAreaR = new Polygon(
  59. new int[]{2928, 2933, 2933, 2928},
  60. new int[]{10192, 10192, 10186, 10186},
  61. 4),
  62. halfShopArea = new Polygon(
  63. new int[]{2928, 2933, 2933, 2928},
  64. new int[]{10195, 10195, 10190, 10190},
  65. 4),
  66. lastShopArea = new Polygon(
  67. new int[]{2928, 2933, 2933, 2928},
  68. new int[]{10199, 10198, 10195, 10195},
  69. 4),
  70. downLadderArea = new Polygon(
  71. new int[]{1935, 1944, 1944, 1935},
  72. new int[]{4970, 4970, 4956, 4956},
  73. 4),
  74. bankArea = new Polygon(
  75. new int[]{2834, 2842, 2842, 2834},
  76. new int[]{10212, 10212, 10207, 10207},
  77. 4),
  78. firstShopArea = new Polygon(
  79. new int[]{2927, 2934, 2934, 2927},
  80. new int[]{10186, 10186, 10183, 10183},
  81. 4),
  82. downStairsArea = new Polygon(
  83. new int[]{1937, 1943, 1943, 1937},
  84. new int[]{4960, 4960, 4956, 4956},
  85. 4),
  86. walkingArea = new Polygon(
  87. new int[]{2842, 2926, 2926, 2842},
  88. new int[]{10236, 10236, 10170, 10170},
  89. 4);
  90.  
  91. private int oreBought;
  92.  
  93. private void setView(){
  94. int camAngle = Camera.getCameraAngle();
  95. int camRot = Camera.getCameraRotation();
  96.  
  97. if (camAngle != 79 && camRot != 58){
  98. Camera.setCameraAngle(79);
  99. Camera.setCameraRotation(58);
  100. }
  101. }
  102.  
  103. public void closeShop(){
  104. Mouse.clickBox(479, 34, 495, 48, 1);
  105. }
  106.  
  107. public void hopWorld(){
  108. closeShop();
  109. super.setLoginBotState(false);
  110. super.setRandomSolverState(false);
  111. worldHop(General.random(1,78),true,true); // random world hop
  112. super.setLoginBotState(true);
  113. super.setRandomSolverState(true);
  114. }
  115.  
  116. public boolean loginState(){
  117. if(!loggedOut()){
  118. return true;
  119. }
  120. return false;
  121. }
  122.  
  123. public void loginAction(){
  124. if(!loginState()){
  125. super.setLoginBotState(active);
  126. }
  127. }
  128.  
  129. public boolean loggedOut(){
  130. return (Login.getLoginState() == Login.STATE.LOGINSCREEN) && (!Screen.getColorAt(100,200).equals(new Color(0,0,0)));
  131. }
  132.  
  133. public boolean waitFor(Condition c, long timeout) {
  134. Timer t = new Timer(timeout);
  135. while (t.isRunning()) {
  136. if(c.active()){
  137. return true;
  138. }
  139. sleep(60, 80);
  140. }
  141. return false;
  142. }
  143.  
  144. private boolean haveOres(){
  145. RSItem[] haveOres = Inventory.find(COAL_ID);
  146. return haveOres != null && haveOres.length > 0;
  147. }
  148.  
  149. private boolean atOrdan(){
  150. RSTile pos = Player.getPosition();
  151. RSTile atShop = SHOPTILE_DOWNSTAIRS;
  152. return pos.getPosition().distanceTo(atShop) < 8;
  153. }
  154.  
  155. public boolean isShopOpen(){
  156. RSInterface shop = Interfaces.get(300);
  157.  
  158. if (shop != null){
  159. return true;
  160. }
  161. return false;
  162. }
  163.  
  164. private boolean atFirstShopArea(){
  165. if(firstShopArea.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  166. sleep(600, 700);
  167. return true;
  168. }
  169. return false;
  170. }
  171.  
  172. private void walkToShop(){
  173. RSTile pos = Player.getPosition();
  174. RSTile shop = new RSTile (2930, 10185, 0);
  175. RSTile[] walkPath = new RSTile[] {new RSTile(2930, 10185, 0), new RSTile(2923, 10192, 0), new RSTile(2915, 10199, 0),
  176. new RSTile(2908, 10209, 0), new RSTile(2898, 10216, 0), new RSTile(2893, 10226, 0),
  177. new RSTile(2885, 10232, 0), new RSTile(2875, 10232, 0), new RSTile(2864, 10230, 0),
  178. new RSTile(2855, 10226, 0), new RSTile (2850, 10219, 0), new RSTile(2845, 10213, 0),
  179. new RSTile(2838, 10207, 0)};
  180.  
  181. if (pos != shop){
  182. if (Walking.walkPath(Walking.invertPath(walkPath))){
  183. println("Time for a little strole");
  184. waitFor(new Condition(){
  185. @ Override
  186. public boolean active(){
  187. return !Player.isMoving() && atFirstShopArea();
  188. }
  189. }, 30000);
  190. }
  191. }
  192. }
  193.  
  194. private boolean atBankArea(){
  195. if(bankArea.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  196. sleep(600, 700);
  197. return true;
  198. }
  199. return false;
  200. }
  201.  
  202.  
  203.  
  204.  
  205. public void walkToBank(){
  206. RSTile pos = Player.getPosition();
  207. RSTile bank = new RSTile (2838, 10207, 0);
  208. RSTile[] walkPath = new RSTile[] {new RSTile(2930, 10185, 0), new RSTile(2923, 10192, 0), new RSTile(2915, 10199, 0),
  209. new RSTile(2908, 10209, 0), new RSTile(2898, 10216, 0), new RSTile(2893, 10226, 0),
  210. new RSTile(2885, 10232, 0), new RSTile(2875, 10232, 0), new RSTile(2864, 10230, 0),
  211. new RSTile(2855, 10226, 0), new RSTile (2850, 10219, 0), new RSTile(2845, 10213, 0),
  212. new RSTile(2838, 10207, 0)};
  213. oreBought += Inventory.getCount(COAL_ID);
  214. if (pos != bank){
  215. if (Walking.walkPath(walkPath)){
  216. waitFor(new Condition(){
  217. @Override
  218. public boolean active(){
  219. return !Player.isMoving() && atBankArea();
  220. }
  221. }, 7000);
  222. }
  223. }
  224. }
  225.  
  226. private boolean walkToFirstInside(){
  227. RSTile pos = Player.getPosition();
  228. RSTile lastInside = new RSTile(2930, 10186, 0);
  229. if (pos != lastInside){
  230. if (Walking.walkTo(lastInside)){
  231. waitFor(new Condition(){
  232. @ Override
  233. public boolean active(){
  234. return !Player.isMoving();
  235. }
  236. }, 4000);
  237. }
  238. }
  239. return false;
  240. }
  241.  
  242. private boolean walkToLast(){
  243. RSTile pos = Player.getPosition();
  244. RSTile last = new RSTile(2929, 10193, 0);
  245. if (pos != last){
  246. if (Walking.walkTo(last)){
  247. waitFor(new Condition(){
  248. @ Override
  249. public boolean active(){
  250. return !Player.isMoving();
  251. }
  252. }, 4000);
  253. }
  254. }
  255. return false;
  256. }
  257.  
  258. private boolean walkToLadder(){
  259. RSTile pos = Player.getPosition();
  260. RSTile last = new RSTile(2931, 10196, 0);
  261. if (pos != last){
  262. if (Walking.walkTo(last)){
  263. waitFor(new Condition(){
  264. @ Override
  265. public boolean active(){
  266. return !Player.isMoving();
  267. }
  268. }, 4000);
  269. }
  270. }
  271. return false;
  272. }
  273.  
  274. private boolean atDownStairsArea(){
  275. if(downStairsArea.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  276. sleep(600, 700);
  277. return true;
  278. }
  279. return false;
  280. }
  281.  
  282. private boolean walkToOrdan(){
  283. RSTile pos = Player.getPosition();
  284. RSTile ordan = new RSTile(1936, 4965, 0);
  285. if (pos != ordan){
  286. if (Walking.walkTo(ordan)){
  287. waitFor(new Condition(){
  288. @ Override
  289. public boolean active(){
  290. return !Player.isMoving();
  291. }
  292. }, 4000);
  293. }
  294. }
  295. return false;
  296. }
  297.  
  298. private boolean walkToLadderDown(){
  299. RSTile pos = Player.getPosition();
  300. RSTile ladder = new RSTile(1940, 4958, 0);
  301. if (pos != ladder){
  302. if (Walking.walkTo(ladder)){
  303. waitFor(new Condition(){
  304. @ Override
  305. public boolean active(){
  306. return !Player.isMoving();
  307. }
  308. }, 4000);
  309. }
  310. }
  311. return false;
  312. }
  313.  
  314. public boolean depositOre(){
  315. RSItem[] gold = Inventory.find(COAL_ID);
  316. if (gold != null && gold.length > 0){
  317. return gold[0].click("Deposit-All");
  318. }
  319. return false;
  320. }
  321.  
  322. private void openShop(){
  323. RSNPC[] ordan = NPCs.findNearest(15, ORDAN_ID);
  324. if (ordan != null && ordan.length > 0){
  325. if (ordan[0].click("Trade")){
  326. waitFor(new Condition(){
  327. @Override
  328. public boolean active(){
  329. return isShopOpen();
  330. }
  331. }, 4000);
  332. }
  333. }
  334. }
  335.  
  336.  
  337. private boolean atWalkingArea(){
  338. if(walkingArea.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  339. return true;
  340. }
  341. return false;
  342. }
  343.  
  344. private boolean atFrontArea(){
  345. if(frontShopArea.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  346. return true;
  347. }
  348. return false;
  349. }
  350.  
  351. private boolean atFrontAreaR(){
  352. if(frontShopAreaR.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  353. return true;
  354. }
  355. return false;
  356. }
  357.  
  358. public void openFrontDoor(){
  359. RSObject[] door = Objects.findNearest(30, FRONT_CLOSED_DOOR_ID);
  360. if(door != null && door.length > 0){
  361. if (DynamicClicking.clickRSObject(door[0], "Open")){
  362. waitFor(new Condition(){
  363. @ Override
  364. public boolean active() {
  365. return !Player.isMoving() && atFrontArea(); }
  366. }, 4000);
  367. }
  368. }
  369. }
  370.  
  371. public void openFrontDoorR(){
  372. RSObject[] door = Objects.findNearest(30, FRONT_CLOSED_DOOR_ID);
  373. if(door != null && door.length > 0){
  374. if (DynamicClicking.clickRSObject(door[0], "Open")){
  375. waitFor(new Condition(){
  376. @ Override
  377. public boolean active() {
  378. return !Player.isMoving() && atFirstShopArea(); }
  379. }, 4000);
  380. }
  381. }
  382. }
  383.  
  384. private boolean atHalfArea(){
  385. if(halfShopArea.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  386. return true;
  387. }
  388. return false;
  389. }
  390.  
  391.  
  392. private void openHalfDoor(){
  393. RSObject[] door = Objects.findNearest(20, HALF_CLOSED_DOOR_ID);
  394. if(door != null && door.length > 0){
  395. if (DynamicClicking.clickRSObject(door[0], "Open")){
  396. waitFor(new Condition(){
  397. @ Override
  398. public boolean active(){
  399. return !Player.isMoving() && atHalfArea();
  400. }
  401. }, 4000);
  402. }
  403. }else {
  404. if (walkToLast()){
  405. waitFor(new Condition(){
  406. @ Override
  407. public boolean active(){
  408. return !Player.isMoving();
  409. }
  410. }, 4000);
  411. }
  412. }
  413. }
  414.  
  415. private boolean isHalfDoorOpen(){
  416. RSObject[] door = Objects.findNearest(15, HALF_OPEN_DOOR_ID);
  417. return door != null && door.length > 0;
  418. }
  419.  
  420.  
  421. private void openHalfDoorR(){
  422. RSObject[] door = Objects.findNearest(20, HALF_CLOSED_DOOR_ID);
  423. if(door != null && door.length > 0){
  424. if (DynamicClicking.clickRSObject(door[0], "Open")){
  425. waitFor(new Condition(){
  426. @ Override
  427. public boolean active(){
  428. return !Player.isMoving() && isHalfDoorOpen();
  429. }
  430. }, 4000);
  431. }
  432. } else {
  433. if (walkToFirstInside()){
  434. waitFor(new Condition(){
  435. @ Override
  436. public boolean active(){
  437. return !Player.isMoving();
  438. }
  439. }, 4000);
  440. }
  441. }
  442. }
  443.  
  444. private boolean atLastArea(){
  445. if(lastShopArea.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  446. return true;
  447. }
  448. return false;
  449. }
  450.  
  451.  
  452. private void openLastDoor(){
  453. RSObject[] door = Objects.findNearest(20, LAST_CLOSED_DOOR_ID);
  454. if(door != null && door.length > 0){
  455. if (DynamicClicking.clickRSObject(door[0], "Open")){
  456. waitFor(new Condition(){
  457. @ Override
  458. public boolean active(){
  459. return !Player.isMoving() && atLastArea();
  460. }
  461. }, 4000);
  462. }
  463. } else {
  464. if (walkToLadder()){
  465. waitFor(new Condition(){
  466. @ Override
  467. public boolean active(){
  468. return !Player.isMoving();
  469. }
  470. }, 4000);
  471. }
  472. }
  473. }
  474.  
  475. private boolean walkToHalf(){
  476. RSTile pos = Player.getPosition();
  477. RSTile half = new RSTile(2929, 10190, 0);
  478. if (pos != half){
  479. if (Walking.walkTo(half)){
  480. waitFor(new Condition(){
  481. @ Override
  482. public boolean active(){
  483. return !Player.isMoving();
  484. }
  485. }, 4000);
  486. }
  487. }
  488. return false;
  489. }
  490.  
  491. private void openLastDoorR(){
  492. RSObject[] door = Objects.findNearest(20, LAST_CLOSED_DOOR_ID);
  493. if(door != null && door.length > 0){
  494. if (DynamicClicking.clickRSObject(door[0], "Open")){
  495. waitFor(new Condition(){
  496. @ Override
  497. public boolean active(){
  498. return !Player.isMoving() && atHalfArea();
  499. }
  500. }, 4000);
  501. }
  502. } else {
  503. if (walkToHalf()){
  504.  
  505. }
  506. }
  507.  
  508. }
  509.  
  510. private boolean atDownArea(){
  511. if(downLadderArea.contains(Player.getPosition().getX(), Player.getPosition().getY())){
  512. return true;
  513. }
  514. return false;
  515. }
  516.  
  517. private void goDownStairs(){
  518. RSObject[] stairs = Objects.findNearest(20, UP_STAIRS_ID);
  519. if(stairs != null && stairs.length > 0){
  520. if (DynamicClicking.clickRSObject(stairs[0], "Climb-down")){
  521. waitFor(new Condition(){
  522. @ Override
  523. public boolean active(){
  524. return atDownArea();
  525. }
  526. }, 4000);
  527. }
  528. }
  529. }
  530.  
  531. private void goUpStairs(){
  532. RSObject[] stairs = Objects.findNearest(20, DOWN_STAIRS_ID);
  533. if(stairs != null && stairs.length > 0){
  534. if (DynamicClicking.clickRSObject(stairs[0], "Climb-up")){
  535. waitFor(new Condition (){
  536. @ Override
  537. public boolean active(){
  538. return atLastArea();
  539. }
  540. }, 4000);
  541. }
  542. }
  543. }
  544.  
  545. private boolean checkStoreStack(){
  546. RSItem[] coal = Interfaces.get(300, 75).getItems();
  547. if(isShopOpen()){
  548. for (int i = 0; i < coal.length; i++){
  549. if (coal[i].getID() == 453){
  550. if (coal[i].getStack() > 2){
  551. return true;
  552. }
  553. }
  554. }
  555. }
  556. return false;
  557. }
  558.  
  559. //Doomguard's buy store snippet
  560.  
  561. private boolean StoreHave(){
  562. RSItem[] items = Interfaces.get(300 , 75).getItems();
  563. for(int i = 0; i < items.length; i++)
  564. if(items[i].getID() == 453){
  565. return true;
  566. }
  567. return false;
  568. }
  569.  
  570.  
  571. private boolean buy(int x){
  572. while(StoreHave() && !Inventory.isFull() && checkStoreStack()){
  573. RSItem[] items = Interfaces.get(300, 75).getItems(); // GET ALL THE ITEM IN THE SHOP
  574. for (int i = 0; i < items.length; i++) { // LOOP THROUGHT THE ITEM
  575. if (items[i].getID() == 453) { // IF THE ITEM IS SAME AS THE ITEM WANT
  576. println(items[i].getID()+ " "+ items[i].getStack());
  577. items[i].changeType(RSItem.TYPE.BANK); // TURN TO A BANK ITEM
  578. Mouse.clickBox(362, 76, 393, 92, 3);
  579. if(x == 10){
  580. if(ChooseOption.isOptionValid("Buy 10")) { // IF BUY 10 IS AVI
  581. ChooseOption.select("Buy 10"); // CLICK BUY TEN
  582. }
  583. sleep(500);
  584. }
  585. if(x == 5){
  586. if(ChooseOption.isOptionValid("Buy 10")) { // IF BUY 5 IS AVI
  587. ChooseOption.select("Buy 10"); // CLICK buy 5
  588. }
  589. sleep(500);
  590. }
  591. if(x == 1){
  592. if(ChooseOption.isOptionValid("Buy 1")) { // IF BUY 1 IS AVI
  593. ChooseOption.select("Buy 1"); // CLICK BUY one
  594. }
  595. sleep(500);
  596. }
  597. if(ChooseOption.isOptionValid("Cancel"))
  598. ChooseOption.select("Cancel"); // CLICK BUY one
  599. }
  600. }
  601. }
  602. return false;
  603. }
  604.  
  605. // wastedbro's World Hopping Snippet
  606.  
  607. public void worldHop(int worldNumber, boolean excludeFrees, boolean excludePopular)
  608. {
  609. logout(); //Logs out if needed
  610. while(loggedOut())
  611. {
  612. openWorldSelect();
  613. }
  614. while(worldSelectOpen())
  615. {
  616. selectWorld(worldNumber,excludeFrees,excludePopular);
  617. }
  618. }
  619.  
  620. public void selectWorld(int worldNumber, boolean excludeFrees, boolean excludePopular)
  621. {
  622. ArrayList<Point> world = new ArrayList<Point>();
  623. int counter = 1;
  624. while((worldNumber == 7 || worldNumber == 15 || worldNumber == 23 || worldNumber == 24 || worldNumber == 31 || worldNumber == 32 || worldNumber == 39 || worldNumber == 40 || worldNumber == 47 || worldNumber == 48 || worldNumber == 55 || worldNumber == 56 || worldNumber == 63 || worldNumber == 64 || worldNumber == 71 || worldNumber == 72))
  625. {
  626. worldNumber = General.random(1, 78);
  627. if((worldNumber == 1 || worldNumber == 2) && excludePopular)
  628. {
  629. continue;
  630. }
  631. if((worldNumber == 8 || worldNumber == 16) && excludeFrees)
  632. {
  633. continue;
  634. }
  635. } //The loops above ensure the world chosen exists and not free/popular depending on the boolean parameters
  636.  
  637.  
  638. for(int columns = 230, y = 1; y < 5 ; columns=columns+95, y++) // Populates the world arrayList with points relative to the world
  639. {
  640. for(int rows = 81, x = 1; x < 17; rows=rows+24, x++, counter++)
  641. {
  642. while(counter == 7 || counter == 15 || counter == 23 || counter == 24 || counter == 31 || counter == 32 || counter == 39 || counter == 40 || counter == 47 || counter == 48 || counter == 55 || counter == 56 || counter == 63 || counter == 64 || counter == 71 || counter == 72)
  643. {
  644. world.add(new Point(0,0));
  645. counter++;
  646. }
  647. world.add(new Point(columns,rows));
  648. }
  649. }
  650.  
  651. worldNumber--;
  652.  
  653. Mouse.clickBox(world.get(worldNumber).x - 10, world.get(worldNumber).y - 5, world.get(worldNumber).x + 10, world.get(worldNumber).y + 5, 1);
  654. for(int x = 0; x < 6; x++) //Waits up to 3 seconds for the login screen. Checks every half a second (Approx.)
  655. {
  656. if(loggedOut())
  657. {
  658. break;
  659. }
  660. sleep(490,510);
  661. }
  662. }
  663.  
  664. public boolean worldSelectOpen()
  665. {
  666. if (Login.getLoginState() == Login.STATE.LOGINSCREEN)
  667. {
  668. Color black = new Color(0,0,0);
  669. return (Screen.getColorAt(100, 200).equals(black));
  670. }
  671. return false;
  672. }
  673.  
  674. public boolean openWorldSelect()
  675. {
  676. if (Login.getLoginState() == Login.STATE.LOGINSCREEN)
  677. {
  678. Mouse.clickBox(10, 465, 100, 495, 0);
  679. for(int x = 0; x < 10; x++)
  680. {
  681. if(worldSelectOpen())
  682. {
  683. return true;
  684. }
  685. sleep(490,510);
  686. }
  687. }
  688. return false;
  689. }
  690.  
  691.  
  692.  
  693. public boolean logout()
  694. {
  695. if (Login.getLoginState() == Login.STATE.INGAME)
  696. {
  697. Login.logout();
  698. for(int x = 0; x < 6; x++)
  699. {
  700. if(loggedOut())
  701. {
  702. return true;
  703. }
  704. sleep(490,510);
  705. }
  706. }
  707. return false;
  708. }
  709.  
  710.  
  711. private Image getImage(String url){
  712. try{
  713. return ImageIO.read(new URL(url));
  714. } catch (IOException e) {
  715. return null;
  716. }
  717. }
  718.  
  719. private final Image img = getImage("http://i43.tinypic.com/28uphdt.jpg");
  720. private static final long startTime = System.currentTimeMillis();
  721. private State SCRIPT_STATE = getState();
  722.  
  723.  
  724. Font font = new Font("Forte", Font.PLAIN, 18);
  725.  
  726.  
  727. @Override
  728. public void onPaint(Graphics g) {
  729.  
  730. Graphics2D gg = (Graphics2D)g;
  731. gg.drawImage(img, 9, 345, null);
  732.  
  733. long timeRan = System.currentTimeMillis() - startTime;
  734. double multiplier = timeRan / 3600000D;
  735. int ore = oreBought;
  736. g.setFont(font);
  737.  
  738. g.setColor(new Color(194, 182, 38));
  739. g.drawString("Action: " + SCRIPT_STATE, 16, 410);
  740. g.drawString("Time running: " + Timing.msToString(timeRan), 16, 430);
  741. g.drawString("Ores p/h: " + (int) (ore / multiplier) + " p/h", 16, 450);
  742. g.drawString("Ores bought: " + ore, 16, 470);
  743. }
  744.  
  745. public enum State{
  746. WORLD_HOP, WALKING_TOSHOP, WALKING_TOBANK, BUY_ORES,
  747. OPEN_SHOP, OPEN_BANK, DEPOSIT_ORES, PASSING_LAST_AREA_R,
  748. PASSING_HALF_AREA_R, PASSING_FRONT_AREA_R, WALKING_TO_STAIRS,
  749. PASSING_FRONT_AREA, PASSING_HALF_AREA, PASSING_LAST_AREA,
  750. PASSING_FIRST_SHOP_AREA, GOING_UP_STAIRS, WALK_TO_ORDAN;
  751. }
  752.  
  753. private State getState(){
  754. if (haveOres() && Inventory.isFull()){
  755. if (atBankArea()){
  756. if (Banking.isBankScreenOpen()){
  757. return State.DEPOSIT_ORES;
  758. } else {
  759. return State.OPEN_BANK;
  760. }
  761. } else {
  762. if(atOrdan()){
  763. return State.WALKING_TO_STAIRS;
  764. } else {
  765. if (atDownStairsArea()){
  766. return State.GOING_UP_STAIRS;
  767. } else {
  768. if (atLastArea()){
  769. return State.PASSING_LAST_AREA_R;
  770. } else {
  771. if (atHalfArea()){
  772. return State.PASSING_HALF_AREA_R;
  773. } else {
  774. if (atFrontAreaR()){
  775. return State.PASSING_FRONT_AREA_R;
  776. } else {
  777. if (atFirstShopArea()){
  778. return State.WALKING_TOBANK;
  779. } else {
  780. if (atWalkingArea()){
  781. return State.WALKING_TOBANK;
  782. }
  783. }
  784. }
  785. }
  786. }
  787. }
  788. }
  789. }
  790. } else {
  791. if (!Inventory.isFull()){
  792. if (atBankArea()){
  793. return State.WALKING_TOSHOP;
  794. } else {
  795. if (atFirstShopArea()){
  796. return State.PASSING_FIRST_SHOP_AREA;
  797. } else {
  798. if (atFrontArea()){
  799. return State.PASSING_FRONT_AREA;
  800. } else {
  801. if (atHalfArea()){
  802. return State.PASSING_HALF_AREA;
  803. } else {
  804. if (atLastArea()){
  805. return State.PASSING_LAST_AREA;
  806. } else {
  807. if (atDownStairsArea()){
  808. return State.WALK_TO_ORDAN;
  809. } else {
  810. if (atWalkingArea()){
  811. return State.WALKING_TOSHOP;
  812. } else {
  813. if (!isShopOpen() && atOrdan()){
  814. return State.OPEN_SHOP;
  815. } else {
  816. if (isShopOpen() && checkStoreStack()){
  817. return State.BUY_ORES;
  818. } else {
  819. if (!checkStoreStack()){
  820. return State.WORLD_HOP;
  821. }
  822. }
  823. }
  824. }
  825. }
  826. }
  827. }
  828. }
  829. }
  830. }
  831. }
  832. }
  833. return null;
  834. }
  835.  
  836.  
  837. @Override
  838. public void run() {
  839. println("Script has been started");
  840. super.setRandomSolverState(true);
  841. setView();
  842.  
  843. while(true){
  844. if (loggedOut()){
  845. super.setLoginBotState(active);
  846. } else {
  847. while(!loggedOut()){
  848. SCRIPT_STATE = getState();
  849.  
  850. switch(SCRIPT_STATE){
  851. case BUY_ORES:
  852. buy(10);
  853.  
  854. case DEPOSIT_ORES:
  855. Banking.isPinScreenOpen();
  856. depositOre();
  857. break;
  858.  
  859. case OPEN_BANK:
  860. Banking.openBankBooth();
  861. break;
  862.  
  863. case OPEN_SHOP:
  864. openShop();
  865. break;
  866.  
  867. case WALKING_TOBANK:
  868. Walking.setControlClick(false);
  869. walkToBank();
  870. break;
  871.  
  872. case WALKING_TOSHOP:
  873. Walking.setControlClick(true);
  874. walkToShop();
  875. break;
  876.  
  877. case PASSING_FRONT_AREA:
  878. Walking.setControlClick(true);
  879. openHalfDoor();
  880. break;
  881.  
  882. case PASSING_FRONT_AREA_R:
  883. Walking.setControlClick(true);
  884. openFrontDoorR();
  885. break;
  886.  
  887. case PASSING_HALF_AREA:
  888. Walking.setControlClick(true);
  889. openLastDoor();
  890. break;
  891.  
  892. case PASSING_HALF_AREA_R:
  893. Walking.setControlClick(true);
  894. openHalfDoorR();
  895. break;
  896.  
  897. case PASSING_LAST_AREA:
  898. Walking.setControlClick(true);
  899. goDownStairs();
  900. break;
  901.  
  902. case PASSING_LAST_AREA_R:
  903. Walking.setControlClick(true);
  904. openLastDoorR();
  905. break;
  906.  
  907. case WALKING_TO_STAIRS:
  908. Walking.setControlClick(true);
  909. walkToLadderDown();
  910. break;
  911.  
  912. case WALK_TO_ORDAN:
  913. Walking.setControlClick(true);
  914. walkToOrdan();
  915. break;
  916.  
  917. case PASSING_FIRST_SHOP_AREA:
  918. Walking.setControlClick(true);
  919. openFrontDoor();
  920. break;
  921.  
  922. case GOING_UP_STAIRS:
  923. goUpStairs();
  924. break;
  925.  
  926. case WORLD_HOP:
  927. setView();
  928. hopWorld();
  929. break;
  930. }
  931. }
  932. }
  933. sleep(50, 150);
  934. }
  935. }
  936. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement