Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package stefano;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics2D;
- import org.osbot.rs07.api.map.Position;
- import org.osbot.rs07.api.model.RS2Object;
- import org.osbot.rs07.input.mouse.MiniMapTileDestination;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import org.osbot.rs07.utility.Area;
- @ScriptManifest(author = "Stefano", info = "Mines Copper!", name = "sMiner", version = 0.04, logo = "")
- public class SMiner extends Script {
- // variables for paint
- int lastAmount;
- int rocksMined = 0;
- int timesBanked = 0;
- // rock id's
- private static final int[] COPPER_ID = { 6821, 6822, 6823 };
- // path to bank
- private Position[] path = { new Position(3283, 3363, 0),
- new Position(3290, 3374, 0), new Position(3292, 3386, 0),
- new Position(3292, 3392, 0), new Position(3291, 3401, 0),
- new Position(3287, 3413, 0), new Position(3282, 3427, 0),
- new Position(3270, 3429, 0), new Position(3256, 3429, 0),
- new Position(3254, 3421, 0) };
- // path to mine
- private Position[] pathMine = { new Position(3254, 3421, 0),
- new Position(3260, 3428, 0), new Position(3272, 3428, 0),
- new Position(3287, 3419, 0), new Position(3289, 3411, 0),
- new Position(3291, 3399, 0), new Position(3291, 3386, 0),
- new Position(3285, 3372, 0), new Position(3286, 3365, 0)
- };
- // player area's where to do things
- private static final Area MINE_AREA = new Area(3277, 3358, 3293, 3371);
- private static final Area BANK_AREA = new Area(3250, 3419, 3257, 3423);
- // player states which will be used
- private enum State {
- MINE, WALK_TO_BANK, BANK, WALK_TO_MINE
- };
- // getters for different states and the conditions
- private State getState() {
- if (inventory.isFull() && MINE_AREA.contains(myPlayer()))
- return State.WALK_TO_BANK;
- if (!inventory.isFull() && BANK_AREA.contains(myPlayer()))
- return State.WALK_TO_MINE;
- if (inventory.isFull() && BANK_AREA.contains(myPlayer()))
- return State.BANK;
- return State.MINE;
- }
- // path to banking with for loop for each position in array
- private void PathtoBank(Position[] path) throws InterruptedException {
- for (int i = 1; i < path.length; i++)
- if (!walkTile(path[i]))
- i--;
- }
- // path to mining with for loop for each position in array
- private void PathtoMine(Position[] path) throws InterruptedException {
- for (int i = 1; i < pathMine.length; i++)
- if (!walkTile(pathMine[i]))
- i--;
- }
- // minimap walking with failsafe
- private boolean walkTile(Position p) throws InterruptedException {
- mouse.move(new MiniMapTileDestination(bot, p), false);
- sleep(random(150, 250));
- mouse.click(false);
- int failsafe = 0;
- while (failsafe < 10 && myPlayer().getPosition().distance(p) > 2) {
- sleep(200);
- failsafe++;
- if (myPlayer().isMoving())
- failsafe = 0;
- }
- if (failsafe == 10)
- return false;
- return true;
- }
- // what happens when script starts.
- @Override
- public void onStart() {
- log("Stefano : Enjoy Mining !");
- }
- public boolean invChange(String itemName){
- return lastAmount != inventory.getAmount(itemName);
- }
- // while script run this is where the magic happens!
- @Override
- public int onLoop() throws InterruptedException {
- if(invChange("Copper ore")){
- rocksMined++;
- }
- lastAmount = (int) inventory.getAmount("Copper ore");
- switch (getState()) {
- case MINE:
- if (!myPlayer().isAnimating()) {
- RS2Object vein = objects.closest(COPPER_ID);
- if (vein != null) {
- if (vein.interact("Mine"))
- sleep(random(1000, 1500));
- }
- }
- break;
- case WALK_TO_BANK:
- PathtoBank(path);
- sleep(random(1500, 2500));
- break;
- case WALK_TO_MINE:
- PathtoMine(pathMine);
- sleep(random(1500, 2500));
- break;
- case BANK:
- RS2Object bankBooth = objects.closest("Bank booth");
- if (bankBooth != null) {
- if (bankBooth.interact("Bank")) {
- while (!bank.isOpen())
- sleep(250);
- bank.depositAll();
- timesBanked++;
- rocksMined--;
- log("banking complete walking back to miningsite");
- }
- }
- break;
- }
- return random(200, 300);
- }
- // what happens if the player leaves us :(
- @Override
- public void onExit() {
- log("Thanks for using sMiner");
- }
- // our nice looking paint =D
- @Override
- public void onPaint(Graphics2D g) {
- Graphics2D gr = (Graphics2D) g;
- gr.setColor(Color.white);
- gr.setFont(new Font("Arial", Font.PLAIN, 15));
- gr.drawString("sMiner by Stefano", 25, 60);
- gr.setFont(new Font("Arial", Font.PLAIN, 10));
- gr.drawString("Mined : " + rocksMined, 25, 75);
- gr.drawString("Times Banked : " + timesBanked, 25, 85);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment