Jump to content

Draynor Village Fisher/Banker [Open Source]


Lol_marcus

Recommended Posts

Feel free to modify as you wish. :)

It fishes for sardines and herrings, if you want to make it fish shrimps just change the "Bait" part to "Net", and edit the string to "Fishing net".

package osrs;

import org.osbot.rs07.api.Bank;
import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(name = "Draynor Village Fisher & Banker", author = "Marcus", version = 1.0, info = "Fishes and banks at Draynor", logo = "")
public class Main extends Script {

    private final String[] TOOLS = {"Fishing rod", "Fishing bait"};
    
    private Area fishArea = new Area(3084, 3234, 3088, 3224); 


    @Override
    public void onStart() {
        log("Starting script...");
    }

    @Override
    public int onLoop() throws InterruptedException {
        
        if (getInventory().isFull()) {
            walkToBank();
            depositInventory();
        } else {
            walkToSpot();
            fish();
        }
        return random(200, 300);
    }

    private void walkToBank() throws InterruptedException {
        log("Walking to bank...");
        getWalking().webWalk(Banks.DRAYNOR);
    }

    private void depositInventory() throws InterruptedException {
    	
    	Bank bank = getBank();
        Inventory inventory = getInventory();
        
        log("Depositing inventory...");
    	if (Banks.DRAYNOR.contains(myPosition())) {
            bank.open();
            Sleep.sleepUntil(() -> bank.isOpen(), random(500, 1000));
            if (!inventory.contains(TOOLS) && !bank.contains(TOOLS)) {
                log("Tools not found in the bank. Stopping script...");
                stop(false);
            }
            bank.depositAllExcept(TOOLS);
            Sleep.sleepUntil(() -> inventory.isEmptyExcept(TOOLS), random(500, 1000));
            if (bank.contains(TOOLS) && !inventory.contains(TOOLS)) {
                bank.withdraw("Fishing rod", 1);
                bank.withdrawAll("Fishing bait");
                Sleep.sleepUntil(() -> getInventory().contains(TOOLS), random(500, 1000));
            }
            bank.close();
            Sleep.sleepUntil(() -> !bank.isOpen(), random(500, 1000));
    	}
    }

    private void walkToSpot() throws InterruptedException {
        log("Walking to fishing spot...");
        getWalking().webWalk(fishArea);
    }

    private void fish() throws InterruptedException {
        log("Fishing...");
        NPC fishingSpot = getNpcs().closest("Fishing spot");
        if (fishingSpot != null && fishingSpot.exists()) {
            fishingSpot.interact("Bait");
            sleep(random(1500,2000));
            getMouse().moveOutsideScreen();
            Sleep.sleepUntil(() -> !myPlayer().isAnimating() || inventory.isFull(), random(90000, 120000));
        }
    }
}

 

  • Like 1
  • Sad 1
Link to comment
Share on other sites

Made some changes

Spoiler
    @Override
    public int onLoop() throws InterruptedException {
        if (getInventory().isFull()) {
            depositInventory();
        } else if (getBank().isOpen()) {
            getBank().close();
        } else if (!fishArea.contains(myPosition())) {
            walkToSpot();
        } else {
            fish();
        }
        return random(200, 300);
    }

    private void walkToBank() throws InterruptedException {
        log("Walking to bank...");
        getWalking().webWalk(Banks.DRAYNOR);
    }

    private void depositInventory() throws InterruptedException {
        if (!Banks.DRAYNOR.contains(myPosition())) {
            walkToBank();
            return;
        }

        log("Depositing inventory...");
        if (getBank().isOpen()) {
            if (!getInventory().contains(TOOLS) && !getBank().contains(TOOLS)) {
                log("Tools not found in the bank. Stopping script...");
                stop(false);
            }

            if (getBank().depositAllExcept(TOOLS)) {
                Sleep.sleepUntil(() -> getInventory().isEmptyExcept(TOOLS), random(500, 1000));
            }

            if (!getInventory().contains(TOOLS)) {
                getBank().withdraw("Fishing rod", 1);
                getBank().withdrawAll("Fishing bait");
                Sleep.sleepUntil(() -> getInventory().contains(TOOLS), random(500, 1000));
            }
        } else if (!getBank().open()) {
            // If I remember correctly open has a built-in sleep
            log("Failed to open bank...");
        }
    }

    private void walkToSpot() {
        log("Walking to fishing spot...");
        getWalking().webWalk(fishArea);
    }

    private void fish() {
        log("Fishing...");
        final NPC fishingSpot = getNpcs().closest("Fishing spot");

        if (fishingSpot == null) {
            return;
        }

        if (fishingSpot.interact("Bait")) {
            getMouse().moveOutsideScreen();
            getBot().getFocusEventHandler().loseFocus();
            Sleep.sleepUntil(()-> !fishingSpot.exists() || getInventory().isFull(), random(90_000, 120_000));
        }
    }

 

Link to comment
Share on other sites

6 minutes ago, Gunman said:

Made some changes

  Hide contents
    @Override
    public int onLoop() throws InterruptedException {
        if (getInventory().isFull()) {
            depositInventory();
        } else if (getBank().isOpen()) {
            getBank().close();
        } else if (!fishArea.contains(myPosition())) {
            walkToSpot();
        } else {
            fish();
        }
        return random(200, 300);
    }

    private void walkToBank() throws InterruptedException {
        log("Walking to bank...");
        getWalking().webWalk(Banks.DRAYNOR);
    }

    private void depositInventory() throws InterruptedException {
        if (!Banks.DRAYNOR.contains(myPosition())) {
            walkToBank();
            return;
        }

        log("Depositing inventory...");
        if (getBank().isOpen()) {
            if (!getInventory().contains(TOOLS) && !getBank().contains(TOOLS)) {
                log("Tools not found in the bank. Stopping script...");
                stop(false);
            }

            if (getBank().depositAllExcept(TOOLS)) {
                Sleep.sleepUntil(() -> getInventory().isEmptyExcept(TOOLS), random(500, 1000));
            }

            if (!getInventory().contains(TOOLS)) {
                getBank().withdraw("Fishing rod", 1);
                getBank().withdrawAll("Fishing bait");
                Sleep.sleepUntil(() -> getInventory().contains(TOOLS), random(500, 1000));
            }
        } else if (!getBank().open()) {
            // If I remember correctly open has a built-in sleep
            log("Failed to open bank...");
        }
    }

    private void walkToSpot() {
        log("Walking to fishing spot...");
        getWalking().webWalk(fishArea);
    }

    private void fish() {
        log("Fishing...");
        final NPC fishingSpot = getNpcs().closest("Fishing spot");

        if (fishingSpot == null) {
            return;
        }

        if (fishingSpot.interact("Bait")) {
            getMouse().moveOutsideScreen();
            getBot().getFocusEventHandler().loseFocus();
            Sleep.sleepUntil(()-> !fishingSpot.exists() || getInventory().isFull(), random(90_000, 120_000));
        }
    }

 

Ic4TyiE.png

Link to comment
Share on other sites

  • 1 year later...

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...