use of 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;
}
use of 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;
}
}
use of 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;
}
use of 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;
}
use of client.Client in project powerbot by powerbot.
the class Skills method experiences.
public int[] experiences() {
final Client client = ctx.client();
if (client == null) {
return new int[0];
}
final PlayerFacade info = client.getPlayerFacade();
final Skill[] skills;
if (info == null || (skills = info.getSkills()) == null) {
return new int[0];
}
final int[] levels = new int[skills.length];
for (int i = 0; i < skills.length; i++) {
final Skill s = skills[i];
if (!s.isNull()) {
levels[i] = s.getExperience();
}
}
return levels;
}
Aggregations