Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.*;
- import java.util.*;
- import org.tribot.api.*;
- import org.tribot.api.input.*;
- import org.tribot.api2007.*;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.types.*;
- import org.tribot.script.interfaces.*;
- import org.tribot.script.*;
- /**
- * @author Spencer - Deluxes
- */
- @ScriptManifest(authors = { "Deluxes" }, category = "Mining", name = "DeluxesESSENCE", description = "Start at Varrock East Bank, in the mine, or somewhere you may encounter on the way. Have a pickaxe equipped or in your inventory.")
- public class DeluxesESS extends Script implements Painting
- {
- ArrayList<Node> nodes = new ArrayList<>();
- public static RSTile[] path = DeluxeUtil.CreatePath(new RSTile(3253, 3422), new RSTile(3262, 3419), new RSTile(3258, 3408), new RSTile(3256, 3398), new RSTile(3253, 3402));
- static Polygon bankArea = DeluxeUtil.CreateArea(new RSTile(3249, 3418), new RSTile(3257, 3425));
- long startTime = System.currentTimeMillis();
- public static String state = "";
- int essMined = 0;
- int lastEss = 0;
- int startExp = Skills.SKILLS.MINING.getXP();
- public static int[] PICK_AXE_IDS = new int[] {1275, 1271, 1273, 1269, 1267, 1265 };
- @Override
- public void onPaint(Graphics g)
- {
- long timeRan = System.currentTimeMillis() - startTime;
- int expGained = Skills.SKILLS.MINING.getXP() - startExp;
- Graphics2D g1 = (Graphics2D)g;
- g1.drawString("STATE: " + state, 236, 225);
- g1.drawString("ESS MINED: " + expGained / 5, 236, 245);
- g1.drawString("EXP Gained: " + expGained + "(" + (Skills.SKILLS.MINING.getCurrentLevel() - Skills.getLevelByXP(startExp)) + ")", 236, 265);
- g1.drawString("TIME RAN: " + Timing.msToString(timeRan), 236, 285);
- g1.drawString("ESS PER HOUR: " + DeluxeUtil.GetAmountPerHour(expGained / 5, startTime), 236, 305);
- }
- public static boolean inVarrock()
- {
- return Player.getPosition().distanceTo(new RSTile(3253, 3401)) < 50;
- }
- public static boolean inBank()
- {
- return DeluxeUtil.inArea(bankArea, Player.getPosition());
- }
- public static boolean inMine()
- {
- RSObject[] ess = Objects.findNearest(150, "Rune Essence");
- return ess.length > 0;
- }
- @Override
- public void run()
- {
- Collections.addAll(nodes, new MineNode(), new BankNode(), new DeathNode());
- Walking.setControlClick(true);
- Walking.setWalkingTimeout(1000);
- Mouse.setSpeed(175);
- loop(40, 50);
- }
- void loop(int min, int max)
- {
- while (true)
- {
- for (final Node node : nodes)
- {
- if (node.validate())
- {
- node.execute();
- sleep(min, max);
- }
- }
- }
- }
- }
- class MineNode extends Node
- {
- @Override
- public void execute()
- {
- int current = 0;
- if ((DeluxesESS.inVarrock() || DeluxesESS.inBank()) && !DeluxesESS.inMine())
- {
- DeluxesESS.state = "Walking to Aubury";
- RSNPC[] aubury = NPCs.find("Aubury");
- if (DeluxesESS.inBank() || (aubury.length > 0 && Player.getPosition().distanceTo(aubury[0].getPosition()) > 10))
- {
- //WebWalking.walkTo(new RSTile(3253, 3401));
- boolean walkPath = DeluxeUtil.TraversePath(DeluxesESS.path, 8);
- if (!walkPath && Player.getPosition().distanceTo(DeluxesESS.path[DeluxesESS.path.length - 1].getPosition()) > 2 && Player.getPosition().distanceTo(DeluxesESS.path[DeluxesESS.path.length - 1].getPosition()) < 6)
- {
- General.println("Checking the door. Might be closed.");
- DeluxesESS.state = "Checking Door";
- RSObject[] door = Objects.getAt(new RSTile(3253, 3398));
- if (door.length > 0)
- {
- Walking.walkTo(door[0].getPosition());
- if (!door[0].isOnScreen())
- {
- Camera.turnToTile(door[0].getPosition());
- }
- DynamicClicking.clickRSObject(door[0], "Open");
- General.println("Doors needs to be opened.");
- do
- {
- General.sleep(100);
- current++;
- } while (Objects.getAt(new RSTile(3253, 3398)).length > 0 && current < 50);
- current = 0;
- }
- }
- else if (!walkPath)
- {
- General.println("Failed to walk path. Using webwalking to fix.");
- WebWalking.walkTo(new RSTile(3253, 3401));
- }
- }
- else
- {
- /*DeluxesESS.state = "Checking Door";
- RSObject[] door = Objects.getAt(new RSTile(3253, 3398));
- if (door.length > 0)
- {
- DynamicClicking.clickRSObject(door[0], "Open");
- }*/
- aubury = NPCs.find("Aubury");
- if (aubury.length > 0 && Player.getPosition().distanceTo(aubury[0].getPosition()) > 5)
- {
- Walking.walkTo(new RSTile(3253, 3401));
- while ((Player.isMoving() && current < 20) && Player.getPosition().distanceTo(aubury[0].getPosition()) > 5)
- {
- General.sleep(100);
- current++;
- }
- current = 0;
- }
- DeluxesESS.state = "Teleport via Aurbury";
- if (aubury.length > 0 && Player.getPosition().distanceTo(aubury[0].getPosition()) < 5)
- {
- if (!aubury[0].isOnScreen())
- {
- Camera.turnToTile(aubury[0].getPosition());
- }
- boolean success = false;
- while (!success)
- success = DynamicClicking.clickRSNPC(aubury[0], "Teleport");
- success = false;
- while (Player.isMoving() || (DeluxesESS.inVarrock() && current < 30))
- {
- General.sleep(100);
- if (!Player.isMoving())
- current++;
- }
- current = 0;
- }
- }
- }
- else if (DeluxesESS.inMine())
- {
- DeluxesESS.state = "Looking for nearest Rune Essence Mine";
- RSObject[] ess = Objects.findNearest(150, "Rune Essence");
- if (ess.length > 0)
- {
- if (Player.getPosition().distanceTo(ess[0].getPosition()) > 5)
- {
- Walking.walkPath(Walking.generateStraightPath(ess[0].getPosition()));
- General.sleep(500, 750);
- while (Player.isMoving() && (Player.getPosition().distanceTo(ess[0].getPosition()) > 5 || !ess[0].isOnScreen()) && current < 50)
- {
- General.sleep(100);
- current++;
- }
- current = 0;
- }
- if (!ess[0].isOnScreen())
- {
- DeluxesESS.state = "Moving Camera";
- Camera.turnToTile(ess[0].getPosition());
- General.sleep(400, 700);
- }
- DeluxesESS.state = "Mining Rune Essence";
- DynamicClicking.clickRSObject(ess[0], "Mine");
- while ((Player.isMoving() && Player.getAnimation() == -1 && current < 30) || (Player.getAnimation() != -1 && !Inventory.isFull()))
- {
- General.sleep(100);
- current++;
- }
- current = 0;
- }
- }
- }
- @Override
- public boolean validate()
- {
- return !Inventory.isFull();
- }
- }
- class BankNode extends Node
- {
- @Override
- public void execute()
- {
- int current = 0;
- RSNPC[] portal = NPCs.findNearest("null");
- if (portal.length > 0 && !DeluxesESS.inVarrock())
- {
- if (Player.getPosition().distanceTo(portal[0].getPosition()) > 2)
- {
- Walking.walkTo(portal[0].getPosition());
- }
- while (Player.isMoving() && Player.getPosition().distanceTo(portal[0].getPosition()) > 2 && current < 50)
- {
- General.sleep(100);
- current++;
- }
- current = 0;
- if (!portal[0].isOnScreen())
- {
- DeluxesESS.state = "Moving Camera";
- Camera.turnToTile(portal[0].getPosition());
- General.sleep(400, 700);
- }
- DeluxesESS.state = "Attempting to leave mine";
- portal[0].click("Exit", "Use", "Leave");
- while (!DeluxesESS.inVarrock() && current < 30)
- {
- General.sleep(100);
- current++;
- }
- current = 0;
- }
- if (DeluxesESS.inVarrock())
- {
- DeluxesESS.state = "Moving to bank";
- WebWalking.walkToBank();
- while (Player.isMoving() && !DeluxesESS.inBank() && current < 20)
- {
- General.sleep(100);
- current++;
- }
- current = 0;
- if (!DeluxesESS.inBank() && !Player.isMoving())
- {
- Walking.walkTo(DeluxeUtil.getRandomTile(DeluxesESS.bankArea));
- }
- }
- if (DeluxesESS.inBank())
- {
- DeluxesESS.state = "Opening Bank";
- Banking.openBankBooth();
- if (Banking.isPinScreenOpen())
- {
- Banking.inPin();
- }
- while (!Banking.isBankScreenOpen() && current < 10)
- {
- General.sleep(100);
- current++;
- }
- current = 0;
- if (Banking.isBankScreenOpen())
- Banking.depositAllExcept(DeluxesESS.PICK_AXE_IDS);
- while (Inventory.isFull() && current < 7.5)
- {
- General.sleep(100);
- current++;
- }
- current = 0;
- }
- }
- @Override
- public boolean validate()
- {
- return Inventory.isFull();
- }
- }
- class DeathNode extends Node
- {
- @Override
- public void execute()
- {
- DeluxesESS.state = "Death Walk";
- while (!DeluxesESS.inVarrock())
- {
- WebWalking.walkTo(new RSTile(3253, 3401));
- General.sleep(100);
- }
- }
- @Override
- public boolean validate()
- {
- return Player.getPosition().distanceTo(new RSTile(3222,3218)) < 100;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement