Jump to content

Fishing script help


GaetanoH

Recommended Posts

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) {

    }
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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