Search in sources :

Example 1 with Locatable

use of org.powerbot.script.Locatable in project powerbot by powerbot.

the class Bank method nearest.

/**
 * Returns the absolute nearest bank for walking purposes. Do not use this to open the bank.
 *
 * @return the {@link Locatable} of the nearest bank or {@link Tile#NIL}
 * @see #open()
 */
public Locatable nearest() {
    Locatable nearest = ctx.npcs.select().select(UNREACHABLE_FILTER).name(Constants.BANK_NPCS).nearest().poll();
    final Tile loc = ctx.players.local().tile();
    for (final GameObject object : ctx.objects.select().select(UNREACHABLE_FILTER).name(Constants.BANK_BOOTHS, Constants.BANK_CHESTS).nearest().limit(1)) {
        if (loc.distanceTo(object) < loc.distanceTo(nearest)) {
            nearest = object;
        }
    }
    if (nearest.tile() != Tile.NIL) {
        return nearest;
    }
    return Tile.NIL;
}
Also used : Tile(org.powerbot.script.Tile) Locatable(org.powerbot.script.Locatable)

Example 2 with Locatable

use of org.powerbot.script.Locatable in project powerbot by powerbot.

the class Bank method nearest.

/**
 * Returns the absolute nearest bank for walking purposes. Do not use this to open the bank.
 *
 * @return the {@link Locatable} of the nearest bank or {@link Tile#NIL}
 * @see #open()
 */
public Locatable nearest() {
    Locatable nearest = ctx.npcs.select().select(UNREACHABLE_FILTER).id(Constants.BANK_NPCS).nearest().poll();
    final Tile loc = ctx.players.local().tile();
    for (final GameObject object : ctx.objects.select().select(UNREACHABLE_FILTER).id(Constants.BANK_BOOTHS, Constants.BANK_COUNTERS, Constants.BANK_CHESTS).nearest().limit(1)) {
        if (loc.distanceTo(object) < loc.distanceTo(nearest)) {
            nearest = object;
        }
    }
    if (nearest.tile() != Tile.NIL) {
        return nearest;
    }
    return Tile.NIL;
}
Also used : Tile(org.powerbot.script.Tile) Locatable(org.powerbot.script.Locatable)

Aggregations

Locatable (org.powerbot.script.Locatable)2 Tile (org.powerbot.script.Tile)2