Search in sources :

Example 21 with Client

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

the class Widgets method get.

/**
 * {@inheritDoc}
 */
@Override
protected List<Widget> get() {
    final Client client = ctx.client();
    if (client == null) {
        return new ArrayList<Widget>(0);
    }
    final Object[] cache = client.getWidgets();
    if (cache == null || cache.length == 0) {
        return new ArrayList<Widget>(0);
    }
    final List<Widget> w = new ArrayList<Widget>(cache.length);
    for (int i = 0; i < cache.length; i++) {
        w.add(new Widget(ctx, i));
    }
    return w;
}
Also used : ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 22 with Client

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

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

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

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

the class Player method valid.

@Override
public boolean valid() {
    final Client client = ctx.client();
    final org.powerbot.bot.rt6.client.Player character = getAccessor();
    if (client == null || character.isNull()) {
        return false;
    }
    final org.powerbot.bot.rt6.client.Player[] players = client.getPlayers();
    for (final org.powerbot.bot.rt6.client.Player p : players) {
        if (character.equals(p)) {
            return true;
        }
    }
    return false;
}
Also used : Client(org.powerbot.bot.rt6.client.Client)

Aggregations

Client (org.powerbot.bot.rt4.client.Client)36 Client (org.powerbot.bot.rt6.client.Client)33 Point (java.awt.Point)26 ArrayList (java.util.ArrayList)13 Client (org.orcid.jaxb.model.v3.dev1.client.Client)11 Test (org.junit.Test)8 Tile (org.powerbot.script.Tile)8 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)6 HashSet (java.util.HashSet)5 Rectangle (java.awt.Rectangle)4 Reflector (org.powerbot.bot.Reflector)4 Condition (org.powerbot.script.Condition)4 Client (client.Client)3 LinkedList (java.util.LinkedList)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)3 Graphics (java.awt.Graphics)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2