use of 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;
}
use of 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];
}
use of 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());
}
use of 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;
}
use of 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);
}
Aggregations