Search in sources :

Example 21 with Client

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

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

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

use of ru.compscicenter.hpc2016.ha1.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)

Example 25 with Client

use of ru.compscicenter.hpc2016.ha1.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;
}
Also used : Skill(org.powerbot.bot.rt6.client.Skill) PlayerFacade(org.powerbot.bot.rt6.client.PlayerFacade) 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)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