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

[BEGINNER] Need advice

Featured Replies

Please do not cry for poor scripting ;) :doge:

 

I can get it to walk -> from cows -> 1st floor -> second ->

how do I make it start banking? make an if statement like below? 

if (BANK_AREA.contains(myPlayer().getposition){
    return CKiller.State.BANK;
}

Here is what I have....(lol states I know)

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


import java.awt.*;

@ScriptManifest(author = "Sinatra", info = "Basic Cow Killer & Banker!", name = "CKiller", version = 0.1, logo = "")
public class CKiller extends Script {
    private final Area MONSTER_AREA = new Area(3242,3255,3265,3296);
    private final Area BANK_AREA = new Area(3207,3216,3210,3220);
    private final Position[] PATH_TO_BANK = {
            new Position(3250,3266,0), new Position(3250,3258,0), new Position(3253,3249,0), new Position(3258,3243,0),
            new Position(3259,3234,0), new Position(3259,3227,0), new Position(3249,3225,0), new Position(3243,3225,0),
            new Position(3235,3225,0), new Position(3230,3218,0), new Position(3222,3218,0), new Position(3215,3218,0),
            new Position(3212,3209,0), new Position(3206,3208,0)
    };
    private final Position[] PATH_TO_STORAGE ={
            new Position(3208,3220,2)
    };
    private final Position[] PATH_TO_MONSTER1 = {
            new Position(3206,3215,2), new Position(3206,3209,2)
    };
    private final Position[] PATH_TO_MONSTER2 ={
            new Position(3206,3208,0), new Position(3212,3209,0), new Position(3215,3218,0), new Position(3222,3218,0),
            new Position(3230,3218,0), new Position(3235,3225,0), new Position(3243,3225,0), new Position(3249,3225,0),
            new Position(3259,3227,0), new Position(3259,3234,0), new Position(3258,3243,0), new Position(3253,3249,0),
            new Position(3250,3258,0), new Position(3250,3266,0)
    };


    private enum State{
        WALK_TO_BANK, WALK_TO_MONSTER, COMBAT, BANK
    }
    private State getState(){
        if(inventory.isFull() && inventory.contains(new String("Cowhide"))) {
            return  State.WALK_TO_BANK;
        }
        return State.COMBAT;
    }

    @Override
    public void onStart() {
        log("The start of maxed combat & bank !");
    }

    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()){
            case COMBAT:
                final NPC Cow = this.npcs.closest("Cow", "Cow calf");
                if(!this.myPlayer().isUnderAttack() && !Cow.isUnderAttack() && !this.myPlayer().isAnimating()){
                    Cow.interact("Attack");
                    sleep(random(300,600));
                }
                else
                    sleep(random(300,600));

                break;
            case BANK:
                RS2Object bankBooth = (RS2Object)this.objects.closest(new String[] {"Bank booth"});
                if (bankBooth != null){
                    if (bankBooth.interact("Bank"))
                    {
                        new ConditionalSleep(10000) {
                            @Override
                            public  boolean condition() throws InterruptedException {
                                return getBank().isOpen();
                            }
                        }.sleep();
                        if (this.getBank().isOpen()){
                            this.getBank().depositAll();
                            sleep(random(377,544));
                        }
                    }
                    this.bank.close();
                    this.log("State: BANKING");
                }
                break;
            case WALK_TO_BANK:
                localWalker.walkPath(PATH_TO_BANK); //path to bank from cows to first floor
                sleep(random(300, 600));
                objects.closest("Staircase").interact("Climb-up"); //up 1 floor
                sleep(random(300, 600));
                objects.closest("Staircase").interact("Climb-up"); // up again
                sleep(random(300, 600));
                localWalker.walkPath(PATH_TO_STORAGE); //top lumby bank floor
                sleep(random(300, 700));
                break;
            case WALK_TO_MONSTER:
                localWalker.walkPath(PATH_TO_MONSTER1); //path from bank to staircase
                objects.closest("Staircase").interact("Climb-down"); //down 1 floor
                sleep(random(300,600));
                objects.closest("Staircase").interact("Climb-down"); //down again
                sleep(random(300,600));
                localWalker.walkPath(PATH_TO_MONSTER2); //path to cows
                break;
        }
        return (random(200,300));
    }

    @Override
    public void onExit() {
        log("Thanks for using my cow killer and Banker!");
        log("Please leave script feedback on my post!");
    }

    @Override
    public void onPaint(Graphics2D g) {

    }

}
if(BANKAREA.contains(myPlayer()&&inventory.isFull())
return State.BANK;


Didn't see you had banking already figured out, that's pretty much all you'll need to check for to start banking.

 

Actually thinking back over this, I would do inventory.contains("Cowhide"), that way, you don't run into issues with it not banking and getting stuck in the bank.

Edited by Twin

  • Author
if(BANKAREA.contains(myPlayer()&&inventory.isFull())
return State.BANK;


Didn't see you had banking already figured out, that's pretty much all you'll need to check for to start banking.

 

Actually thinking back over this, I would do inventory.contains("Cowhide"), that way, you don't run into issues with it not banking and getting stuck in the bank.

 

i get this error.. any ideas?

5731668985.png

i get this error.. any ideas?

5731668985.png

 

Add another ) after myPlayer(), That was my fault in the original code I gave you.

 

Edited by Twin

I'd work on that walk to bank state a bit, its poorly designed and full of patterns.

 

Conditional Sleeps are ideal, as they will wait until a condition is true, or the time out has been reached (user defined).

Edited by Tom

  • 3 years later...
  • Author

wow chris nice code it looks like shit!

Just now, Chris said:

wow chris nice code it looks like shit!

thank :feels:

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.