Jump to content

How to get any bank booths location


Recommended Posts

Posted (edited)

getBank() returns an instance of the Bank class, the bank class does not represent an actual bank but rather an "API regarding bank functionality".

 

Though it has to get the actual bank booth object / npc from somewhere right? I'm just looking for a way to access this so I can get its position when it finds one

Edited by Mykindos
Posted
RS2Object booth = getObjects().closest("Bank booth);

booth.interact("Bank"); //clicks bank
booth.getPosition(); //returns position

But you should already know that right?

 

 

I was looking for a more convenient method of getting all types of banks, like npcs  as well.

 

Unless OSBot doesnt interact with npc banks, in that case I am retarded.

Posted

If you want to account for both NPCs & Objects:

 

1. Put all NPCs and RS2Objects in an Entity list.

2. Filter that list for entities that have a "Bank" action.

3. Take a random entity from the list or sort the whole list by distance using a Comparator and take the first one (if you'd like the closest).

4.Profit.

 

Alternatively you can look for the closest NPC and then for the closest Object and then compare the two and take the closest one.

Posted (edited)
private final String bankBooth = "Bank Booth";

Entity booth = getObjects().closest(bankBooth);
                
                if (booth != null) {
                    camera.toPosition(booth.getPosition());
                }
/* or */

Entity booth = getObjects().closest(bankBooth);

                if (booth != null) {
                    camera.toPosition(new Position(booth.getPosition()));
                }

all I can think of

Edited by Acinate
Posted (edited)
// variables

    private Area bankArea = new Area(x1, y1, x2, y2);


// main method

    private void openBank() {
        int x = random(1, 3);
        adjustCamera();
        if (x == 1 || x == 2) {
            Entity bankBooth = objects.closest("Bank booth");
            if (bankBooth.exists() && bankArea.contains(bankBooth)) {
                if (bankBooth.isVisible()) {
                    bankBooth.interact("Bank");
                    sleepFor(500, 900);
                }
                if (!bankBooth.isVisible()) {
                    localWalker.walk(bankBooth.getPosition(), false);
                    sleepFor(750, 1500);
                }
            }
        }
        if (x == 3) {
            NPC banker = npcs.closest("Banker");
            if (banker.exists() && bankArea.contains(banker)) {
                if (banker.isOnScreen()) {
                    banker.interact("Bank");
                    sleepFor(500, 900);
                }
                if (!banker.isOnScreen()) {
                    localWalker.walk(banker.getPosition(), false);
                    sleepFor(750, 1500);
                }
            }
        }
    }


// true or false methods

    private boolean bankScreenOpen() {
        return this.bank.isOpen();
    }

    private boolean playerIsAtBank() {
        return this.bankArea.contains(myPlayer());
    }


// custom methods

    private void sleepFor(int x, int y) {
        try {
            sleep(random(x, y));
        } catch (InterruptedException e) {
            log("interrupted sleep exception");
            e.printStackTrace();
        }
    }

    private void adjustCamera() {
        if (camera.getPitchAngle() <= 60) {
            camera.toTop();
        }
    }

hope this helps! I plan on releasing some tutorials soon to help the community grow, since I noticed there was little to no tutorials. In the walk method, you can change the false to true to change the camera angle sometimes. you should also be able to figure out how to get the camera to do your bidding with the examples above. Normally i only move the camera up and down when i play which is why i have adjustCamera(). i use it quite often actually.

Edited by shiny greninja

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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