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.

How to walk to the closest Bank?

Featured Replies

I'm attempting to create my first script. I've made a good amount of progress but I don't know how to determine the Bank closest to my current position and walk to it. I searched the forum but didn't find a relevant solution.
Any help is appreciated.

Edited by Adept



//Credits to LoudPacks

public class BankHandler{
private enum Bank {
    DRAYNOR(Banks.DRAYNOR),
    AL_KHARID(Banks.AL_KHARID),
    LUMBRIDGE(Banks.LUMBRIDGE_UPPER),
    FALADOR_EAST(Banks.FALADOR_EAST),
    FALADOR_WEST(Banks.FALADOR_WEST),
    VARROCK_EAST(Banks.FALADOR_EAST),
    VARROCK_WEST(Banks.VARROCK_WEST),
    SEERS(Banks.CAMELOT),
    CATHERBY(Banks.CATHERBY),
    EDGEVILLE(Banks.EDGEVILLE),
    YANILLE(Banks.YANILLE),
    GNOME_STRONGHOLD(Banks.GNOME_STRONGHOLD),
    ARDOUNGE_NORTH(Banks.ARDOUGNE_NORTH),
    ARDOUNE_SOUTH(Banks.ARDOUGNE_SOUTH),
    CASTLE_WARS(Banks.CASTLE_WARS),
    DUEL_ARENA(Banks.DUEL_ARENA),
    PEST_CONTROL(Banks.PEST_CONTROL),
    CANIFIS(Banks.CANIFIS),
    BLAST_FURNACE(new Area(1949, 4956, 1947, 4958)),
    TZHAAR(Banks.TZHAAR),
    GRAND_EXCHANGE(Banks.GRAND_EXCHANGE);

    private final Area area;

    Bank(Area area) {
        this.area = area;
    }
}

    public static Area closestTo(Entity e) {
        HashMap<Bank, Integer> distMap = new HashMap<Bank, Integer>();
        for (Bank b : Bank.values()) {
            distMap.put(b, e.getPosition().distance(b.area.getRandomPosition()));
        }
        HashMap<Integer, Bank> distMapSorted = sortByDistance(distMap);
        Area cBank = distMapSorted.values().toArray(new Bank[Bank.values().length])[0].area;
        return cBank;
    }

    private static <K, V extends Comparable<? super V>> HashMap<V, K> sortByDistance(Map<K, V> map) {
        HashMap<V, K> result = new LinkedHashMap<>();
        Stream<Map.Entry<K, V>> st = map.entrySet().stream();
        st.sorted(Map.Entry.comparingByValue()).forEachOrdered(e -> result.put(e.getValue(), e.getKey()));
        return result;
    }
}

 

  • Author

Sweet! Thank you so much Saiyan!

51 minutes ago, Adept said:

I'm attempting to create my first script. I've made a good amount of progress but I don't know how to determine the Bank closest to my current position and walk to it. I searched the forum but didn't find a relevant solution.
Any help is appreciated.

Create an array of bank areas that you want to include, and then call getWalking().webWalk(area[]).

The documentation states:

UPOukSc.png

So:

getWalking().webWalk(Banks.VARROCK_WEST, Banks.LUMBRIDGE_UPPER, Banks.FALADOR_EAST);

Would walk to the closest bank out of those three

  • Author
Just now, Explv said:

Create an array of bank areas that you want to include, and then call getWalking().webWalk(area[]).

The documentation states:

UPOukSc.png

So:


getWalking().webWalk(Banks.VARROCK_WEST, Banks.LUMBRIDGE_UPPER, Banks.FALADOR_EAST);

Would walk to the closest bank out of those three

A brief and clear explanation! Thank you!

  • 3 months later...
39 minutes ago, bottingbandit said:

How do you know to use "getWalking()"? I don't see that in the API

when you extend script its inherited from MethodProvider.

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.