Advertisement
Guest User

Untitled

a guest
Dec 13th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.31 KB | None | 0 0
  1. package scripts;
  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.Image;
  8. import java.awt.Point;
  9. import java.awt.Rectangle;
  10. import java.awt.RenderingHints;
  11. import java.io.BufferedReader;
  12. import java.io.File;
  13. import java.io.FileNotFoundException;
  14. import java.io.FileWriter;
  15. import java.io.IOException;
  16. import java.io.InputStreamReader;
  17. import java.net.MalformedURLException;
  18. import java.net.URL;
  19. import java.util.Scanner;
  20.  
  21. import javax.imageio.ImageIO;
  22. import javax.swing.WindowConstants;
  23.  
  24. import org.tribot.api.General;
  25. import org.tribot.api.Timing;
  26. import org.tribot.api.input.Mouse;
  27. import org.tribot.api2007.Banking;
  28. import org.tribot.api2007.Game;
  29. import org.tribot.api2007.Inventory;
  30. import org.tribot.api2007.Login;
  31. import org.tribot.api2007.Login.STATE;
  32. import org.tribot.api2007.Objects;
  33. import org.tribot.api2007.Options;
  34. import org.tribot.api2007.PathFinding;
  35. import org.tribot.api2007.Player;
  36. import org.tribot.api2007.Walking;
  37. import org.tribot.api2007.types.RSObject;
  38. import org.tribot.api2007.types.RSTile;
  39. import org.tribot.script.Script;
  40. import org.tribot.script.ScriptManifest;
  41. import org.tribot.script.interfaces.Ending;
  42. import org.tribot.script.interfaces.MouseActions;
  43. import org.tribot.script.interfaces.Painting;
  44. import org.tribot.util.Util;
  45.  
  46. @ScriptManifest(authors = ("Nate"), category = ("Money Making"), name = ("nCabbage Picker v1"))
  47.  
  48. public class CabbagePicker extends Script implements Painting, MouseActions, Ending {
  49.  
  50. private RSTile DEPOSIT_BOX_TILE = new RSTile(3045, 3235),
  51. depositBoxBackupTile = new RSTile(3047,3236),
  52. cabbageTileSF = new RSTile(3052,3282),
  53. cabbageTileEM = new RSTile(3051, 3507),
  54. cabbageBackupTileSF = new RSTile(3054,3292),
  55. cabbageBackupTileEM = new RSTile(3052,3509),
  56. edgeBank = new RSTile(3095, 3494),
  57. prePreCabbageTileEM = new RSTile(3075, 3514),
  58. preCabbageTileEM = new RSTile(3072,3520),
  59. preCabbageTileEM2 = new RSTile(3061,3518),
  60. cabbageTileR = new RSTile(2956,3255),
  61. cabbageBackupTileR = new RSTile(2950, 3255),
  62. cabbageTileSV = new RSTile(3227,3384),
  63. cabbageBackupTileSV = new RSTile(3225,3382),
  64. preCabbageTileSV1 = new RSTile(3212,3385),
  65. preCabbageTileSV2 = new RSTile(3251,3388),
  66. vEastBank1 = new RSTile(3253,3420),
  67. vEastBank2 = new RSTile(3250,3420),
  68. dBank1 = new RSTile(3092,3243),
  69. dBank2 = new RSTile(3094,3243),
  70. preCabbageTileDM1 = new RSTile(3110,3282),
  71. preCabbageTileDM2 = new RSTile(3109,3333),
  72. cabbageTileDM = new RSTile(3087,3360),
  73. cabbageBackupTileDM = new RSTile(3086,3360),
  74. dCenter = new RSTile(3110, 3294),
  75. preDCenter = new RSTile(3112, 3303);
  76. private final int DEPOSIT_BOX_ID = 26254,
  77. CABBAGE_GROUND_ID = 1161,
  78. CABBAGE_ID = 1965,
  79. DRAYNOR_CABBAGE_GROUND_ID = 11494,
  80. DRAYNOR_CABBAGE_ID = 1967;
  81. private int count, current, last, cabbagePrice = getPrice(CABBAGE_ID),
  82. sleepCheck = 0;
  83. private RSObject depositBox, cabbageGround;
  84. private boolean cabbageNearby, GUIcomplete = false, notConnected = false,
  85. justPicked = false, infoOpen = true, showInfo = true, running = true,
  86. invFull, justBanked, reset = false, paintEnabled = true;
  87. private final long startTime = Timing.currentTimeMillis();
  88. private String status = "Initializing", area;
  89. private Font regFont = new Font("Verdana", Font.BOLD, 14);
  90. private final Image img = getImage("http://i.imgur.com/pmXeqI1.png");
  91. private final RenderingHints aa = new
  92. RenderingHints(RenderingHints.KEY_ANTIALIASING,
  93. RenderingHints.VALUE_ANTIALIAS_ON);
  94. private File outputFile;
  95. private Scanner sc;
  96. private Rectangle whereToClick = new Rectangle(120, 340, 40, 20);
  97.  
  98. @Override
  99. public void run() {
  100. runScriptInfo();
  101. runGUI();
  102. checkCabbagePrice();
  103. while (Login.getLoginState() != STATE.INGAME) {
  104. General.sleep(500);
  105. }
  106. General.useAntiBanCompliance(true);
  107. Mouse.setSpeed(General.random(150, 220));
  108. if (area != null)
  109. println("Location: " + area);
  110. if (Player.getPosition().getPlane() != 0)
  111. println("Please start the bot when you are on the base plane (no dungeons or up stairs) of runescape");
  112. else if (area != null && area.equals("South Falador"))
  113. while (running) {
  114. sleep(400);
  115. loopSF();
  116. }
  117. else if (area != null && area.equals("Edgeville Monastery"))
  118. while (running) {
  119. sleep(400);
  120. loopEM();
  121. }
  122. else if (area != null && area.equals("Rimmington"))
  123. while (running) {
  124. sleep(400);
  125. loopR();
  126. }
  127. else if (area != null && area.equals("South Varrock"))
  128. while (running) {
  129. sleep(400);
  130. loopSV();
  131. }
  132. else if (area != null && area.equals("Draynor Manor"))
  133. while (running) {
  134. sleep(400);
  135. loopDM();
  136. }
  137. else
  138. println("Error: No selected location could be found");
  139. }
  140.  
  141. private void loopDM() {
  142. cabbageNearby = checkForCabbagesDM();
  143.  
  144. if (Inventory.isFull()) {
  145. dBank();
  146. justPicked = false;
  147. justBanked = true;
  148. }
  149. else if (!cabbageNearby) {
  150. if (justPicked) {
  151. sleep(500);
  152. }
  153. else {
  154. if (Game.getRunEnergy() >= 20) {
  155. if (Options.setRunOn(true))
  156. status = "Running to cabbages";
  157. }
  158. else
  159. status = "Walking to cabbages";
  160. if (justBanked) {
  161. RSTile[] path1 = Walking.generateStraightPath(preCabbageTileDM1);
  162. Walking.walkPath(path1);
  163. sleep(3000);
  164. PathFinding.aStarWalk(dCenter);
  165. sleep(1000);
  166. }
  167. RSTile[] path2 = Walking.generateStraightPath(preCabbageTileDM2);
  168. Walking.walkPath(path2);
  169. sleep(3000);
  170. RSTile[] path3 = Walking.generateStraightPath(cabbageTileDM);
  171. Walking.walkPath(path3);
  172. while (Player.isMoving())
  173. sleep(50);
  174. }
  175. }
  176. else {
  177. pickCabbagesDM();
  178. }
  179. }
  180.  
  181. private void pickCabbagesDM() {
  182. current = Inventory.getCount(DRAYNOR_CABBAGE_ID);
  183. last = current;
  184. invFull = Inventory.isFull();
  185. justBanked = false;
  186. while (!invFull) {
  187. if (reset){
  188. sleepCheck = 0;
  189. reset = false;
  190. println("Attemping to fix error");
  191. break;
  192. }
  193. RSObject[] cabbages = Objects.findNearest(10,DRAYNOR_CABBAGE_GROUND_ID);
  194. if (cabbages.length > 0 && cabbages != null) {
  195. cabbageGround = cabbages[0];
  196. if (cabbageGround.isClickable()) {
  197. if (cabbageGround.click("Pick")) {
  198. status = "Picking Cabbages";
  199. while (current - last != 1) {
  200. sleep((long) (Math.random() * 100 + 100));
  201. if (sleepCheck > 40) {
  202. reset = true;
  203. println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
  204. break;
  205. }
  206. else
  207. reset = false;
  208. sleepCheck++;
  209. current = Inventory.getCount(DRAYNOR_CABBAGE_ID);
  210. }
  211. sleepCheck = 0;
  212. last = current;
  213. count++;
  214. justPicked = true;
  215. }
  216. }
  217. else {
  218. Walking.blindWalkTo(cabbageBackupTileDM);
  219. sleep(500);
  220. }
  221. }
  222. else if (justPicked) {
  223. status = "Waiting out spawn";
  224. sleep(500);
  225. }
  226. else {
  227. Walking.blindWalkTo(cabbageBackupTileDM);
  228. sleep(500);
  229. }
  230. sleep(100);
  231. invFull = Inventory.isFull();
  232. }
  233. }
  234.  
  235. private boolean checkForCabbagesDM() {
  236. RSObject[] cabbages = Objects.find(15, DRAYNOR_CABBAGE_GROUND_ID);
  237. if (cabbages.length > 0 && cabbages != null)
  238. return true;
  239. else
  240. return false;
  241. }
  242.  
  243. private void dBank() {
  244. if (Banking.isInBank()) {
  245. status = "Banking";
  246. if (Banking.openBank()) {
  247. Banking.depositAll();
  248. Banking.close();
  249. }
  250. }
  251. else {
  252. if (justPicked) {
  253. if (Game.getRunEnergy() >= 20) {
  254. if (Options.setRunOn(true))
  255. status = "Running to bank";
  256. }
  257. else
  258. status = "Walking to bank";
  259. RSTile[] path1 = Walking.generateStraightPath(preCabbageTileDM2);
  260. Walking.walkPath(path1);
  261. sleep(3000);
  262. PathFinding.aStarWalk(preDCenter);
  263. sleep(500);
  264. PathFinding.aStarWalk(dCenter);
  265. sleep(1000);
  266. RSTile[] path2 = Walking.generateStraightPath(preCabbageTileDM1);
  267. Walking.walkPath(path2);
  268. sleep(1000);
  269. PathFinding.aStarWalk(dBank1);
  270. }
  271. PathFinding.aStarWalk(dBank1);
  272. status = "Moving to bank";
  273. sleep(2000);
  274. if (Banking.isInBank()) {
  275. status = "Banking";
  276. if (Banking.openBank()) {
  277. Banking.depositAll();
  278. Banking.close();
  279. }
  280. }
  281. else {
  282. status = "Heading to bank";
  283. Walking.blindWalkTo(dBank2);
  284. }
  285. }
  286. }
  287.  
  288. private void loopSV() {
  289. cabbageNearby = checkForCabbagesSV();
  290.  
  291. if (Inventory.isFull()) {
  292. vBank();
  293. justPicked = false;
  294. justBanked = true;
  295. }
  296. else if (!cabbageNearby) {
  297. if (justPicked) {
  298. sleep(500);
  299. }
  300. else {
  301. if (Game.getRunEnergy() >= 20) {
  302. if (Options.setRunOn(true))
  303. status = "Running to cabbages";
  304. }
  305. else
  306. status = "Walking to cabbages";
  307. if (justBanked)
  308. Walking.blindWalkTo(preCabbageTileSV2);
  309. RSTile[] path1 = Walking.generateStraightPath(preCabbageTileSV1);
  310. Walking.walkPath(path1);
  311. sleep(500);
  312. PathFinding.aStarWalk(cabbageBackupTileSV);
  313. while (Player.isMoving()) {
  314. sleep(50);
  315. }
  316. }
  317. }
  318. else {
  319. pickCabbagesSV();
  320. }
  321. }
  322.  
  323. private boolean checkForCabbagesSV() {
  324. RSObject[] cabbages = Objects.find(10, CABBAGE_GROUND_ID);
  325. if (cabbages.length > 0 && cabbages != null)
  326. return true;
  327. else
  328. return false;
  329. }
  330.  
  331. private void pickCabbagesSV() {
  332. justBanked = false;
  333. current = Inventory.getCount(CABBAGE_ID);
  334. last = current;
  335. int decider;
  336. invFull = Inventory.isFull();
  337. while (!invFull) {
  338. if (reset){
  339. sleepCheck = 0;
  340. reset = false;
  341. println("Attemping to fix error");
  342. break;
  343. }
  344. RSObject[] cabbages = Objects.findNearest(10,CABBAGE_GROUND_ID);
  345. if (cabbages.length > 0 && cabbages != null) {
  346. cabbageGround = cabbages[0];
  347. if (cabbageGround.isClickable()) {
  348. if (cabbageGround.click("Pick")) {
  349. status = "Picking Cabbages";
  350. while (current - last != 1) {
  351. sleep((long) (Math.random() * 100 + 100));
  352. if (sleepCheck > 40) {
  353. reset = true;
  354. println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
  355. break;
  356. }
  357. else
  358. reset = false;
  359. sleepCheck++;
  360. current = Inventory.getCount(CABBAGE_ID);
  361. }
  362. sleepCheck = 0;
  363. last = current;
  364. count++;
  365. justPicked = true;
  366. }
  367. }
  368. else {
  369. decider = (int) (Math.random() * 100);
  370. if (decider >= 50)
  371. Walking.blindWalkTo(cabbageBackupTileSV);
  372. else
  373. Walking.blindWalkTo(cabbageTileSV);
  374. sleep(500);
  375. }
  376. }
  377. else if (justPicked) {
  378. status = "Waiting out spawn";
  379. sleep(500);
  380. }
  381. else {
  382. Walking.blindWalkTo(preCabbageTileSV1);
  383. decider = (int) (Math.random() * 100);
  384. if (decider >= 50)
  385. Walking.blindWalkTo(cabbageBackupTileSV);
  386. else
  387. Walking.blindWalkTo(cabbageTileSV);
  388. sleep(1500);
  389. }
  390. sleep(100);
  391. invFull = Inventory.isFull();
  392. }
  393. }
  394.  
  395. private void vBank() {
  396. if (Banking.isInBank()) {
  397. if (Banking.openBank())
  398. Banking.depositAll();
  399. }
  400. else {
  401. if (justPicked) {
  402. if (Game.getRunEnergy() >= 20) {
  403. if (Options.setRunOn(true))
  404. status = "Running to bank";
  405. }
  406. else
  407. status = "Walking to bank";
  408. Walking.blindWalkTo(preCabbageTileSV1);
  409. sleep(200);
  410. Walking.blindWalkTo(preCabbageTileSV2);
  411. sleep(300);
  412. }
  413. RSTile[] path1 = Walking.generateStraightPath(vEastBank1);
  414. Walking.walkPath(path1);
  415. status = "Heading to bank";
  416. if (Banking.isInBank()) {
  417. if (Banking.openBank())
  418. Banking.depositAll();
  419. }
  420. else
  421. Walking.blindWalkTo(vEastBank2);
  422. }
  423. while (Player.isMoving())
  424. sleep(50);
  425. }
  426.  
  427. @SuppressWarnings("deprecation")
  428. private void loopR() {
  429. cabbageNearby = checkForCabbagesR();
  430.  
  431. if (Inventory.isFull()) {
  432. useDepositBox();
  433. justPicked = false;
  434. }
  435. else if (!cabbageNearby) {
  436. if (justPicked) {
  437. sleep(500);
  438. }
  439. else {
  440. if (Game.getRunEnergy() >= 20) {
  441. if (Options.setRunOn(true))
  442. status = "Running to cabbages";
  443. }
  444. else
  445. status = "Walking to cabbages";
  446. RSTile[] pathR = Walking.generateStraightPath(cabbageTileR);
  447. pathR = Walking.randomizePath(pathR, 3, 3);
  448. Walking.walkPath(pathR);
  449. while (Player.isMoving() || PathFinding.distanceTo(cabbageTileR, false) > 3)
  450. sleep(100);
  451. }
  452. }
  453. else {
  454. pickCabbagesR();
  455. }
  456. }
  457.  
  458. private void pickCabbagesR() {
  459. current = Inventory.getCount(CABBAGE_ID);
  460. last = current;
  461. int decider;
  462. invFull = Inventory.isFull();
  463. while (!invFull) {
  464. if (reset){
  465. sleepCheck = 0;
  466. reset = false;
  467. println("Fixing error");
  468. break;
  469. }
  470. RSObject[] cabbages = Objects.findNearest(15,CABBAGE_GROUND_ID);
  471. if (cabbages.length > 0 && cabbages != null) {
  472. cabbageGround = cabbages[0];
  473. if (cabbageGround.isClickable()) {
  474. if (cabbageGround.click("Pick")) {
  475. status = "Picking Cabbages";
  476. while (current - last != 1) {
  477. sleep((long) (Math.random() * 100 + 100));
  478. if (sleepCheck > 40) {
  479. reset = true;
  480. println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
  481. break;
  482. }
  483. else
  484. reset = false;
  485. sleepCheck++;
  486. current = Inventory.getCount(CABBAGE_ID);
  487. }
  488. last = current;
  489. count++;
  490. justPicked = true;
  491. sleepCheck = 0;
  492. }
  493. else
  494. PathFinding.aStarWalk(cabbageBackupTileR);
  495. }
  496. else {
  497. decider = (int) (Math.random() * 100);
  498. if (decider >= 50)
  499. Walking.blindWalkTo(cabbageBackupTileR);
  500. else
  501. PathFinding.aStarWalk(cabbageTileR);
  502. sleep(500);
  503. }
  504. }
  505. else if (justPicked)
  506. sleep(500);
  507. else {
  508. Walking.blindWalkTo(preCabbageTileEM);
  509. decider = (int) (Math.random() * 100);
  510. if (decider >= 50)
  511. Walking.blindWalkTo(cabbageBackupTileR);
  512. else
  513. Walking.blindWalkTo(cabbageTileR);
  514. sleep(500);
  515. }
  516. sleep(100);
  517. invFull = Inventory.isFull();
  518. }
  519. }
  520.  
  521. private boolean checkForCabbagesR() {
  522. RSObject[] cabbages = Objects.findNearest(10, CABBAGE_GROUND_ID);
  523. if (cabbages.length > 0 && cabbages != null)
  524. if (cabbages[0].isClickable())
  525. return true;
  526. else
  527. return false;
  528. else
  529. return false;
  530. }
  531.  
  532. @SuppressWarnings("deprecation")
  533. private void loopEM() {
  534. cabbageNearby = checkForCabbagesEM();
  535.  
  536. if (Inventory.isFull()) {
  537. emBank();
  538. }
  539. else if (!cabbageNearby) {
  540. if (justPicked) {
  541. sleep(500);
  542. }
  543. else {
  544. if (Game.getRunEnergy() >= 20) {
  545. if (Options.setRunOn(true))
  546. status = "Running to cabbages";
  547. }
  548. else
  549. status = "Walking to cabbages";
  550. Walking.blindWalkTo(prePreCabbageTileEM);
  551. while (PathFinding.distanceTo(prePreCabbageTileEM, false) > 5)
  552. sleep(100);
  553. PathFinding.aStarWalk(preCabbageTileEM2);
  554. Walking.walkPath(Walking.generateStraightPath(cabbageTileEM));
  555. while (Player.isMoving())
  556. sleep(100);
  557.  
  558. }
  559. }
  560. else {
  561. pickCabbagesEM();
  562. }
  563. }
  564.  
  565. private void pickCabbagesEM() {
  566. current = Inventory.getCount(CABBAGE_ID);
  567. last = current;
  568. int decider;
  569. invFull = Inventory.isFull();
  570. while (!invFull) {
  571. if (reset){
  572. sleepCheck = 0;
  573. reset = false;
  574. println("Fixing error");
  575. break;
  576. }
  577. RSObject[] cabbages = Objects.findNearest(50,CABBAGE_GROUND_ID);
  578. if (cabbages.length > 0 && cabbages != null) {
  579. cabbageGround = cabbages[0];
  580. if (cabbageGround.isClickable()) {
  581. if (cabbageGround.click("Pick")) {
  582. status = "Picking Cabbages";
  583. while (current - last != 1) {
  584. sleep((long) (Math.random() * 100 + 100));
  585. if (sleepCheck > 40) {
  586. reset = true;
  587. println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
  588. break;
  589. }
  590. else
  591. reset = false;
  592. current = Inventory.getCount(CABBAGE_ID);
  593. sleepCheck++;
  594. }
  595. last = current;
  596. count++;
  597. justPicked = true;
  598. sleepCheck = 0;
  599. }
  600. }
  601. else if (justPicked) {
  602. status = "Waiting out spawn";
  603. sleep(500);
  604. }
  605. else {
  606. decider = (int) (Math.random() * 100);
  607. if (decider >= 50)
  608. Walking.blindWalkTo(cabbageBackupTileEM);
  609. else
  610. Walking.blindWalkTo(cabbageTileEM);
  611. sleep(500);
  612. }
  613. }
  614. else if (justPicked) {
  615. status = "Waiting out spawn";
  616. sleep(500);
  617. }
  618. else {
  619. Walking.blindWalkTo(preCabbageTileEM);
  620. decider = (int) (Math.random() * 100);
  621. if (decider >= 50)
  622. Walking.blindWalkTo(cabbageBackupTileEM);
  623. else
  624. Walking.blindWalkTo(cabbageTileEM);
  625. sleep(500);
  626. }
  627. sleep(100);
  628. invFull = Inventory.isFull();
  629. }
  630. }
  631.  
  632. private boolean checkForCabbagesEM() {
  633. RSObject[] cabbages = Objects.find(10, CABBAGE_GROUND_ID);
  634. if (cabbages.length > 0 && cabbages != null)
  635. return true;
  636. else
  637. return false;
  638. }
  639.  
  640. @SuppressWarnings("deprecation")
  641. private void emBank() {
  642. if (Banking.isInBank()) {
  643. justPicked = false;
  644. status = "Banking";
  645. if (Banking.openBank())
  646. if (Banking.depositAll() > 0)
  647. Banking.close();;
  648. }
  649. else {
  650. if (justPicked || cabbageNearby) {
  651. justPicked = false;
  652. if (Game.getRunEnergy() >= 20)
  653. if (Options.setRunOn(true))
  654. status = "Running to bank";
  655. status = "Walking to bank";
  656. Walking.blindWalkTo(preCabbageTileEM2);
  657. Walking.blindWalkTo(preCabbageTileEM);
  658. while (PathFinding.distanceTo(preCabbageTileEM, false) > 4)
  659. sleep(50);
  660. }
  661. if (Game.getRunEnergy() >= 20)
  662. if (Options.setRunOn(true))
  663. status = "Running to bank";
  664. status = "Walking to bank";
  665. RSTile[] path2 = Walking.generateStraightPath(edgeBank);
  666. path2 = Walking.randomizePath(path2, 1, 1);
  667. Walking.walkPath(path2);
  668. sleep(400);
  669. if (Banking.isInBank()) {
  670. if (Banking.openBank())
  671. if (Banking.depositAll() > 0)
  672. Banking.close();
  673. }
  674. }
  675. }
  676.  
  677. private void loopSF() {
  678. cabbageNearby = checkForCabbagesSF();
  679.  
  680. if (Inventory.isFull()) {
  681. useDepositBox();
  682. }
  683. else if (!cabbageNearby) {
  684. if (Game.getRunEnergy() >= 20) {
  685. if (Options.setRunOn(true))
  686. status = "Running to cabbages";
  687. }
  688. else
  689. status = "Walking to cabbages";
  690. RSTile[] path = Walking.generateStraightPath(cabbageTileSF);
  691. path = Walking.randomizePath(path, 4, 4);
  692. Walking.walkPath(path);
  693. sleep(500);
  694. }
  695. else {
  696. pickCabbagesSF();
  697. }
  698. }
  699.  
  700. private void pickCabbagesSF() {
  701. current = Inventory.getCount(CABBAGE_ID);
  702. last = current;
  703. invFull = Inventory.isFull();
  704. while (!invFull) {
  705. if (reset){
  706. sleepCheck = 0;
  707. reset = false;
  708. println("Fixing error");
  709. break;
  710. }
  711. RSObject[] cabbages = Objects.findNearest(25,CABBAGE_GROUND_ID);
  712. if (cabbages.length > 0 && cabbages != null) {
  713. cabbageGround = cabbages[0];
  714. if (cabbageGround.isClickable()) {
  715. if (cabbageGround.click("Pick")) {
  716. status = "Picking Cabbages";
  717. while (current - last != 1) {
  718. sleep((long) (Math.random() * 100 + 100));
  719. if (sleepCheck > 40) {
  720. reset = true;
  721. println("Error; bot took no action for unusual amount of time (more than a few seconds unintentionally)");
  722. break;
  723. }
  724. else
  725. reset = false;
  726. sleepCheck++;
  727. current = Inventory.getCount(CABBAGE_ID);
  728. }
  729. sleepCheck = 0;
  730. last = current;
  731. count++;
  732. }
  733. }
  734. else {
  735. PathFinding.aStarWalk(cabbageBackupTileSF);
  736. sleep(500);
  737. }
  738. }
  739. else {
  740. PathFinding.aStarWalk(cabbageBackupTileSF);
  741. sleep(500);
  742. }
  743. sleep(100);
  744. invFull = Inventory.isFull();
  745. }
  746. }
  747.  
  748. private boolean checkForCabbagesSF() {
  749. RSObject[] cabbages = Objects.find(25, CABBAGE_GROUND_ID);
  750. if (cabbages.length > 0 && cabbages != null)
  751. return true;
  752. else
  753. return false;
  754. }
  755.  
  756. private void useDepositBox() {
  757. RSObject[] dBox = Objects.findNearest(7, DEPOSIT_BOX_ID);
  758. if (dBox.length > 0 && dBox != null) {
  759. depositBox = dBox[0];
  760. if (depositBox.isClickable()) {
  761. if (depositBox.click("Deposit")) {
  762. sleep(1000);
  763. status = "Banking Cabbages";
  764. if (Banking.isDepositBoxOpen()) {
  765. Banking.depositAll();
  766. sleep(1000);
  767. if (Inventory.getCount(CABBAGE_ID) > 0 && Banking.isDepositBoxOpen())
  768. Banking.depositAll();
  769. if ((Math.random() * 100) > 70)
  770. Banking.close();
  771. }
  772. }
  773. else
  774. PathFinding.aStarWalk(depositBoxBackupTile);
  775. }
  776. else {
  777. PathFinding.aStarWalk(depositBoxBackupTile);
  778. if (depositBox.isClickable()) {
  779. depositBox.click("Deposit");
  780. Banking.depositAll();
  781. }
  782. }
  783. }
  784. else {
  785. sleep(200);
  786. if (Inventory.isFull()) {
  787. if (Game.getRunEnergy() >= 20) {
  788. if (Options.setRunOn(true))
  789. status = "Running to deposit";
  790. else
  791. status = "Walking to deposit";
  792. }
  793. else
  794. status = "Walking to deposit";
  795. RSTile[] path2 = Walking.generateStraightPath(DEPOSIT_BOX_TILE);
  796. path2 = Walking.randomizePath(path2, 2, 2);
  797. Walking.walkPath(path2);
  798. while (Player.isMoving())
  799. sleep(100);
  800. RSObject[] dBox1 = Objects.findNearest(7, DEPOSIT_BOX_ID);
  801. if (dBox1.length > 0 && dBox1 != null) {
  802. depositBox = dBox1[0];
  803. if (depositBox.isClickable()) {
  804. if (depositBox.click("Deposit")) {
  805. sleep(1000);
  806. status = "Banking Cabbages";
  807. if (Banking.isDepositBoxOpen()) {
  808. Banking.depositAll();
  809. sleep(1000);
  810. if (Inventory.getCount(CABBAGE_ID) > 0 && Banking.isDepositBoxOpen())
  811. Banking.depositAll();
  812. if ((Math.random() * 100) > 70)
  813. Banking.close();
  814. }
  815. }
  816. }
  817. }
  818. }
  819. }
  820. }
  821.  
  822. private void checkCabbagePrice() {
  823. if (!area.equals("Draynor Manor")) {
  824. if (cabbagePrice == -1) {
  825. cabbagePrice = 100;
  826. notConnected = true;
  827. }
  828. if (notConnected) {
  829. println("Could not connect to RSBuddy price guide, will assume cabbages are worth 100gp each");
  830. }
  831. else
  832. println("Connected to RSBuddy price guide, cabbages are worth " + cabbagePrice + "gp each");
  833. }
  834. else
  835. println("Reminder: Draynor Manor cabbages are NOT tradeable");
  836. }
  837.  
  838. private void runScriptInfo() {
  839. File scriptInfo = new File("nCabbagePicker.txt");
  840. try {
  841. sc = new Scanner(scriptInfo);
  842. if (sc.hasNext()) {
  843. if (sc.nextLine().equals("displayInfo=false")) {
  844. showInfo = false;
  845. sc.close();
  846. }
  847. }
  848. } catch (FileNotFoundException e) {
  849. // add action if not found
  850. e.printStackTrace();
  851. }
  852. if (showInfo) {
  853. ScriptInfo info = new ScriptInfo();
  854. info.setSize(350,300);
  855. info.setResizable(false);
  856. info.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
  857. info.setTitle("Information");
  858. info.setVisible(true);
  859. while (infoOpen) {
  860. sleep(1000);
  861. infoOpen = info.getOpen();
  862. }
  863. if (!info.getDisplayInfo()) {
  864. try {
  865. outputFile = new File(Util.getWorkingDirectory() + "\\nCabbagePicker.txt");
  866. outputFile.createNewFile();
  867. FileWriter output = new FileWriter(outputFile);
  868. output.write("displayInfo=false");
  869. output.flush();
  870. output.close();
  871. } catch (IOException e1) {
  872. e1.printStackTrace();
  873. }
  874. }
  875. }
  876. }
  877.  
  878. private void runGUI() {
  879. GUI GUI = new GUI();
  880. GUI.setSize(408,300);
  881. GUI.setResizable(false);
  882. GUI.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
  883. GUI.setTitle("nCabbage Picker GUI");
  884. GUI.setVisible(true);
  885. while (!GUIcomplete) {
  886. sleep(1000);
  887. GUIcomplete = GUI.getGUIcomplete();
  888. }
  889. GUI.setVisible(false);
  890. area = (GUI.getArea());
  891. }
  892.  
  893. public static int getPrice(final int itemId) {
  894. try {
  895. URL url = new URL("https://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + itemId);
  896. try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) {
  897. String line = reader.readLine();
  898. return line == null ? -1 : Integer.parseInt(line.substring(11, line.indexOf(',')));
  899. } catch (IOException e) {
  900. e.printStackTrace();
  901. }
  902. } catch (MalformedURLException e) {
  903. e.printStackTrace();
  904. }
  905. return -1;
  906. }
  907.  
  908. private Image getImage(String url) {
  909. try {
  910. return ImageIO.read(new URL(url));
  911. } catch(IOException e) {
  912. return null;
  913. }
  914. }
  915.  
  916. @Override
  917. public void mouseClicked(Point click, int button, boolean isBot) {
  918. if (!isBot && button == 1 && whereToClick.contains(click)) {
  919. paintEnabled = (!paintEnabled);
  920. }
  921. }
  922.  
  923. @Override
  924. public void mouseDragged(Point arg0, int arg1, boolean arg2) {
  925. {}
  926.  
  927. }
  928.  
  929. @Override
  930. public void mouseMoved(Point mousePos, boolean isBot) {
  931. {}
  932. }
  933.  
  934. @Override
  935. public void mouseReleased(Point arg0, int arg1, boolean arg2) {
  936. {}
  937.  
  938. }
  939.  
  940. @Override
  941. public void onPaint(Graphics g) {
  942. long currentTime = Timing.timeFromMark(startTime);
  943. long gpPerHour = (long)((long)3600000 * count * cabbagePrice)/((long)currentTime);
  944. int gpMade = count*cabbagePrice;
  945. int cabbagesHour = (int) ((long)((long)3600000 * count)/((long)currentTime));
  946. Graphics2D gg = (Graphics2D)g;
  947. gg.setRenderingHints(aa);
  948. Rectangle r = new Rectangle(120, 340, 40, 20);
  949. if (!r.contains(Mouse.getPos())) {
  950. paintEnabled = true;
  951. }
  952. else paintEnabled = false;
  953. if (paintEnabled) {
  954. gg.drawImage(img, 65, 275, null);
  955. gg.setColor(Color.WHITE);
  956. gg.setFont(regFont);
  957. gg.drawString("Cabbages Picked: " + count, 280, 365);
  958. gg.drawString("Status: " + status, 280, 385);
  959. gg.drawString("Time Running: " + Timing.msToString(currentTime), 280, 405);
  960. if (area != null && area.equals("Draynor Manor"))
  961. gg.drawString("Cabbages/Hr: " + cabbagesHour, 280, 425);
  962. else
  963. gg.drawString("Gp/Hr: " + gpPerHour, 280, 425);
  964. if (area != null && !area.equals("Draynor Manor"))
  965. gg.drawString("Total gp: " + gpMade, 280, 445);
  966. }
  967. gg.drawRect(120, 340, 40, 20);
  968. gg.drawString("Hide", 124, 355);
  969. }
  970.  
  971. @Override
  972. public void onEnd() {
  973. println("If you enjoyed the script please leave a review on the official thread on TriBot forums! If you encountered any bugs/issues please leave a response too. Thank you for using nCabbage Picker");
  974.  
  975. }
  976. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement