Search in sources :

Example 1 with Player

use of org.powerbot.bot.rt6.client.Player in project powerbot by powerbot.

the class Movement method destination.

/**
 * Determines the current destination of the player.
 *
 * @return the {@link Tile} destination; or {@link Tile#NIL} if there is no destination
 */
public Tile destination() {
    final Client client = ctx.client();
    if (client == null) {
        return Tile.NIL;
    }
    final int dX = client.getDestinationX(), dY = client.getDestinationY();
    if (dX == -1 || dY == -1) {
        return Tile.NIL;
    }
    return ctx.game.mapOffset().derive(dX, dY);
}
Also used : Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 2 with Player

use of org.powerbot.bot.rt6.client.Player in project powerbot by powerbot.

the class Actor method interacting.

public Actor interacting() {
    final Actor nil = ctx.npcs.nil();
    final org.powerbot.bot.rt6.client.Actor actor = getAccessor();
    final int index = actor != null ? actor.getInteracting() : -1;
    if (index == -1) {
        return nil;
    }
    final Client client = ctx.client();
    if (client == null) {
        return nil;
    }
    if (index < 32768) {
        final Node node = HashTable.lookup(client.getNpcTable(), index, Node.class);
        if (node == null) {
            return nil;
        }
        final Reflector r = client.reflector;
        if (node.isTypeOf(NpcNode.class)) {
            return new org.powerbot.script.rt6.Npc(ctx, new NpcNode(r, node).getNpc());
        } else if (node.isTypeOf(Npc.class)) {
            return new org.powerbot.script.rt6.Npc(ctx, new Npc(r, node));
        }
        return nil;
    } else {
        final int pos = index - 32768;
        final Player[] arr = client.getPlayers();
        return pos >= 0 && pos < arr.length ? new org.powerbot.script.rt6.Player(ctx, arr[pos]) : nil;
    }
}
Also used : Npc(org.powerbot.bot.rt6.client.Npc) Player(org.powerbot.bot.rt6.client.Player) NpcNode(org.powerbot.bot.rt6.client.NpcNode) LinkedListNode(org.powerbot.bot.rt6.client.LinkedListNode) Node(org.powerbot.bot.rt6.client.Node) Reflector(org.powerbot.bot.Reflector) Point(java.awt.Point) Client(org.powerbot.bot.rt6.client.Client) NpcNode(org.powerbot.bot.rt6.client.NpcNode)

Example 3 with Player

use of org.powerbot.bot.rt6.client.Player in project powerbot by powerbot.

the class GroundItems method get.

protected List<GroundItem> get(int radius) {
    if (radius < 1) {
        radius = 110;
    }
    final List<GroundItem> items = new ArrayList<GroundItem>();
    final Client client = ctx.client();
    if (client == null) {
        return items;
    }
    final HashTable table = client.getItemTable();
    if (table.isNull()) {
        return items;
    }
    final int plane = client.getFloor();
    long id;
    NodeListCache cache;
    final Tile base = ctx.game.mapOffset();
    final Tile player = ctx.players.local().tile();
    if (base == Tile.NIL || player == Tile.NIL || !player.matrix(ctx).valid()) {
        return items;
    }
    final int bx = base.x(), mx = bx + 103, by = base.y(), my = by + 103;
    for (int x = Math.max(bx, player.x() - radius); x <= Math.min(mx, player.x() + radius); x++) {
        for (int y = Math.max(by, player.y() - radius); y <= Math.min(my, player.y() + radius); y++) {
            id = x | y << 14 | plane << 28;
            cache = org.powerbot.bot.rt6.HashTable.lookup(table, id, NodeListCache.class);
            if (cache.isNull()) {
                continue;
            }
            for (final ItemNode item : NodeQueue.get(cache.getDeque(), ItemNode.class)) {
                items.add(new GroundItem(ctx, new Tile(x, y, plane), item));
            }
        }
    }
    return items;
}
Also used : ItemNode(org.powerbot.bot.rt6.client.ItemNode) HashTable(org.powerbot.bot.rt6.client.HashTable) ArrayList(java.util.ArrayList) NodeListCache(org.powerbot.bot.rt6.client.NodeListCache) Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt6.client.Client)

