Search in sources :

Example 86 with Client

use of org.orcid.jaxb.model.v3.dev1.client.Client in project powerbot by powerbot.

the class GameObject method tile.

@Override
public Tile tile() {
    final Client client = ctx.client();
    final int r = relative();
    final int rx = r >> 16, rz = r & 0xffff;
    if (client != null && rx != 0 && rz != 0) {
        return new Tile(client.getOffsetX() + (rx >> 7), client.getOffsetY() + (rz >> 7), client.getFloor());
    }
    return Tile.NIL;
}
Also used : Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt4.client.Client) Point(java.awt.Point)

Example 87 with Client

use of org.orcid.jaxb.model.v3.dev1.client.Client in project powerbot by powerbot.

the class GameObject method id.

@Override
public int id() {
    final Client client = ctx.client();
    if (client == null) {
        return -1;
    }
    final int id = object != null ? (object.getUid() >> 14) & 0xffff : -1;
    if (object == null) {
        return id;
    }
    int index = -1;
    final CacheObjectConfig c = CacheObjectConfig.load(Bot.CACHE_WORKER, id);
    if (c == null) {
        return id;
    }
    if (c.stageOperationId != -1) {
        final Cache cache = client.getVarbitCache();
        final Varbit varBit = new Varbit(object.object.reflector, HashTable.lookup(cache.getTable(), c.stageOperationId, Varbit.class));
        if (varBit.obj.get() != null) {
            final int mask = lookup[varBit.getEndBit() - varBit.getStartBit()];
            index = ctx.varpbits.varpbit(varBit.getIndex()) >> varBit.getStartBit() & mask;
        }
    } else if (c.stageIndex >= 0) {
        index = ctx.varpbits.varpbit(c.stageIndex);
    }
    if (index >= 0) {
        final int[] configs = c.materialPointers;
        if (configs != null && index < configs.length && configs[index] != -1) {
            return configs[index];
        }
    }
    return id;
}
Also used : Varbit(org.powerbot.bot.rt4.client.Varbit) Client(org.powerbot.bot.rt4.client.Client) Point(java.awt.Point) Cache(org.powerbot.bot.rt4.client.Cache)

Example 88 with Client

use of org.orcid.jaxb.model.v3.dev1.client.Client in project powerbot by powerbot.

the class GroundItem method valid.

@Override
public boolean valid() {
    final Client c = ctx.client();
    if (c == null || node.isNull()) {
        return false;
    }
    final NodeDeque[][][] nd = c.getGroundItems();
    if (nd != null) {
        final int f = c.getFloor();
        if (f < 0 || f >= nd.length || nd[f] == null) {
            return false;
        }
        final Tile t = tile.tile().derive(-c.getOffsetX(), -c.getOffsetY());
        if (t.x() < 0 || t.y() < 0 || t.x() >= nd[f].length) {
            return false;
        }
        final NodeDeque[] nd2 = nd[f][t.x()];
        if (nd2 == null || t.y() >= nd2.length) {
            return false;
        }
        final NodeDeque d = nd2[t.y()];
        return d != null && NodeQueue.get(d, ItemNode.class).contains(node);
    }
    return false;
}
Also used : Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt4.client.Client) NodeDeque(org.powerbot.bot.rt4.client.NodeDeque) Point(java.awt.Point)

Example 89 with Client

use of org.orcid.jaxb.model.v3.dev1.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 90 with Client

use of org.orcid.jaxb.model.v3.dev1.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)

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)18 Test (org.junit.Test)17 Client (org.orcid.jaxb.model.v3.dev1.client.Client)11 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)9 Tile (org.powerbot.script.Tile)8 HashSet (java.util.HashSet)6 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)5 Rectangle (java.awt.Rectangle)4 ClientSummary (org.orcid.jaxb.model.v3.dev1.client.ClientSummary)4 DBUnitTest (org.orcid.test.DBUnitTest)4 Reflector (org.powerbot.bot.Reflector)4 Condition (org.powerbot.script.Condition)4 Client (client.Client)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)3 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)3