Jump to content

Malcolm's Cabbage Picker


Malcolm
 Share

Recommended Posts

Be gentle. This is the very very VERY first thing I ever wrote. It's super simple but it works. Makes about 20k an hour. If anyone wants it they can use it. It picks cabbages at the Edgeville Monastery and banks at Edgeville bank.

NOTE: There are two walking instances line by line because for what ever reason walk() wanted to walk south of the Monastery towards Barb and go up to Edgeville that way so I just put another location in so it would walk the other way. 

Updated: On a suggestion I added in a conditional sleep to this.

Updated: Added more conditional sleeps were required. Added a new logo for this bad boy 

package cabbage_picker;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.ui.Message;

@ScriptManifest(author = "Malcolm", info = "Pick Cabbage", name = "Cabbage Picker", version = 0.2, logo = "https://imgur.com/kDRjP7M.png")
public class Main extends Script {

    int cabbagesBefore = 0;
    private final Area BANKS[] = { Banks.EDGEVILLE };
    private Area cabbagePatch = new Area(3057, 3508, 3046, 3501);

    public void onStart() {
        log("Cabbage Picker");
    }

    public void onExit() {
        log("Enjoy your Cabbages!");
    }

    public int onLoop() throws InterruptedException {

        if (getInventory().isFull()) {
            if (!Banks.EDGEVILLE.contains(myPlayer())) {
                getWalking().walk(new Area(3070, 3520, 3066, 3520).getRandomPosition());
                getWalking().walk(new Area(3087, 3518, 3078, 3515).getRandomPosition());
                walkToClosestBank();
            } else if (!getBank().isOpen()) {
                getBank().open();
                new ConditionalSleep(2000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return bank.isOpen();
                    }
                }.sleep();
                getBank().depositAll();
                new ConditionalSleep(2000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getInventory().isEmpty();
                    }
                }.sleep();
                getBank().close();
                new ConditionalSleep(2000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return !bank.isOpen();
                    }
                }.sleep();
                getWalking().walk(new Area(3087, 3518, 3078, 3515).getRandomPosition());
                getWalking().walk(cabbagePatch);
            } else {
                getBank().depositAll();
                new ConditionalSleep(2000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getInventory().isEmpty();
                    }
                }.sleep();
                getBank().close();
                new ConditionalSleep(2000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return !bank.isOpen();
                    }
                }.sleep();
                getWalking().walk(new Area(3087, 3518, 3078, 3515).getRandomPosition());
                getWalking().walk(cabbagePatch);
            }
        } else {
            if (!cabbagePatch.contains(myPlayer())) {
                getWalking().walk(cabbagePatch);
            } else {
                Entity Cabbage = objects.closest("Cabbage");
                cabbagesBefore = (int) getInventory().getAmount("Cabbage");
                if (Cabbage != null) {
                    if (!myPlayer().isAnimating()) {
                        if (!myPlayer().isMoving()) {
                            Cabbage.interact("Pick");
                            new ConditionalSleep(2000) {
                                @Override
                                public boolean condition() throws InterruptedException {
                                    return getInventory().getAmount("Cabbage") > cabbagesBefore;
                                }
                            }.sleep();
                        }
                    }
                }
            }
        }
        return random(600, 900);
    }

    public void walkToClosestBank() {
        getWalking().webWalk(BANKS);
    }

    public void onMessage(Message message) {
        if (message.getMessage().contains("You pick a cabbage"))
            cabbagesBefore++;
    }
}

 

Edited by Malcolm_OS
  • Like 1
  • Boge 1
Link to comment
Share on other sites

4 minutes ago, Hope said:

Thank you for this script, I will look into expanding my farm with this

No problem man. I just switched the webWalk to just walk to see if that eliminates it walking south of the Monastery. Seems to work so far. If you want to use it and there is an issue I'll fix it up for you.

Link to comment
Share on other sites