Example 4 with Player

use of org.powerbot.bot.rt6.client.Player in project powerbot by powerbot.

the class HintArrow method tile.

@Override
public Tile tile() {
    final Client client = ctx.client();
    if (client == null || arrow.obj.get() == null) {
        return Tile.NIL;
    }
    final int type = type();
    final int target = targetId();
    if (type == -1 || type == 0) {
        return Tile.NIL;
    }
    if (type == 1) {
        org.powerbot.script.rt6.Npc npc = null;
        final Node node = HashTable.lookup(client.getNpcTable(), target, Node.class);
        if (!node.isNull()) {
            final Reflector r = client.reflector;
            if (node.isTypeOf(NpcNode.class)) {
                npc = new org.powerbot.script.rt6.Npc(ctx, new NpcNode(r, node).getNpc());
            } else if (node.isTypeOf(Npc.class)) {
                npc = new org.powerbot.script.rt6.Npc(ctx, new Npc(r, node));
            }
        }
        return npc != null ? npc.tile() : Tile.NIL;
    } else if (type == 2) {
        return ctx.game.mapOffset().derive(arrow.getX() >> 9, arrow.getY() >> 9, floor());
    }
    final Player[] players = client.getPlayers();
    if (type != 10 || target < 0 || target >= players.length) {
        return Tile.NIL;
    }
    final Player localPlayer = players[target];
    if (localPlayer != null) {
        return new org.powerbot.script.rt6.Player(ctx, localPlayer).tile();
    }
    return Tile.NIL;
}
Also used : Npc(org.powerbot.bot.rt6.client.Npc) Player(org.powerbot.bot.rt6.client.Player) NpcNode(org.powerbot.bot.rt6.client.NpcNode) Node(org.powerbot.bot.rt6.client.Node) Reflector(org.powerbot.bot.Reflector) Client(org.powerbot.bot.rt6.client.Client) NpcNode(org.powerbot.bot.rt6.client.NpcNode)

Example 5 with Player

use of org.powerbot.bot.rt6.client.Player in project powerbot by powerbot.

the class Players method get.

/**
 * Returns all the {@link org.powerbot.script.rt6.Player}s in the region.
 *
 * @return an array of all the loaded {@link org.powerbot.script.rt6.Player}s
 */
@Override
protected List<org.powerbot.script.rt6.Player> get() {
    final List<org.powerbot.script.rt6.Player> players = new ArrayList<org.powerbot.script.rt6.Player>();
    final Client client = ctx.client();
    if (client == null) {
        return players;
    }
    final int count = client.getPlayerCount();
    final int[] keys = client.getPlayerIndices();
    final Player[] arr = client.getPlayers();
    if (keys == null || arr == null) {
        return players;
    }
    for (int i = 0; i < Math.min(Math.min(keys.length, arr.length), count); i++) {
        final int key = keys[i];
        final Player player = arr[key];
        if (!player.isNull()) {
            players.add(new org.powerbot.script.rt6.Player(ctx, player));
        }
    }
    return players;
}
Also used : Player(org.powerbot.bot.rt6.client.Player) ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client)

Aggregations

Client (org.powerbot.bot.rt6.client.Client)5 Player (org.powerbot.bot.rt6.client.Player)3 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 Reflector (org.powerbot.bot.Reflector)2 Node (org.powerbot.bot.rt6.client.Node)2 Npc (org.powerbot.bot.rt6.client.Npc)2 NpcNode (org.powerbot.bot.rt6.client.NpcNode)2 HashTable (org.powerbot.bot.rt6.client.HashTable)1 ItemNode (org.powerbot.bot.rt6.client.ItemNode)1 LinkedListNode (org.powerbot.bot.rt6.client.LinkedListNode)1 NodeListCache (org.powerbot.bot.rt6.client.NodeListCache)1 Tile (org.powerbot.script.Tile)1