Jump to content

[BEGINNER] Need advice


Chris

Recommended Posts

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

    }

}
Link to comment
Share on other sites

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
  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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