Search in sources :

Example 71 with Client

use of ru.compscicenter.hpc2016.ha1.client.Client in project powerbot by powerbot.

the class GroundItems method get.

private List<GroundItem> get(int radius, final int floor) {
    if (radius < 1) {
        radius = 110;
    }
    final List<GroundItem> r = new CopyOnWriteArrayList<GroundItem>();
    final Client client = ctx.client();
    final NodeDeque[][][] dequeArray;
    if (client == null || (dequeArray = client.getGroundItems()) == null) {
        return r;
    }
    final NodeDeque[][] rows;
    if (floor > -1 && floor < dequeArray.length) {
        rows = dequeArray[floor];
    } else {
        rows = null;
    }
    if (rows == null) {
        return r;
    }
    final List<GroundItem> list = new LinkedList<GroundItem>();
    final Tile tile = new Tile(client.getOffsetX(), client.getOffsetY(), floor);
    final Tile ct = ctx.players.local().tile().derive(-tile.x(), -tile.y());
    for (int x = Math.max(0, ct.x() - radius); x < Math.min(rows.length, ct.x() + radius + 1); x++) {
        final NodeDeque[] row = rows[x];
        if (row == null) {
            continue;
        }
        for (int y = Math.max(0, ct.y() - radius); y < Math.min(row.length, ct.y() + radius + 1); y++) {
            for (final ItemNode n : NodeQueue.get(row[y], ItemNode.class)) {
                list.add(new GroundItem(ctx, tile.derive(x, y), n));
            }
        }
    }
    return list;
}
Also used : ItemNode(org.powerbot.bot.rt4.client.ItemNode) Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt4.client.Client) NodeDeque(org.powerbot.bot.rt4.client.NodeDeque) LinkedList(java.util.LinkedList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 72 with Client

use of ru.compscicenter.hpc2016.ha1.client.Client 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 73 with Client

use of ru.compscicenter.hpc2016.ha1.client.Client in project powerbot by powerbot.

the class HintArrow method valid.

@Override
public boolean valid() {
    final Client client = ctx.client();
    if (client == null) {
        return false;
    }
    final org.powerbot.bot.rt6.client.HintArrow[] arr = client.getHintArrows();
    return arrow.obj.get() != null && arr != null && Arrays.asList(arr).contains(arrow);
}
Also used : Client(org.powerbot.bot.rt6.client.Client)

Example 74 with Client

use of ru.compscicenter.hpc2016.ha1.client.Client in project powerbot by powerbot.

the class HintArrows method get.

/**
 * {@inheritDoc}
 */
@Override
protected List<org.powerbot.script.rt6.HintArrow> get() {
    final List<org.powerbot.script.rt6.HintArrow> items = new ArrayList<org.powerbot.script.rt6.HintArrow>();
    final Client client = ctx.client();
    if (client == null) {
        return items;
    }
    final HintArrow[] arr = client.getHintArrows();
    for (final HintArrow arrow : arr != null ? arr : new HintArrow[0]) {
        if (arrow.isNull()) {
            items.add(new org.powerbot.script.rt6.HintArrow(ctx, arrow));
        }
    }
    return items;
}
Also used : HintArrow(org.powerbot.bot.rt6.client.HintArrow) ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client)

Example 75 with Client

use of ru.compscicenter.hpc2016.ha1.client.Client in project powerbot by powerbot.

the class Players method local.

public Player local() {
    final Player r = new Player(ctx, null);
    final Client client = ctx.client();
    if (client == null) {
        return r;
    }
    return new Player(ctx, client.getPlayer());
}
Also used : Client(org.powerbot.bot.rt4.client.Client)

Aggregations

Client (org.powerbot.bot.rt4.client.Client)36 Client (org.powerbot.bot.rt6.client.Client)33 Point (java.awt.Point)25 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 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)3 Graphics (java.awt.Graphics)2 LinkedList (java.util.LinkedList)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2