Search in sources :

Example 1 with Node

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

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

the class Actor method getBarData.

private CombatStatusData[] getBarData() {
    final LinkedListNode[] nodes = getBarNodes();
    final Client client = ctx.client();
    if (nodes == null || client == null) {
        return null;
    }
    final CombatStatusData[] data = new CombatStatusData[nodes.length];
    for (int i = 0; i < nodes.length; i++) {
        if (nodes[i] == null || nodes[i].isNull() || !nodes[i].isTypeOf(CombatStatus.class)) {
            data[i] = null;
            continue;
        }
        final CombatStatus status = new CombatStatus(nodes[i].reflector, nodes[i]);
        final org.powerbot.bot.rt6.client.LinkedList statuses;
        try {
            statuses = status.getList();
        } catch (final IllegalArgumentException ignored) {
            continue;
        }
        if (statuses == null) {
            data[i] = null;
            continue;
        }
        final LinkedListNode node = statuses.getSentinel().getNext();
        if (node.isNull() || !node.isTypeOf(CombatStatusData.class)) {
            data[i] = null;
            continue;
        }
        data[i] = new CombatStatusData(node.reflector, node);
    }
    return data;
}
Also used : CombatStatus(org.powerbot.bot.rt6.client.CombatStatus) LinkedListNode(org.powerbot.bot.rt6.client.LinkedListNode) CombatStatusData(org.powerbot.bot.rt6.client.CombatStatusData) Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 3 with Node

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

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

the class Actor method getBarData.

private CombatStatusData[] getBarData() {
    final Node[] nodes = getBarNodes();
    final Client client = ctx.client();
    if (nodes == null || client == null) {
        return null;
    }
    final CombatStatusData[] data = new CombatStatusData[nodes.length];
    for (int i = 0; i < nodes.length; i++) {
        if (nodes[i] == null || nodes[i].isNull() || !nodes[i].isTypeOf(CombatStatus.class)) {
            data[i] = null;
            continue;
        }
        final CombatStatus status = new CombatStatus(nodes[i].reflector, nodes[i]);
        final org.powerbot.bot.rt4.client.LinkedList statuses;
        try {
            statuses = status.getList();
        } catch (final IllegalArgumentException ignored) {
            continue;
        }
        if (statuses == null) {
            data[i] = null;
            continue;
        }
        final Node node = statuses.getSentinel().getNext();
        if (node.isNull() || !node.isTypeOf(CombatStatusData.class)) {
            data[i] = null;
            continue;
        }
        data[i] = new CombatStatusData(node.reflector, node);
    }
    return data;
}
Also used : CombatStatus(org.powerbot.bot.rt4.client.CombatStatus) Node(org.powerbot.bot.rt4.client.Node) CombatStatusData(org.powerbot.bot.rt4.client.CombatStatusData) Client(org.powerbot.bot.rt4.client.Client) Point(java.awt.Point)

Example 5 with Node

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

the class Actor method getBarNodes.

private Node[] getBarNodes() {
    final org.powerbot.bot.rt4.client.Actor accessor = getActor();
    if (accessor == null) {
        return null;
    }
    final org.powerbot.bot.rt4.client.LinkedList barList = accessor.getCombatStatusList();
    if (barList == null) {
        return null;
    }
    final Node tail = barList.getSentinel();
    final Node health;
    final Node secondary;
    final Node current;
    current = tail.getNext();
    if (!current.getNext().equals(tail)) {
        secondary = current;
        health = current.getNext();
    } else {
        secondary = null;
        health = current;
    }
    return new Node[] { secondary, health };
}
Also used : Node(org.powerbot.bot.rt4.client.Node)

Aggregations

Client (org.powerbot.bot.rt6.client.Client)7 Point (java.awt.Point)5 Reflector (org.powerbot.bot.Reflector)4 Node (org.powerbot.bot.rt6.client.Node)3 Npc (org.powerbot.bot.rt6.client.Npc)3 NpcNode (org.powerbot.bot.rt6.client.NpcNode)3 ArrayList (java.util.ArrayList)2 Node (org.powerbot.bot.rt4.client.Node)2 LinkedListNode (org.powerbot.bot.rt6.client.LinkedListNode)2 MenuItemNode (org.powerbot.bot.rt6.client.MenuItemNode)2 Player (org.powerbot.bot.rt6.client.Player)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 ReflectProxy (org.powerbot.bot.ReflectProxy)1 Client (org.powerbot.bot.rt4.client.Client)1 CombatStatus (org.powerbot.bot.rt4.client.CombatStatus)1 CombatStatusData (org.powerbot.bot.rt4.client.CombatStatusData)1 HashTable (org.powerbot.bot.rt6.HashTable)1 BoundaryObject (org.powerbot.bot.rt6.client.BoundaryObject)1