use of org.orcid.jaxb.model.v3.dev1.client.Client in project powerbot by powerbot.
the class Menu method getMenuItemNodes.
private List<MenuItemNode> getMenuItemNodes() {
final List<MenuItemNode> nodes = new LinkedList<MenuItemNode>();
final Client client = ctx.client();
if (client == null) {
return nodes;
}
final boolean collapsed;
if (collapsed = client.isMenuCollapsed()) {
for (final MenuGroupNode n : NodeQueue.get(client.getCollapsedMenuItems(), MenuGroupNode.class)) {
nodes.addAll(NodeQueue.get(n.getItems(), MenuItemNode.class));
}
} else {
nodes.addAll(NodeQueue.get(client.getMenuItems(), MenuItemNode.class));
}
if (nodes.size() > 1) {
final MenuItemNode node = nodes.get(0);
final String action = node.getAction();
if (action != null && StringUtils.stripHtml(action).equalsIgnoreCase(collapsed ? "Walk here" : "Cancel")) {
Collections.reverse(nodes);
}
}
return nodes;
}
use of org.orcid.jaxb.model.v3.dev1.client.Client in project powerbot by powerbot.
the class Objects method get.
protected List<GameObject> get(final Locatable l, int radius) {
radius = Math.min(radius, 110);
final List<GameObject> items = new ArrayList<GameObject>();
final Client client = ctx.client();
if (client == null) {
return items;
}
final Tile[][][] grounds = client.getWorld().getLandscape().getTiles();
final int floor = ctx.game.floor();
if (floor < 0 || floor >= grounds.length) {
return items;
}
final Set<GameObject> set = new HashSet<GameObject>();
final Tile[][] rows = grounds[floor];
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;
}
for (RenderableNode node = tile.getInteractives(); !node.isNull(); node = node.getNext()) {
final RenderableEntity r = node.getEntity();
if (r.isNull()) {
continue;
}
if (r.isTypeOf(org.powerbot.bot.rt6.client.GameObject.class)) {
final org.powerbot.bot.rt6.client.GameObject o = new org.powerbot.bot.rt6.client.GameObject(r.reflector, r);
if (o.getId() != -1) {
set.add(new GameObject(ctx, new BasicObject(o, floor), GameObject.Type.INTERACTIVE));
}
} else if (r.isTypeOf(DynamicGameObject.class)) {
final DynamicGameObject o = new DynamicGameObject(r.reflector, r);
if (o.getBridge().getId() != -1) {
set.add(new GameObject(ctx, new BasicObject(o, floor), GameObject.Type.INTERACTIVE));
}
}
}
final Object[] objs = { tile.getBoundary1(), tile.getBoundary2(), tile.getFloorDecoration(), tile.getWallDecoration1(), tile.getWallDecoration2() };
for (int i = 0; i < objs.length; i++) {
if (objs[i] == null) {
continue;
}
Class<?> type = null;
for (final Class<?> e : o_types[i]) {
@SuppressWarnings("unchecked") final Class<? extends ReflectProxy> c = (Class<? extends ReflectProxy>) e;
if (c != null && tile.reflector.isTypeOf(objs[i], c)) {
type = c;
break;
}
}
if (type == null) {
continue;
}
try {
items.add(new GameObject(ctx, new BasicObject((RenderableEntity) type.getConstructor(Reflector.class, Object.class).newInstance(tile.reflector, objs[i]), floor), types[i]));
} catch (final InstantiationException ignored) {
} catch (final IllegalAccessException ignored) {
} catch (final InvocationTargetException ignored) {
} catch (final NoSuchMethodException ignored) {
}
}
}
}
items.addAll(set);
set.clear();
return items;
}
use of org.orcid.jaxb.model.v3.dev1.client.Client in project powerbot by powerbot.
the class LocalPath method getGraph.
static Graph getGraph(final ClientContext ctx) {
final Client client = ctx.client();
if (client == null) {
return null;
}
final int floor = client.getFloor();
final CollisionMap[] maps = client.getCollisionMaps();
final CollisionMap map;
if (maps == null || floor < 0 || floor >= maps.length || (map = maps[floor]) == null) {
return null;
}
final int[][] arr = map.getFlags();
final double[][] costs = getCosts(ctx, arr.length, arr.length);
return arr != null ? new Graph(arr, costs, map.getOffsetX(), map.getOffsetY()) : null;
}
use of org.orcid.jaxb.model.v3.dev1.client.Client in project powerbot by powerbot.
the class LocalPath method getCosts.
static double[][] getCosts(final ClientContext ctx, final int w, final int h) {
final Client client = ctx.client();
final Landscape landscape = client.getLandscape();
final org.powerbot.bot.rt4.client.Tile[][][] tiles;
final int floor = client.getFloor();
final org.powerbot.bot.rt4.client.Tile[][] rows;
if (landscape == null || (tiles = landscape.getTiles()) == null || floor < 0 || floor > tiles.length || (rows = tiles[floor]) == null) {
return new double[0][0];
}
final double[][] arr = new double[w][h];
for (int x = 0; x < Math.min(w, rows.length); x++) {
final org.powerbot.bot.rt4.client.Tile[] row = rows[x];
if (row == null) {
continue;
}
final int h2 = row.length;
for (int y = 0; y < Math.min(h, h2); y++) {
final org.powerbot.bot.rt4.client.Tile tile = row[y];
if (tile == null) {
continue;
}
if (tile.getGameObjectLength() > 0 || tile.getBoundaryObject() != null || tile.getWallObject() != null) {
for (int dx = Math.max(0, x - 1); dx <= Math.min(w - 1, x + 1); dx++) {
for (int dy = Math.max(0, y - 1); dy <= Math.min(h - 1, y + 1); dy++) {
arr[dx][dy] += Random.nextDouble();
}
}
}
}
}
return arr;
}
use of org.orcid.jaxb.model.v3.dev1.client.Client in project powerbot by powerbot.
the class Menu method click.
/**
* Attempts to click the menu command provided by the filter.
*
* @param filter The filter to apply to the menu.
* @param click Whether or not to left-click.
* @return {@code true} if the mouse has successfully clicked within the bounds of the
* MenuCommand.
*/
private boolean click(final Filter<? super MenuCommand> filter, final boolean click) {
final Client client = ctx.client();
int idx;
if (client == null || (idx = indexOf(filter)) == -1) {
return false;
}
if (click && !client.isMenuOpen() && idx == 0) {
return ctx.input.click(true);
}
if (!client.isMenuOpen()) {
if (!ctx.input.click(false)) {
return false;
}
}
if (!Condition.wait(new Condition.Check() {
@Override
public boolean poll() {
return client.isMenuOpen();
}
}, 15, 10) || (idx = indexOf(filter)) == -1) {
return false;
}
final Rectangle rectangle = new Rectangle(client.getMenuX(), client.getMenuY() + 19 + idx * 15, client.getMenuWidth(), 15);
Condition.sleep(Random.hicks(idx));
if (!ctx.input.move(Random.nextInt(rectangle.x, rectangle.x + rectangle.width), Random.nextInt(rectangle.y, rectangle.y + rectangle.height)) || !client.isMenuOpen()) {
return false;
}
final Point p = ctx.input.getLocation();
return client.isMenuOpen() && rectangle.contains(p) && (!click || ctx.input.click(true));
}
Aggregations