Search in sources :

Example 1 with NpcNode

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

the class Npcs method get.

/**
 * {@inheritDoc}
 */
@Override
protected List<org.powerbot.script.rt6.Npc> get() {
    final List<org.powerbot.script.rt6.Npc> npcs = new ArrayList<org.powerbot.script.rt6.Npc>();
    final Client client = ctx.client();
    if (client == null) {
        return npcs;
    }
    final int[] keys = client.getNpcIndices();
    final org.powerbot.bot.rt6.client.HashTable table = client.getNpcTable();
    if (keys == null || table.isNull()) {
        return npcs;
    }
    final Reflector r = client.reflector;
    for (int index = 0; index < client.getNpcCount() && index < keys.length; ++index) {
        final Node o = HashTable.lookup(table, keys[index], Node.class);
        if (o.isTypeOf(NpcNode.class)) {
            npcs.add(new org.powerbot.script.rt6.Npc(ctx, new NpcNode(r, o).getNpc()));
        } else if (o.isTypeOf(Npc.class)) {
            npcs.add(new org.powerbot.script.rt6.Npc(ctx, new Npc(r, o)));
        }
    }
    return npcs;
}
Also used : Npc(org.powerbot.bot.rt6.client.Npc) Reflector(org.powerbot.bot.Reflector) NpcNode(org.powerbot.bot.rt6.client.NpcNode) Node(org.powerbot.bot.rt6.client.Node) ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client) NpcNode(org.powerbot.bot.rt6.client.NpcNode)

Example 2 with NpcNode

use of org.powerbot.bot.rt6.client.NpcNode 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 NpcNode

use of org.powerbot.bot.rt6.client.NpcNode 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)

Aggregations

Reflector (org.powerbot.bot.Reflector)3 Client (org.powerbot.bot.rt6.client.Client)3 Node (org.powerbot.bot.rt6.client.Node)3 Npc (org.powerbot.bot.rt6.client.Npc)3 NpcNode (org.powerbot.bot.rt6.client.NpcNode)3 Player (org.powerbot.bot.rt6.client.Player)2 Point (java.awt.Point)1 ArrayList (java.util.ArrayList)1 LinkedListNode (org.powerbot.bot.rt6.client.LinkedListNode)1