use of org.powerbot.bot.rt4.client.Tile 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);
}
use of org.powerbot.bot.rt4.client.Tile 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);
}
use of org.powerbot.bot.rt4.client.Tile in project powerbot by powerbot.
the class GameObject method tile.
@Override
public Tile tile() {
final Client client = ctx.client();
final int r = relative();
final int rx = r >> 16, rz = r & 0xffff;
if (client != null && rx != 0 && rz != 0) {
return new Tile(client.getOffsetX() + (rx >> 7), client.getOffsetY() + (rz >> 7), client.getFloor());
}
return Tile.NIL;
}
use of org.powerbot.bot.rt4.client.Tile in project powerbot by powerbot.
the class GroundItem method valid.
@Override
public boolean valid() {
final Client c = ctx.client();
if (c == null || node.isNull()) {
return false;
}
final NodeDeque[][][] nd = c.getGroundItems();
if (nd != null) {
final int f = c.getFloor();
if (f < 0 || f >= nd.length || nd[f] == null) {
return false;
}
final Tile t = tile.tile().derive(-c.getOffsetX(), -c.getOffsetY());
if (t.x() < 0 || t.y() < 0 || t.x() >= nd[f].length) {
return false;
}
final NodeDeque[] nd2 = nd[f][t.x()];
if (nd2 == null || t.y() >= nd2.length) {
return false;
}
final NodeDeque d = nd2[t.y()];
return d != null && NodeQueue.get(d, ItemNode.class).contains(node);
}
return false;
}
use of org.powerbot.bot.rt4.client.Tile in project powerbot by powerbot.
the class GroundItems method get.
private List<GroundItem> get(int radius, final int floor) {
if (radius < 1) {
radius = 110;
}
final List<GroundItem> r = new CopyOnWriteArrayList<GroundItem>();
final Client client = ctx.client();
final NodeDeque[][][] dequeArray;
if (client == null || (dequeArray = client.getGroundItems()) == null) {
return r;
}
final NodeDeque[][] rows;
if (floor > -1 && floor < dequeArray.length) {
rows = dequeArray[floor];
} else {
rows = null;
}
if (rows == null) {
return r;
}
final List<GroundItem> list = new LinkedList<GroundItem>();
final Tile tile = new Tile(client.getOffsetX(), client.getOffsetY(), floor);
final Tile ct = ctx.players.local().tile().derive(-tile.x(), -tile.y());
for (int x = Math.max(0, ct.x() - radius); x < Math.min(rows.length, ct.x() + radius + 1); x++) {
final NodeDeque[] row = rows[x];
if (row == null) {
continue;
}
for (int y = Math.max(0, ct.y() - radius); y < Math.min(row.length, ct.y() + radius + 1); y++) {
for (final ItemNode n : NodeQueue.get(row[y], ItemNode.class)) {
list.add(new GroundItem(ctx, tile.derive(x, y), n));
}
}
}
return list;
}
Aggregations