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.

How to make ore detection more accurate?

Featured Replies

So my mining script currently works good enough if no one is around, but once more people show up my script fails to see that the rock as already been depleted and mines it anyways by the time it figures that out and switches rocks the rock it switches to is depleted as well and then a endless cycle starts.

So how can I make my script be able to know what rocks are depleted and which are not. I suppose using a color picker or something could work? but could it really work and how would you implement something like that.

I don't know anything about it but if someone else's mined it wouldn't it be a different id or something? If it works when it's just you there maybe you can go from there

  • Author
2 minutes ago, SagemodeJ said:

I don't know anything about it but if someone else's mined it wouldn't it be a different id or something? If it works when it's just you there maybe you can go from there

As far as I have been able to see it is the same id regardless of it is mined or not. Colorpicker could work but there is a range of RGB values for a non-depleted rock, So idk how I would make that range work. Or even how to really implement a good color picker.

1 minute ago, loopback said:

As far as I have been able to see it is the same id regardless of it is mined or not. Colorpicker could work but there is a range of RGB values for a non-depleted rock, So idk how I would make that range work. Or even how to really implement a good color picker.

Hmmm not sure but goodluck with the solution somebody will help :)

19 minutes ago, loopback said:

So my mining script currently works good enough if no one is around, but once more people show up my script fails to see that the rock as already been depleted and mines it anyways by the time it figures that out and switches rocks the rock it switches to is depleted as well and then a endless cycle starts.

So how can I make my script be able to know what rocks are depleted and which are not. I suppose using a color picker or something could work? but could it really work and how would you implement something like that.

 

You can use the modified colours of the object to check if the rock has ore.

Here is an enum I already created:

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

    private final short COLOUR;

    Rock(final int COLOUR) {
        this.COLOUR = (short) COLOUR;
    }

    public boolean hasOre(final RS2Object object){
        if (object == null || object.getModifiedColors() == null || !"Rocks".equals(object.getName())) {
            return false; 
        }
        
        for(final short colour : object.getDefinition().getModifiedModelColors()){
            if(colour == this.COLOUR) {
                return true;
            }
        }
        return false;
    }
}

 

You can then use it like so:

RS2Object currentRock;

@Override
public final int onLoop() throws InterruptedException {
    if (!myPlayer().isAnimating() || !Rock.TIN.hasOre(currentRock)) {
        mine(); 
    }
    return 200;
}

private void mine() {
    currentRock = getObjects().closest(obj -> Rock.TIN.hasOre(obj));
    if (currentRock != null && currentRock.interact("Mine")) {
       new ConditionalSleep(5000) {
           @Override
           public boolean condition() {
               return myPlayer().isAnimating() || !Rock.TIN.hasOre(currentRock); 
           }
       }.sleep();
    }
}

 

Sorry if there are any syntax errors, i'm just leaving work. Will check it when i'm home.

Edited by Explv

  • Author

Alright I'll be sure to give these a try a bit later on when I have the time. Thanks !

  • Author
6 hours ago, dreameo said:

null rocks have a specific id 

I haven't been able to see it, Care to share how to get the ID's?

  • Author

Ok so I have been able to get the script to not click on depleted rocks. However how would I tell it to switch rocks when someone depletes the rock while mining?

  • Author
17 minutes ago, Juggles said:

ID is different when depleted

Just tested, And I guess I never hovered over them fast enough to see that ID change. Well that's what I get for doing everything at 4am

  • Author

Okay so I got everything working mostly, except now my script sometimes decides to switch to another rock even though neither is depleted and my script will still click the same rock like 2 or 3 times like it spam clicking.

EDIT: I am currently using sleep to get around this problem I am pretty sure it has to do with my script not knowing if it is mining\animating or not. But I have methods in my script that should cover that.

Edited by loopback

1 hour ago, loopback said:

Okay so I got everything working mostly, except now my script sometimes decides to switch to another rock even though neither is depleted and my script will still click the same rock like 2 or 3 times like it spam clicking.

EDIT: I am currently using sleep to get around this problem I am pretty sure it has to do with my script not knowing if it is mining\animating or not. But I have methods in my script that should cover that.

You should use something called a "ConditionalSleep", search the forums and API for it's use.

Your condition within this should be if you haven't animated in the last 3 seconds or so.

For a split second, the player will not animate and pause in between swings, so that is probably messing up your current logic.

  • Author
37 minutes ago, Final said:

You should use something called a "ConditionalSleep", search the forums and API for it's use.

Your condition within this should be if you haven't animated in the last 3 seconds or so.

For a split second, the player will not animate and pause in between swings, so that is probably messing up your current logic.

I have that in my script already, and it checks if my player has been animating or moving. However my character still clicks 1-3 times per rock and randomly switches rocks for no reason, The ConditionalSleep has helped a bit (I am using the one from your tut) but they don't seem to solve the problem just work around it by delaying how much it happens.

        if (Iron != null && !isMining()) {
            log("chk_iron_mining");
            new Sleep(() -> !Rock.IRON.hasOre(Iron) || !isMining(), 10000).sleep();
            Iron.interact("Mine");
        }

    private boolean isMining() {

        if (myPlayer().isAnimating() && myPlayer().getInteracting() != null && myPlayer().isMoving()) {
            return true;
        }
            return false;
    }

            case MINEIron:

                sleep(900);
                MineIron();
                sleep(random(1250, 1600));
                break;

    private State getState() {
        if (getInventory().isFull())
            return State.BANK;
        if (!getInventory().isFull() && !isMining() && ore == 0)
            return State.MINECopper;
        if (!getInventory().isFull() && !isMining() && ore == 1)
            return State.MINETin;
        if (!isMining() && !getInventory().isFull() && ore == 2)
            return State.MINEIron;
        return State.WAIT;
    }

Relevant code snippets.

 

EDIT: I think one of the problems is that the animation for mining does not stop always if it has been depleted by someone else

Edited by loopback

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.