Guest User

Untitled

a guest
Jan 21st, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.27 KB | None | 0 0
  1. import java.awt.Graphics;
  2. import java.awt.Point;
  3. import java.awt.Polygon;
  4. import java.awt.Shape;
  5. import java.awt.event.KeyEvent;
  6. import java.awt.*;
  7.  
  8.  
  9. import javax.print.DocFlavor.STRING;
  10.  
  11.  
  12. import com.rsbuddy.event.listeners.PaintListener;
  13. import com.rsbuddy.script.ActiveScript;
  14. import com.rsbuddy.script.Manifest;
  15. import com.rsbuddy.script.methods.Bank;
  16. import com.rsbuddy.script.methods.Calculations;
  17. import com.rsbuddy.script.methods.Camera;
  18. import com.rsbuddy.script.methods.Equipment;
  19. import com.rsbuddy.script.methods.Game;
  20. import com.rsbuddy.script.methods.Inventory;
  21. import com.rsbuddy.script.methods.Keyboard;
  22. import com.rsbuddy.script.methods.Menu;
  23. import com.rsbuddy.script.methods.Mouse;
  24. import com.rsbuddy.script.methods.Npcs;
  25. import com.rsbuddy.script.methods.Objects;
  26. import com.rsbuddy.script.methods.Players;
  27. import com.rsbuddy.script.methods.Skills;
  28. import com.rsbuddy.script.methods.Walking;
  29. import com.rsbuddy.script.methods.Widgets;
  30. import com.rsbuddy.script.task.LoopTask;
  31. import com.rsbuddy.script.util.Filter;
  32. import com.rsbuddy.script.util.Random;
  33. import com.rsbuddy.script.util.Timer;
  34. import com.rsbuddy.script.wrappers.Area;
  35. import com.rsbuddy.script.wrappers.GameObject;
  36. import com.rsbuddy.script.wrappers.Model;
  37. import com.rsbuddy.script.wrappers.Npc;
  38. import com.rsbuddy.script.wrappers.Path;
  39. import com.rsbuddy.script.wrappers.Tile;
  40. import com.rsbuddy.script.task.LoopTask;
  41.  
  42. import java.awt.BasicStroke;
  43. import java.awt.Color;
  44. import java.awt.Font;
  45. import java.awt.Graphics;
  46. import java.awt.Graphics2D;
  47. import java.awt.Image;
  48. import java.awt.Rectangle;
  49. import java.awt.RenderingHints;
  50. import java.awt.event.KeyEvent;
  51. import java.awt.event.MouseEvent;
  52. import java.awt.event.MouseListener;
  53. import java.awt.event.MouseMotionListener;
  54. import java.io.IOException;
  55. import java.lang.reflect.InvocationTargetException;
  56. import java.net.URL;
  57. import java.util.Arrays;
  58. import java.awt.BorderLayout;
  59. import java.awt.event.ActionEvent;
  60. import java.awt.event.ActionListener;
  61.  
  62. import javax.swing.ButtonGroup;
  63. import javax.swing.JButton;
  64. import javax.swing.JCheckBox;
  65. import javax.swing.JComboBox;
  66. import javax.swing.JFrame;
  67. import javax.swing.JPanel;
  68. import javax.swing.JRadioButton;
  69. import javax.swing.SwingUtilities;
  70. import javax.imageio.ImageIO;
  71. import java.awt.*;
  72.  
  73. import com.rsbuddy.script.methods.Bank.DepositBox;
  74.  
  75.  
  76.  
  77.  
  78.  
  79. @Manifest(authors={"Baal887"}, name="Ess", keywords={"baal887, mining, dwarf, dungeon, dwarvern, resource, miner"}, version=0.1, description="Mines the coal in the Dwarvern Resource Dungeon.")
  80. public class EssMiner extends ActiveScript implements PaintListener, MouseListener {
  81.  
  82.  
  83. public static boolean antibanning;
  84. public static boolean notHovered;
  85. static int targetRockID;
  86. static Tile targetRockLoc;
  87. GameObject coal;
  88. int i;
  89. GameObject lastRock;
  90.  
  91. public int[] essenceId = { 2419, 2491 };
  92. public int[] portalId = { 39831, 2 };
  93. public int[] pickId = { 1265, 1267, 1269, 1273, 1271, 1275 };
  94. public int doorId = (24381);
  95. public int closedDoorId = (24379);
  96.  
  97. public int invCount;
  98.  
  99. String Status;
  100. public boolean showhide = true;
  101. public boolean doOnce;
  102. public long startTime;
  103. public int startExp;
  104. public int startLevel;
  105. public Area shop = new Area (new Tile(3248,3396), new Tile(3258, 3405));
  106. public Area bank = new Area (new Tile(3248,3414), new Tile(3258, 3425));
  107. public Area outside = new Area (new Tile(3131,3287), new Tile(3369, 3535));
  108. public Tile bankTile = new Tile(3253, 3420);
  109. public Tile shopTile = new Tile(3253, 3401);
  110. public Tile shopDoorTile = new Tile(3253, 3398);
  111. public Tile shopClosedDoorTile = new Tile(3253, 3399);
  112.  
  113.  
  114.  
  115. private enum State {
  116. DOBANK, MINE, BANKTOSTORE, STORETOBANK, ENTERESS, EXITESS, EXITSTORE, Unknown
  117. }
  118.  
  119.  
  120.  
  121. public boolean onStart() {
  122. doOnce = true;
  123. startTime = System.currentTimeMillis();
  124. startExp = Skills.getCurrentExp(14);
  125. startLevel = Skills.getCurrentLevel(14);
  126. Mouse.setSpeed(Random.nextInt(6, 8));
  127. AntiBanCamera CameraAntiBan = new AntiBanCamera();
  128. getContainer().submit(CameraAntiBan);
  129. AntiBanMouse MouseAntiBan = new AntiBanMouse();
  130. getContainer().submit(MouseAntiBan); //submit the task to the task container
  131. AntiBanTab TabAntiBan = new AntiBanTab(); //init the sample task
  132. getContainer().submit(TabAntiBan); //submit the task to the task container
  133. return true;
  134. }
  135.  
  136.  
  137.  
  138. public void onFinish() {
  139. Mouse.moveOffScreen();
  140. }
  141.  
  142. public State getState() {
  143. if(inShop()) {
  144. if(Inventory.isFull()) {
  145. return State.EXITSTORE;
  146. }
  147. }
  148. if (bank.contains(Players.getLocal().getLocation())) {
  149. if (Inventory.isFull()) {
  150. return State.DOBANK;
  151. }
  152. }
  153. if (outside.contains(Players.getLocal().getLocation())) {
  154. if(Inventory.isFull()) {
  155. if(!bank.contains(Players.getLocal().getLocation())) {
  156. if(inShop()) {
  157. return State.EXITSTORE;
  158. } else {
  159. return State.STORETOBANK;
  160. }
  161. } else {
  162. return State.DOBANK;
  163. }
  164. } else {
  165. if(shop.contains(Players.getLocal().getLocation())) {
  166. return State.ENTERESS;
  167. }
  168. if(!shop.contains(Players.getLocal().getLocation()) && !inShop()) {
  169. return State.BANKTOSTORE;
  170. }
  171. }
  172. }
  173. if(Players.getLocal().getLocation().getX() >= 5000) {
  174. if(!Inventory.isFull()) {
  175. return State.MINE;
  176. } else {
  177. return State.EXITESS;
  178. }
  179. }
  180. return State.Unknown;
  181. }
  182.  
  183. public int loop() {
  184.  
  185. if(Players.getLocal().isInCombat()) {
  186. return Random.nextInt(70, 100);
  187. }
  188. if(antibanning) {
  189. Status = "antibanning";
  190. return Random.nextInt(70, 100);
  191. }
  192.  
  193. Mouse.setSpeed(Random.nextInt(4, 8));
  194.  
  195.  
  196. try {
  197.  
  198. switch (getState()) {
  199.  
  200. case DOBANK:
  201. doBank();
  202. break;
  203.  
  204. case MINE:
  205. mineEss();
  206. break;
  207.  
  208. case BANKTOSTORE:
  209. bankToStore();
  210. break;
  211.  
  212. case STORETOBANK:
  213. storeToBank();
  214. break;
  215.  
  216. case ENTERESS:
  217. if(!inShop()) {
  218. if(isDoorThere()) {
  219. openDoor();
  220. } else {
  221. enterShop();
  222. }
  223. } else {
  224. enterEss();
  225. }
  226. break;
  227.  
  228. case EXITESS:
  229. exitEss();
  230. break;
  231.  
  232. case EXITSTORE:
  233. if(isDoorThere()) {
  234. openDoor();
  235. } else {
  236. storeToBank();
  237. }
  238. break;
  239.  
  240.  
  241. case Unknown:
  242. sleep(100, 150);
  243. break;
  244. }
  245. }
  246. catch (Exception e) {
  247. sleep(1000, 1500);
  248. }
  249. return Random.nextInt(100, 150);
  250. }
  251.  
  252. public boolean inShop() {
  253. if(Calculations.distanceTo(shopTile) <= 2) {
  254. return true;
  255. } else {
  256. return false;
  257. }
  258. }
  259.  
  260. public void exitEss() {
  261. GameObject portal = Objects.getNearest(portalId);
  262. if(portal != null) {
  263. if(Calculations.distanceTo(portal) >=6) {
  264. walkTo(portal.getLocation().randomize(2,2));
  265. } else {
  266. if(!portal.isOnScreen()) {
  267. Camera.turnTo(portal, 10);
  268. sleep(50, 75);
  269. } else {
  270. if(!Players.getLocal().isMoving()) {
  271. portal.interact("Enter");
  272. sleep(550, 750);
  273. }
  274. }
  275. }
  276. }
  277. }
  278.  
  279.  
  280.  
  281.  
  282. public void enterShop() {
  283. if(Calculations.distanceTo(shopTile) > 2) {
  284. if(!Players.getLocal().isMoving()) {
  285. walkTo(shopTile.randomize(2,2));
  286. }
  287. }
  288. }
  289.  
  290.  
  291. public void openDoor() {
  292. GameObject door = Objects.getTopAt(shopDoorTile);
  293. if(door != null) {
  294. if(door.getId() == doorId) {
  295. if(Calculations.distanceTo(door) >= 6) {
  296. walkTo(door.getLocation().randomize(2,2));
  297. } else {
  298. if(!door.isOnScreen()) {
  299. Camera.turnTo(door, 10);
  300. sleep(50, 75);
  301. } else {
  302. if(!Players.getLocal().isMoving()) {
  303. door.interact("Open");
  304. sleep(700, 1100);
  305. }
  306. }
  307. }
  308. }
  309. }
  310. }
  311.  
  312.  
  313.  
  314. public void enterEss() {
  315. Npc aubury = Npcs.getNearest(5913);
  316. if(aubury != null) {
  317. if(!aubury.isOnScreen()) {
  318. Camera.turnTo(aubury, 10);
  319. sleep(50, 75);
  320. } else {
  321. aubury.interact("Teleport");
  322. for (int i = 0; i < 20; i++) {
  323. sleep(150, 200);
  324. if(!shop.contains(Players.getLocal().getLocation())) {
  325. break;
  326. }
  327. }
  328. }
  329. }
  330. }
  331.  
  332. public boolean inArea(Area Area_area) {
  333. if(Area_area.contains(Players.getLocal().getLocation())) {
  334. return true;
  335. } else {
  336. return false;
  337. }
  338. }
  339.  
  340.  
  341.  
  342. public boolean isDoorThere() {
  343. GameObject door = Objects.getTopAt(shopDoorTile);
  344. if(door != null) {
  345. if(door.getId() == doorId) {
  346. return true;
  347. } else {
  348. return false;
  349. }
  350. } else {
  351. return false;
  352. }
  353. }
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360. public void doBank() {
  361. if(!Bank.isOpen()) {
  362. Bank.open();
  363. } else {
  364. if(Bank.depositAllExcept(pickId)) {
  365. Bank.close();
  366. }
  367. }
  368. }
  369.  
  370.  
  371.  
  372. public void bankToStore() {
  373. walkTo(shopTile.randomize(2, 2));
  374. }
  375.  
  376. public void storeToBank() {
  377. walkTo(bankTile.randomize(2, 2));
  378. }
  379.  
  380.  
  381. private void mineEss() {
  382. GameObject ess = Objects.getNearest(essenceId);
  383. if(ess != null){
  384. if(ess.isOnScreen()){
  385. ess.interact("Mine");
  386. sleep(50, 75);
  387. for(i=0;i<20 || Players.getLocal().getAnimation() == -1;i++) {
  388. sleep(150);
  389. }
  390. if(Players.getLocal().getAnimation() != -1) {
  391. sleep(120);
  392. for(i = 0;i<1000;i++) {
  393. sleep(120);
  394. if(Inventory.isFull()) {
  395. break;
  396. }
  397. }
  398. }
  399. } else {
  400. if(Calculations.distanceTo(ess) >= 6) {
  401. walkTo(ess.getLocation().randomize(2,2));
  402. } else {
  403. Camera.turnTo(ess, 10);
  404. sleep(50, 70);
  405. }
  406. }
  407. }
  408. }
  409.  
  410.  
  411. public void walkTo(Tile tile) {
  412. if(Calculations.distanceTo(Walking.getDestination()) > 3) {
  413. sleep(70, 100);
  414. } else {
  415. Walking.stepTowards(tile);
  416. sleep(70, 100);
  417. }
  418. }
  419.  
  420.  
  421. public class AntiBanMouse extends LoopTask {
  422.  
  423. public int loop() {
  424. final int num = Random.nextInt(0, 6);
  425. switch (num) {
  426. case 0:
  427. log.info("AntiBan Active. Mousing");
  428. antibanning = true;
  429. if(!notHovered) {
  430. for(i = 0;i<30;i++) {
  431. sleep(150);
  432. if(notHovered) {
  433. break;
  434. }
  435. }
  436. }
  437. Mouse.moveSlightly();
  438. antibanning = false;
  439. break;
  440. case 1:
  441. log.info("AntiBan Active. Mousing");
  442. antibanning = true;
  443. if(!notHovered) {
  444. for(i = 0;i<30;i++) {
  445. sleep(150);
  446. if(notHovered) {
  447. break;
  448. }
  449. }
  450. }
  451. Mouse.moveRandomly(2000);
  452. antibanning = false;
  453. break;
  454. }
  455. return Random.nextInt(10000, 30000);
  456. }
  457. }
  458.  
  459. public class AntiBanTab extends LoopTask {
  460.  
  461. public int loop() {
  462. final int num = Random.nextInt(0, 8);
  463. switch (num) {
  464. case 0:
  465. antibanning = true;
  466. log.info("AntiBan Active. Tabbing");
  467. int TAB = Random.nextInt(1, 8);
  468. if (TAB == 1) {
  469. Game.openTab(2);
  470. sleep(1000,2500);
  471. }
  472. if (TAB == 2) {
  473. Game.openTab(2);
  474. sleep(1000,2500);
  475. }
  476. if (TAB == 3) {
  477. Game.openTab(5);
  478. sleep(1000,2500);
  479. }
  480. if (TAB == 4) {
  481. Game.openTab(9);
  482. sleep(1000,2500);
  483. }
  484. if (TAB == 5) {
  485. Game.openTab(7);
  486. sleep(1000,2500);
  487. }
  488. if (TAB == 6) {
  489. Game.openTab(4);
  490. sleep(1000,2500);
  491. }
  492. if (TAB == 7) {
  493. Game.openTab(14);
  494. sleep(1000,2500);
  495. }
  496. if (TAB == 8) {
  497. Game.openTab(6);
  498. sleep(1000,2500);
  499. }
  500. if(Game.getCurrentTab() == 2) {
  501. Skills.hover(Skills.COMPONENT_MINING);
  502. }
  503. antibanning = false;
  504. break;
  505.  
  506. case 1:
  507. antibanning = true;
  508. if(!notHovered) {
  509. for(i = 0;i<30;i++) {
  510. sleep(150);
  511. if(notHovered) {
  512. break;
  513. }
  514. }
  515. }
  516. Game.openTab(2);
  517. sleep(1000, 1300);
  518. if(Game.getCurrentTab() == 2) {
  519. Skills.hover(Skills.COMPONENT_MINING);
  520. sleep(1500,1900);
  521. antibanning = false;
  522. }
  523. }
  524. return Random.nextInt(10000, 30000);
  525. }
  526. }
  527.  
  528.  
  529.  
  530. public static class AntiBanCamera extends LoopTask {
  531. @Override
  532. public int loop() {
  533. if (Random.nextInt(0, 3) == 1) {
  534. antibanning = true;
  535. turnCamera();
  536. antibanning = false;
  537. }
  538. return Random.nextInt(10000, 20000);
  539. }
  540.  
  541. public void turnCamera() {
  542. char[] LR = new char[]{KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT};
  543. char[] UD = new char[]{KeyEvent.VK_UP, KeyEvent.VK_DOWN};
  544. char[] LRUD = new char[]{KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
  545. KeyEvent.VK_UP, KeyEvent.VK_DOWN};
  546. int random2 = Random.nextInt(0, 2);
  547. int random1 = Random.nextInt(0, 2);
  548. int random4 = Random.nextInt(0, 4);
  549.  
  550. if (Random.nextInt(0, 3) == 0) {
  551. if (Random.nextInt(0, 2) == 0) {
  552. Keyboard.pressKey(LR[random1]);
  553. try {
  554. Thread.sleep(Random.nextInt(100, 400));
  555. } catch (Exception e) {
  556. }
  557. Keyboard.pressKey(UD[random2]);
  558. try {
  559. Thread.sleep(Random.nextInt(300, 600));
  560. } catch (Exception e) {
  561. }
  562. Keyboard.releaseKey(UD[random2]);
  563. try {
  564. Thread.sleep(Random.nextInt(100, 400));
  565. } catch (Exception e) {
  566. }
  567. Keyboard.releaseKey(LR[random1]);
  568. } else {
  569. Keyboard.pressKey(UD[random2]);
  570. try {
  571. Thread.sleep(Random.nextInt(100, 400));
  572. } catch (Exception e) {
  573. }
  574. Keyboard.pressKey(LR[random1]);
  575. try {
  576. Thread.sleep(Random.nextInt(300, 600));
  577. } catch (Exception e) {
  578. }
  579. Keyboard.releaseKey(LR[random1]);
  580. try {
  581. Thread.sleep(Random.nextInt(100, 400));
  582. } catch (Exception e) {
  583. }
  584. Keyboard.releaseKey(UD[random2]);
  585. }
  586. } else {
  587. Keyboard.pressKey(LRUD[random4]);
  588. if (random4 > 1) {
  589. try {
  590. Thread.sleep(Random.nextInt(300, 600));
  591. } catch (Exception e) {
  592. }
  593. } else {
  594. try {
  595. Thread.sleep(Random.nextInt(500, 900));
  596. } catch (Exception e) {
  597. }
  598. }
  599. Keyboard.releaseKey(LRUD[random4]);
  600. }
  601. }
  602. }
  603.  
  604.  
  605. private final RenderingHints antialiasing = new RenderingHints(
  606. RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  607.  
  608. //START: Code generated using Enfilade's Easel
  609. private final Color color1 = new Color(0, 0, 0);
  610. private final Color color2 = new Color(230, 92, 92);
  611. private final Color color3 = new Color(255, 0, 0);
  612.  
  613. private final BasicStroke stroke1 = new BasicStroke(1);
  614.  
  615. private final Font font1 = new Font("Complex_IV50", 0, 32);
  616. private final Font font2 = new Font("Broadway BT", 1, 12);
  617. private final Font font3 = new Font("Constantia", 0, 12);
  618.  
  619.  
  620.  
  621. public void onRepaint(Graphics g1) {
  622.  
  623. int xpGained = Skills.getCurrentExp(14) - startExp;
  624. int levelsGained = Skills.getCurrentLevel(14) - startLevel;
  625.  
  626. long millis = System.currentTimeMillis() - startTime;
  627. long hours = millis / (1000 * 60 * 60);
  628. millis -= hours * (1000 * 60 * 60);
  629. long minutes = millis / (1000 * 60);
  630. String mins = "" + minutes;
  631. while (mins.length() < 2) {
  632. mins = "0" + mins;
  633. }
  634. millis -= minutes * (1000 * 60);
  635. long seconds = millis / 1000;
  636. String secs = "" + seconds;
  637. while (secs.length() < 2) {
  638. secs = "0" + secs;
  639. }
  640. float xpsec = 0;
  641. if ((minutes > 0 || hours > 0 || seconds > 0) && xpGained > 0) {
  642. xpsec = ((float) xpGained) / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
  643. }
  644. float xpmin = xpsec * 60;
  645. float xphour = xpmin * 60;
  646.  
  647. int XPTNL = Skills.getExpToNextLevel(14);
  648. final int TTL = (int) ((double) XPTNL / (double) xphour * 3600000);
  649.  
  650. Graphics2D g = (Graphics2D)g1;
  651. g.setRenderingHints(antialiasing);
  652. if (showhide) {
  653. g.setColor(color1);
  654. g.setStroke(stroke1);
  655. g.drawRect(2, 230, 514, 105);
  656. g.setFont(font1);
  657. g.setColor(color2);
  658. g.drawString("Baal887's Miner", 192, 280);
  659. g.setFont(font2);
  660. g.setColor(color3);
  661. g.drawString("Levels Gained: " + levelsGained, 6, 280);
  662. g.drawString("EXP/Hour: " + (int) xphour, 6, 306);
  663. g.drawString("Time Running: " + hours + ":" + mins + ":" + secs, 6, 254);
  664. g.drawString("Time to Level: " + Timer.format(TTL), 6, 332);
  665. }
  666. g.setFont(font3);
  667. g.setColor(color2);
  668. g.drawString("Show/Hide", 454, 330);
  669. }
  670. //END: Code generated using Enfilade's Easel
  671.  
  672.  
  673.  
  674. @Override
  675. public void mouseClicked(MouseEvent e) {
  676. int x = e.getX();
  677. int y = e.getY();
  678. if (x >= 450 && x < 450 + 70 && y >= 313 && y < 313 + 20) {
  679. if (showhide) {
  680. showhide = false;
  681. } else {
  682. showhide = true;
  683. }
  684. }
  685. }
  686.  
  687.  
  688.  
  689. @Override
  690. public void mouseEntered(MouseEvent e) {
  691. // TODO Auto-generated method stub
  692.  
  693. }
  694.  
  695.  
  696.  
  697. @Override
  698. public void mouseExited(MouseEvent e) {
  699. // TODO Auto-generated method stub
  700.  
  701. }
  702.  
  703.  
  704.  
  705. @Override
  706. public void mousePressed(MouseEvent e) {
  707. // TODO Auto-generated method stub
  708.  
  709. }
  710.  
  711.  
  712.  
  713. @Override
  714. public void mouseReleased(MouseEvent e) {
  715. // TODO Auto-generated method stub
  716.  
  717. }
  718.  
  719.  
  720. }
Add Comment
Please, Sign In to add comment