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.

My first script: Feedback wanted :)

Featured Replies

Hi guys watched a few java vids and chris's tutorials and wanted to try and make a chaos druid script that banks and loots, its works preety well froze an hour in. Theres a few things i cant get my head around. I understand the ways ive got to a solution are probably inefficient and anything that i can improve or read up on please tell me.

1. is there a better way to do my second conditional sleep in killDruids method. Atm it will kill a druid that drops desired loot, kill another and then pick it up. it skips the goLoop method before it appears on floor.

2. My do loop doensnt work in goloot() method, if i get a double herb drop itll only pick one up and then pick the next one up next kill.

3. In goLoot i can only loot things that decrease the free spaces in invent so arnt noted or runes due to the way i program the conditional statement. Chaos druids drop many runes and mith bolts that i cant find a way of picking up. 

I got 2months of nothing to do and want to put most of my time into scripting. At the end i want to be able to have a preety much fully auto script (lvl 3 to money making) with muling. So any help and things to read java and osbot related would be greatly appreciated. Thanks

 

  public class Main extends Script {

        private final Area chaosDruidPen = new Area(3104,9944,3120,9923);
        private final String[] GOOD_LOOT = {"Grimy ranarr weed", "Grimy dwarf weed", "Grimy cadantine", "Grimy lantadyme", "Grimy kwuarm", "Grimy avantoe"};
        GroundItem loots;


        @Override
        public void onStart() throws InterruptedException {
        }

        @Override
        public int onLoop() throws InterruptedException {

            if (canKillDruids()) {
                log("Can kill druids");
                killDruids();
            } else {
                log("Cant kill druids need to bank");
                goBank();
            }
            return random(300, 600);
        }

        private boolean canKillDruids() {
            return !getInventory().isFull() && getInventory().contains("Lobster");
        }

        private void killDruids() {
            if (myPlayer().getHealthPercent() > 50) {
                if (inChaosDruidPen()) {
                    log("we are in the right area");
                    NPC druid = getNpcs().closest(cd -> cd != null && cd.getName().equals("Chaos druid") && (cd.getHealthPercent() > 0) && cd.isAttackable() && cd.exists() && getMap().canReach(cd));
                    if (druid != null && !getCombat().isFighting()) {
                        log("Found a druid to attack");
                        druid.interact("Attack");
                        new ConditionalSleep(3000, 1000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return getCombat().isFighting();
                            }
                        }.sleep();
                        new ConditionalSleep(20000, 2000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return druid.getHealthPercent() == 0;
                            }
                        }.sleep();
                        goLoot();
                    }
                }
            } else {

                int count2 = myPlayer().getHealthPercent() ;

                getInventory().interact("Eat", "Lobster");
                new ConditionalSleep(2000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return myPlayer().getHealthPercent()> count2;
                    }

            }.sleep();
            }
        }

        private void goLoot() {

            do {
                    GroundItem loots = getGroundItems().closest(l -> l != null && l.exists() && getMap().canReach(l) && Arrays.asList(GOOD_LOOT).contains(l.getName()));

                    if (loots != null) {
                        log("We've found some loot");
                        int count = getInventory().getEmptySlotCount();
                        loots.interact("Take");
                        new ConditionalSleep(5000, 1000) {
                            @Override
                            public boolean condition() throws InterruptedException {
                                return getInventory().getEmptySlotCount() < count;
                            }
                        }.sleep();
                    }
                } while ( loots != null && !getInventory().isFull());

            }



        private void goBank() throws InterruptedException {
            if (!Banks.EDGEVILLE.contains(myPosition())) {
                getWalking().webWalk(Banks.EDGEVILLE);
            }else if (!getBank().isOpen()) {
                    getBank().open();
                    if (getInventory().isFull() || !getInventory().contains("Lobster")) {
                        getBank().depositAllExcept("Air rune", "Mind rune");
                        if (getBank().contains("Lobster")) {
                            log("Withdrawing Lobbies");
                            getBank().withdraw("Lobster", 15);
                        } else {
                            stop(true);
                        }
                    }
                }
            }

		  private boolean inChaosDruidPen(){
            if (!chaosDruidPen.contains(myPosition())) {
                log("Webwalking to druids");
                getWalking().webWalk(chaosDruidPen);
                return true;
            }else{
                return true;

            }
        }
    }

 p.s sorry dont know how to do the "reveal hidden contents thing" soz :/

 

Edited by Luke Reading

There's a lot of things wrong lol but here's something I see a lot of people doing:

interact method() // boolean

New Conditional sleep...

 

Your conditional sleep should only execute if the interact method is true. The way you have it written, the conditional sleep always runs regardless if the interact actually happened.

 

It should always be like this:

 

if (druid.interact("attack")){

   insert conditiona sleep here...

}

 

It might be hard to get your head to wrap around it. You would think interacts should be a void right(void methods are usually actions and return nothing). Well if you interact, you want to know if it was successful. So that's why the action returns a boolean.

  • Author
23 minutes ago, dreameo said:

There's a lot of things wrong lol but here's something I see a lot of people doing:

interact method() // boolean

New Conditional sleep...

 

Your conditional sleep should only execute if the interact method is true. The way you have it written, the conditional sleep always runs regardless if the interact actually happened.

 

It should always be like this:

 

if (druid.interact("attack")){

   insert conditiona sleep here...

}

 

It might be hard to get your head to wrap around it. You would think interacts should be a void right(void methods are usually actions and return nothing). Well if you interact, you want to know if it was successful. So that's why the action returns a boolean.

Thanks dude for the help, ill implement this.

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.