Search in sources :

Example 21 with Client

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

the class Game method getViewport.

public Viewport getViewport() {
    final Client client = ctx.client();
    if (client == null) {
        return new Viewport(0, 0, 0, 0);
    }
    if (viewport_component != null && (viewport_component.contentType() == 1337 || viewport_component.contentType() == 1407)) {
        final Rectangle r = viewport_component.viewportRect();
        if (r.width + r.height > 0) {
            return new Viewport(r.x, r.y, r.width, r.height);
        }
    }
    for (int i = 0; i < client.getWidgets().length; i++) {
        for (final Component c : ctx.widgets.widget(i)) {
            if (c.contentType() == 1337 || c.contentType() == 1407) {
                // TODO 1403?
                if (!c.valid()) {
                    continue;
                }
                viewport_component = c;
                final Rectangle r = c.viewportRect();
                return new Viewport(r.x, r.y, r.width, r.height);
            }
        }
    }
    return new Viewport(0, 0, 0, 0);
}
Also used : Rectangle(java.awt.Rectangle) Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 22 with Client

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

the class Movement method destination.

/**
 * Determines the current destination of the player.
 *
 * @return the {@link Tile} destination; or {@link Tile#NIL} if there is no destination
 */
public Tile destination() {
    final Client client = ctx.client();
    if (client == null) {
        return Tile.NIL;
    }
    final int dX = client.getDestinationX(), dY = client.getDestinationY();
    if (dX == -1 || dY == -1) {
        return Tile.NIL;
    }
    return ctx.game.mapOffset().derive(dX, dY);
}
Also used : Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 23 with Client

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

the class Npcs method get.

/**
 * {@inheritDoc}
 */
@Override
protected List<org.powerbot.script.rt6.Npc> get() {
    final List<org.powerbot.script.rt6.Npc> npcs = new ArrayList<org.powerbot.script.rt6.Npc>();
    final Client client = ctx.client();
    if (client == null) {
        return npcs;
    }
    final int[] keys = client.getNpcIndices();
    final org.powerbot.bot.rt6.client.HashTable table = client.getNpcTable();
    if (keys == null || table.isNull()) {
        return npcs;
    }
    final Reflector r = client.reflector;
    for (int index = 0; index < client.getNpcCount() && index < keys.length; ++index) {
        final Node o = HashTable.lookup(table, keys[index], Node.class);
        if (o.isTypeOf(NpcNode.class)) {
            npcs.add(new org.powerbot.script.rt6.Npc(ctx, new NpcNode(r, o).getNpc()));
        } else if (o.isTypeOf(Npc.class)) {
            npcs.add(new org.powerbot.script.rt6.Npc(ctx, new Npc(r, o)));
        }
    }
    return npcs;
}
Also used : Npc(org.powerbot.bot.rt6.client.Npc) Reflector(org.powerbot.bot.Reflector) NpcNode(org.powerbot.bot.rt6.client.NpcNode) Node(org.powerbot.bot.rt6.client.Node) ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client) NpcNode(org.powerbot.bot.rt6.client.NpcNode)

Example 24 with Client

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

the class Varpbits method array.

/**
 * Returns the array of settings for the game.
 *
 * @return an array of the game's settings
 */
public int[] array() {
    final Client client = ctx.client();
    if (client == null) {
        return null;
    }
    final int[] arr = client.getPlayerFacade().getVarpbits().get();
    return arr != null ? arr.clone() : new int[0];
}
Also used : Client(org.powerbot.bot.rt6.client.Client)

Example 25 with Client

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

the class Widget method valid.

/**
 * {@inheritDoc}
 */
@Override
public boolean valid() {
    final Client client = ctx.client();
    if (client == null || index < 0) {
        return false;
    }
    final Object[] containers = client.getWidgets();
    return containers.length > 0 && index < containers.length && containers[index] != null && new ComponentContainer(client.reflector, containers[index]).getComponents().length > 0;
}
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)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