Search in sources :

Example 6 with Tile

use of org.powerbot.bot.rt6.client.Tile 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;
}
Also used : RenderableEntity(org.powerbot.bot.rt6.client.RenderableEntity) Reflector(org.powerbot.bot.Reflector) ArrayList(java.util.ArrayList) DynamicGameObject(org.powerbot.bot.rt6.client.DynamicGameObject) Client(org.powerbot.bot.rt6.client.Client) HashSet(java.util.HashSet) ReflectProxy(org.powerbot.bot.ReflectProxy) Tile(org.powerbot.bot.rt6.client.Tile) InvocationTargetException(java.lang.reflect.InvocationTargetException) DynamicGameObject(org.powerbot.bot.rt6.client.DynamicGameObject) DynamicGameObject(org.powerbot.bot.rt6.client.DynamicGameObject) DynamicBoundaryObject(org.powerbot.bot.rt6.client.DynamicBoundaryObject) BoundaryObject(org.powerbot.bot.rt6.client.BoundaryObject) FloorObject(org.powerbot.bot.rt6.client.FloorObject) DynamicFloorObject(org.powerbot.bot.rt6.client.DynamicFloorObject) DynamicWallObject(org.powerbot.bot.rt6.client.DynamicWallObject) WallObject(org.powerbot.bot.rt6.client.WallObject) RenderableNode(org.powerbot.bot.rt6.client.RenderableNode)

Example 7 with Tile

use of org.powerbot.bot.rt6.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);
}
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 8 with Tile

use of org.powerbot.bot.rt6.client.Tile in project powerbot by powerbot.

the class HintArrow method tile.

@Override
public Tile tile() {
    final Client client = ctx.client();
    if (client == null || arrow.obj.get() == null) {
        return Tile.NIL;
    }
    final int type = type();
    final int target = targetId();
    if (type == -1 || type == 0) {
        return Tile.NIL;
    }
    if (type == 1) {
        org.powerbot.script.rt6.Npc npc = null;
        final Node node = HashTable.lookup(client.getNpcTable(), target, Node.class);
        if (!node.isNull()) {
            final Reflector r = client.reflector;
            if (node.isTypeOf(NpcNode.class)) {
                npc = new org.powerbot.script.rt6.Npc(ctx, new NpcNode(r, node).getNpc());
            } else if (node.isTypeOf(Npc.class)) {
                npc = new org.powerbot.script.rt6.Npc(ctx, new Npc(r, node));
            }
        }
        return npc != null ? npc.tile() : Tile.NIL;
    } else if (type == 2) {
        return ctx.game.mapOffset().derive(arrow.getX() >> 9, arrow.getY() >> 9, floor());
    }
    final Player[] players = client.getPlayers();
    if (type != 10 || target < 0 || target >= players.length) {
        return Tile.NIL;
    }
    final Player localPlayer = players[target];
    if (localPlayer != null) {
        return new org.powerbot.script.rt6.Player(ctx, localPlayer).tile();
    }
    return Tile.NIL;
}
Also used : Npc(org.powerbot.bot.rt6.client.Npc) Player(org.powerbot.bot.rt6.client.Player) NpcNode(org.powerbot.bot.rt6.client.NpcNode) Node(org.powerbot.bot.rt6.client.Node) Reflector(org.powerbot.bot.Reflector) Client(org.powerbot.bot.rt6.client.Client) NpcNode(org.powerbot.bot.rt6.client.NpcNode)

Aggregations

Client (org.powerbot.bot.rt6.client.Client)7 Point (java.awt.Point)3 ArrayList (java.util.ArrayList)3 Tile (org.powerbot.script.Tile)3 HashSet (java.util.HashSet)2 ReflectProxy (org.powerbot.bot.ReflectProxy)2 Reflector (org.powerbot.bot.Reflector)2 Rectangle (java.awt.Rectangle)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Client (org.powerbot.bot.rt4.client.Client)1 Tile (org.powerbot.bot.rt4.client.Tile)1 BoundaryObject (org.powerbot.bot.rt6.client.BoundaryObject)1 DynamicBoundaryObject (org.powerbot.bot.rt6.client.DynamicBoundaryObject)1 DynamicFloorObject (org.powerbot.bot.rt6.client.DynamicFloorObject)1 DynamicGameObject (org.powerbot.bot.rt6.client.DynamicGameObject)1 DynamicWallObject (org.powerbot.bot.rt6.client.DynamicWallObject)1 Floor (org.powerbot.bot.rt6.client.Floor)1 FloorObject (org.powerbot.bot.rt6.client.FloorObject)1 HashTable (org.powerbot.bot.rt6.client.HashTable)1