Jump to content

Fishing script help


Recommended Posts

Posted

Hello, so I'm busy making a trout/salmon fishing script I know it's far from finished but somehow the bot always seems to get a nullpointer exception and I can't seem to find the problem... Can somebody please help me out?
 

Thanks in advance GaetanoH

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import java.awt.*;

/**
 * Created by Gaetano on 15/03/16.
 */
@ScriptManifest(name = "Salmon/Trout Fisher", author = "GaetanoH", version = 1.0, info = "", logo = "")
public class Fisher extends Script {

    public enum State {
        FISHING, DROPPING;
    }

    public State getState(){
        if(!inventory.contains("Raw trout") && !inventory.contains("Raw salmon")){
            log("fishing");
            return State.FISHING;
        }

        if(inventory.isFull() && inventory.contains("Raw trout") && inventory.contains("Raw salmon")){
            log("dropping");
            return State.DROPPING;
        }

        return null;
    }

    @Override
    public void onStart() throws InterruptedException {
        log("Welcome to my Barbarian Village Fisher/Cooker, start with a fly fishing rod with enough feathers, a tinderbox and a axe equipped.");
    }

    @Override
    public void onExit() throws InterruptedException {
        log("Thanks for using my script");
    }

    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()) {
            case FISHING:
                if(!myPlayer().isAnimating()){
                    getNpcs().closest("Fishing spot").interact("Lure");
                }
                break;
            case DROPPING:
                getInventory().dropAllExcept("Fly fishing rod", "Feather");
                break;
        }

        return random(500, 800);
    }

    @Override
    public void onPaint(Graphics2D g) {

    }
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...