Search in sources :

Example 96 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 int[] c = new int[0];
    final Client client = ctx.client();
    if (client == null) {
        return c;
    }
    final int[] varpbits = client.getVarpbits();
    return varpbits != null ? varpbits.clone() : c;
}
Also used : Client(org.powerbot.bot.rt4.client.Client)

Example 97 with Client

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

the class Component method _screenPoint.

private Point _screenPoint(final int depth) {
    if (depth > RECURSION_DEPTH) {
        return new Point(-1, -1);
    }
    final Client client = ctx.client();
    final Widget component = getInternalComponent();
    if (client == null || component == null) {
        return new Point(-1, -1);
    }
    final int pId = parentId();
    int x = 0, y = 0;
    if (pId != -1) {
        final Point point = ctx.widgets.component(pId >> 16, pId & 0xffff)._screenPoint(depth + 1);
        x = point.x;
        y = point.y;
    } else {
        final Rectangle[] bounds = client.getWidgetBoundsArray();
        final int index = component.getBoundsArrayIndex();
        if (bounds != null && index > 0 && index < bounds.length && bounds[index] != null) {
            return new Point(bounds[index].x, bounds[index].y);
        }
    }
    if (pId != -1) {
        final Component child = ctx.widgets.component(pId >> 16, pId & 0xffff);
        final int horizontalScrollSize = child.scrollWidthMax(), verticalScrollSize = child.scrollHeightMax();
        if (horizontalScrollSize > 0 || verticalScrollSize > 0) {
            x -= child.scrollX();
            y -= child.scrollY();
        }
    }
    x += component.getX();
    y += component.getY();
    return new Point(x, y);
}
Also used : Widget(org.powerbot.bot.rt6.client.Widget) Rectangle(java.awt.Rectangle) Point(java.awt.Point) Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 98 with Client

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

the class Component method parentId.

public int parentId() {
    final Client client = ctx.client();
    final Widget component = getInternalComponent();
    if (client == null || component == null) {
        return -1;
    }
    final int pId = component.getParentId();
    if (pId != -1) {
        return pId;
    }
    final int uid = id() >>> 16;
    int i = 0;
    for (final ComponentNode node : new HashTable<ComponentNode>(client.getWidgetTable(), ComponentNode.class)) {
        if (uid == node.getUid()) {
            return (int) node.getId();
        }
        if (i++ >= 1500) {
            System.out.printf("WARNING: parentId operation killed -- beyond depth of %d.%n", 1500);
            break;
        }
    }
    return -1;
}
Also used : HashTable(org.powerbot.bot.rt6.HashTable) Widget(org.powerbot.bot.rt6.client.Widget) Client(org.powerbot.bot.rt6.client.Client) ComponentNode(org.powerbot.bot.rt6.client.ComponentNode) Point(java.awt.Point)

Example 99 with Client

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

the class Players method get.

/**
 * Returns all the {@link org.powerbot.script.rt6.Player}s in the region.
 *
 * @return an array of all the loaded {@link org.powerbot.script.rt6.Player}s
 */
@Override
protected List<org.powerbot.script.rt6.Player> get() {
    final List<org.powerbot.script.rt6.Player> players = new ArrayList<org.powerbot.script.rt6.Player>();
    final Client client = ctx.client();
    if (client == null) {
        return players;
    }
    final int count = client.getPlayerCount();
    final int[] keys = client.getPlayerIndices();
    final Player[] arr = client.getPlayers();
    if (keys == null || arr == null) {
        return players;
    }
    for (int i = 0; i < Math.min(Math.min(keys.length, arr.length), count); i++) {
        final int key = keys[i];
        final Player player = arr[key];
        if (!player.isNull()) {
            players.add(new org.powerbot.script.rt6.Player(ctx, player));
        }
    }
    return players;
}
Also used : Player(org.powerbot.bot.rt6.client.Player) ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client)

Example 100 with Client

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

the class Projectiles method get.

/**
 * {@inheritDoc}
 */
@Override
protected List<org.powerbot.script.rt6.Projectile> get() {
    final List<org.powerbot.script.rt6.Projectile> items = new ArrayList<org.powerbot.script.rt6.Projectile>();
    final Client client = ctx.client();
    if (client == null) {
        return items;
    }
    for (final ProjectileNode n : NodeQueue.get(client.getProjectileDeque(), ProjectileNode.class)) {
        final Projectile p = n.getProjectile();
        if (!p.isNull()) {
            items.add(new org.powerbot.script.rt6.Projectile(ctx, p));
        }
    }
    return items;
}
Also used : ArrayList(java.util.ArrayList) Client(org.powerbot.bot.rt6.client.Client) ProjectileNode(org.powerbot.bot.rt6.client.ProjectileNode) Projectile(org.powerbot.bot.rt6.client.Projectile)

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