Jump to content

How to get any bank booths location


Tom

Recommended Posts

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

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

// 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
Link to comment
Share on other sites

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