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.

Cases utilized correctly?

Featured Replies

Hi Guys,

I am new to scripting and have been learning through videos, threads and the OSbot scripting discord. Below is a script I have made for Barbarian Fishing, cooking and banking. 

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;



@ScriptManifest(logo ="" , name ="Barbarian Fishing! xD" , version =1.0 , info ="Fish and Cook, Trout and Salmon. + Banking!" , author ="J$" )

public class Main extends Script {

    public final Area barbarianFish = new Area(3109, 3434, 3102, 3423);
    public final Area bankArea = new Area(3094, 3489, 3093, 3491);
    private final org.osbot.rs07.api.map.Position bankTeller = new org.osbot.rs07.api.map.Position(3094, 3491, 0);



    enum State {
        WALK_TO_FISH, WALK_TO_BANK, COOK_FISH, DEPOSIT, IDLE, FISH_FISH
    }


    @Override
    public void onStart() throws InterruptedException {

    }


    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()){

            case FISH_FISH:
                log("FISHING THE FISH");
                NPC salmon = getNpcs().closest("Rod Fishing spot");
                if (barbarianFish.contains(myPlayer())) {
                    if (!myPlayer().isAnimating()) {
                        if (salmon != null) {
                            if (getMap().canReach(salmon)) {
                                if (salmon.interact("Lure")) {
                                    log("Starting to fish.");
                                    getCamera().movePitch(67);
                                    getCamera().moveYaw(3);
                                    getMouse().moveOutsideScreen();
                                }
                            } else {
                                Sleep.sleepUntil(() -> myPlayer().isAnimating(), 3000);
                            }
                        }
                    }
                }
                break;

            case COOK_FISH:
                log("COOKING FISH");
                if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) {
                    RS2Widget cookOpt = getWidgets().get(270, 14, 38);
                    RS2Object fire = getObjects().closest("Fire");
                    if (fire != null) {
                        if (!myPlayer().isAnimating()) {
                            if (cookOpt != null) {
                                cookOpt.interact("Cook");
                                getMouse().moveOutsideScreen();
                            } else {
                                sleep(1000);
                                if (!myPlayer().isAnimating()) {
                                    getInventory().interactWithNameThatContains("Use", "Raw salmon", "Raw trout");
                                    fire.interact("Use");
                                }
                            }
                        }
                    }
                }
                break;

            case WALK_TO_FISH:
                log("WALKING TO FISH");
                getWalking().webWalk(barbarianFish);
                break;

            case WALK_TO_BANK:
                log("WALKING TO BANK");
                getWalking().webWalk(bankArea);
                break;

            case DEPOSIT:
                log("DEPOSITING IN BANK");
                if (bank.isOpen()){
                    bank.depositAllExcept("Fly fishing rod", "Feather");
                } else {
                    NPC bankBooth = getNpcs().closest("Banker");
                    if (bankBooth != null && bankBooth.interact("Bank")){
                        new ConditionalSleep(1000){
                            @Override
                            public boolean condition(){
                                return bank.isOpen();
                            }
                        }.sleep();
                    }
                }
                break;

            case IDLE:
                log("IDLING");
        }
        return 700;
    }

    private State getState() {

        if (getInventory().isEmptyExcept("Fly fishing rod", "Feather", "Raw salmon", "Raw trout") && barbarianFish.contains(myPlayer())) {
            log("FISH_FISH");
            return State.FISH_FISH;
        } else if (!barbarianFish.contains(myPlayer()) && getInventory().isEmptyExcept("Fly fishing rod", "Feather")) {
            log("WALK_TO_FISH");
            return State.WALK_TO_FISH;
        } else if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) {
            log("COOK_FISH");
            return State.COOK_FISH;
        } else if (getInventory().contains("Salmon", "Trout") && bankArea.contains(myPlayer())) {
            log("DEPOSIT");
            return State.DEPOSIT;
        } else if (!bankArea.contains(myPlayer())) {
            log("WALK_TO_BANK");
            return State.WALK_TO_BANK;
        }
        log("IDLE");
        return State.IDLE;
    }

    @Override
    public void onExit() throws InterruptedException {

    }

}

The problem I am running into is, I can get the bot to perform 4/5 functions, but not all 5. For example, as the scripts sits now, It will bank if full of Cooked Fish, Deposit, Walk to Fish, Fish the fish, but now gets stuck when fishing because it wont recognize the inv.isFull(). 

 

I feel like I am in the right direction, but missing something small or misunderstanding something small rather. Any help and or feedback on the script would be appreciated as well. Thanks!

 

if your invent is full of raw fish, 

if (getInventory().isEmptyExcept("Fly fishing rod", "Feather", "Raw salmon", "Raw trout") && barbarianFish.contains(myPlayer())) {
            log("FISH_FISH");
            return State.FISH_FISH;

will still return FISH_FISH, as technically inventory is still empty except for those items, add in a check for if inventory is not full and you should be good.

  • Author
23 minutes ago, GPSwap said:

if your invent is full of raw fish, 


if (getInventory().isEmptyExcept("Fly fishing rod", "Feather", "Raw salmon", "Raw trout") && barbarianFish.contains(myPlayer())) {
            log("FISH_FISH");
            return State.FISH_FISH;

will still return FISH_FISH, as technically inventory is still empty except for those items, add in a check for if inventory is not full and you should be good.

I do that here. Do I need to have it check before? - if (!getInventory().isFull() && barbarian.Fish.contains(myPlayer))) {

 

} else if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) {
    log("COOK_FISH");

Edit: 

private State getState() {

    if (!getInventory().isFull() && barbarianFish.contains(myPlayer())) {
        log("FISH_FISH");
        return State.FISH_FISH;
    } else if (!barbarianFish.contains(myPlayer()) && getInventory().isEmptyExcept("Fly fishing rod", "Feather")) {
        log("WALK_TO_FISH");
        return State.WALK_TO_FISH;
    } else if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) {
        log("COOK_FISH");
        return State.COOK_FISH;
    } else if (getInventory().contains("Salmon", "Trout") && bankArea.contains(myPlayer())) {
        log("DEPOSIT");
        return State.DEPOSIT;
    } else if (!bankArea.contains(myPlayer())) {
        log("WALK_TO_BANK");
        return State.WALK_TO_BANK;
    }
    log("IDLE");
    return State.IDLE;
}

and is now working. Thank you @GPSwap

Edited by m3JS

2 minutes ago, m3JS said:

I do that here. Do I need to have it check before? - if (!getInventory().isFull() && barbarian.Fish.contains(myPlayer))) {

 


} else if (getInventory().contains("Raw trout", "Raw salmon") && getInventory().isFull()) {
    log("COOK_FISH");

 

 

you check for your fish_fish state first, so if that is true it wont move past it, do something like and it should work 
 

     if (getInventory().isEmptyExcept("Fly fishing rod", "Feather", "Raw salmon", "Raw trout") && barbarianFish.contains(myPlayer()) && !getInventory.isFull()) {
            log("FISH_FISH");
            return State.FISH_FISH;

 

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.