Search in sources :

Example 81 with Client

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

the class Menu method close.

/**
 * Attempts to close the menu.
 *
 * @return {@code true} if the menu was closed, {@code false} otherwise.
 */
public boolean close() {
    final Client client = ctx.client();
    if (client == null) {
        return false;
    }
    if (!client.isMenuOpen()) {
        return true;
    }
    final Component c = ((InputSimulator) ctx.input).getComponent();
    final Dimension d = new Dimension(c != null ? c.getWidth() : 0, c != null ? c.getHeight() : 0);
    final int mx = client.getMenuX(), my = client.getMenuY();
    final int w = (int) d.getWidth(), h = (int) d.getHeight();
    int x1, x2;
    final int y1, y2;
    x1 = x2 = mx;
    y1 = y2 = Math.min(h - 5, Math.max(4, my + Random.nextInt(-10, 10)));
    x1 = Math.max(4, x1 + Random.nextInt(-30, -10));
    x2 = x2 + client.getMenuWidth() + Random.nextInt(10, 30);
    if (x2 <= w - 5 && (x1 - mx >= 5 || Random.nextBoolean())) {
        ctx.input.move(x2, y2);
    } else {
        ctx.input.move(x1, y1);
    }
    return Condition.wait(new Condition.Check() {

        @Override
        public boolean poll() {
            return client.isMenuOpen();
        }
    }, 10, 50);
}
Also used : Condition(org.powerbot.script.Condition) InputSimulator(org.powerbot.bot.InputSimulator) Dimension(java.awt.Dimension) Client(org.powerbot.bot.rt4.client.Client) Component(java.awt.Component) Point(java.awt.Point)

Example 82 with Client

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

the class Movement method destination.

/**
 * Returns the destination of the player, as represented by the red flag on the mini-map while
 * traversing. If the player is not moving, this will return {@link Tile#NIL}.
 *
 * @return The destination of the player.
 */
public Tile destination() {
    final Client client = ctx.client();
    if (client == null) {
        return Tile.NIL;
    }
    final int dX = client.getDestinationX(), dY = client.getDestinationY();
    if (dX <= 0 || dY <= 0) {
        return Tile.NIL;
    }
    return ctx.game.mapOffset().derive(dX, dY);
}
Also used : Client(org.powerbot.bot.rt4.client.Client) Point(java.awt.Point)

Example 83 with Client

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

the class Npc method valid.

@Override
public boolean valid() {
    final Client client = ctx.client();
    if (client == null || npc == null || npc.isNull()) {
        return false;
    }
    final org.powerbot.bot.rt4.client.Npc[] arr = client.getNpcs();
    for (final org.powerbot.bot.rt4.client.Npc a : arr) {
        if (npc.equals(a)) {
            return true;
        }
    }
    return false;
}
Also used : Client(org.powerbot.bot.rt4.client.Client)

Example 84 with Client

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

the class Objects method get.

public List<GameObject> get(final Locatable l, int radius) {
    radius = Math.min(radius, 110);
    final List<GameObject> r = new CopyOnWriteArrayList<GameObject>();
    final Client client = ctx.client();
    if (client == null) {
        return r;
    }
    final Tile[][][] tiles = client.getLandscape().getTiles();
    final int floor = client.getFloor();
    if (floor < 0 || floor >= tiles.length) {
        return r;
    }
    final Tile[][] rows = tiles[floor];
    final HashSet<GameObject> set = new HashSet<GameObject>();
    int start_x = 0, end_x = Integer.MAX_VALUE, start_y = 0, end_y = Integer.MAX_VALUE;
    if (radius >= 0) {
        final org.powerbot.script.Tile mo = ctx.game.mapOffset(), lp = l.tile();
        if (mo != org.powerbot.script.Tile.NIL && lp != org.powerbot.script.Tile.NIL) {
            final org.powerbot.script.Tile t = lp.derive(-mo.x(), -mo.y());
            start_x = t.x() - radius;
            end_x = t.x() + radius;
            start_y = t.y() - radius;
            end_y = t.y() + radius;
        }
    }
    for (int x = Math.max(0, start_x); x <= Math.min(end_x, rows.length - 1); x++) {
        final Tile[] col = rows[x];
        for (int y = Math.max(0, start_y); y <= Math.min(end_y, col.length - 1); y++) {
            final Tile tile = col[y];
            if (tile.isNull()) {
                continue;
            }
            final int len = Math.max(0, tile.getGameObjectLength());
            final ReflectProxy[] fo = { tile.getBoundaryObject(), tile.getFloorObject(), tile.getWallObject() };
            final ReflectProxy[] arr = new ReflectProxy[3 + len];
            System.arraycopy(fo, 0, arr, 0, 3);
            final org.powerbot.bot.rt4.client.GameObject[] interactive = tile.getGameObjects();
            System.arraycopy(interactive, 0, arr, 3, Math.min(len, interactive.length));
            for (final ReflectProxy p : arr) {
                final BasicObject o = new BasicObject(p);
                if (!o.object.isNull()) {
                    final int t = o.getMeta() & 0x3f;
                    final GameObject.Type type;
                    if (t == 0 || t == 1 || t == 9) {
                        type = GameObject.Type.BOUNDARY;
                    } else if (t == 2 || t == 3 || t == 4 || t == 5 || t == 6 || t == 7 || t == 8) {
                        type = GameObject.Type.WALL_DECORATION;
                    } else if (t == 10 || t == 11) {
                        type = GameObject.Type.INTERACTIVE;
                    } else if (t == 22) {
                        type = GameObject.Type.FLOOR_DECORATION;
                    } else {
                        type = GameObject.Type.UNKNOWN;
                    }
                    set.add(new GameObject(ctx, o, type));
                }
            }
        }
    }
    return new ArrayList<GameObject>(set);
}
Also used : ReflectProxy(org.powerbot.bot.ReflectProxy) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Tile(org.powerbot.bot.rt4.client.Tile) Client(org.powerbot.bot.rt4.client.Client) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) HashSet(java.util.HashSet)

Example 85 with Client

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

the class Actor method inCombat.

public boolean inCombat() {
    final Client client = ctx.client();
    if (client == null) {
        return false;
    }
    final CombatStatusData[] data = getBarData();
    return data != null && data[1] != null && data[1].getCycleEnd() < client.getCycle();
}
Also used : CombatStatusData(org.powerbot.bot.rt6.client.CombatStatusData) 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