Search in sources :

Example 11 with Client

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

the class Game method tileHeight.

/**
 * Determines the tile height at the provided point in the game region.
 *
 * @param rX    the relative x
 * @param rY    the relative y
 * @param plane the plane
 * @return the height at the given point
 */
public int tileHeight(final int rX, final int rY, int plane) {
    final Client c = ctx.client();
    if (c == null) {
        return 0;
    }
    if (plane == -1) {
        plane = c.getFloor();
    }
    final int x = rX >> 9, y = rY >> 9;
    final byte[][][] configs = c.getWorld().getFloorSettings().getBytes();
    if (x < 0 || x > 103 || y < 0 || y > 103) {
        return 0;
    }
    if (plane < 3 && (configs[1][x][y] & 2) != 0) {
        ++plane;
    }
    final Floor[] landscape = c.getWorld().getLandscape().getFloors();
    if (plane < 0 || plane >= landscape.length) {
        return 0;
    }
    try {
        final int[][] heights = landscape[plane].getHeights();
        final int aX = rX & 0x1ff;
        final int aY = rY & 0x1ff;
        final int start_h = heights[x][y] * (512 - aX) + heights[x + 1][y] * aX >> 9;
        final int end_h = heights[x][1 + y] * (512 - aX) + heights[x + 1][y + 1] * aX >> 9;
        return start_h * (512 - aY) + end_h * aY >> 9;
    } catch (final Exception ignored) {
    }
    return 0;
}
Also used : Floor(org.powerbot.bot.rt6.client.Floor) Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 12 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.getCrossHairType() : -1;
    if (type < 0 || type > 2) {
        return Crosshair.NONE;
    }
    return Crosshair.values()[type];
}
Also used : Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 13 with Client

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

the class Game method mapOffset.

/**
 * Determines the base of the loaded region.
 *
 * @return the {@link Tile} of the base
 */
public Tile mapOffset() {
    final Client client = ctx.client();
    if (client == null) {
        return Tile.NIL;
    }
    final MapOffset b = client.getWorld().getMapOffset();
    if (b.isNull()) {
        return Tile.NIL;
    }
    return new Tile(b.getX(), b.getY(), client.getFloor());
}
Also used : MapOffset(org.powerbot.bot.rt6.client.MapOffset) Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt6.client.Client)

Example 14 with Client

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

the class Game method clientState.

/**
 * Returns the current client state.
 *
 * @return the client state
 * @see org.powerbot.script.rt6.Constants#GAME_LOGIN
 * @see org.powerbot.script.rt6.Constants#GAME_LOBBY
 * @see org.powerbot.script.rt6.Constants#GAME_LOGGING
 * @see org.powerbot.script.rt6.Constants#GAME_MAP_LOADED
 * @see org.powerbot.script.rt6.Constants#GAME_MAP_LOADING
 */
public int clientState() {
    final Client client = ctx.client();
    if (client == null) {
        return -1;
    }
    final int state = client.getClientState();
    if (state == client.reflector.getConstant("V_CLIENT_GAMESTATE_LOGIN_SCREEN")) {
        return Constants.GAME_LOGIN;
    } else if (state == client.reflector.getConstant("V_CLIENT_GAMESTATE_LOBBY_SCREEN")) {
        return Constants.GAME_LOBBY;
    } else if (state == client.reflector.getConstant("V_CLIENT_GAMESTATE_LOGGING_IN")) {
        return Constants.GAME_LOGGING;
    } else if (state == client.reflector.getConstant("V_CLIENT_GAMESTATE_ENVIRONMENT_PLAYABLE")) {
        return Constants.GAME_MAP_LOADED;
    } else if (state == client.reflector.getConstant("V_CLIENT_GAMESTATE_ENVIRONMENT_LOADING")) {
        return Constants.GAME_MAP_LOADING;
    }
    return -1;
}
Also used : Client(org.powerbot.bot.rt6.client.Client) Point(java.awt.Point)

Example 15 with Client

use of ru.compscicenter.hpc2016.ha1.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)

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