Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Scripts' Power Miner

Featured Replies

Wrote this tonight in about 3 hours...how does it look so far? Also, would like to know how to add some anti-ban type behavior.

import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;


import java.awt.*;


@ScriptManifest(name = "AIOMiner", author = "Scripts", version = 0.1, info = "", logo = "")
public class main extends Script {

    private long startTime;

    @[member=Override]
    public void onStart() {
        startTime = System.currentTimeMillis();
        log("Welcome to Scripts' AIOMiner.");
        log("If you have any issues or suggestions, please contact me via forums.");
    }

    public final String formatTime(final long ms){
        long s = ms / 1000, m = s / 60, h = m / 60;
        s %= 60; m %= 60; h %= 24;
        return String.format("%02d:%02d:%02d", h, m, s);
    }

    private enum State {
        MINE, DROP, WAIT
    };

    private State getState() {

        RS2Object tinRock = getRockWithOre(Rock.TIN);

        if (inventory.isFull())
            return State.DROP;
        if (tinRock != null && !myPlayer().isAnimating() && !myPlayer().isMoving())
            return State.MINE;
        return State.WAIT;

    }

    @[member=Override]
    public void onExit() {

        log("Thanks for using Scripts' AIOMiner.");
        log("If you had any issues or suggestions, please contact me via forums.");

    }

    @[member=Override]
    public int onLoop() throws InterruptedException {

        switch (getState()) {
            case MINE:
                RS2Object tinRock = getRockWithOre(Rock.TIN);
                if (tinRock != null) {
                    tinRock.interact("Mine");
                    sleep(random(2000, 3000));
                    mouse.moveVerySlightly();
                }
                break;
            case DROP:
                if (inventory.isFull()) {
                    vDrop();
                    break;
                }
            case WAIT:
                sleep(random(500,700));
                break;
        }
        return random(200,300);
    }

    @[member=Override]
    public void onPaint(Graphics2D g) {
        final long runTime = System.currentTimeMillis() - startTime;

        Point mP = getMouse().getPosition();

        //mouse X
        g.drawLine(mP.x - 5, mP.y + 5, mP.x + 5, mP.y - 5);
        g.drawLine(mP.x + 5, mP.y + 5, mP.x - 5, mP.y - 5);

        g.setColor(Color.white);
        g.setFont(g.getFont().deriveFont(18.0f));
        g.drawString("Run Time:" + formatTime(runTime), 10, 335);//runntime

    }

    public enum Rock {

        CLAY(6705),
        COPPER(4645),
        TIN(53),
        IRON(2576),
        SILVER(74),
        COAL(10508),
        GOLD(8885),
        MITHRIL(-22239),
        ADAMANTITE(21662),
        RUNITE(-31437);

        final short COLOR;

        Rock(final int COLOR) {

            this.COLOR = (short) COLOR;
        }
    }

    public RS2Object getRockWithOre(Rock rock){

        return getObjects().closest((RS2Object obj) -> {

            short[] colors = obj.getDefinition().getModifiedModelColors();

            if(colors != null){

                for(short c : colors){

                    if(c == rock.COLOR) return true;
                }
            }
            return false;
        });
    }

    public static final int[] MOUSEKEY_DROP = new int[]{

            0,4,8,12,16,20,1,5,9,13,17,21,2,6,10,14,18,22,3,7,11,15,19,23};

    public void vDrop() {

        for (int i : MOUSEKEY_DROP) {
            getInventory().interact(i, "Drop");
        }
        inventory.dropAll();
    }

}

Edited by Scripts

Pretty good to start with but this logic is not really a good way to handle mining

case MINE:
    RS2Object tinRock = getRockWithOre(Rock.TIN);
    if (tinRock != null) {
        tinRock.interact("Mine");
        sleep(random(2000, 3000));
        mouse.moveVerySlightly();
    }
    break;

Try staying away from static sleeps

 

Rather use ConditionalSleeps

if(tinRock.interact("Mine")) {                               
    new ConditionalSleep(3000) {
        @[member='Override']
        public boolean condition() {
            return myPlayer().isAnimating();
        }
     }.sleep();
}

 Sleep until you are animating then return in your loop while you are animating aka still mining.

(This also means if your character is animating but the rock is depleted it waits so you need to add an extra check if the rock you are mining is still not depleted otherwise even if you are animating you can consider yourself done mining that rock)

Edited by House

Pretty good to start with but this logic is not really a good way to handle mining

case MINE:
    RS2Object tinRock = getRockWithOre(Rock.TIN);
    if (tinRock != null) {
        tinRock.interact("Mine");
        sleep(random(2000, 3000));
        mouse.moveVerySlightly();
    }
    break;

Try staying away from static sleeps

 

Rather use ConditionalSleeps

if(tinRock.interact("Mine")) {                               
    new ConditionalSleep(3000) {
        @[member='Override']
        public boolean condition() {
            return myPlayer().isAnimating();
        }
     }.sleep();
}

 Sleep until you are animating then return in your loop while you are animating aka still mining.

(This also means if your character is animating but the rock is depleted it waits so you need to add an extra check if the rock you are mining is still not depleted otherwise even if you are animating you can consider yourself done mining that rock)

 

 

Sorry to hijack your thread (and to spontaneously ask a question), but is a conditional sleep always preferable to static sleeping?  For example, if I'm a clicking a spell like high alchemy or something, does it make sense to use a conditional sleep?  I can't imagine what the condition would be in that case.

 

Thanks

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.