Search in sources :

Example 51 with Client

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

the class Actor method interacting.

/**
 * The current entity of which this entity is interacting with. If
 * the client is not loaded or there is no entity being interacted with,
 * this will return {@link Npcs#nil()}.
 *
 * @return The entity of which is being interacted with.
 */
public Actor interacting() {
    final Actor nil = ctx.npcs.nil();
    final org.powerbot.bot.rt4.client.Actor actor = getActor();
    final int index = actor != null ? actor.getInteractingIndex() : -1;
    if (index == -1) {
        return nil;
    }
    final Client client = ctx.client();
    if (client == null) {
        return nil;
    }
    if (index < 32768) {
        final org.powerbot.bot.rt4.client.Npc[] npcs = client.getNpcs();
        return index >= 0 && index < npcs.length ? new Npc(ctx, npcs[index]) : nil;
    } else {
        final int pos = index - 32768;
        if (pos == client.getPlayerIndex()) {
            return new Player(ctx, client.getPlayer());
        }
        final org.powerbot.bot.rt4.client.Player[] players = client.getPlayers();
        return pos >= 0 && pos < players.length ? new Player(ctx, players[pos]) : nil;
    }
}
Also used : Point(java.awt.Point) Client(org.powerbot.bot.rt4.client.Client)

Example 52 with Client

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

the class Actor method getBarData.

private CombatStatusData[] getBarData() {
    final Node[] 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.rt4.client.LinkedList statuses;
        try {
            statuses = status.getList();
        } catch (final IllegalArgumentException ignored) {
            continue;
        }
        if (statuses == null) {
            data[i] = null;
            continue;
        }
        final Node 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.rt4.client.CombatStatus) Node(org.powerbot.bot.rt4.client.Node) CombatStatusData(org.powerbot.bot.rt4.client.CombatStatusData) Client(org.powerbot.bot.rt4.client.Client) Point(java.awt.Point)

Example 53 with Client

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

the class Game method crosshair.

/**
 * Determines the current {@link Crosshair} displayed.
 *
 * @return the displayed {@link Crosshair}
 */
public Crosshair crosshair() {
    final Client client = ctx.client();
    final int type = client != null ? client.getCrosshairIndex() : -1;
    if (type < 0 || type > 2) {
        return Crosshair.NONE;
    }
    return Crosshair.values()[type];
}
Also used : Client(org.powerbot.bot.rt4.client.Client)

Example 54 with Client

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

the class Game method hintArrow.

/**
 * The {@link HintArrow}.
 *
 * @return {@link HintArrow}.
 */
public HintArrow hintArrow() {
    // TODO: hint arrow
    final HintArrow r = new HintArrow();
    final Client client = ctx.client();
    if (client == null) {
        return r;
    }
    return r;
}
Also used : Client(org.powerbot.bot.rt4.client.Client)

Example 55 with Client

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

the class Widget method getInternalComponents.

Object[] getInternalComponents() {
    final Client client = ctx.client();
    if (client == null) {
        return null;
    }
    final Object[] containers = client.getWidgets();
    final ComponentContainer container;
    if (containers != null && index >= 0 && index < containers.length && !(container = new ComponentContainer(client.reflector, containers[index])).isNull()) {
        return container.getComponents();
    }
    return null;
}
Also used : ComponentContainer(org.powerbot.bot.rt6.client.ComponentContainer) 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