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.

TSRunner - Need some feedback

Featured Replies

Hi Scripting Community,

I would like to get some feedback on my first script TSRunner (Trout Salmon Runner).

I have some background in software development and testing but would not consider myself a developer.

I have written the below script to run to the fishing spot in barb village and collect fish on the ground , then head to the GE to bank and repeat (I chose not to go to edge bank)- I have tested it for 2hrs+ and seems to be working (20-25k per hour)- albeit it seems to be competing with many looting bots in the area.

One problem I have been experiencing is if there is a large loot pile on the floor, it always seems to try and "take" the first one. I'm guessing it is trying to "take" index 0. Can you specify the index in anyway so say if there is a pile on the floor it will take the 6th or 7th item if it exists?

529794267_ScreenShot2020-04-02at7_55_29am.png.34c5c1aec0333776131df701a16b94ed.png

Code:

import java.awt.Graphics2D;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.event.WebWalkEvent;
import org.osbot.rs07.event.webwalk.PathPreferenceProfile;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Aurial", info = "Trout - Salmon Runner", logo = "", name = "TSRunner", version = 1)
public class TSRunnerScript extends Script {

    private Area fishLocation = new Area(3104, 3435, 3109, 3431);
    private Area bankLocation = new Area(3161, 3492, 3168, 3486);

    enum State {
        RUNNING2BANK, RUNNING2FISH, LOOTING;
    }

    private State currentState;

    private Boolean checkInventoryIsEmpty(){
        if(inventory.isEmpty()){
            log("TSRunner || Inventory IS empty.");
            return true;
        }
        else {
            log("TSRunner || Inventory IS NOT empty!");
            log("TSRunner || Will attempt to Bank items");
            return false;
        }
    }

    private void goToFishSpot() throws InterruptedException {
        if(!inventory.isEmpty()){
            currentState = State.RUNNING2BANK;
        }
        else {
            log("TSRunner || Heading to fishing location...");
            WebWalkEvent webEvent = new WebWalkEvent(fishLocation);
            webEvent.useSimplePath();
            PathPreferenceProfile ppp = new PathPreferenceProfile();
            ppp.setAllowTeleports(false);
            webEvent.setPathPreferenceProfile(ppp);
            execute(webEvent);
            log("TSRunner || Arrived at fishing location...");
            sleep(random(300,500));
        }
    }

    private void lootFish() throws InterruptedException {
        log("TSRunner || Looting fish...");
        while (!inventory.isFull()){
            if(!myPlayer().isAnimating() || !myPlayer().isMoving() || !myPlayer().isUnderAttack()){
                GroundItem fishies = getGroundItems().closest("Salmon", "Trout", "Raw salmon", "Raw trout");
                if(fishies != null){
                    if(inventory.isEmpty()){
                        fishies.interact("Walk here");
                    }
                    sleep(random(20, 333));
                    fishies.interact("Take");
                    sleep(random(20, 333));
                }
            }
        }
        if(inventory.isFull()){
            log("TSRunner || Inventory is full.");
            currentState = State.RUNNING2BANK;
        }
    }

    private void goToBankAndDepositFish() throws InterruptedException {
        log("TSRunner || Heading to bank location...");
        WebWalkEvent webEvent = new WebWalkEvent(bankLocation);
        webEvent.useSimplePath();
        PathPreferenceProfile ppp = new PathPreferenceProfile();
        ppp.setAllowTeleports(false);
        webEvent.setPathPreferenceProfile(ppp);
        execute(webEvent);
        log("TSRunner || Arrived at bank location...");
        sleep(random(300,500));
        if (!myPlayer().isAnimating() || !myPlayer().isMoving() || !myPlayer().isUnderAttack()) {
            log("TSRunner || Attempting to deposit all...");
            sleep(random(300,500));
            if (inventory.isFull()) {
                if (getBank().isOpen()) {
                    sleep(random(200,300));
                    getBank().depositAll();
                    sleep(random(50, 100));
                    log("TSRunner || Banking finished...");
                    currentState = State.RUNNING2FISH;
                }
                else {
                    sleep(random(300,500));
                    getBank().open();
                    sleep(random(200,300));
                    getBank().depositAll();
                    sleep(random(50, 100));
                    log("TSRunner || Banking finished...");
                    currentState = State.RUNNING2FISH;
                }
            }
        }
    }

    @Override
    public void onStart(){
        log("-----------------------");
        log("TSRunner || Starting...");
        log("-----------------------");
        if (checkInventoryIsEmpty()){
            currentState = State.RUNNING2FISH;
        }
        else {
            currentState = State.RUNNING2BANK;
        }
    }

    @Override
    public int onLoop() throws InterruptedException{
        switch (currentState){
            case RUNNING2FISH:
                return first();
            case LOOTING:
                return second();
            case RUNNING2BANK:
                return third();
        }
        return random(200, 300);
    }

    private int first() throws InterruptedException {
        goToFishSpot();
        currentState = State.LOOTING;
        return random(200, 300);
    }

    private int second() throws InterruptedException{
        lootFish();
        return random(200,300);
    }

    private int third() throws InterruptedException{
        goToBankAndDepositFish();
        return random(200,300);
    }

    @Override
    public void onExit(){
        log("---------------------");
        log("TSRunner || Ending...");
        log("---------------------");
    }

    @Override
    public void onPaint(Graphics2D g){
    }
}

Made a script that does the same exact thing, just had it spam the hell out of the loot pile. Seems to work well. Maybe you can just have it click the ground-tile with loot on it if it keeps insisting on rightclicking and doing index 0?
 

Another option would be to add all grounditems to a list, then have it do a different index from that list when looting.

  • Author
34 minutes ago, botelias said:

Made a script that does the same exact thing, just had it spam the hell out of the loot pile. Seems to work well. Maybe you can just have it click the ground-tile with loot on it if it keeps insisting on rightclicking and doing index 0?
 

Another option would be to add all grounditems to a list, then have it do a different index from that list when looting.

Thanks for the advice - really appreciate it.

Could you show me an example for the grounditems -> list option?

You can do something like this: 

Stream<GroundItem> fishItems = getGroundItems().getAll().stream().filter((e) -> e.getName().contains("Raw"));

You can than manipulate that data to do as you wish.

Create an account or sign in to comment

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.