- import java.awt.*;
- import java.util.Map;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.script.methods.*;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- @ScriptManifest(authors = {"BOOM BOOM"}, category = "Mining", name = "RDMiner", version = 1.0, description = ("Have a pickaxe in Inventory or Equipment"))
- public class RDMiner extends Script implements PaintListener, ServerMessageListener {
- public int coal[] = { 32426, 32427, 32428 };
- public int coal2[] = { 33400, 33401, 33402, };
- public int bankId = 25937;
- public RSTile path = new RSTile(1043, 4578);
- public RSTile path2 = new RSTile(1064, 4573);
- private long startTime;
- private int orePrice;
- private int oresMined = 0;
- public int ran = random(4, 6);
- public int actionID = 1;
- public static final int INTERFACE_BANK = 11;
- public static final int INTERFACE_DEPOSIT_BOX_INTERFACE = 19;
- public boolean onStart(Map<String, String> args) { //What the script will do when it has been started.
- log("Happy Botting :)");
- orePrice = grandExchange.loadItemInfo(440).getMarketPrice();
- startTime = System.currentTimeMillis();
- return true;
- }
- private boolean isInArea(final int minX, final int minY, final int maxX, final int maxY) {
- final int x = getMyPlayer().getLocation().getX();
- final int y = getMyPlayer().getLocation().getY();
- if (x >= minX && x <= maxX && y >= minY && y <= maxY) {
- return true;
- }
- return false;
- }
- public void action(){//Credits to ishitpants for area tiles.
- final RSObject Ore = objects.getNearest(coal2);
- if (!inventory.isFull() && !isOpen()) {//1 = mining
- actionID = 1;
- } else if (inventory.isFull()) {//2 = banking
- actionID = 2;
- } else if (isInArea(1061, 4565, 1070, 4582) && actionID == 4){//4 = walking to mine
- actionID = 1;
- } else if (isInArea(1041, 4575, 1044, 4578) && actionID == 3) {//3 = walking to bank
- actionID = 2;
- } else if (isInArea(1041, 4575, 1044, 4578) && actionID == 2) {
- actionID = 4;
- } else if (isInArea(1062, 4560, 1075, 4585) && actionID == 1) {
- actionID = 1;
- } else if (Ore != null && isInArea(1062, 4560, 1075, 4585) && actionID == 1) {
- actionID = 5;
- }
- }
- public boolean depositBox(){
- return isOpen() && interfaces.getComponent(INTERFACE_BANK, INTERFACE_DEPOSIT_BOX_INTERFACE).doClick();
- }
- public boolean isOpen(){
- return interfaces.get(INTERFACE_BANK).isValid();
- }
- public boolean open(){
- final RSObject Bank = objects.getNearest(bankId);
- if (Bank.isOnScreen()){
- tiles.doAction(Bank.getLocation(), "Deposit");
- while (getMyPlayer().isMoving()) {
- return false;
- }
- sleep(750);
- } else {
- walking.walkTo(path);
- log("Walk");
- }
- return false;
- }
- public boolean dwarf(){
- return npcs.getNearestToAttack("Dwarf")==null;
- }
- private void AntiBan() {
- final int r = random(1, 360);
- final int b = random(750, 1500);
- int randomNum = random(1, 30);
- int ra = random(1, 45);
- if (randomNum == 6) {
- if (ra == 1) {
- if (game.getCurrentTab() != game.TAB_STATS) {
- game.openTab(game.TAB_STATS);
- mouse.move(random(680, 730), random(355, 370));
- }
- }
- if (ra == 2) {
- game.openTab(random(1, 14));
- }
- if (ra == 3) {
- Point mPos = mouse.getClientLocation();
- mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
- }
- if (ra == 4) {
- Point mPos = mouse.getClientLocation();
- mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
- }
- if (ra == 5) {
- Point mPos = mouse.getClientLocation();
- mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
- }
- if (ra == 6) {
- Point mPos = mouse.getClientLocation();
- mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
- }
- if (ra == 7) {
- Point mPos = mouse.getClientLocation();
- mouse.move(mPos.x + random(-90, 90), mPos.y + random(-90, 90));
- }
- if (ra == 8) {
- camera.setAngle(random(100, 360));
- }
- if (ra == 9) {
- camera.setAngle(random(100, 360));
- }
- if (ra == 10) {
- camera.setAngle(random(100, 360));
- }
- if(ra == 11){
- camera.setAltitude(true);
- }
- if(ra == 12){
- camera.setAltitude(false);
- }
- if(ra == 13) {
- camera.moveRandomly(b);
- }
- if(ra == 14) {
- camera.setAngle(r);
- }
- if(ra == 15) {
- camera.setCompass('n');
- }
- if(ra == 16) {
- camera.setCompass('w');
- }
- if(ra == 17) {
- camera.setCompass('e');
- }
- if(ra == 18) {
- camera.setCompass('s');
- }
- }
- }
- public boolean bank() {
- final RSObject Bank = objects.getNearest(bankId);
- if (calc.distanceTo(Bank.getLocation()) <=5){
- log("Open");
- open();
- sleep(750);
- if (isOpen()){
- depositBox();
- sleep(1000);
- walking.walkTo(path2);
- return true;
- }else{
- open();
- return false;
- }
- } else if (calc.distanceTo(Bank.getLocation()) > 5 && inventory.isFull()){
- walking.walkTo(path);
- return false;
- }
- return false;
- }
- public boolean doMine() {
- final int a = 32426;
- final int b[] = { 32427, 32438 };
- final int c = 32428;
- final RSObject Ore = objects.getNearest(coal);
- final RSObject Ore2 = objects.getNearest(coal2);
- final RSObject A = objects.getNearest(a);
- final RSObject B = objects.getNearest(b);
- final RSObject C = objects.getNearest(c);
- if (calc.distanceTo(Ore) <= 10) {
- if (Ore != null) {
- if (Ore.isOnScreen()) {
- if (getMyPlayer().isMoving()){
- return false;
- }
- if (getMyPlayer().getAnimation() == 624 && calc.distanceTo(Ore2) < 1 && calc.distanceTo(Ore) < 1) {
- return false;
- }
- tiles.doAction(Ore.getLocation(), "Mine");
- sleep(1750, 2000);
- return true;
- } else {
- walking.walkTo(Ore.getLocation());
- }
- } else {
- return false;
- }
- } else if (calc.distanceTo(Ore) > 10) {
- if (!calc.pointOnScreen(calc.tileToScreen(Ore.getLocation()))) {
- final int whichOre = random(1, 3);
- if (whichOre == 1) {
- walking.walkTo(Ore.getLocation());
- sleep(1200, 1800);
- while (getMyPlayer().isMoving()) {
- sleep(10, 20);
- }
- return false;
- } else {
- walking.walkTo(path2);
- sleep(1200, 1800);
- while (getMyPlayer().isMoving()) {
- sleep(10, 20);
- }
- return false;
- }
- }
- } else {
- return false;
- }
- return false;
- }
- public boolean check() {
- final RSObject Ore = objects.getNearest(coal2);
- while (getMyPlayer().getAnimation() == 624) {
- if (Ore != null) {
- doMine();
- return true;
- }else{
- return false;
- }
- }
- return false;
- }
- public boolean mine() {
- if (getMyPlayer().getAnimation() == -1) {
- doMine();
- }else{
- check();
- }
- return false;
- }
- public void onFinish() { //What the script will do when stopped.
- log("RDMiner");
- }
- public void onRepaint(Graphics g) {
- final int percent = skills.getPercentToNextLevel(Skills.MINING); //change the MINING to the stat u want
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- long profit = orePrice * oresMined;
- final RenderingHints rh = new RenderingHints(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- Font font = new Font("Monospaced", Font.BOLD, 17);
- ((Graphics2D) g).setRenderingHints(rh);
- g.setColor(new Color(250, 0, 0, 95));
- g.fillRect(545, 205, 195, 262);
- g.setFont(font);
- g.setColor(new Color(0, 0, 0));
- g.drawString("RDMiner", 565, 215);
- g.setFont(font);
- g.setColor(new Color(0, 0, 0));
- g.drawString("Run Time :" + hours + ":" + minutes + ":" + seconds, 565, 230);
- g.setFont(font);
- g.setColor(new Color(0, 0, 0));
- g.drawString("Ores Mined : " + oresMined, 565, 245);
- g.setFont(font);
- g.setColor(new Color(0, 0, 0));
- g.drawString("Profit : " + profit, 565, 260);
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent f) { //What it will do if it recieves a message in game, by the System.
- final String m = f.getMessage();
- if (m.contains("manage")) {
- oresMined++;
- }
- if (m.contains("You do not have")) {
- log("no Pickaxe... logging out and stopping script");
- game.logout(true);
- stopScript();
- }
- if (m.contains("Hi") || m.contains(" ello")) {
- keyboard.sendText("Sorry, I don't feel like talking.", true);
- }
- }
- public int loop() { //Your main code should be here, it will keep repeating it.
- mouse.setSpeed(ran);
- action();
- AntiBan();
- int runEnergy = random(60, 80);
- if (walking.getEnergy() >= runEnergy) {
- walking.setRun(true);
- }
- if (getMyPlayer().getAnimation() == 397){
- final RSNPC dwarf = npcs.getNearestFreeToAttack("Dwarf");
- if(calc.tileOnScreen(dwarf.getLocation())) {
- dwarf.doAction("attack");
- sleep(250, 500);
- } else {
- walking.walkTo(dwarf.getLocation());
- }
- }
- switch (actionID) {
- case 1:
- mine();
- break;
- case 2:
- bank();
- break;
- case 3:
- walking.walkTo(path);
- actionID = 2;
- break;
- case 4:
- walking.walkTo(path2);
- actionID = 1;
- break;
- case 5:
- AntiBan();
- actionID = 1;
- }
- return 0;
- }
- }