Thondar

WineGrabber

Jun 24th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.22 KB | None | 0 0
  1. import java.awt.event.*;
  2. import javax.swing.*;
  3. import javax.swing.border.EmptyBorder;
  4.  
  5. import java.awt.BasicStroke;
  6. import java.awt.Color;
  7. import java.awt.Font;
  8. import java.awt.Graphics;
  9. import java.awt.Graphics2D;
  10. import java.awt.Point;
  11. import java.io.BufferedReader;
  12. import java.io.IOException;
  13. import java.io.InputStreamReader;
  14. import java.net.URL;
  15. import java.net.URLConnection;
  16. import java.util.LinkedList;
  17. import java.util.List;
  18. import org.powerbot.concurrent.Task;
  19. import org.powerbot.concurrent.strategy.Condition;
  20. import org.powerbot.concurrent.strategy.Strategy;
  21. import org.powerbot.game.api.ActiveScript;
  22. import org.powerbot.game.api.Manifest;
  23. import org.powerbot.game.api.methods.Calculations;
  24. import org.powerbot.game.api.methods.Game;
  25. import org.powerbot.game.api.methods.Settings;
  26. import org.powerbot.game.api.methods.Tabs;
  27. import org.powerbot.game.api.methods.Walking;
  28. import org.powerbot.game.api.methods.Widgets;
  29. import org.powerbot.game.api.methods.input.Keyboard;
  30. import org.powerbot.game.api.methods.input.Mouse;
  31. import org.powerbot.game.api.methods.interactive.NPCs;
  32. import org.powerbot.game.api.methods.interactive.Players;
  33. import org.powerbot.game.api.methods.node.GroundItems;
  34. import org.powerbot.game.api.methods.node.SceneEntities;
  35. import org.powerbot.game.api.methods.tab.Inventory;
  36. import org.powerbot.game.api.methods.widget.Camera;
  37. import org.powerbot.game.api.util.Filter;
  38. import org.powerbot.game.api.util.Random;
  39. import org.powerbot.game.api.util.Time;
  40. import org.powerbot.game.api.wrappers.Area;
  41. import org.powerbot.game.api.wrappers.Entity;
  42. import org.powerbot.game.api.wrappers.Tile;
  43. import org.powerbot.game.api.wrappers.interactive.NPC;
  44. import org.powerbot.game.api.wrappers.interactive.Player;
  45. import org.powerbot.game.api.wrappers.node.GroundItem;
  46. import org.powerbot.game.api.wrappers.node.Item;
  47. import org.powerbot.game.api.wrappers.node.SceneObject;
  48. import org.powerbot.game.api.wrappers.widget.WidgetChild;
  49. import org.powerbot.game.bot.event.MessageEvent;
  50. import org.powerbot.game.bot.event.listener.MessageListener;
  51. import org.powerbot.game.bot.event.listener.PaintListener;
  52.  
  53. @Manifest(authors = { "beharon, revised by jadedtdt" }, name = "Beharon's Wine Grabber", description = "Makes about 200k-250k gold/hr!. Grabs Wine of Zamorak. WorldHopper||LodeStone||Teleport||Beeper. Version 2.4 ....", version = 2.4)
  54. public class WineGrabber extends ActiveScript implements PaintListener, MessageListener {
  55. // Tiles
  56. Area atBank = new Area(new Tile[] {
  57. new Tile(2942, 3373, 0), new Tile(2942, 3368, 0),
  58. new Tile(2948, 3368, 0), new Tile(2948, 3373, 0)
  59. });
  60. Area atZamorak = new Area(new Tile(2946, 3472, 0), new Tile(2955, 3476, 0));
  61. Area atLodestone = new Area(new Tile[] {
  62. new Tile(2966, 3406, 0), new Tile(2970, 3406, 0),
  63. new Tile(2966, 3402, 0), new Tile(2970, 3402, 0)
  64. });
  65. Area atCentralFalador = new Area(new Tile[] {
  66. new Tile(2960, 3385, 0), new Tile(2960, 3370, 0),
  67. new Tile(2969, 3370, 0), new Tile(2969, 3385, 0)
  68. });
  69. Tile bankTile = new Tile(2945, 3367, 0);
  70. Area zamorakPath = new Area(new Tile[] {
  71. new Tile(2942, 3468, 0), new Tile(2961, 3468, 0),
  72. new Tile(2961, 3392, 0), new Tile(2942, 3394, 0)
  73. });
  74. Tile[] tilesToZamorak = new Tile[] { new Tile(2944, 3370, 0),
  75. new Tile(2945, 3375, 0), new Tile(2950, 3376, 0),
  76. new Tile(2954, 3379, 0), new Tile(2955, 3381, 0),
  77. new Tile(2963, 3384, 0), new Tile(2965, 3389, 0),
  78. new Tile(2965, 3394, 0), new Tile(2963, 3399, 0),
  79. new Tile(2961, 3404, 0), new Tile(2961, 3409, 0),
  80. new Tile(2958, 3413, 0), new Tile(2955, 3417, 0),
  81. new Tile(2953, 3422, 0), new Tile(2951, 3427, 0),
  82. new Tile(2949, 3432, 0), new Tile(2948, 3437, 0),
  83. new Tile(2947, 3442, 0), new Tile(2945, 3449, 0),
  84. new Tile(2945, 3454, 0), new Tile(2948, 3458, 0),
  85. new Tile(2949, 3463, 0), new Tile(2952, 3467, 0),
  86. new Tile(2955, 3471, 0), new Tile(2950, 3474, 0)
  87. };
  88. Tile[] running = new Tile[] {
  89. new Tile(2948, 3462, 0), new Tile(2949, 3460, 0),
  90. new Tile(2948, 3458, 0), new Tile(2949, 3459, 0),
  91. new Tile(2950, 3456, 0), new Tile(2948, 3453, 0),
  92. new Tile(2948, 3450, 0), new Tile(2947, 3448, 0)
  93. };
  94.  
  95. Tile[] tilesToBankLode = new Tile[] {
  96. new Tile(2966, 3394, 0), new Tile(2961, 3384, 0),
  97. new Tile(2956, 3380, 0), new Tile(2951, 3378, 0),
  98. new Tile(2947, 3375, 0), new Tile(2945, 3368, 0)
  99. };
  100. Tile[] tilesToBankTele = new Tile[] {
  101. new Tile(2957, 3381, 0), new Tile(2952, 3378, 0),
  102. new Tile(2947, 3375, 0), new Tile(2946, 3371, 0),
  103. new Tile(2945, 3368, 0)
  104. };
  105.  
  106.  
  107. Tile hover = new Tile(2946, 3473, 0);
  108.  
  109. // CPU Settings
  110. boolean ForcedLow;
  111. int CPULevel;
  112.  
  113. // Widgets
  114. private static WidgetChild TeleGrab;
  115. private static WidgetChild FalaSpell;
  116. private static WidgetChild FalaTele;
  117. private static WidgetChild Close;
  118. private static WidgetChild Lobby;
  119. private static WidgetChild skipEmail;
  120. private static WidgetChild worldSelect;
  121. private static WidgetChild Play;
  122. private static WidgetChild TeleOrder;
  123.  
  124. //GE Prices
  125.  
  126. private int WineP(int id) throws IOException {
  127. URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + 245);
  128. URLConnection con = url.openConnection();
  129. BufferedReader in = new BufferedReader(new InputStreamReader(
  130. con.getInputStream()));
  131. String line = "";
  132. String inputLine;
  133. while ((inputLine = in.readLine()) != null) {
  134. line += inputLine;
  135. }
  136. in.close();
  137. if (!line.contains("mark_price"))
  138. return -1;
  139. line = line.substring(line.indexOf("mark_price\":\"")
  140. + "mark_price\":\"".length());
  141. line = line.substring(0, line.indexOf("\""));
  142. return Integer.parseInt(line.replaceAll(",", ""));
  143. }
  144.  
  145. private int LawP(int id) throws IOException {
  146. URL url = new URL("http://open.tip.it/json/ge_single_item?item=" + 563);
  147. URLConnection con = url.openConnection();
  148. BufferedReader in = new BufferedReader(new InputStreamReader(
  149. con.getInputStream()));
  150. String line = "";
  151. String inputLine;
  152. while ((inputLine = in.readLine()) != null) {
  153. line += inputLine;
  154. }
  155. in.close();
  156. if (!line.contains("mark_price"))
  157. return -1;
  158. line = line.substring(line.indexOf("mark_price\":\"")
  159. + "mark_price\":\"".length());
  160. line = line.substring(0, line.indexOf("\""));
  161. return Integer.parseInt(line.replaceAll(",", ""));
  162. }
  163.  
  164. //GE Prices Ints
  165. int winePrice;
  166. int lawPrice;
  167.  
  168. //GUI Stats
  169. int wineshop = 3;
  170. int winesmax = 15;
  171.  
  172. // Bot Stats
  173. int winesCollected;
  174. int timeRun;
  175. int winesTotalMissed;
  176. int winesMissed;
  177. int lawRunesLeft;
  178. int waterRunesLeft;
  179. int mageXpCounter;
  180. int mageXpGained;
  181. long mageXpHr;
  182.  
  183. // Monitoring
  184. int inventoryTab;
  185. boolean Warning;
  186.  
  187. // Wine of Zamorak Timing
  188. long firstWine;
  189. long secondWine;
  190. long lastWine;
  191. boolean found;
  192.  
  193. // Time Calculations
  194. long startTime;
  195. long elapsedTime;
  196. String time;
  197. long hr, min, sec;
  198. int refreshTime;
  199.  
  200. // GUI
  201. Gui g;
  202. private boolean guiWait = true;
  203. public boolean hop = false;
  204. public boolean beep = false;
  205.  
  206. @Override
  207. protected void setup() {
  208.  
  209. while (Camera.getPitch() < 80) {
  210. Camera.setPitch(true);
  211. Time.sleep(100);
  212. }
  213.  
  214. //GE Prices
  215.  
  216. try {
  217. winePrice = WineP(245);
  218. lawPrice = LawP(563);
  219. } catch (IOException e) {
  220. e.printStackTrace();
  221. }
  222.  
  223. //GE Prices End
  224.  
  225. if (!Tabs.getCurrent().equals(Tabs.MAGIC))
  226. Tabs.MAGIC.open();
  227. Time.sleep(100);
  228. TeleOrder = Widgets.get(192, 18);
  229. TeleOrder.click(true);
  230. Time.sleep(100);
  231.  
  232. if (!Tabs.getCurrent().equals(Tabs.INVENTORY))
  233. Tabs.INVENTORY.open();
  234. Time.sleep(100);
  235.  
  236. lawRunesLeft = Inventory.getCount(true, 563);
  237. waterRunesLeft = Inventory.getCount(true, 555);
  238. inventoryTab = Inventory.getCount(245);
  239. if (lawRunesLeft < 28)
  240. Warning = true;
  241. else
  242. Warning = false;
  243.  
  244. startTime = System.currentTimeMillis();
  245. firstWine = 0;
  246. secondWine = 0;
  247. lastWine = 0;
  248. found = false;
  249. log.info("Script Started. Using Version 2.4");
  250.  
  251. g = new Gui();
  252. g.setVisible(true);
  253. final WaitGui guiTask = new WaitGui();
  254. provide(new Strategy(guiTask, guiTask));
  255. provide(new Strategy(new WaitGui(), new WaitGui()));
  256. provide(new Strategy(new Run(), new Run()));
  257. provide(new Strategy(new GrabZammy(), new GrabZammy()));
  258. provide(new Strategy(new TeleFalador(), new TeleFalador()));
  259. provide(new Strategy(new BankIt(), new BankIt()));
  260. provide(new Strategy(new TraverseZammy(), new TraverseZammy()));
  261. provide(new Strategy(new ToBankLode(), new ToBankLode()));
  262. provide(new Strategy(new ToBankTele(), new ToBankTele()));
  263.  
  264. }
  265.  
  266. private class WaitGui implements Task, Condition {
  267.  
  268. @Override
  269. public void run() {
  270. while (guiWait && isWorking()) {
  271. Time.sleep(500);
  272.  
  273. }
  274. }
  275.  
  276. public boolean validate() {
  277. return guiWait;
  278. }
  279.  
  280. }
  281.  
  282. public void messageReceived(MessageEvent e) {
  283. String txt = e.getMessage().toLowerCase();
  284. if(txt.contains("too late")) {
  285. log.info("A wine was missed.");
  286. if (beep = true) {
  287. System.out.println("\007\007\007");
  288. }
  289. winesTotalMissed++;
  290. winesMissed++;
  291. mageXpCounter++;
  292. }
  293. }
  294.  
  295. private class TraverseZammy implements Task, Condition {
  296.  
  297. public void run() {
  298. System.out.println("Started traverse zammy");
  299. while (!atZamorak.contains(Players.getLocal().getLocation())
  300. && isWorking()) {
  301. Walking.setRun(true);
  302. if (Calculations.distance(new Tile(2950, 3474, 0), Players
  303. .getLocal().getLocation()) < 10) {
  304. Walking.walk(new Tile(2950, 3474, 0));
  305. Time.sleep(2000, 3200);
  306. } else {
  307. walkPath(tilesToZamorak);
  308. Time.sleep(1000);
  309. }
  310. }
  311. }
  312.  
  313. public boolean validate() {
  314. if (!Tabs.getCurrent().equals(Tabs.INVENTORY))
  315. Tabs.INVENTORY.open();
  316. return (atBank.contains(Players.getLocal().getLocation())
  317. && Inventory.getCount() < 28 && lawRunesLeft >= 27)
  318. || zamorakPath.contains(Players.getLocal().getLocation()) &&
  319. !Players.getLocal().isInCombat();
  320. }
  321.  
  322. }
  323.  
  324. private class BankIt implements Task, Condition {
  325.  
  326. @Override
  327. public void run() {
  328. Walking.setRun(false);
  329.  
  330. //Banking
  331. if (Bank.isOpen()) {
  332. Bank.depositAllExcept(563, 555);
  333. lawRunesLeft = Inventory.getCount(true, 563);
  334. inventoryTab = 0;
  335. Time.sleep(1000, 2000);
  336. if (lawRunesLeft < 30) {
  337. if (Bank.withdraw(563, 60)) {
  338. lawRunesLeft += 28;
  339. Warning = true;
  340. } else {
  341. System.out
  342. .println("ran out of bank supply, not enough law runes to complete. closing script");
  343. stop();
  344. }
  345.  
  346. }
  347.  
  348. Bank.close();
  349. } else {
  350. if (!Players.getLocal().equals(bankTile)) {
  351. Walking.walk(bankTile);
  352. Time.sleep(2000, 3000);
  353. }
  354.  
  355. Bank.open();
  356. Time.sleep(1000, 1500);
  357. }
  358. }
  359.  
  360. @Override
  361. public boolean validate() {
  362. if (!Tabs.getCurrent().equals(Tabs.INVENTORY))
  363. Tabs.INVENTORY.open();
  364. return atBank.contains(Players.getLocal().getLocation())
  365. || (Inventory.getCount() == 28 && lawRunesLeft == 0);
  366. }
  367. }
  368.  
  369. public class ToBankLode implements Task, Condition {
  370.  
  371. @Override
  372. public void run() {
  373. System.out.println("Starting banking");
  374. Time.sleep(1000);
  375. SceneObject LodeStone = SceneEntities.getNearest(new Filter<SceneObject>() {
  376.  
  377. public boolean accept(SceneObject entity) {
  378. return entity.getId() == 69835;
  379. }
  380. });
  381. if (LodeStone.isOnScreen()) {
  382. atBank.contains(Players.getLocal().getLocation());
  383. while (!atBank.contains(Players.getLocal().getLocation())) {
  384. walkPath(tilesToBankLode);
  385. Time.sleep(1500, 1800);
  386. }
  387. }else{
  388. log.info("error");
  389. }
  390. }
  391.  
  392. @Override
  393. public boolean validate() {
  394.  
  395. return atLodestone.contains(Players.getLocal().getLocation())
  396. && (Inventory.getCount() == 28);
  397. }
  398.  
  399.  
  400. }
  401. private class ToBankTele implements Task, Condition {
  402.  
  403. @Override
  404. public void run() {
  405. atBank.contains(Players.getLocal().getLocation());
  406. while (!atBank.contains(Players.getLocal().getLocation())) {
  407. walkPath(tilesToBankTele);
  408. Time.sleep(1500, 1800);
  409. }
  410. }
  411.  
  412. @Override
  413. public boolean validate() {
  414. return atCentralFalador.contains(Players.getLocal().getLocation());
  415. }
  416.  
  417. }
  418. private class TeleFalador implements Task, Condition {
  419.  
  420. @Override
  421. public void run() {
  422. Tabs.MAGIC.open();
  423. Time.sleep(1000);
  424.  
  425. if (waterRunesLeft != 0) {
  426. FalaSpell = Widgets.get(192, 46);
  427. FalaSpell.click(true);
  428. log.info("Teleporting to Falador");
  429. Time.sleep(Random.nextInt(3000, 4300));
  430. }else{
  431. FalaTele = Widgets.get(192, 24);
  432. FalaTele.click(true);
  433. Time.sleep(500);
  434. Mouse.move(275, 200);
  435. Mouse.click(true);
  436. Time.sleep(500);
  437. if (Players.getLocal().getAnimation() == -1) {
  438. log.info("Teleporting to LodeStone");
  439. Time.sleep(15000);
  440. }else{
  441. log.info("Didn't click the right LodeStone!");
  442. return;
  443. }
  444. }
  445. }
  446.  
  447. @Override
  448. public boolean validate() {
  449. return atZamorak.contains(Players.getLocal().getLocation())
  450. && (Inventory.getCount() == 28);
  451. }
  452.  
  453.  
  454. }
  455.  
  456. public class Run implements Task, Condition {
  457.  
  458. @Override
  459. public void run() {
  460. Walking.setRun(true);
  461. log.info("ENGAGED IN COMBAT!");
  462. Time.sleep(200);
  463. while (Players.getLocal().isInCombat()) {
  464. walkPath(running);
  465. Time.sleep(200);
  466. }
  467. }
  468.  
  469. @Override
  470. public boolean validate() {
  471. return Players.getLocal().isInCombat();
  472. }
  473.  
  474. }
  475. private class GrabZammy implements Task, Condition {
  476.  
  477. public void run() {
  478. while (!Players.getLocal().getLocation()
  479. .equals(new Tile(2947, 3473, 0))) {
  480. Walking.walk(new Tile(2947, 3472, -1));
  481.  
  482. Time.sleep(4000, 5000);
  483. }
  484. if (lawRunesLeft == 0) {
  485. System.out.println("Ran out of Law Runes");
  486. Time.sleep(10000);
  487. }
  488.  
  489. GrabWine();
  490. lawRunesLeft--;
  491. if (!Tabs.getCurrent().equals(Tabs.INVENTORY))
  492. Tabs.INVENTORY.open();
  493. if (inventoryTab == Inventory.getCount(245)) {
  494. } else {
  495. winesCollected++;
  496. inventoryTab++;
  497. mageXpCounter++;
  498. }
  499.  
  500. if (hop = true) {
  501. WorldHopping();
  502. }
  503. }
  504.  
  505. @Override
  506. public boolean validate() {
  507. if (!Tabs.getCurrent().equals(Tabs.INVENTORY))
  508. Tabs.INVENTORY.open();
  509. return Inventory.getCount() < 28
  510. && atZamorak.contains(Players.getLocal().getLocation())
  511. && lawRunesLeft > 1
  512. && !Players.getLocal().isInCombat();
  513. }
  514. }
  515.  
  516. public void WorldHopping() {
  517. if (hop = true) {
  518. if (winesMissed == wineshop) {
  519. Close = Widgets.get(548, 150);
  520. Close.click(true);
  521. Time.sleep(Random.nextInt(500, 1500));
  522. log.info("Hopping World-Initiated");
  523. Lobby = Widgets.get(182, 2);
  524. Lobby.click(true);
  525. Time.sleep(Random.nextInt(3000, 5000));
  526. skipEmail = Widgets.get(906, 378);
  527. if (skipEmail.isOnScreen()) {
  528. skipEmail.click(true);
  529. }
  530. Time.sleep(Random.nextInt(3000, 5000));
  531. Mouse.move(190, 190);
  532. Mouse.click(true);
  533. Time.sleep(Random.nextInt(700, 1300));
  534. worldSelect = Widgets.get(906, 214);
  535. worldSelect.click(true);
  536. Time.sleep(Random.nextInt(100, 500));
  537. Mouse.move(372, 211);
  538. Mouse.click(true);
  539. Time.sleep(Random.nextInt(500, 1000));
  540. Play = Widgets.get(906, 196);
  541. Play.click(true);
  542. if (Game.isLoggedIn()) {
  543. log.info("Hopping World-Complete");
  544. Time.sleep(1000);
  545. }else{
  546. Time.sleep(1000);
  547. }
  548. winesMissed = 0;
  549. }
  550.  
  551. if (winesTotalMissed >= winesmax) {
  552. log.info("TOO MANY WINES MISSED, LOGGING OUT");
  553. stop();
  554. }
  555. }
  556. }
  557. public void GrabWine() {
  558. Time.sleep(1000);
  559. Tabs.MAGIC.open();
  560. TeleGrab = Widgets.get(192, 44);
  561. Time.sleep(1000);
  562. TeleGrab.click(true);
  563. Time.sleep(500);
  564. MouseMoveToZammy();
  565. determineCompetition();
  566. setRefreshRate();
  567. GroundItem WineOfZamorak = newItem();
  568.  
  569. Mouse.click(tileToScreen(WineOfZamorak.getLocation(), -500), true);
  570. Time.sleep(3000, 4000);
  571. }
  572. private GroundItem newItem() {
  573. GroundItem wine = GroundItems.getNearest(245);
  574. while (wine == null && isWorking()) {
  575.  
  576. wine = GroundItems.getNearest(245);
  577.  
  578. Time.sleep(refreshTime);
  579. }
  580. if (!found) {
  581. firstWine = System.currentTimeMillis();
  582. found = true;
  583. } else {
  584. secondWine = System.currentTimeMillis();
  585. found = false;
  586. }
  587. return wine;
  588.  
  589. }
  590.  
  591. public long findLastTime() {
  592.  
  593. if (firstWine > secondWine) {
  594.  
  595. return lastWine;
  596.  
  597. } else {
  598.  
  599. lastWine = (secondWine - firstWine) / 1000;
  600. return lastWine;
  601. }
  602. }
  603.  
  604. public void MouseMoveToZammy() {
  605. Point a = new Point();
  606. a = tileToScreen(hover, -500);
  607. Mouse.move(a.x, a.y);
  608.  
  609. }
  610.  
  611. public boolean isWorking() {
  612. if (this.isRunning() && !this.isPaused())
  613. return true;
  614. return false;
  615.  
  616. }
  617. int id = 245;
  618. int getPrice(int id) throws IOException {
  619. String price;
  620. URL url = new URL("http://services.runescape.com/m=itemdb_rs/viewitem.ws?obj=" + id);
  621. java.net.URLConnection con = url.openConnection();
  622. BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
  623. String line;
  624. while ((line = in.readLine()) != null) {
  625. if (line.contains("<td>")) {
  626. price = line.substring(line.indexOf(">") + 1, line.indexOf("/") - 1);
  627. price = price.replace(",", "");
  628. try {
  629. return Integer.parseInt(price);
  630. } catch (Exception e) {
  631. return -1;
  632. }
  633. }
  634. }
  635. return -1;
  636. }
  637.  
  638. //START: Code generated using Enfilade's Easel
  639. private final Color color1 = new Color(255, 255, 255);
  640. private final Color color2 = new Color(0, 0, 0);
  641. private final Color color3 = new Color(255, 0, 51);
  642.  
  643. private final BasicStroke stroke1 = new BasicStroke(1);
  644.  
  645. private final Font font1 = new Font("Arial", 0, 20);
  646. private final Font font2 = new Font("Arial", 0, 10);
  647.  
  648. public void onRepaint(Graphics g1) {
  649. int mageXpGained = (mageXpCounter*43);
  650. int lawsUsed = (winesTotalMissed+winesCollected);
  651.  
  652. Graphics2D g = (Graphics2D)g1;
  653. g.setColor(color1);
  654. g.fillRect(2, 272, 514, 63);
  655. g.setColor(color2);
  656. g.setStroke(stroke1);
  657. g.drawRect(2, 272, 514, 63);
  658. g.setFont(font1);
  659. g.drawString("Beharon's Wine Grabber", 7, 292);
  660. g.setFont(font2);
  661. if (ForcedLow) {
  662. g.setColor(color3);
  663. g.drawString("CPU Usage Level: Forced Low Usage", 237, 286);
  664. } else {
  665. g.drawString("CPU Usage Level: Level " + CPULevel, 237, 286);
  666. }
  667. g.setColor(color2);
  668. g.drawString("Wines Grabbed: " + winesCollected, 8, 303);
  669. g.drawString("Wines Missed: " + winesTotalMissed, 11, 320);
  670. g.drawString(timeRun(), 468, 290);
  671. g.drawString("Law Runes Left: " + lawRunesLeft, 104, 303);
  672. g.drawString("Wine Timing: " + findLastTime(), 109, 320);
  673. g.drawString("Magic Exp Gained: " + mageXpGained, 233, 303);
  674. g.drawString("Magic Exp Gained / Hr: " + "soon", 227, 320);
  675. g.drawString("Profit Gained: " + ((winesCollected*winePrice) - (lawsUsed*lawPrice)), 383, 303);
  676. g.drawString("Profit Gained / Hr: " + "soon", 373, 320);
  677. if (Warning) {
  678. g.setColor(color3);
  679. g.drawString("Warning - Running on Bank Supply", 94, 332);
  680. }
  681.  
  682. //END: Code generated using Enfilade's Easel
  683.  
  684. }
  685.  
  686. public String timeRun() {
  687. elapsedTime = System.currentTimeMillis() - startTime;
  688. time = "";
  689. hr = elapsedTime / (1000 * 60 * 60);
  690. min = (elapsedTime % (1000 * 60 * 60)) / (1000 * 60);
  691. sec = ((elapsedTime % (1000 * 60 * 60)) % (1000 * 60)) / 1000;
  692.  
  693. if (hr < 10)
  694. time += "0" + hr + ":";
  695. else
  696. time += hr + ":";
  697.  
  698. if (min < 10)
  699. time += "0" + min + ":";
  700. else
  701. time += min + ":";
  702. if (sec < 10)
  703. time += "0" + sec;
  704. else
  705. time += sec;
  706. return time;
  707. }
  708.  
  709. public void determineCompetition() {
  710. Filter<Player> a = new Filter<Player>() {
  711. public boolean accept(Player test) {
  712. if (test.getName().equals(Players.getLocal().getName()))
  713. return false;
  714. return true;
  715. }
  716. };
  717. if (Players.getNearest(a) == null) {
  718. // no competition
  719. ForcedLow = true;
  720.  
  721. } else {
  722. if (!(Calculations.distance(Players.getNearest(a).getLocation(),
  723. Players.getLocal().getLocation()) < 5)) {
  724. ForcedLow = true;
  725.  
  726. } else
  727. ForcedLow = false;
  728. }
  729. }
  730.  
  731. public void setRefreshRate() {
  732. if (ForcedLow == true)
  733. refreshTime = 200;
  734. else
  735. switch (CPULevel) {
  736. case 1:
  737. refreshTime = 50;
  738. break;
  739. case 2:
  740. refreshTime = 40;
  741. break;
  742. case 3:
  743. refreshTime = 30;
  744. break;
  745. case 4:
  746. refreshTime = 20;
  747. break;
  748. case 5:
  749. refreshTime = 10;
  750. break;
  751. default:
  752. refreshTime = 25;
  753. }
  754. }
  755.  
  756. public Point tileToScreen(Tile tile, double dX, double dY, int height) {
  757.  
  758. return Calculations.groundToScreen(
  759. (int) ((tile.getX() - Game.getBaseX() + dX) * 512.0D),
  760. (int) ((tile.getY() - Game.getBaseY() + dY) * 512.0D), 1,
  761. height);
  762. }
  763.  
  764. public Point tileToScreen(Tile tile, int height) {
  765. return tileToScreen(tile, 0.5D, 0.5D, height);
  766. }
  767.  
  768. private boolean walkPath(final Tile[] path) {
  769. boolean a = false;
  770. final Tile next = getNext(path);
  771. final Tile dest = Walking.getDestination();
  772. final Tile myTile = Players.getLocal().getLocation();
  773. if (dest.getX() == -1 || Calculations.distance(myTile, dest) < 6
  774. || Calculations.distance(next, Walking.getDestination()) > 3) {
  775. if (!Walking.walk(next)) {
  776. if (Walking.walk(path[0])) {
  777. Time.sleep(500);
  778. a = true;
  779. } else {
  780. if (dividePath(path[0]))
  781. Time.sleep(500);
  782. }
  783. } else {
  784. Time.sleep(500);
  785. a = true;
  786. }
  787. }
  788. return a;
  789. }
  790.  
  791. private Tile getNext(final Tile[] tiles) {
  792. for (int i = tiles.length - 1; i >= 0; --i) {
  793. if (Calculations.distance(Players.getLocal().getLocation(),
  794. tiles[i]) < 15 && tiles[i] != Walking.getDestination())
  795. return tiles[i];
  796. }
  797. return null;
  798. }
  799.  
  800. private boolean dividePath(final Tile t) {
  801. final Tile mine = Players.getLocal().getLocation();
  802. final int x = t.getX(), y = t.getY(), z = t.getPlane(), myX = mine
  803. .getX(), myY = mine.getY();
  804. final Tile newT = new Tile((int) (x + myX) / 2, (int) (y + myY) / 2, z);
  805. if (Walking.walk(newT))
  806. return true;
  807. return dividePath(newT);
  808. }
  809.  
  810. public static class Bank {
  811.  
  812. private static final int[] BANKERS = { 44, 45, 494, 495, 496, 497, 498,
  813. 499, 553, 909, 958, 1036, 2271, 2354, 2355, 2718, 2759, 3198,
  814. 3293, 3416, 3418, 3824, 4456, 4457, 4458, 4459, 5488, 5901,
  815. 5912, 6362, 6532, 6533, 6534, 6535, 7605, 8948, 9710, 14367 };
  816. private static final int[] BANK_BOOTHS = { 782, 2213, 2995, 5276, 6084,
  817. 10517, 11402, 11758, 12759, 14367, 19230, 20325, 24914, 11338,
  818. 25808, 26972, 29085, 52589, 34752, 35647, 36786, 2012, 2015,
  819. 2019, 42217, 42377, 42378 };
  820. private static final int[] DEPOSIT_BOXES = { 2045, 9398, 20228, 24995,
  821. 25937, 26969, 32924, 32930, 32931, 34755, 36788, 39830, 45079 };
  822. private static final int[] BANK_CHESTS = { 2693, 4483, 8981, 12308,
  823. 21301, 20607, 21301, 27663, 42192 };
  824. private static final int[] WIDGET_BANK_TAB = { 65, 63, 61, 59, 57, 55,
  825. 53, 51, 49 };
  826.  
  827. private static final int BANK_TOGGLE_REARRANGE_MODE_SETTING = 304;
  828. private static final int BANK_SEARCH_SETTING = 1248;
  829. private static final int BANK_TOGGLE_WITHDRAW_MODE_SETTING = 115;
  830. private static final int WIDGET_BANK = 762;
  831. private static final int WIDGET_BANK_BUTTON_CLOSE = 45;
  832. private static final int WIDGET_BANK_BUTTON_DEPOSIT_EQUIPPED_ITEMS = 38;
  833. private static final int WIDGET_BANK_BUTTON_DEPOSIT_FAMILIAR_INVENTORY = 40;
  834. private static final int WIDGET_BANK_BUTTON_DEPOSIT_INVENTORY_ITEMS = 34;
  835. private static final int WIDGET_BANK_BUTTON_DEPOSIT_MONEY_POUCH = 36;
  836. private static final int WIDGET_BANK_BUTTON_OPEN_EQUIP = 120;
  837. private static final int WIDGET_BANK_BUTTON_SEARCH = 18;
  838. private static final int WIDGET_BANK_BUTTON_SWAP = 16;
  839. private static final int WIDGET_BANK_BUTTON_WITHDRAW_TOGGLE = 19;
  840. private static final int WIDGET_BANK_INVENTORY = 95;
  841. private static final int WIDGET_BANK_SCROLLBAR = 116;
  842. private static final int WIDGET_DEPOSIT_BOX = 11;
  843. private static final int WIDGET_DEPOSIT_BOX_BUTTON_CLOSE = 15;
  844. private static final int WIDGET_DEPOSIT_BOX_INVENTORY = 17;
  845. private static final int WIDGET_DEPOSIT_BUTTON_DEPOSIT_EQUIPPED_ITEMS = 23;
  846. private static final int WIDGET_DEPOSIT_BUTTON_DEPOSIT_FAMILIAR_INVENTORY = 25;
  847. private static final int WIDGET_DEPOSIT_BUTTON_DEPOSIT_INVENTORY_ITEMS = 19;
  848. private static final int WIDGET_DEPOSIT_BUTTON_DEPOSIT_MONEY_POUCH = 21;
  849.  
  850. public static boolean isOpen() {
  851. return Widgets.get(WIDGET_BANK).validate();
  852. }
  853.  
  854. public static boolean isDepositOpen() {
  855. return Widgets.get(WIDGET_DEPOSIT_BOX).validate();
  856. }
  857.  
  858. public static boolean open() {
  859. if (isOpen() || isDepositOpen()) {
  860. return true;
  861. }
  862. final Entity bankEntity = findBankEntity();
  863. if (bankEntity != null) {
  864. if (bankEntity.isOnScreen()) {
  865. if (bankEntity.interact("Bank", "")
  866. || bankEntity.interact("Use")
  867. || bankEntity.interact("Open")
  868. || bankEntity.interact("Deposit")) {
  869. for (int i = 0; i < 10
  870. && (!isOpen() && !isDepositOpen()); i++) {
  871. if (Players.getLocal().isMoving()) {
  872. i = 0;
  873. }
  874. Time.sleep(200);
  875. }
  876. }
  877. }
  878. }
  879. return isOpen() || isDepositOpen();
  880. }
  881.  
  882. public static boolean close() {
  883. if (Widgets.get(WIDGET_BANK, WIDGET_BANK_BUTTON_CLOSE).interact(
  884. "Close")
  885. || Widgets.get(WIDGET_DEPOSIT_BOX,
  886. WIDGET_DEPOSIT_BOX_BUTTON_CLOSE).interact("Close")) {
  887. for (int i = 0; i < 10 && (isDepositOpen() || isOpen()); i++) {
  888. Time.sleep(150);
  889. }
  890. }
  891. return !isOpen() && !isDepositOpen();
  892. }
  893.  
  894. public static boolean withdraw(final int itemID, final int amount) {
  895. if (isOpen()) {
  896. if (amount >= -1) {
  897. final Item item = getItem(itemID);
  898. if (item == null) {
  899. return false;
  900. }
  901. final WidgetChild itemWidget = item.getWidgetChild();
  902. final int count = Inventory.getCount();
  903. Widgets.scroll(itemWidget,
  904. Widgets.get(WIDGET_BANK, WIDGET_BANK_SCROLLBAR));
  905. switch (amount) {
  906. case -1:
  907. itemWidget.interact("Withdraw-All but one",
  908. item.getName());
  909. break;
  910. case 0:
  911. itemWidget.interact("Withdraw-All", item.getName());
  912. break;
  913. case 1:
  914. itemWidget.click(true);
  915. break;
  916. default:
  917. if (!itemWidget.interact("Withdraw-" + amount,
  918. item.getName())) {
  919. if (itemWidget.interact("Withdraw-X",
  920. item.getName())) {
  921. Time.sleep(Random.nextInt(1000, 1300));
  922. Keyboard.sendText(String.valueOf(amount), true);
  923. }
  924. } else
  925.  
  926. break;
  927. }
  928. for (int i = 0; i < 150; i++) {
  929. final int newCount = Inventory.getCount(true);
  930. if (newCount > count || newCount == 28) {
  931. Time.sleep(Random.nextInt(100, 125));
  932. return true;
  933. }
  934. Time.sleep(20);
  935. }
  936. }
  937. }
  938. return false;
  939. }
  940.  
  941. public static boolean withdraw(final String itemName, final int amount) {
  942. return withdraw(nameToID(itemName), amount);
  943. }
  944.  
  945. public static boolean deposit(final int itemID, final int amount) {
  946. if (isOpen() || isDepositOpen()) {
  947. if (isOpen() ? Inventory.getCount() == 0 : getBoxCount() == 0) {
  948. return true;
  949. }
  950. if (amount >= 0) {
  951. final int count = isOpen() ? Inventory.getCount(true,
  952. itemID) : getBoxCount(true, itemID);
  953. final Item item = isOpen() ? getInventoryItem(itemID)
  954. : getBoxItem(itemID);
  955. if (item == null) {
  956. return true;
  957. }
  958. final WidgetChild itemWidget = item.getWidgetChild();
  959. switch (amount) {
  960. case 0:
  961. itemWidget.interact((count > 1 ? "Deposit-All"
  962. : "Deposit"), item.getName());
  963. break;
  964. case 1:
  965. itemWidget.interact("Deposit", item.getName());
  966. break;
  967. default:
  968. if (!itemWidget.interact("Deposit-" + amount,
  969. item.getName())) {
  970. if (itemWidget
  971. .interact("Deposit-X", item.getName())) {
  972. Time.sleep(Random.nextInt(1000, 1300));
  973. Keyboard.sendText(String.valueOf(amount), true);
  974. }
  975. }
  976. break;
  977. }
  978. for (int i = 0; i < 100; i++) {
  979. final int newCount = isOpen() ? Inventory.getCount(
  980. true, itemID) : getBoxCount(true, itemID);
  981. if (newCount < count || newCount == 0) {
  982. Time.sleep(Random.nextInt(100, 125));
  983. return true;
  984. }
  985. Time.sleep(Random.nextInt(10, 15));
  986. }
  987. }
  988. }
  989. return false;
  990. }
  991.  
  992. public static boolean deposit(final String itemName, final int amount) {
  993. return deposit(nameToID(itemName), amount);
  994. }
  995.  
  996. public static boolean depositAllExcept(final int... itemIDs) {
  997. if (isOpen() || isDepositOpen()) {
  998. if (isOpen() ? Inventory.getCount() == 0 : getBoxCount() == 0) {
  999. return true;
  1000. }
  1001. if (isOpen() ? getInventoryCount(false, itemIDs) == 0
  1002. : getBoxCount(false, itemIDs) == 0) {
  1003. return depositAll();
  1004. }
  1005. final Item[] items = isOpen() ? Inventory.getItems()
  1006. : getBoxItems();
  1007. outer: for (final Item item : items) {
  1008. if (item != null && item.getId() != -1) {
  1009. for (final int itemID : itemIDs) {
  1010. if (item.getId() == itemID) {
  1011. continue outer;
  1012. }
  1013. }
  1014. for (int j = 0; j < 5
  1015. && Inventory.getCount(item.getId()) != 0; j++) {
  1016. if (deposit(item.getId(), 0)) {
  1017. Time.sleep(Random.nextInt(75, 125));
  1018. }
  1019. }
  1020. }
  1021. }
  1022. return isOpen() ? getInventoryCount(true)
  1023. - getInventoryCount(true, itemIDs) == 0
  1024. : getBoxCount(true) - getBoxCount(true, itemIDs) == 0;
  1025. }
  1026. return false;
  1027. }
  1028.  
  1029. public static int getBoxCount(final boolean includeStacks,
  1030. final int... itemIDs) {
  1031. int count = 0;
  1032. if (Widgets.get(WIDGET_DEPOSIT_BOX, WIDGET_DEPOSIT_BOX_INVENTORY)
  1033. .validate()) {
  1034. for (final Item item : getBoxItems(itemIDs)) {
  1035. if (item != null) {
  1036. count += includeStacks ? item.getStackSize() : 1;
  1037. }
  1038. }
  1039. }
  1040. return count;
  1041. }
  1042.  
  1043. public static int getBoxCount(final int... itemIDs) {
  1044. return getBoxCount(false, itemIDs);
  1045. }
  1046.  
  1047. public static int getBoxCount(final boolean includeStacks) {
  1048. return getBoxCountExcept(includeStacks, -1);
  1049. }
  1050.  
  1051. public static int getBoxCount() {
  1052. return getBoxCountExcept(false, -1);
  1053. }
  1054.  
  1055. public static int getBoxCountExcept(final boolean includeStacks,
  1056. final int... itemIDs) {
  1057. int count = 0;
  1058. outer: for (final Item item : getBoxItems()) {
  1059. if (item != null) {
  1060. for (final int itemID : itemIDs) {
  1061. if (item.getId() == itemID) {
  1062. continue outer;
  1063. }
  1064. }
  1065. count += includeStacks ? item.getStackSize() : 1;
  1066. }
  1067. }
  1068. return count;
  1069. }
  1070.  
  1071. public static int getBoxCountExcept(final int... itemIDs) {
  1072. return getBoxCountExcept(false, itemIDs);
  1073. }
  1074.  
  1075. public static int getCount(final boolean includeStacks,
  1076. final int... itemIDs) {
  1077. int count = 0;
  1078. for (final Item item : getItems(itemIDs)) {
  1079. if (item != null) {
  1080. count += includeStacks ? item.getStackSize() : 1;
  1081. }
  1082. }
  1083. return count;
  1084. }
  1085.  
  1086. public static int getCount(final int... itemIDs) {
  1087. return getCount(false, itemIDs);
  1088. }
  1089.  
  1090. public static int getCount(final boolean includeStacks) {
  1091. return getCountExcept(includeStacks, -1);
  1092. }
  1093.  
  1094. public static int getCount() {
  1095. return getCountExcept(false, -1);
  1096. }
  1097.  
  1098. public static int getCountExcept(final boolean includeStacks,
  1099. final int... itemIDs) {
  1100. int count = 0;
  1101. outer: for (final Item item : getItems()) {
  1102. if (item != null) {
  1103. for (int itemID : itemIDs) {
  1104. if (item.getId() == itemID) {
  1105. continue outer;
  1106. }
  1107. }
  1108. count += includeStacks ? item.getStackSize() : 1;
  1109. }
  1110. }
  1111. return count;
  1112. }
  1113.  
  1114. public static int getCountExcept(final int... itemIDs) {
  1115. return getCountExcept(false, itemIDs);
  1116. }
  1117.  
  1118. public static Item[] getItems() {
  1119. final List<Item> items = new LinkedList<Item>();
  1120. if (Widgets.get(WIDGET_BANK, WIDGET_BANK_INVENTORY).validate()) {
  1121. for (final WidgetChild item : Widgets.get(WIDGET_BANK,
  1122. WIDGET_BANK_INVENTORY).getChildren()) {
  1123. if (item != null && item.getChildId() != -1) {
  1124. items.add(new Item(item));
  1125. }
  1126. }
  1127. }
  1128. return items.toArray(new Item[items.size()]);
  1129. }
  1130.  
  1131. public static Item[] getItems(final int... itemIDs) {
  1132. final List<Item> items = new LinkedList<Item>();
  1133. for (final Item item : getItems()) {
  1134. for (final int itemID : itemIDs) {
  1135. if (item.getId() == itemID) {
  1136. items.add(item);
  1137. }
  1138. }
  1139. }
  1140. return items.toArray(new Item[items.size()]);
  1141. }
  1142.  
  1143. public static Item getItem(final int itemID) {
  1144. for (final Item item : getItems()) {
  1145. if (item.getId() == itemID) {
  1146. return item;
  1147. }
  1148. }
  1149. return null;
  1150. }
  1151.  
  1152. public static Item getItem(final String itemName) {
  1153. return getItem(nameToID(itemName));
  1154. }
  1155.  
  1156. public static Item[] getBoxItems() {
  1157. final List<Item> items = new LinkedList<Item>();
  1158. if (Widgets.get(WIDGET_DEPOSIT_BOX, WIDGET_DEPOSIT_BOX_INVENTORY)
  1159. .validate()) {
  1160. for (final WidgetChild item : Widgets.get(WIDGET_DEPOSIT_BOX,
  1161. WIDGET_DEPOSIT_BOX_INVENTORY).getChildren()) {
  1162. if (item != null && item.getChildId() != -1) {
  1163. items.add(new Item(item));
  1164. }
  1165. }
  1166. }
  1167. return items.toArray(new Item[items.size()]);
  1168. }
  1169.  
  1170. public static Item[] getBoxItems(final int... itemIDs) {
  1171. final List<Item> items = new LinkedList<Item>();
  1172. for (final Item item : getBoxItems()) {
  1173. for (final int itemID : itemIDs) {
  1174. if (item.getId() == itemID) {
  1175. items.add(item);
  1176. }
  1177. }
  1178. }
  1179. return items.toArray(new Item[items.size()]);
  1180. }
  1181.  
  1182. public static Item getBoxItem(final int itemID) {
  1183. for (final Item item : getBoxItems()) {
  1184. if (item.getId() == itemID) {
  1185. return item;
  1186. }
  1187. }
  1188. return null;
  1189. }
  1190.  
  1191. public static Item getBoxItem(final String itemName) {
  1192. return getBoxItem(nameToID(itemName));
  1193. }
  1194.  
  1195. public static boolean depositAll() {
  1196. return Widgets.get(
  1197. isOpen() ? WIDGET_BANK : WIDGET_DEPOSIT_BOX,
  1198. isOpen() ? WIDGET_BANK_BUTTON_DEPOSIT_INVENTORY_ITEMS
  1199. : WIDGET_DEPOSIT_BUTTON_DEPOSIT_INVENTORY_ITEMS)
  1200. .interact("Deposit carried items");
  1201. }
  1202.  
  1203. public static boolean depositEquipped() {
  1204. return Widgets.get(
  1205. isOpen() ? WIDGET_BANK : WIDGET_DEPOSIT_BOX,
  1206. isOpen() ? WIDGET_BANK_BUTTON_DEPOSIT_EQUIPPED_ITEMS
  1207. : WIDGET_DEPOSIT_BUTTON_DEPOSIT_EQUIPPED_ITEMS)
  1208. .interact("Deposit worn items");
  1209. }
  1210.  
  1211. public static boolean depositFamiliar() {
  1212. return Widgets.get(
  1213. isOpen() ? WIDGET_BANK : WIDGET_DEPOSIT_BOX,
  1214. isOpen() ? WIDGET_BANK_BUTTON_DEPOSIT_FAMILIAR_INVENTORY
  1215. : WIDGET_DEPOSIT_BUTTON_DEPOSIT_FAMILIAR_INVENTORY)
  1216. .interact("Deposit beast of burden inventory");
  1217. }
  1218.  
  1219. public static boolean depositMoneyPouch() {
  1220. return Widgets.get(
  1221. isOpen() ? WIDGET_BANK : WIDGET_DEPOSIT_BOX,
  1222. isOpen() ? WIDGET_BANK_BUTTON_DEPOSIT_MONEY_POUCH
  1223. : WIDGET_DEPOSIT_BUTTON_DEPOSIT_MONEY_POUCH)
  1224. .interact("Deposit money pouch contents");
  1225. }
  1226.  
  1227. public static boolean setWithdrawModeToItem() {
  1228. return (Settings.get(BANK_TOGGLE_WITHDRAW_MODE_SETTING) == 0 || Settings
  1229. .get(BANK_TOGGLE_WITHDRAW_MODE_SETTING) == 1
  1230. && Widgets.get(WIDGET_BANK,
  1231. WIDGET_BANK_BUTTON_WITHDRAW_TOGGLE).interact(
  1232. "Switch to item"));
  1233. }
  1234.  
  1235. public static boolean setWithdrawModeToNote() {
  1236. return (Settings.get(BANK_TOGGLE_WITHDRAW_MODE_SETTING) == 1 || Settings
  1237. .get(BANK_TOGGLE_WITHDRAW_MODE_SETTING) == 0
  1238. && Widgets.get(WIDGET_BANK,
  1239. WIDGET_BANK_BUTTON_WITHDRAW_TOGGLE).interact(
  1240. "Switch to note"));
  1241. }
  1242.  
  1243. public static boolean setRearrangeModeToInsert() {
  1244. return (Settings.get(BANK_TOGGLE_REARRANGE_MODE_SETTING) == 1 || Settings
  1245. .get(BANK_TOGGLE_REARRANGE_MODE_SETTING) != 1
  1246. && Widgets.get(WIDGET_BANK, WIDGET_BANK_BUTTON_SWAP)
  1247. .interact("Switch to insert"));
  1248. }
  1249.  
  1250. public static boolean setRearrangeModeToSwap() {
  1251. return (Settings.get(BANK_TOGGLE_REARRANGE_MODE_SETTING) == 0 || Settings
  1252. .get(BANK_TOGGLE_REARRANGE_MODE_SETTING) == 1
  1253. && Widgets.get(WIDGET_BANK, WIDGET_BANK_BUTTON_SWAP)
  1254. .interact("Switch to swap"));
  1255. }
  1256.  
  1257. public static boolean openEquipment() {
  1258. return Widgets.get(WIDGET_BANK, WIDGET_BANK_BUTTON_OPEN_EQUIP)
  1259. .interact("Show Equipment Stats");
  1260. }
  1261.  
  1262. public static int getCurrentTab() {
  1263. return ((Settings.get(BANK_SEARCH_SETTING) >>> 24) - 136) / 8;
  1264. }
  1265.  
  1266. public static boolean openTab(final int tab) {
  1267. try {
  1268. return Widgets.get(WIDGET_BANK, WIDGET_BANK_TAB[tab - 1])
  1269. .interact("View " + (tab == 1 ? "all" : "tab " + tab));
  1270. } catch (ArrayIndexOutOfBoundsException ignored) {
  1271. }
  1272. return false;
  1273. }
  1274.  
  1275. public static boolean isSearchOpen() {
  1276. return Settings.get(BANK_SEARCH_SETTING) == Integer.MIN_VALUE;
  1277. }
  1278.  
  1279. public static boolean searchItem(final String itemName) {
  1280. if (isSearchOpen()) {
  1281. if (!Widgets.get(WIDGET_BANK, WIDGET_BANK_BUTTON_SEARCH)
  1282. .interact("Search")) {
  1283. return false;
  1284. }
  1285. for (int i = 0; i < 30 && isSearchOpen(); i++) {
  1286. Time.sleep(50);
  1287. }
  1288. Time.sleep(Random.nextInt(130, 285));
  1289. }
  1290. if (Widgets.get(WIDGET_BANK, WIDGET_BANK_BUTTON_SEARCH).interact(
  1291. "Search")) {
  1292. for (int i = 0; i < 30 && !isSearchOpen(); i++) {
  1293. Time.sleep(50);
  1294. }
  1295. if (isSearchOpen()) {
  1296. Time.sleep(Random.nextInt(130, 285));
  1297. Keyboard.sendText(itemName, true);
  1298. Time.sleep(Random.nextInt(500, 800));
  1299. return true;
  1300. }
  1301. }
  1302. return false;
  1303. }
  1304.  
  1305. private static Entity findBankEntity() {
  1306. final SceneObject bankBooth = SceneEntities.getNearest(BANK_BOOTHS);
  1307. final SceneObject bankChest = SceneEntities.getNearest(BANK_CHESTS);
  1308. final SceneObject depositBox = SceneEntities
  1309. .getNearest(DEPOSIT_BOXES);
  1310. final NPC banker = NPCs.getNearest(BANKERS);
  1311. Entity bankEntity = null;
  1312. if (bankBooth != null) {
  1313. if (banker != null) {
  1314. if (Random.nextInt(1, 11) < 7) {
  1315. bankEntity = bankBooth;
  1316. } else {
  1317. bankEntity = banker;
  1318. }
  1319. } else {
  1320. bankEntity = bankBooth;
  1321. }
  1322. } else if (banker != null) {
  1323. bankEntity = banker;
  1324. } else if (bankChest != null) {
  1325. bankEntity = bankChest;
  1326. } else if (depositBox != null) {
  1327. bankEntity = depositBox;
  1328. }
  1329. return bankEntity;
  1330. }
  1331.  
  1332. private static int nameToID(final String itemName) {
  1333. final Item[] items = isOpen() ? getItems() : getBoxItems();
  1334. for (final Item item : items) {
  1335. if (item.getName().toLowerCase().equals(itemName.toLowerCase())) {
  1336. return item.getId();
  1337. }
  1338. if (item.getName().toLowerCase()
  1339. .contains(itemName.toLowerCase())) {
  1340. return item.getId();
  1341. }
  1342. }
  1343. return -1;
  1344. }
  1345.  
  1346. private static Item getInventoryItem(final int itemID) {
  1347. for (final Item item : Inventory.getItems()) {
  1348. if (item.getId() == itemID) {
  1349. return new Item(item.getWidgetChild());
  1350. }
  1351. }
  1352. return null;
  1353. }
  1354.  
  1355. private static int getInventoryCount(final boolean includeStacks) {
  1356. int count = 0;
  1357. for (final Item item : Inventory.getItems()) {
  1358. count += includeStacks ? item.getStackSize() : 1;
  1359. }
  1360. return count;
  1361. }
  1362.  
  1363. private static int getInventoryCount(final boolean includeStacks,
  1364. final int... itemIDs) {
  1365. int count = 0;
  1366. for (final int itemID : itemIDs) {
  1367. count += Inventory.getCount(includeStacks, itemID);
  1368. }
  1369. return count;
  1370. }
  1371. }
  1372.  
  1373. @SuppressWarnings("serial")
  1374. public class Gui extends JFrame {
  1375. private JPanel contentPane;
  1376.  
  1377. /**
  1378. * Create the frame.
  1379. */
  1380. @SuppressWarnings({ "rawtypes", "unchecked" })
  1381. public Gui() {
  1382. super("Beharon's Wine Grabber"); // name the window that it the GUI
  1383. // pops in
  1384.  
  1385. addWindowListener(new WindowAdapter() {
  1386. public void windowClosing(WindowEvent e) {
  1387. }
  1388. });
  1389.  
  1390. final JCheckBox chckbxTomeOfFrost = new JCheckBox("Tome of Frost?");
  1391. final JCheckBox chckbxRunicStaff = new JCheckBox("Runic Staff?");
  1392. final JCheckBox chckbxBeep = new JCheckBox("Using Beeper?");
  1393. final JCheckBox chckbxHopping = new JCheckBox("Hopping?");
  1394. final JCheckBox chckbxStoppingAfterX = new JCheckBox("Stopping after X Misses?");
  1395. final JComboBox comboBox = new JComboBox();
  1396. final JComboBox comboBoxWinesMax = new JComboBox();
  1397. final JComboBox comboBoxWinesHop = new JComboBox();
  1398. final JLabel lblMissesforHop = new JLabel("Misses for Hop:");
  1399. final JLabel lblMaximum = new JLabel("Max Misses:");
  1400.  
  1401. setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  1402. setBounds(100, 100, 450, 300);
  1403. contentPane = new JPanel();
  1404. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  1405. setContentPane(contentPane);
  1406. contentPane.setLayout(null);
  1407.  
  1408. JButton btnStart = new JButton("Start");
  1409. btnStart.addActionListener(new ActionListener() {
  1410. @Override
  1411. public void actionPerformed(ActionEvent e) {
  1412.  
  1413. if (chckbxTomeOfFrost.isSelected()) {
  1414. waterRunesLeft = 1000000;
  1415. log.info("Using Tome of Frost");
  1416. }
  1417.  
  1418. if (chckbxRunicStaff.isSelected()) {
  1419. waterRunesLeft = 1000000;
  1420. lawRunesLeft = 1000000;
  1421. log.info("Using a Runic Staff");
  1422. log.info("Beware: The bot will not know when the charges run out!");
  1423. }
  1424. if (chckbxBeep.isSelected()) {
  1425. beep = false;
  1426. }
  1427.  
  1428. if (chckbxStoppingAfterX.isSelected()) {
  1429. String t = comboBoxWinesMax.getSelectedItem().toString(); {
  1430. if (t.equals("2")) {
  1431. winesmax = 2;
  1432. } else if (t.equals("3")) {
  1433. winesmax = 3;
  1434. } else if (t.equals("4")) {
  1435. winesmax = 4;
  1436. } else if (t.equals("5")) {
  1437. winesmax = 5;
  1438. } else if (t.equals("6")) {
  1439. winesmax = 6;
  1440. } else if (t.equals("7")) {
  1441. winesmax = 7;
  1442. } else if (t.equals("8")) {
  1443. winesmax = 8;
  1444. } else if (t.equals("9")) {
  1445. winesmax = 9;
  1446. } else if (t.equals("10")) {
  1447. winesmax = 10;
  1448. } else if (t.equals("11")) {
  1449. winesmax = 11;
  1450. } else if (t.equals("12")) {
  1451. winesmax = 12;
  1452. } else if (t.equals("13")) {
  1453. winesmax = 13;
  1454. } else if (t.equals("14")) {
  1455. winesmax = 14;
  1456. } else if (t.equals("15")) {
  1457. winesmax = 15;
  1458. } else if (t.equals("18")) {
  1459. winesmax = 18;
  1460. } else if (t.equals("21")) {
  1461. winesmax = 21;
  1462. } else if (t.equals("24")) {
  1463. winesmax = 24;
  1464. } else if (t.equals("27")) {
  1465. winesmax = 27;
  1466. } else if (t.equals("30")) {
  1467. winesmax = 30;
  1468. }
  1469.  
  1470. }
  1471. log.info("Stopping after: " + winesmax + " misses.");
  1472. }else{
  1473. winesmax = 1000000;
  1474. }
  1475.  
  1476. if (chckbxHopping.isSelected()) {
  1477. hop = true;
  1478. log.info("Using hopping method");
  1479.  
  1480. String u = comboBoxWinesHop.getSelectedItem().toString(); {
  1481. if (u.equals("1")) {
  1482. wineshop = 1;
  1483. log.info("Hopping after: " + wineshop + " miss.");
  1484. } else if (u.equals("2")) {
  1485. wineshop = 2;
  1486. log.info("Hopping after: " + wineshop + " misses.");
  1487. } else if (u.equals("3")) {
  1488. wineshop = 3;
  1489. log.info("Hopping after: " + wineshop + " misses.");
  1490. } else if (u.equals("4")) {
  1491. wineshop = 4;
  1492. log.info("Hopping after: " + wineshop + " misses.");
  1493. } else if (u.equals("5")) {
  1494. wineshop = 5;
  1495. log.info("Hopping after: " + wineshop + " misses.");
  1496. }
  1497. }
  1498. }else{
  1499. log.info("Not using hopping method");
  1500. hop = false;
  1501. wineshop = 1000000;
  1502. }
  1503. //THANK YOU GOOGLE386 FOR FIXING COMPILING ERROR! :D
  1504. //Changed from 1.7.0 to 1.6.0 to fix a majority of issues.
  1505. String s = comboBox.getSelectedItem().toString(); {
  1506. if (s.equals("Lowest")) {
  1507. CPULevel = 1;
  1508. } else if (s.equals("Low")) {
  1509. CPULevel = 2;
  1510. } else if (s.equals("Moderate")) {
  1511. CPULevel = 3;
  1512. } else if (s.equals("High")) {
  1513. CPULevel = 4;
  1514. } else if (s.equals("Highest")) {
  1515. CPULevel = 5;
  1516. }
  1517. }
  1518. guiWait = false;
  1519. dispose();
  1520. }
  1521. });
  1522.  
  1523. btnStart.setBounds(177, 189, 89, 23);
  1524. contentPane.add(btnStart);
  1525.  
  1526. comboBox.setModel(new DefaultComboBoxModel(new String[] {"Lowest", "Low", "Moderate", "High", "Highest"}));
  1527. comboBox.setSelectedIndex(2);
  1528. comboBox.setBounds(177, 78, 89, 20);
  1529. contentPane.add(comboBox);
  1530.  
  1531. JLabel lblBeharonsWineGrabber = new JLabel("Beharon's Wine Grabber");
  1532. lblBeharonsWineGrabber.setHorizontalAlignment(SwingConstants.CENTER);
  1533. lblBeharonsWineGrabber.setFont(new Font("Book Antiqua", Font.PLAIN, 14));
  1534. lblBeharonsWineGrabber.setBounds(82, 11, 271, 14);
  1535. contentPane.add(lblBeharonsWineGrabber);
  1536.  
  1537. JLabel lblCpuUsage = new JLabel("CPU Usage:");
  1538. lblCpuUsage.setHorizontalAlignment(SwingConstants.CENTER);
  1539. lblCpuUsage.setBounds(82, 81, 85, 14);
  1540. contentPane.add(lblCpuUsage);
  1541.  
  1542. lblMaximum.setFont(new Font("Stencil", Font.PLAIN, 11));
  1543. lblMaximum.setBounds(57, 161, 97, 14);
  1544. contentPane.add(lblMaximum);
  1545.  
  1546. lblMissesforHop.setVisible(false);
  1547. lblMissesforHop.setFont(new Font("Stencil", Font.PLAIN, 11));
  1548. lblMissesforHop.setBounds(57, 131, 97, 14);
  1549. contentPane.add(lblMissesforHop);
  1550.  
  1551. comboBoxWinesMax.setMaximumRowCount(30);
  1552. comboBoxWinesMax.setModel(new DefaultComboBoxModel(new String[] {"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "18", "21", "24", "27", "30"}));
  1553. comboBoxWinesMax.setSelectedIndex(13);
  1554. comboBoxWinesMax.setBounds(177, 157, 89, 20);
  1555. contentPane.add(comboBoxWinesMax);
  1556.  
  1557. comboBoxWinesHop.setVisible(false);
  1558. comboBoxWinesHop.setMaximumRowCount(5);
  1559. comboBoxWinesHop.setModel(new DefaultComboBoxModel(new String[] {"1", "2", "3", "4", "5"}));
  1560. comboBoxWinesHop.setSelectedIndex(2);
  1561. comboBoxWinesHop.setBounds(177, 127, 89, 20);
  1562. contentPane.add(comboBoxWinesHop);
  1563.  
  1564. chckbxTomeOfFrost.setBounds(82, 47, 97, 23);
  1565. contentPane.add(chckbxTomeOfFrost);
  1566.  
  1567. chckbxBeep.setSelected(true);
  1568. chckbxBeep.setBounds(280, 47, 97, 23);
  1569. contentPane.add(chckbxBeep);
  1570.  
  1571. chckbxRunicStaff.setBounds(177, 47, 97, 23);
  1572. contentPane.add(chckbxRunicStaff);
  1573.  
  1574. chckbxHopping.addActionListener(new ActionListener() {
  1575. public void actionPerformed(ActionEvent arg0) {
  1576. if (chckbxHopping.isSelected()) {
  1577. comboBoxWinesHop.setVisible(true);
  1578. lblMissesforHop.setVisible(true);
  1579. }else{
  1580. comboBoxWinesHop.setVisible(false);
  1581. lblMissesforHop.setVisible(false);
  1582. }
  1583. }
  1584. });
  1585. chckbxHopping.setForeground(Color.RED);
  1586. chckbxHopping.setBounds(177, 105, 97, 23);
  1587. contentPane.add(chckbxHopping);
  1588.  
  1589. chckbxStoppingAfterX.addActionListener(new ActionListener() {
  1590. public void actionPerformed(ActionEvent arg0) {
  1591. if (chckbxStoppingAfterX.isSelected()) {
  1592. comboBoxWinesMax.setVisible(true);
  1593. lblMaximum.setVisible(true);
  1594. }else{
  1595. comboBoxWinesMax.setVisible(false);
  1596. lblMaximum.setVisible(false);
  1597. }
  1598. }
  1599. });
  1600. chckbxStoppingAfterX.setSelected(true);
  1601. chckbxStoppingAfterX.setBounds(280, 105, 148, 23);
  1602. contentPane.add(chckbxStoppingAfterX);
  1603. }
  1604.  
  1605. }
  1606. }
Advertisement
Add Comment
Please, Sign In to add comment