Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.Polygon;
- import java.awt.Shape;
- import java.awt.event.KeyEvent;
- import java.awt.*;
- import javax.print.DocFlavor.STRING;
- import com.rsbuddy.event.listeners.PaintListener;
- import com.rsbuddy.script.ActiveScript;
- import com.rsbuddy.script.Manifest;
- import com.rsbuddy.script.methods.Bank;
- import com.rsbuddy.script.methods.Calculations;
- import com.rsbuddy.script.methods.Camera;
- import com.rsbuddy.script.methods.Equipment;
- import com.rsbuddy.script.methods.Game;
- import com.rsbuddy.script.methods.Inventory;
- import com.rsbuddy.script.methods.Keyboard;
- import com.rsbuddy.script.methods.Menu;
- import com.rsbuddy.script.methods.Mouse;
- import com.rsbuddy.script.methods.Npcs;
- import com.rsbuddy.script.methods.Objects;
- import com.rsbuddy.script.methods.Players;
- import com.rsbuddy.script.methods.Skills;
- import com.rsbuddy.script.methods.Walking;
- import com.rsbuddy.script.methods.Widgets;
- import com.rsbuddy.script.task.LoopTask;
- import com.rsbuddy.script.util.Filter;
- import com.rsbuddy.script.util.Random;
- import com.rsbuddy.script.util.Timer;
- import com.rsbuddy.script.wrappers.Area;
- import com.rsbuddy.script.wrappers.GameObject;
- import com.rsbuddy.script.wrappers.Model;
- import com.rsbuddy.script.wrappers.Npc;
- import com.rsbuddy.script.wrappers.Path;
- import com.rsbuddy.script.wrappers.Tile;
- import com.rsbuddy.script.task.LoopTask;
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Rectangle;
- import java.awt.RenderingHints;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import java.io.IOException;
- import java.lang.reflect.InvocationTargetException;
- import java.net.URL;
- import java.util.Arrays;
- import java.awt.BorderLayout;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import javax.swing.ButtonGroup;
- import javax.swing.JButton;
- import javax.swing.JCheckBox;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.JRadioButton;
- import javax.swing.SwingUtilities;
- import javax.imageio.ImageIO;
- import java.awt.*;
- import com.rsbuddy.script.methods.Bank.DepositBox;
- @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.")
- public class EssMiner extends ActiveScript implements PaintListener, MouseListener {
- public static boolean antibanning;
- public static boolean notHovered;
- static int targetRockID;
- static Tile targetRockLoc;
- GameObject coal;
- int i;
- GameObject lastRock;
- public int[] essenceId = { 2419, 2491 };
- public int[] portalId = { 39831, 2 };
- public int[] pickId = { 1265, 1267, 1269, 1273, 1271, 1275 };
- public int doorId = (24381);
- public int closedDoorId = (24379);
- public int invCount;
- String Status;
- public boolean showhide = true;
- public boolean doOnce;
- public long startTime;
- public int startExp;
- public int startLevel;
- public Area shop = new Area (new Tile(3248,3396), new Tile(3258, 3405));
- public Area bank = new Area (new Tile(3248,3414), new Tile(3258, 3425));
- public Area outside = new Area (new Tile(3131,3287), new Tile(3369, 3535));
- public Tile bankTile = new Tile(3253, 3420);
- public Tile shopTile = new Tile(3253, 3401);
- public Tile shopDoorTile = new Tile(3253, 3398);
- public Tile shopClosedDoorTile = new Tile(3253, 3399);
- private enum State {
- DOBANK, MINE, BANKTOSTORE, STORETOBANK, ENTERESS, EXITESS, EXITSTORE, Unknown
- }
- public boolean onStart() {
- doOnce = true;
- startTime = System.currentTimeMillis();
- startExp = Skills.getCurrentExp(14);
- startLevel = Skills.getCurrentLevel(14);
- Mouse.setSpeed(Random.nextInt(6, 8));
- AntiBanCamera CameraAntiBan = new AntiBanCamera();
- getContainer().submit(CameraAntiBan);
- AntiBanMouse MouseAntiBan = new AntiBanMouse();
- getContainer().submit(MouseAntiBan); //submit the task to the task container
- AntiBanTab TabAntiBan = new AntiBanTab(); //init the sample task
- getContainer().submit(TabAntiBan); //submit the task to the task container
- return true;
- }
- public void onFinish() {
- Mouse.moveOffScreen();
- }
- public State getState() {
- if(inShop()) {
- if(Inventory.isFull()) {
- return State.EXITSTORE;
- }
- }
- if (bank.contains(Players.getLocal().getLocation())) {
- if (Inventory.isFull()) {
- return State.DOBANK;
- }
- }
- if (outside.contains(Players.getLocal().getLocation())) {
- if(Inventory.isFull()) {
- if(!bank.contains(Players.getLocal().getLocation())) {
- if(inShop()) {
- return State.EXITSTORE;
- } else {
- return State.STORETOBANK;
- }
- } else {
- return State.DOBANK;
- }
- } else {
- if(shop.contains(Players.getLocal().getLocation())) {
- return State.ENTERESS;
- }
- if(!shop.contains(Players.getLocal().getLocation()) && !inShop()) {
- return State.BANKTOSTORE;
- }
- }
- }
- if(Players.getLocal().getLocation().getX() >= 5000) {
- if(!Inventory.isFull()) {
- return State.MINE;
- } else {
- return State.EXITESS;
- }
- }
- return State.Unknown;
- }
- public int loop() {
- if(Players.getLocal().isInCombat()) {
- return Random.nextInt(70, 100);
- }
- if(antibanning) {
- Status = "antibanning";
- return Random.nextInt(70, 100);
- }
- Mouse.setSpeed(Random.nextInt(4, 8));
- try {
- switch (getState()) {
- case DOBANK:
- doBank();
- break;
- case MINE:
- mineEss();
- break;
- case BANKTOSTORE:
- bankToStore();
- break;
- case STORETOBANK:
- storeToBank();
- break;
- case ENTERESS:
- if(!inShop()) {
- if(isDoorThere()) {
- openDoor();
- } else {
- enterShop();
- }
- } else {
- enterEss();
- }
- break;
- case EXITESS:
- exitEss();
- break;
- case EXITSTORE:
- if(isDoorThere()) {
- openDoor();
- } else {
- storeToBank();
- }
- break;
- case Unknown:
- sleep(100, 150);
- break;
- }
- }
- catch (Exception e) {
- sleep(1000, 1500);
- }
- return Random.nextInt(100, 150);
- }
- public boolean inShop() {
- if(Calculations.distanceTo(shopTile) <= 2) {
- return true;
- } else {
- return false;
- }
- }
- public void exitEss() {
- GameObject portal = Objects.getNearest(portalId);
- if(portal != null) {
- if(Calculations.distanceTo(portal) >=6) {
- walkTo(portal.getLocation().randomize(2,2));
- } else {
- if(!portal.isOnScreen()) {
- Camera.turnTo(portal, 10);
- sleep(50, 75);
- } else {
- if(!Players.getLocal().isMoving()) {
- portal.interact("Enter");
- sleep(550, 750);
- }
- }
- }
- }
- }
- public void enterShop() {
- if(Calculations.distanceTo(shopTile) > 2) {
- if(!Players.getLocal().isMoving()) {
- walkTo(shopTile.randomize(2,2));
- }
- }
- }
- public void openDoor() {
- GameObject door = Objects.getTopAt(shopDoorTile);
- if(door != null) {
- if(door.getId() == doorId) {
- if(Calculations.distanceTo(door) >= 6) {
- walkTo(door.getLocation().randomize(2,2));
- } else {
- if(!door.isOnScreen()) {
- Camera.turnTo(door, 10);
- sleep(50, 75);
- } else {
- if(!Players.getLocal().isMoving()) {
- door.interact("Open");
- sleep(700, 1100);
- }
- }
- }
- }
- }
- }
- public void enterEss() {
- Npc aubury = Npcs.getNearest(5913);
- if(aubury != null) {
- if(!aubury.isOnScreen()) {
- Camera.turnTo(aubury, 10);
- sleep(50, 75);
- } else {
- aubury.interact("Teleport");
- for (int i = 0; i < 20; i++) {
- sleep(150, 200);
- if(!shop.contains(Players.getLocal().getLocation())) {
- break;
- }
- }
- }
- }
- }
- public boolean inArea(Area Area_area) {
- if(Area_area.contains(Players.getLocal().getLocation())) {
- return true;
- } else {
- return false;
- }
- }
- public boolean isDoorThere() {
- GameObject door = Objects.getTopAt(shopDoorTile);
- if(door != null) {
- if(door.getId() == doorId) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- public void doBank() {
- if(!Bank.isOpen()) {
- Bank.open();
- } else {
- if(Bank.depositAllExcept(pickId)) {
- Bank.close();
- }
- }
- }
- public void bankToStore() {
- walkTo(shopTile.randomize(2, 2));
- }
- public void storeToBank() {
- walkTo(bankTile.randomize(2, 2));
- }
- private void mineEss() {
- GameObject ess = Objects.getNearest(essenceId);
- if(ess != null){
- if(ess.isOnScreen()){
- ess.interact("Mine");
- sleep(50, 75);
- for(i=0;i<20 || Players.getLocal().getAnimation() == -1;i++) {
- sleep(150);
- }
- if(Players.getLocal().getAnimation() != -1) {
- sleep(120);
- for(i = 0;i<1000;i++) {
- sleep(120);
- if(Inventory.isFull()) {
- break;
- }
- }
- }
- } else {
- if(Calculations.distanceTo(ess) >= 6) {
- walkTo(ess.getLocation().randomize(2,2));
- } else {
- Camera.turnTo(ess, 10);
- sleep(50, 70);
- }
- }
- }
- }
- public void walkTo(Tile tile) {
- if(Calculations.distanceTo(Walking.getDestination()) > 3) {
- sleep(70, 100);
- } else {
- Walking.stepTowards(tile);
- sleep(70, 100);
- }
- }
- public class AntiBanMouse extends LoopTask {
- public int loop() {
- final int num = Random.nextInt(0, 6);
- switch (num) {
- case 0:
- log.info("AntiBan Active. Mousing");
- antibanning = true;
- if(!notHovered) {
- for(i = 0;i<30;i++) {
- sleep(150);
- if(notHovered) {
- break;
- }
- }
- }
- Mouse.moveSlightly();
- antibanning = false;
- break;
- case 1:
- log.info("AntiBan Active. Mousing");
- antibanning = true;
- if(!notHovered) {
- for(i = 0;i<30;i++) {
- sleep(150);
- if(notHovered) {
- break;
- }
- }
- }
- Mouse.moveRandomly(2000);
- antibanning = false;
- break;
- }
- return Random.nextInt(10000, 30000);
- }
- }
- public class AntiBanTab extends LoopTask {
- public int loop() {
- final int num = Random.nextInt(0, 8);
- switch (num) {
- case 0:
- antibanning = true;
- log.info("AntiBan Active. Tabbing");
- int TAB = Random.nextInt(1, 8);
- if (TAB == 1) {
- Game.openTab(2);
- sleep(1000,2500);
- }
- if (TAB == 2) {
- Game.openTab(2);
- sleep(1000,2500);
- }
- if (TAB == 3) {
- Game.openTab(5);
- sleep(1000,2500);
- }
- if (TAB == 4) {
- Game.openTab(9);
- sleep(1000,2500);
- }
- if (TAB == 5) {
- Game.openTab(7);
- sleep(1000,2500);
- }
- if (TAB == 6) {
- Game.openTab(4);
- sleep(1000,2500);
- }
- if (TAB == 7) {
- Game.openTab(14);
- sleep(1000,2500);
- }
- if (TAB == 8) {
- Game.openTab(6);
- sleep(1000,2500);
- }
- if(Game.getCurrentTab() == 2) {
- Skills.hover(Skills.COMPONENT_MINING);
- }
- antibanning = false;
- break;
- case 1:
- antibanning = true;
- if(!notHovered) {
- for(i = 0;i<30;i++) {
- sleep(150);
- if(notHovered) {
- break;
- }
- }
- }
- Game.openTab(2);
- sleep(1000, 1300);
- if(Game.getCurrentTab() == 2) {
- Skills.hover(Skills.COMPONENT_MINING);
- sleep(1500,1900);
- antibanning = false;
- }
- }
- return Random.nextInt(10000, 30000);
- }
- }
- public static class AntiBanCamera extends LoopTask {
- @Override
- public int loop() {
- if (Random.nextInt(0, 3) == 1) {
- antibanning = true;
- turnCamera();
- antibanning = false;
- }
- return Random.nextInt(10000, 20000);
- }
- public void turnCamera() {
- char[] LR = new char[]{KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT};
- char[] UD = new char[]{KeyEvent.VK_UP, KeyEvent.VK_DOWN};
- char[] LRUD = new char[]{KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
- KeyEvent.VK_UP, KeyEvent.VK_DOWN};
- int random2 = Random.nextInt(0, 2);
- int random1 = Random.nextInt(0, 2);
- int random4 = Random.nextInt(0, 4);
- if (Random.nextInt(0, 3) == 0) {
- if (Random.nextInt(0, 2) == 0) {
- Keyboard.pressKey(LR[random1]);
- try {
- Thread.sleep(Random.nextInt(100, 400));
- } catch (Exception e) {
- }
- Keyboard.pressKey(UD[random2]);
- try {
- Thread.sleep(Random.nextInt(300, 600));
- } catch (Exception e) {
- }
- Keyboard.releaseKey(UD[random2]);
- try {
- Thread.sleep(Random.nextInt(100, 400));
- } catch (Exception e) {
- }
- Keyboard.releaseKey(LR[random1]);
- } else {
- Keyboard.pressKey(UD[random2]);
- try {
- Thread.sleep(Random.nextInt(100, 400));
- } catch (Exception e) {
- }
- Keyboard.pressKey(LR[random1]);
- try {
- Thread.sleep(Random.nextInt(300, 600));
- } catch (Exception e) {
- }
- Keyboard.releaseKey(LR[random1]);
- try {
- Thread.sleep(Random.nextInt(100, 400));
- } catch (Exception e) {
- }
- Keyboard.releaseKey(UD[random2]);
- }
- } else {
- Keyboard.pressKey(LRUD[random4]);
- if (random4 > 1) {
- try {
- Thread.sleep(Random.nextInt(300, 600));
- } catch (Exception e) {
- }
- } else {
- try {
- Thread.sleep(Random.nextInt(500, 900));
- } catch (Exception e) {
- }
- }
- Keyboard.releaseKey(LRUD[random4]);
- }
- }
- }
- private final RenderingHints antialiasing = new RenderingHints(
- RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- //START: Code generated using Enfilade's Easel
- private final Color color1 = new Color(0, 0, 0);
- private final Color color2 = new Color(230, 92, 92);
- private final Color color3 = new Color(255, 0, 0);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Complex_IV50", 0, 32);
- private final Font font2 = new Font("Broadway BT", 1, 12);
- private final Font font3 = new Font("Constantia", 0, 12);
- public void onRepaint(Graphics g1) {
- int xpGained = Skills.getCurrentExp(14) - startExp;
- int levelsGained = Skills.getCurrentLevel(14) - startLevel;
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- String mins = "" + minutes;
- while (mins.length() < 2) {
- mins = "0" + mins;
- }
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- String secs = "" + seconds;
- while (secs.length() < 2) {
- secs = "0" + secs;
- }
- float xpsec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && xpGained > 0) {
- xpsec = ((float) xpGained) / (float) (seconds + (minutes * 60) + (hours * 60 * 60));
- }
- float xpmin = xpsec * 60;
- float xphour = xpmin * 60;
- int XPTNL = Skills.getExpToNextLevel(14);
- final int TTL = (int) ((double) XPTNL / (double) xphour * 3600000);
- Graphics2D g = (Graphics2D)g1;
- g.setRenderingHints(antialiasing);
- if (showhide) {
- g.setColor(color1);
- g.setStroke(stroke1);
- g.drawRect(2, 230, 514, 105);
- g.setFont(font1);
- g.setColor(color2);
- g.drawString("Baal887's Miner", 192, 280);
- g.setFont(font2);
- g.setColor(color3);
- g.drawString("Levels Gained: " + levelsGained, 6, 280);
- g.drawString("EXP/Hour: " + (int) xphour, 6, 306);
- g.drawString("Time Running: " + hours + ":" + mins + ":" + secs, 6, 254);
- g.drawString("Time to Level: " + Timer.format(TTL), 6, 332);
- }
- g.setFont(font3);
- g.setColor(color2);
- g.drawString("Show/Hide", 454, 330);
- }
- //END: Code generated using Enfilade's Easel
- @Override
- public void mouseClicked(MouseEvent e) {
- int x = e.getX();
- int y = e.getY();
- if (x >= 450 && x < 450 + 70 && y >= 313 && y < 313 + 20) {
- if (showhide) {
- showhide = false;
- } else {
- showhide = true;
- }
- }
- }
- @Override
- public void mouseEntered(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseExited(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mousePressed(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- @Override
- public void mouseReleased(MouseEvent e) {
- // TODO Auto-generated method stub
- }
- }
Add Comment
Please, Sign In to add comment