Search in sources :

Example 16 with Client

use of org.powerbot.bot.rt6.client.Client in project powerbot by powerbot.

the class Menu method hoverIndex.

private Point hoverIndex(final Client client, final int index) {
    int _index = 0, main = -1;
    Vector2 addum = new Vector2(0, 16 * index);
    collapsed: if (client.isMenuCollapsed()) {
        for (final MenuGroupNode g : NodeQueue.get(client.getCollapsedMenuItems(), MenuGroupNode.class)) {
            main++;
            final List<MenuItemNode> t = NodeQueue.get(g.getItems(), MenuItemNode.class);
            for (int i = 0; i < t.size(); i++) {
                if (_index++ == index) {
                    if (i == 0) {
                        addum = new Vector2(0, 16 * main);
                        break collapsed;
                    } else {
                        return hoverSub(client, main, i);
                    }
                }
            }
        }
        if (client.isMenuOpen()) {
            close();
        }
        return new Point(-1, -1);
    }
    final Vector2 p = new Vector2(client.getMenuX() + Random.nextInt(4, client.getMenuWidth() - 5), client.getMenuY() + 21 + Random.nextInt(2, 15)).add(addum);
    return ctx.input.move(p.toPoint()) && client.isMenuOpen() ? p.toPoint() : new Point(-1, -1);
}
Also used : MenuItemNode(org.powerbot.bot.rt6.client.MenuItemNode) Vector2(org.powerbot.script.Vector2) List(java.util.List) LinkedList(java.util.LinkedList) Point(java.awt.Point) MenuGroupNode(org.powerbot.bot.rt6.client.MenuGroupNode) Point(java.awt.Point)

Example 17 with Client

use of org.powerbot.bot.rt6.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 18 with Client

use of org.powerbot.bot.rt6.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 19 with Client

use of org.powerbot.bot.rt6.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 20 with Client

use of org.powerbot.bot.rt6.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)26 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 LinkedList (java.util.LinkedList)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 ClientRedirectUri (org.orcid.jaxb.model.v3.dev1.client.ClientRedirectUri)3 Graphics (java.awt.Graphics)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2