I refactored this for you - should give you an idea of how and when to use conditional sleeps :) Good job for your first script however!

I was unsure on the distances as I didn't test this so used web walking - if the distances are short enough that can be changed back to:

getWalking.walk();
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.Entity;

@ScriptManifest(author = "Malcolm", info = "Pick Cabbage", name = "Cabbage Picker", version = 0.1, logo = "")
public class Main extends Script {

    private Area cabbagePatch = new Area(3057, 3508, 3046, 3501);

    public void onStart() {
        log("Cabbage Picker");
    }

    public void onExit() {
        log("Enjoy your Cabbages!");
    }

    public int onLoop() throws InterruptedException {
        if (getInventory().isFull()) {
            if (!Banks.EDGEVILLE.contains(myPosition())) {
                getWalking().webWalk(Banks.EDGEVILLE);
            } else {
                if (!getBank().isOpen()) {
                    if (getBank().open()) {
                        new ConditionalSleep(5000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return getBank().isOpen();
                            }
                        }.sleep();
                    }
                } else {
                    if (getBank().depositAll()) {
                        new ConditionalSleep(10_000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return getInventory().isEmpty();
                            }
                        }.sleep();
                    }
                }
            }
        } else {
            if (!cabbagePatch.contains(myPosition())) {
                getWalking().webWalk(cabbagePatch);
            } else {
                Entity cabbage = objects.closest("Cabbage");
                long cabbagesBefore = getInventory().getAmount("Cabbage");
                if (cabbage != null) {
                    if (cabbage.interact("Pick")) {
                        new ConditionalSleep(10_000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return getInventory().getAmount("Cabbage") > cabbagesBefore;
                            }
                        }.sleep();
                    }
                }
            }
        }
        return 500;
    }
}

 

Edited by Ragnar Lothbrok
Link to comment
Share on other sites

37 minutes ago, Ragnar Lothbrok said:

I refactored this for you - should give you an idea of how and when to use conditional sleeps :) Good job for your first script however!

I was unsure on the distances as I didn't test this so used web walking - if the distances are short enough that can be changed back to:


getWalking.walk();

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.Entity;

@ScriptManifest(author = "Malcolm", info = "Pick Cabbage", name = "Cabbage Picker", version = 0.1, logo = "")
public class Main extends Script {

    private Area cabbagePatch = new Area(3057, 3508, 3046, 3501);

    public void onStart() {
        log("Cabbage Picker");
    }

    public void onExit() {
        log("Enjoy your Cabbages!");
    }

    public int onLoop() throws InterruptedException {
        if (getInventory().isFull()) {
            if (!Banks.EDGEVILLE.contains(myPosition())) {
                getWalking().webWalk(Banks.EDGEVILLE);
            } else {
                if (!getBank().isOpen()) {
                    if (getBank().open()) {
                        new ConditionalSleep(5000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return getBank().isOpen();
                            }
                        }.sleep();
                    }
                } else {
                    if (getBank().depositAll()) {
                        new ConditionalSleep(10_000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return getInventory().isEmpty();
                            }
                        }.sleep();
                    }
                }
            }
        } else {
            if (!cabbagePatch.contains(myPosition())) {
                getWalking().webWalk(cabbagePatch);
            } else {
                Entity cabbage = objects.closest("Cabbage");
                long cabbagesBefore = getInventory().getAmount("Cabbage");
                if (cabbage != null) {
                    if (cabbage.interact("Pick")) {
                        new ConditionalSleep(10_000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return getInventory().getAmount("Cabbage") > cabbagesBefore;
                            }
                        }.sleep();
                    }
                }
            }
        }
        return 500;
    }
}

 

I must admit. I probably write some of the messiest code around ?

Good thing I still know whats going on within that mess.

1 hour ago, gekkebakker said:

how can people even run 100 accounts ? my pc would crash heavily XD
 

 

nice script

Mine too man.

Thanks ?

Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

 Share

  • Recently Browsing   0 members

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