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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations