Advertisement
Guest User

Untitled

a guest
Jun 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.21 KB | None | 0 0
  1. /**
  2. *
  3. * @author Frederick
  4. */
  5. import java.awt.Graphics;
  6. import java.awt.Color;
  7.  
  8. import org.rsbot.script.ScriptManifest;
  9. import org.rsbot.event.listeners.PaintListener;
  10. import org.rsbot.script.Script;
  11. import org.rsbot.script.methods.Game;
  12. import org.rsbot.script.methods.Skills;
  13. import org.rsbot.script.wrappers.RSInterface;
  14. import org.rsbot.script.wrappers.RSComponent;
  15. import org.rsbot.script.wrappers.RSGroundItem;
  16. import org.rsbot.script.wrappers.RSObject;
  17. import org.rsbot.script.wrappers.RSTile;
  18. import org.rsbot.script.wrappers.RSNPC;
  19.  
  20. @ScriptManifest(name = "TISolver", authors = {"Fred"}, version = 1.08, description = "Solves the Tutorial Quest for you")
  21. public class TISolver extends Script implements PaintListener {
  22.  
  23. boolean autoCreate = false, usernameTaken = false, passwordDunMatch = false;
  24. String prefix, password, username;
  25. int[] interfaceID;
  26. int suffix = -1;
  27. RSTile referenceTile;
  28. RSObject hole, plank, bag;
  29. RSNPC Vant, Goblin, Vant2, Roddeck;
  30. int[] NPCIDs = {8850, 8862, 8848, 8867};
  31. int[] armoursonfloor = {1117, 1173, 1277};
  32. int accountsCreated = 0;
  33. int height = 1;
  34. long startTime = 0;
  35. long totalTime = 0;
  36. long averageTime = 0;
  37. boolean mining = true;
  38. String blabla = "random stuff";
  39.  
  40. @Override
  41. public boolean onStart() {
  42. env.disableRandom("Login");
  43. env.enableRandom("InterfaceCloser");
  44. TISolverGUI gui = new TISolverGUI();
  45. gui.setVisible(true);
  46. while (gui.isVisible()) {
  47. sleep(500);
  48. }
  49. if (gui.autoCheck.isSelected()) {
  50. autoCreate = true;
  51. prefix = gui.prefixText.getText();
  52. password = gui.passwordText.getText();
  53. }
  54. if (gui.skillCombo.getSelectedItem() == "Woodcutting") {
  55. mining = false;
  56. }
  57. return true;
  58. }
  59.  
  60. @Override
  61. public void onFinish() {
  62. env.enableRandom("LoginBot");
  63. }
  64.  
  65. @Override
  66. public int loop() {
  67. if (!game.isLoggedIn()) {
  68. if (autoCreate) {
  69. startTime = System.currentTimeMillis();
  70. if (interfaceThatContains("Create a Free") == null) {
  71. if (!interfaces.getComponent(596, 85).isValid()) {
  72. return random(250, 300);
  73. }
  74. interfaces.getComponent(596, 85).doClick();
  75. sleep(random(1000, 1500));
  76. }
  77. interfaces.getComponent(673, 81).doClick();
  78. sleep(random(1000, 1500));
  79. do {
  80. if (usernameTaken) {
  81. interfaceThatContains("close").doClick();
  82. int numberOfCharToDelete = (suffix - 1 == -1) ? 0 : ("" + suffix).length();
  83. for (int i = 0; i < numberOfCharToDelete; i++) {
  84. keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  85. sleep(random(200, 300));
  86. keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  87. }
  88. }
  89. username = prefix + ((suffix == -1) ? "" : ("" + suffix));
  90. if (username.length() > 12) {
  91. log("Used up all account names");
  92. stopScript();
  93. return -1;
  94. }
  95. if (usernameTaken) {
  96. keyboard.sendText("" + suffix, false);
  97. } else {
  98. keyboard.sendText(username, false);
  99. }
  100. suffix++;
  101. interfaces.getComponent(673, 65).doClick();
  102. sleep(random(1500, 2000));
  103. while (interfaceThatContains("Please wait...") != null) {
  104. sleep(100);
  105. }
  106. usernameTaken = true;
  107. } while (interfaces.getComponent(673, 84).getBackgroundColor() != 1803);
  108. usernameTaken = false;
  109. do {
  110. if (passwordDunMatch) {
  111. RSComponent temp = interfaces.getComponent(673, 65);
  112. mouse.move(random(temp.getAbsoluteX() + 142, temp.getAbsoluteX() + temp.getWidth()), random(temp.getAbsoluteY(), temp.getAbsoluteY() + temp.getHeight()));
  113. mouse.click(true);
  114. sleep(random(1000, 1500));
  115. int numberOfCharInTextBox = interfaces.getComponent(673, 66).getText().length();
  116. for (int i = 0; i < numberOfCharInTextBox; i++) {
  117. keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  118. sleep(random(200, 300));
  119. keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  120. }
  121. }
  122. sleep(random(1000, 1500));
  123. keyboard.sendText(password, false);
  124. if (passwordDunMatch) {
  125. RSComponent temp = interfaces.getComponent(673, 49);
  126. mouse.move(random(temp.getAbsoluteX() + 142, temp.getAbsoluteX() + temp.getWidth()), random(temp.getAbsoluteY(), temp.getAbsoluteY() + temp.getHeight()));
  127. mouse.click(true);
  128. sleep(random(1000, 1500));
  129. int numberOfCharInTextBox = interfaces.getComponent(673, 50).getText().length();
  130. for (int i = 0; i < numberOfCharInTextBox; i++) {
  131. keyboard.pressKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  132. sleep(random(200, 300));
  133. keyboard.releaseKey((char) java.awt.event.KeyEvent.VK_BACK_SPACE);
  134. }
  135. } else {
  136. interfaces.getComponent(673, 49).doClick();
  137. }
  138. sleep(random(1000, 1500));
  139. keyboard.sendText(password, false);
  140. interfaces.getComponent(673, 28).doClick();
  141. sleep(random(1500, 2000));
  142. passwordDunMatch = true;
  143. } while (interfaceThatContains("Please make sure both passwords match") != null);
  144. passwordDunMatch = false;
  145. while (interfaceThatContains("Please wait...") != null) {
  146. sleep(100);
  147. }
  148. while (interfaceThatContains("Play RuneScape") != null) {
  149. interfaces.getComponent(669, 18).doClick();
  150. sleep(random(1000, 2000));
  151. }
  152. interfaces.getComponent(596, 55).doClick();
  153. sleep(random(1000, 1500));
  154. keyboard.sendText(username, false);
  155. interfaces.getComponent(596, 62).doClick();
  156. sleep(random(1000, 1500));
  157. keyboard.sendText(password, false);
  158. while (interfaceThatContains("Click Here To Play") == null) {
  159. interfaces.getComponent(596, 63).doClick();
  160. sleep(random(2000, 3000));
  161. }
  162. sleep(random(750, 1000));
  163. while (interfaceThatContains("Date of Birth Entry") == null || interfaceThatContains("Click Here To Play") != null) {
  164. interfaces.getComponent(906, 170).doClick();
  165. sleep(random(3000, 4000));
  166. }
  167. interfaces.getComponent(204, 29).doClick();
  168. sleep(random(500, 1000));
  169. interfaces.getComponent(204, 86).getComponent(0).doClick();
  170. sleep(random(500, 1000));
  171. interfaces.getComponent(204, 45).doClick();
  172. sleep(random(500, 1000));
  173. interfaces.getComponent(204, 98).getComponent(0).doClick();
  174. sleep(random(500, 1000));
  175. interfaces.getComponent(204, 61).doClick();
  176. sleep(random(500, 1000));
  177. mouse.move(interfaces.getComponent(204, 111).getComponent(1).getLocation());
  178. sleep(500);
  179. mouse.drag(interfaces.getComponent(204, 111).getComponent(5).getLocation());
  180. sleep(500);
  181. interfaces.getComponent(204, 110).getComponent(2).doClick();
  182. sleep(random(500, 1000));
  183. interfaces.getComponent(204, 18).doClick();
  184. sleep(random(1000, 1500));
  185. while (interfaceThatContains("Select Character") == null) {
  186. interfaces.getComponent(1051, 14).doClick();
  187. sleep(random(2000, 3000));
  188. }
  189. interfaces.getComponent(1028, random(17, 37)).doClick();
  190. sleep(random(500, 1000));
  191. interfaces.getComponent(1028, 94).doClick();
  192. sleep(random(500, 1000));
  193. interfaces.getComponent(1028, 96).doClick();
  194. sleep(random(2000, 3000));
  195. return 100;
  196. } else {
  197. log("Please login first =)");
  198. stopScript();
  199. return -1;
  200. }
  201. }
  202. if (canContinue()) {
  203. clickContinue();
  204. return random(200, 300);
  205. }
  206. if (!interfaces.getComponent(752, 4).getText().contains(blabla)) {
  207. blabla = interfaces.getComponent(752, 4).getText();
  208. mouse.move(random(188, 332), random(444, 453));
  209. mouse.click(true);
  210. return random(750, 1000);
  211. }
  212. if (interfaceThatContains("Controls") != null) {
  213. int key = java.awt.event.KeyEvent.VK_UP;
  214. keyboard.pressKey((char) key);
  215. sleep(random(1000, 1500));
  216. keyboard.releaseKey((char) key);
  217. key = (random(0, 2) == 0) ? java.awt.event.KeyEvent.VK_LEFT : java.awt.event.KeyEvent.VK_RIGHT;
  218. keyboard.pressKey((char) key);
  219. sleep(random(1000, 1500));
  220. keyboard.releaseKey((char) key);
  221. return random(200, 300);
  222. }
  223. if (interfaceThatContains("Rotate the camera using the arrow") != null || interfaceThatContains("Talk to Sir Vant to find out") != null) {
  224. if (interfaceThatContains("Great, you've got the dragon in the right place") != null) {
  225. Vant = npcs.getNearest(NPCIDs[2]);
  226. } else {
  227. Vant = npcs.getNearest(NPCIDs[0]);
  228. }
  229. if (Vant == null) {
  230. return random(200, 300);
  231. }
  232. if (!Vant.isOnScreen()) {
  233. walking.walkTo(Vant.getLocation());
  234. sleepUntilNotMoving();
  235. }
  236. Vant.doAction("Talk");
  237. sleep(random(1000, 2000));
  238. return random(200, 300);
  239. }
  240. if (interfaceThatContains("Right-click on the items on the floor") != null) {
  241. RSGroundItem stuff = groundItems.getNearest(armoursonfloor);
  242. while (stuff != null) {
  243. stuff.doAction("Take");
  244. sleep(random(500, 750));
  245. stuff = groundItems.getNearest(armoursonfloor);
  246. }
  247. return random(200, 300);
  248. }
  249. if (interfaceThatContains("Click on the flashing") != null) {
  250. if (interfaceThatContains("worn items") != null) {
  251. game.openTab(Game.TAB_EQUIPMENT);
  252. } else if (interfaceThatContains("quest journal") != null) {
  253. game.openTab(Game.TAB_QUESTS);
  254. } else if (interfaceThatContains("objectives") != null) {
  255. interfaceThatHasAction("Objectives").doClick();
  256. } else if (interfaceThatContains("stats") != null) {
  257. game.openTab(Game.TAB_STATS);
  258. } else {
  259. game.openTab(Game.TAB_INVENTORY);
  260. }
  261. return random(200, 300);
  262. }
  263. if (interfaceThatContains("Right-click on an item in your inventory") != null) {
  264. while (inventory.getCount(1117) == 1) {
  265. inventory.getItem(1117).doAction("Wear");
  266. sleep(random(500, 750));
  267. }
  268. while (inventory.getCount(1173) == 1) {
  269. inventory.getItem(1173).doAction("Wield");
  270. sleep(random(500, 750));
  271. }
  272. while (inventory.getCount(1277) == 1) {
  273. inventory.getItem(1277).doAction("Wield");
  274. sleep(random(500, 750));
  275. }
  276. return random(200, 300);
  277. }
  278. if (interfaceThatContains("Your worn items screen shows you") != null) {
  279. while ((Goblin = npcs.getNearest(NPCIDs[1])) != null) {
  280. if (Goblin.getAnimation() == 6182) {
  281. break;
  282. }
  283. if (!Goblin.isOnScreen()) {
  284. walking.walkTo(Goblin.getLocation());
  285. sleepUntilNotMoving();
  286. }
  287. if (!getMyPlayer().isInCombat()) {
  288. Goblin.doAction("Attack");
  289. sleep(random(3000, 4000));
  290. }
  291. }
  292. return random(300, 500);
  293. }
  294. if (interfaceThatContains("You'll see that Unstable Foundations is") != null) {
  295. mouse.move(random(564, 664), random(309, 314));
  296. mouse.click(true);
  297. return random(750, 1000);
  298. }
  299. if (interfaceThatContains("Quest journals record") != null) {
  300. interfaces.getComponent(463,75).doClick();
  301. return random(1000,1250);
  302. }
  303. if (interfaceThatContains("Now click on the world map") != null) {
  304. interfaces.getComponent(548, 176).doClick();
  305. sleep(random(300, 500));
  306. interfaces.getComponent(749,17).doClick();
  307. return random(750, 1000);
  308. }
  309. if (interfaceThatContains("Click on the compass") != null) {
  310. while (interfaces.getComponent(755, 0).getComponents().length > 0) {
  311. sleep(100);
  312. }
  313. interfaceThatHasAction("Face North").doClick();
  314. return random(750, 1000);
  315. }
  316. if (interfaceThatContains("Time to get on with the quest") != null) {
  317. if (interfaceThatContains("You'll need to climb over") != null) {
  318. hole = objects.getNearest(45603);
  319. hole.doAction("Climb");
  320. return random(750, 1000);
  321. }
  322. bag = objects.getNearest(45783);
  323. while (inventory.getCount(15277) == 0) {
  324. if (!calc.tileOnScreen(bag.getLocation())) {
  325. walking.walkTo(bag.getLocation());
  326. sleepUntilNotMoving();
  327. }
  328. bag.doAction("Search");
  329. sleep(random(6000, 7000));
  330. }
  331. return random(750, 1000);
  332. }
  333. if (interfaceThatContains("The wall is too high") != null) {
  334. plank = objects.getNearest(45652);
  335. camera.setAltitude(true);
  336. plank.doAction("Take");
  337. return random(1500, 2000);
  338. }
  339. if (interfaceThatContains("Right-click on the plank in your inventory") != null) {
  340. hole = objects.getNearest(45603);
  341. game.openTab(Game.TAB_INVENTORY);
  342. while (inventory.getCount(15276) == 1) {
  343. inventory.getItem(15276).doAction("Use");
  344. sleep(random(750, 1000));
  345. hole.doAction("Use");
  346. sleep(random(2000, 3000));
  347. }
  348. return random(750, 1000);
  349. }
  350. if (interfaceThatContains("The ramp should make it possible for you") != null) {
  351. hole = objects.getNearest(45603);
  352. RSTile currentTile = getMyPlayer().getLocation();
  353. while (getMyPlayer().getLocation().getY() == currentTile.getY()) {
  354. hole.doAction("Climb");
  355. sleep(random(1000, 1500));
  356. while (getMyPlayer().getAnimation() != -1) {
  357. sleep(100);
  358. }
  359. }
  360. return random(2000, 3000);
  361. }
  362. if (objects.getNearest(45795) != null) {
  363. if (calc.distanceTo(objects.getNearest(45795).getLocation()) < 5) {
  364. while (inventory.getCount(15277) == 1) {
  365. inventory.getItem(15277).doAction("Use");
  366. sleep(random(300, 500));
  367. objects.getNearest(45795).doAction("Use");
  368. sleep(random(3000, 5000));
  369. }
  370. return random(200, 300);
  371. }
  372. }
  373. if (interfaceThatContains("Explore the cellar until") != null) {
  374. referenceTile = objects.getNearest(45563).getLocation();
  375. if (calc.distanceTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17)) > 5 && getMyPlayer().getLocation().getY() < referenceTile.getY() + 17) {
  376. walking.walkTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17));
  377. sleepUntilNotMoving();
  378. walking.setRun(true);
  379. walking.walkTo(new RSTile(referenceTile.getX() - 1, referenceTile.getY() + 17));
  380. sleepUntilNotMoving();
  381. }
  382. walking.walkTo(new RSTile(referenceTile.getX() - 15, referenceTile.getY() + 24));
  383. sleepUntilNotMoving();
  384. return random(750, 1000);
  385. }
  386. if (interfaceThatContains("Check the quest journal") != null) {
  387. camera.setAltitude(true);
  388. if (inventory.getCount(590) == 0) {
  389. bag = objects.getNearest(45783);
  390. while (inventory.getCount(590) == 0) {
  391. if (!calc.tileOnScreen(bag.getLocation())) {
  392. walking.walkTo(bag.getLocation());
  393. sleepUntilNotMoving();
  394. }
  395. bag.doAction("Search");
  396. sleep(random(6000, 7000));
  397. }
  398. return random(500, 750);
  399. }
  400. if (inventory.getCount(15278) == 1) {
  401. inventory.getItem(15278).doAction("Rip");
  402. return random(500, 750);
  403. }
  404. if (inventory.getCount(15280) > 0) {
  405. inventory.getItem(15284).doAction("Use");
  406. sleep(random(500, 750));
  407. inventory.getItem(15280).doAction("Use");
  408. return random(500, 750);
  409. }
  410. RSObject Pillar = objects.getNearest(45564);
  411. if (inventory.getCount(15281) == 2) {
  412. inventory.getItem(15281).doAction("Use");
  413. sleep(random(500, 750));
  414. Pillar.doAction("Use");
  415. return random(1000, 1500);
  416. }
  417. if (inventory.getCount(15282) == 1) {
  418. inventory.getItem(15282).doAction("Use");
  419. sleep(random(500, 750));
  420. Pillar.doAction("Use");
  421. return random(1000, 1500);
  422. }
  423. Pillar = objects.getNearest(45565);
  424. if (!calc.tileOnScreen(Pillar.getLocation())) {
  425. walking.walkTo(Pillar.getLocation());
  426. sleepUntilNotMoving();
  427. return random(500, 750);
  428. }
  429. if (inventory.getCount(15281) == 1) {
  430. inventory.getItem(15281).doAction("Use");
  431. sleep(random(500, 750));
  432. Pillar.doAction("Use");
  433. return random(1000, 1500);
  434. }
  435. if (inventory.getCount(15283) == 1) {
  436. inventory.getItem(15283).doAction("Use");
  437. sleep(random(500, 750));
  438. Pillar.doAction("Use");
  439. return random(1000, 1500);
  440. }
  441.  
  442. }
  443. if (interfaceThatContains("give Sir Vant a tinderbox") != null) {
  444. camera.setAltitude(true);
  445. Vant = npcs.getNearest(NPCIDs[2]);
  446. if (Vant == null) {
  447. return random(500, 750);
  448. }
  449. if (!calc.pointOnScreen(Vant.getScreenLocation())) {
  450. walking.walkTo(Vant.getLocation());
  451. sleepUntilNotMoving();
  452. }
  453. while (inventory.getCount(590) > 1) {
  454. inventory.getItem(590).doAction("Use");
  455. sleep(random(500, 750));
  456. if (!Vant.doAction("Use")) {
  457. camera.setAngle(random(0, 360));
  458. }
  459. return random(2000, 3000);
  460. }
  461. }
  462. if (interfaceThatContains("Use your tinderbox on the pillar") != null) {
  463. camera.setAltitude(true);
  464. RSObject Pillar = objects.getNearest(45565);
  465. if (!calc.tileOnScreen(Pillar.getLocation())) {
  466. walking.walkTo(Pillar.getLocation());
  467. sleepUntilNotMoving();
  468. }
  469. inventory.getItem(590).doAction("Use");
  470. sleep(random(500, 750));
  471. Pillar.doAction("Use");
  472. return random(5000, 7000);
  473. }
  474. if (interfaceThatContains("RUN! RUN! RUN!") != null) {
  475. RSObject Pillar = objects.getNearest(45565);
  476. walking.walkTo(new RSTile(Pillar.getLocation().getX() + 7, Pillar.getLocation().getY()));
  477. return random(2000, 3000);
  478. }
  479. if (interfaceThatContains("Congratulations, the dragon's dead!") != null) {
  480. Roddeck = npcs.getNearest(NPCIDs[3]);
  481. Roddeck.doAction("Talk");
  482. return random(1000, 1500);
  483. }
  484. if (interfaceThatContains("Click on the question mark button") != null) {
  485. interfaceThatHasAction("Advisor").doClick();
  486. sleep(random(2000,3000));
  487. interfaces.getComponent(498,12).doClick();
  488. return random(500, 750);
  489. }
  490. if (interfaceThatContains("Sir Vant wants his squire's kit back") != null) {
  491. game.openTab(Game.TAB_EQUIPMENT);
  492. sleep(random(500, 750));
  493. while (equipment.getItem(17).getID() != -1) {
  494. equipment.getItem(17).doAction("Remove");
  495. sleep(random(750, 1000));
  496. }
  497. while (equipment.getItem(20).getID() != -1) {
  498. equipment.getItem(20).doAction("Remove");
  499. sleep(random(750, 1000));
  500. }
  501. while (equipment.getItem(23).getID() != -1) {
  502. equipment.getItem(23).doAction("Remove");
  503. sleep(random(750, 1000));
  504. }
  505. return random(500, 750);
  506. }
  507. if (interfaceThatContains("To give Sir Vant an item") != null) {
  508. game.openTab(Game.TAB_INVENTORY);
  509. sleep(random(500, 750));
  510. Vant = npcs.getNearest(NPCIDs[2]);
  511. if (!Vant.isOnScreen()) {
  512. walking.walkTo(Vant.getLocation());
  513. sleepUntilNotMoving();
  514. }
  515. while (inventory.getCount(590) == 1) {
  516. inventory.getItem(590).doAction("Use");
  517. sleep(random(500, 750));
  518. Vant.doAction("Use");
  519. sleep(random(5000, 6000));
  520. }
  521. return random(500, 750);
  522. }
  523. if (interfaceThatContains("Okay, I'll get on with it") != null) {
  524. interfaceThatContains("Okay, I'll get on with it").doClick();
  525. return random(500, 750);
  526. }
  527. if (interfaceThatContains("I'll mine through the rocks") != null) {
  528. if (mining) {
  529. interfaceThatContains("I'll mine through the rocks").doClick();
  530. } else {
  531. interfaceThatContains("I'll chop through the roots").doClick();
  532. }
  533. return random(500, 750);
  534. }
  535. if (interfaceThatContains("Speak to Roddeck, your advisor, about breaking") != null) {
  536. camera.setAltitude(true);
  537. Roddeck = npcs.getNearest(NPCIDs[3]);
  538. if (!Roddeck.isOnScreen()) {
  539. walking.walkTo(Roddeck.getLocation());
  540. sleepUntilNotMoving();
  541. }
  542. Roddeck.doAction("Talk");
  543. return random(500, 750);
  544. }
  545. if (interfaceThatContains("While you've got a pickaxe") != null) {
  546. RSObject damagedWallRock = objects.getNearest(45595);
  547. if (!calc.tileOnScreen(damagedWallRock.getLocation())) {
  548. walking.walkTo(damagedWallRock.getLocation());
  549. sleepUntilNotMoving();
  550. }
  551. damagedWallRock.doAction("Mine");
  552. sleep(random(5000, 6000));
  553. return random(500, 750);
  554. }
  555. if (interfaceThatContains("While you've got a hatchet") != null) {
  556. RSObject roots = objects.getNearest(45598);
  557. if (!calc.tileOnScreen(roots.getLocation())) {
  558. walking.walkTo(roots.getLocation());
  559. sleepUntilNotMoving();
  560. }
  561. roots.doAction("Chop");
  562. sleep(random(5000, 6000));
  563. return random(500, 750);
  564. }
  565. if (interfaceThatContains("Your current objective is to raise your Mining level") != null) {
  566. camera.setAltitude(true);
  567. RSObject Rocks = objects.getNearest(45580);
  568. if (!calc.tileOnScreen(Rocks.getLocation())) {
  569. walking.walkTo(Rocks.getLocation());
  570. sleepUntilNotMoving();
  571. }
  572. while (skills.getCurrentLevel(Skills.MINING) < 2) {
  573. Rocks.doAction("Mine");
  574. sleep(random(2000, 3000));
  575. while (getMyPlayer().getAnimation() == 6747) {
  576. sleep(100);
  577. }
  578. }
  579. return random(500, 750);
  580. }
  581. if (interfaceThatContains("Your current objective is to raise your Woodcutting level") != null) {
  582. camera.setAltitude(true);
  583. RSObject treeRoots = objects.getTopAt(new RSTile(objects.getNearest(45589).getLocation().getX(), objects.getNearest(45589).getLocation().getY() + 1));
  584. if (!calc.tileOnScreen(treeRoots.getLocation())) {
  585. walking.walkTo(treeRoots.getLocation());
  586. sleepUntilNotMoving();
  587. }
  588. while (skills.getCurrentLevel(Skills.WOODCUTTING) < 2) {
  589. treeRoots.doAction("Chop");
  590. sleep(random(2000, 3000));
  591. while (getMyPlayer().getAnimation() == 879) {
  592. sleep(100);
  593. }
  594. }
  595. return random(500, 750);
  596. }
  597. if (interfaceThatContains("set yourself an objective") != null) {
  598. interfaceThatHasAction("Objectives").doClick();
  599. sleep(random(1000, 1500));
  600. if (mining) {
  601. if (interfaceThatContains("Increase Mining from") == null) {
  602. interfaceThatHasAction("Give random objective").doClick();
  603. }
  604. sleep(random(1000, 1500));
  605. interfaceThatContains("Increase Mining from").doClick();
  606. sleep(random(500, 750));
  607. } else {
  608. if (interfaceThatContains("Increase Woodcutting from") == null) {
  609. interfaceThatHasAction("Give random objective").doClick();
  610. }
  611. sleep(random(1000, 1500));
  612. interfaceThatContains("Increase Woodcutting from").doClick();
  613. sleep(random(500, 750));
  614. }
  615. if (interfaceThatContains("Advisor") == null) {
  616. interfaceThatHasAction("Advisor").doClick();
  617. }
  618. return random(1000, 2000);
  619. }
  620. if (interfaceThatContains("advisor button") != null) {
  621. if (interfaceThatContains("How can I raise my") == null) {
  622. interfaceThatHasAction("Advisor").doClick();
  623. }
  624. sleep(random(1000, 1500));
  625. if (interfaceThatContains("How can I raise my") == null) {
  626. return random(500, 750);
  627. }
  628. interfaceThatContains("How can I raise my").doClick();
  629. return random(500, 750);
  630. }
  631. if (interfaceThatContains("Your Mining level is now high enough") != null) {
  632. RSObject damagedWallRock = objects.getNearest(45595);
  633. if (damagedWallRock != null) {
  634. if (!calc.tileOnScreen(damagedWallRock.getLocation())) {
  635. walking.walkTo(damagedWallRock.getLocation());
  636. sleepUntilNotMoving();
  637. }
  638. damagedWallRock.doAction("Mine");
  639. return random(500, 750);
  640. } else {
  641. damagedWallRock = objects.getNearest(45597);
  642. if (damagedWallRock == null) {
  643. return random(200, 300);
  644. }
  645. damagedWallRock.doAction("Climb");
  646. sleep(random(750, 1000));
  647. while (getMyPlayer().getAnimation() == 12280 || getMyPlayer().isMoving()) {
  648. sleep(100);
  649. }
  650. return random(500, 750);
  651. }
  652. }
  653. if (interfaceThatContains("Your Woodcutting level is now high enough") != null) {
  654. RSObject root = objects.getNearest(45598);
  655. if (root != null) {
  656. if (!calc.tileOnScreen(root.getLocation())) {
  657. walking.walkTo(root.getLocation());
  658. sleepUntilNotMoving();
  659. }
  660. root.doAction("Chop");
  661. return random(500, 750);
  662. } else {
  663. root = objects.getNearest(45600);
  664. if (root == null) {
  665. return random(200, 300);
  666. }
  667. root.doAction("Climb");
  668. sleep(random(750, 1000));
  669. while (getMyPlayer().isMoving()) {
  670. sleep(100);
  671. }
  672. return random(500, 750);
  673. }
  674. }
  675. if (interfaceThatContains("Escape up the ladder to freedom!") != null) {
  676. game.openTab(Game.TAB_INVENTORY);
  677. while (inventory.contains(15286)) {
  678. inventory.getItem(15286).doAction("Drop");
  679. sleep(random(500, 750));
  680. clickContinue();
  681. }
  682. while (inventory.contains(15285)) {
  683. inventory.getItem(15285).doAction("Drop");
  684. sleep(random(500, 750));
  685. clickContinue();
  686. }
  687. RSObject ladder = objects.getNearest(45784);
  688. if (ladder == null) {
  689. return random(250, 300);
  690. }
  691. interfaceThatHasAction("Face North").doClick();
  692. if (calc.distanceTo(ladder.getLocation()) > 3) {
  693. walking.walkTo(ladder.getLocation());
  694. sleepUntilNotMoving();
  695. }
  696. while (interfaceThatContains("Thank you again") == null) {
  697. ladder = objects.getNearest(45784);
  698. if (ladder == null) {
  699. break;
  700. }
  701. ladder.doAction("Climb");
  702. }
  703. return random(500, 750);
  704. }
  705. if (interfaceThatContains("You're out!") != null) {
  706. Vant = npcs.getNearest(NPCIDs[2]);
  707. if (Vant == null) {
  708. mouse.move(random(188, 332), random(444, 453));
  709. mouse.click(true);
  710. return random(500, 750);
  711. }
  712. if (Vant.isMoving()) {
  713. mouse.move(random(188, 332), random(444, 453));
  714. mouse.click(true);
  715. return random(500, 750);
  716. }
  717. walking.walkTo(Vant.getLocation());
  718. camera.setAltitude(true);
  719. sleepUntilNotMoving();
  720. if (!calc.pointOnScreen(Vant.getScreenLocation())) {
  721. walking.walkTo(Vant.getLocation());
  722. sleepUntilNotMoving();
  723. }
  724. Vant.doAction("Talk");
  725. return random(500, 750);
  726. }
  727. if (interfaceThatContains("Roddeck would like to offer you some") != null) {
  728. camera.setAltitude(true);
  729. Roddeck = npcs.getNearest(NPCIDs[3]);
  730. if (!Roddeck.isOnScreen()) {
  731. walking.walkTo(Roddeck.getLocation());
  732. sleepUntilNotMoving();
  733. }
  734. Roddeck.doAction("Talk");
  735. return random(500, 750);
  736. }
  737. if (interfaceThatContains("You may now leave via the door") != null) {
  738. interfaceThatHasAction("Face North").doClick();
  739. RSObject door = objects.getNearest(45801);
  740. if (door == null) {
  741. return random(200, 300);
  742. }
  743. door.doAction("Open");
  744. return random(500, 750);
  745. }
  746. if (calc.distanceTo(new RSTile(3204, 3246)) < 8) {
  747. if (!autoCreate) {
  748. log("Tutorial Finished! =)");
  749. game.logout(false);
  750. stopScript();
  751. } else {
  752. java.io.BufferedWriter out;
  753. java.io.FileWriter fstream;
  754. java.io.File accounts = new java.io.File("Accounts.txt");
  755. if (accounts.exists()) {
  756. try {
  757. fstream = new java.io.FileWriter("Accounts.txt", true);
  758. out = new java.io.BufferedWriter(fstream);
  759. out.newLine();
  760. out.write(username);
  761. out.close();
  762. } catch (java.io.IOException e) {
  763. }
  764. } else {
  765. try {
  766. fstream = new java.io.FileWriter("Accounts.txt", false);
  767. out = new java.io.BufferedWriter(fstream);
  768. out.write(username);
  769. out.close();
  770. } catch (java.io.IOException e) {
  771. }
  772. }
  773. log("Account " + username + " has been saved");
  774. accountsCreated++;
  775. totalTime += System.currentTimeMillis() - startTime;
  776. averageTime = totalTime / accountsCreated;
  777. game.logout(true);
  778. while (game.isLoggedIn()) {
  779. sleep(10);
  780. }
  781. return random(2000, 3000);
  782. }
  783. }
  784. return random(200, 300);
  785. }
  786.  
  787. public void onRepaint(Graphics g) {
  788. final int x = 515 - 230;
  789. int y = 4;
  790. long timeToDisplay = averageTime;
  791. long minutes = timeToDisplay / 1000 / 60;
  792. timeToDisplay -= minutes * 1000 * 60;
  793. long seconds = timeToDisplay / 1000;
  794. g.setColor(new Color(0, 0, 0, 150));
  795. g.fillRoundRect(x, y, 230, height, 15, 15);
  796. g.setColor(new Color(0, 255, 0, 255));
  797. g.drawRoundRect(x, y, 230, height, 20, 15);
  798. g.drawString("TISolver v" + getVersion(), x + 76, y += 15);
  799. if (autoCreate) {
  800. g.drawString("Accounts Created: " + accountsCreated, x + 60, y += 15);
  801. if (accountsCreated > 0) {
  802. g.drawString("Average Time per Account: " + minutes + "min" + seconds + "sec", x + 10, y += 15);
  803. }
  804. }
  805. height = y + 3;
  806. }
  807.  
  808. public String getVersion() {
  809. return "" + getClass().getAnnotation(ScriptManifest.class).version();
  810. }
  811.  
  812. public RSComponent interfaceThatContains(String str) {
  813. for (RSInterface i : interfaces.getAll()) {
  814. if (i.isValid()) {
  815. for (RSComponent children : i.getComponents()) {
  816. if (children.isValid()) {
  817. if (children.getComponents().length > 0) {
  818. for (RSComponent component : children.getComponents()) {
  819. if (component.isValid()) {
  820. if (component.containsText(str)) {
  821. return component;
  822. }
  823. }
  824. }
  825. } else {
  826. if (children.containsText(str)) {
  827. return children;
  828. }
  829. }
  830. }
  831. }
  832. }
  833. }
  834. return null;
  835. }
  836.  
  837. public RSComponent interfaceThatHasAction(String str) {
  838. for (RSInterface i : interfaces.getAll()) {
  839. if (i.isValid()) {
  840. for (RSComponent child : i.getComponents()) {
  841. if (child.isValid()) {
  842. if (child.getActions() != null) {
  843. for (String s : child.getActions()) {
  844. if (s != null && s.contains(str)) {
  845. return child;
  846. }
  847. }
  848. }
  849. if (child.getComponents().length > 0) {
  850. for (RSComponent component : child.getComponents()) {
  851. if (component.isValid() && component.getActions() != null) {
  852. for (String s : component.getActions()) {
  853. if (s != null && s.contains(str)) {
  854. return component;
  855. }
  856. }
  857. }
  858. }
  859. }
  860. }
  861. }
  862. }
  863. }
  864. return null;
  865. }
  866.  
  867. public void sleepUntilNotMoving() {
  868. sleep(random(700, 1000));
  869. while (getMyPlayer().isMoving()) {
  870. sleep(random(25, 100));
  871. }
  872. }
  873.  
  874. public RSComponent getContinueChildInterface() {
  875. RSInterface[] valid = interfaces.getAll();
  876. for (RSInterface iface : valid) {
  877. if (iface.getIndex() != 137 && iface.getIndex() != 752) {
  878. int len = iface.getChildCount();
  879. for (int i = 0; i < len; i++) {
  880. RSComponent child = iface.getComponent(i);
  881. if (child.containsText("Click here to continue") && child.getWidth() > 30 && child.getAbsoluteY() > 337) {
  882. return child;
  883. }
  884. }
  885. }
  886. }
  887. return null;
  888. }
  889.  
  890. public boolean canContinue() {
  891. return getContinueChildInterface() != null;
  892. }
  893.  
  894. public boolean clickContinue() {
  895. RSComponent cont = getContinueChildInterface();
  896. return !(cont != null && cont.isValid()) || cont.doClick();
  897. }
  898.  
  899. public class TISolverGUI extends javax.swing.JFrame {
  900.  
  901. /** Creates new form TISolverGUI */
  902. public TISolverGUI() {
  903. initComponents();
  904. setLocationRelativeTo(getOwner());
  905. }
  906.  
  907. /** This method is called from within the constructor to
  908. * initialize the form.
  909. * WARNING: Do NOT modify this code. The content of this method is
  910. * always regenerated by the Form Editor.
  911. */
  912. @SuppressWarnings("unchecked")
  913. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  914. private void initComponents() {
  915.  
  916. autoCheck = new javax.swing.JCheckBox();
  917. jLabel1 = new javax.swing.JLabel();
  918. prefixText = new javax.swing.JTextField();
  919. jLabel2 = new javax.swing.JLabel();
  920. passwordText = new javax.swing.JTextField();
  921. jLabel3 = new javax.swing.JLabel();
  922. skillCombo = new javax.swing.JComboBox();
  923. jButton1 = new javax.swing.JButton();
  924.  
  925. setTitle("Settings");
  926. addWindowListener(new java.awt.event.WindowAdapter() {
  927. public void windowClosing(java.awt.event.WindowEvent evt) {
  928. formWindowClosing(evt);
  929. }
  930. });
  931.  
  932. autoCheck.setText("Auto-Create Account");
  933. autoCheck.addActionListener(new java.awt.event.ActionListener() {
  934. public void actionPerformed(java.awt.event.ActionEvent evt) {
  935. autoCheckActionPerformed(evt);
  936. }
  937. });
  938.  
  939. jLabel1.setText("Prefix:");
  940.  
  941. prefixText.setEditable(false);
  942.  
  943. jLabel2.setText("Password:");
  944.  
  945. passwordText.setEditable(false);
  946.  
  947. jLabel3.setText("Train Skill:");
  948.  
  949. skillCombo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Mining", "Woodcutting" }));
  950.  
  951. jButton1.setText("OK");
  952. jButton1.addActionListener(new java.awt.event.ActionListener() {
  953. public void actionPerformed(java.awt.event.ActionEvent evt) {
  954. jButton1ActionPerformed(evt);
  955. }
  956. });
  957.  
  958. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  959. getContentPane().setLayout(layout);
  960. layout.setHorizontalGroup(
  961. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  962. .addGroup(layout.createSequentialGroup()
  963. .addContainerGap()
  964. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  965. .addComponent(jButton1)
  966. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  967. .addComponent(autoCheck)
  968. .addGroup(layout.createSequentialGroup()
  969. .addGap(21, 21, 21)
  970. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  971. .addComponent(jLabel2)
  972. .addComponent(jLabel1))
  973. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  974. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  975. .addComponent(prefixText)
  976. .addComponent(passwordText, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)))
  977. .addGroup(layout.createSequentialGroup()
  978. .addComponent(jLabel3)
  979. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  980. .addComponent(skillCombo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
  981. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  982. );
  983. layout.setVerticalGroup(
  984. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  985. .addGroup(layout.createSequentialGroup()
  986. .addContainerGap()
  987. .addComponent(autoCheck)
  988. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  989. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  990. .addComponent(jLabel1)
  991. .addComponent(prefixText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  992. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  993. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  994. .addComponent(jLabel2)
  995. .addComponent(passwordText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  996. .addGap(18, 18, 18)
  997. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  998. .addComponent(jLabel3)
  999. .addComponent(skillCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  1000. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  1001. .addComponent(jButton1)
  1002. .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  1003. );
  1004.  
  1005. pack();
  1006. }// </editor-fold>
  1007.  
  1008. private void autoCheckActionPerformed(java.awt.event.ActionEvent evt) {
  1009. if (autoCheck.isSelected()) {
  1010. prefixText.setEditable(true);
  1011. passwordText.setEditable(true);
  1012. } else {
  1013. prefixText.setEditable(false);
  1014. passwordText.setEditable(false);
  1015. }
  1016. }
  1017.  
  1018. private void formWindowClosing(java.awt.event.WindowEvent evt) {
  1019. stopScript();
  1020. }
  1021.  
  1022. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  1023. setVisible(false);
  1024. }
  1025. // Variables declaration - do not modify
  1026. public javax.swing.JCheckBox autoCheck;
  1027. private javax.swing.JButton jButton1;
  1028. private javax.swing.JLabel jLabel1;
  1029. private javax.swing.JLabel jLabel2;
  1030. private javax.swing.JLabel jLabel3;
  1031. private javax.swing.JTextField passwordText;
  1032. public javax.swing.JTextField prefixText;
  1033. public javax.swing.JComboBox skillCombo;
  1034. // End of variables declaration
  1035. }
  1036. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement