Search in sources :

Example 1 with TileMatrix

use of org.powerbot.script.rt4.TileMatrix in project powerbot by powerbot.

the class DrawGroundItems method repaint.

public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    final Player player = ctx.players.local();
    if (player == null) {
        return;
    }
    final Tile tile = player.tile();
    if (tile == null) {
        return;
    }
    final FontMetrics metrics = render.getFontMetrics();
    final int tHeight = metrics.getHeight();
    final int plane = ctx.game.floor();
    final List<GroundItem> check = new ArrayList<GroundItem>();
    ctx.groundItems.select(10).addTo(check);
    for (int x = tile.x() - 10; x <= tile.x() + 10; x++) {
        n: for (int y = tile.y() - 10; y <= tile.y() + 10; y++) {
            int d = 0;
            final Tile loc = new Tile(x, y, plane);
            for (final GroundItem groundItem : ctx.groundItems.select(check).at(loc)) {
                final Point screen = new TileMatrix(ctx, loc).centerPoint();
                if (screen.x == -1 || screen.y == -1) {
                    continue n;
                }
                final String name = groundItem.name();
                String s = "";
                s += groundItem.id();
                if (!name.isEmpty()) {
                    s += " " + name;
                }
                final int stack = groundItem.stackSize();
                if (stack > 1) {
                    s += " (" + groundItem.stackSize() + ")";
                }
                final int ty = screen.y - tHeight * (++d) + tHeight / 2;
                final int tx = screen.x - metrics.stringWidth(s) / 2;
                render.setColor(Color.green);
                render.drawString(s, tx, ty);
            }
        }
    }
}
Also used : Player(org.powerbot.script.rt6.Player) FontMetrics(java.awt.FontMetrics) GroundItem(org.powerbot.script.rt6.GroundItem) ArrayList(java.util.ArrayList) Tile(org.powerbot.script.Tile) Point(java.awt.Point) Point(java.awt.Point) TileMatrix(org.powerbot.script.rt6.TileMatrix)

Example 2 with TileMatrix

use of org.powerbot.script.rt4.TileMatrix in project powerbot by powerbot.

the class DrawProjectiles method repaint.

@Override
public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    for (final Projectile projectile : ctx.projectiles.select()) {
        final Tile t = projectile.tile();
        final TileMatrix m = new TileMatrix(ctx, t);
        if (!m.valid()) {
            continue;
        }
        m.bounds(new int[] { -128, 128, -256, 0, -128, 128 });
        m.draw(render, 255);
    }
}
Also used : Tile(org.powerbot.script.Tile) TileMatrix(org.powerbot.script.rt6.TileMatrix) Projectile(org.powerbot.script.rt6.Projectile)

Example 3 with TileMatrix

use of org.powerbot.script.rt4.TileMatrix in project powerbot by powerbot.

the class DrawGroundItems method repaint.

public void repaint(final Graphics render) {
    if (ctx.game.clientState() != Constants.GAME_LOADED) {
        return;
    }
    final Player player = ctx.players.local();
    if (player == null) {
        return;
    }
    final Tile tile = player.tile();
    if (tile == null) {
        return;
    }
    final FontMetrics metrics = render.getFontMetrics();
    final int tHeight = metrics.getHeight();
    final List<GroundItem> check = new ArrayList<GroundItem>();
    ctx.groundItems.select(10).addTo(check);
    for (int x = -10; x <= 10; x++) {
        for (int y = -10; y <= 10; y++) {
            int d = 0;
            final Tile loc = tile.derive(x, y);
            final Point screen = new TileMatrix(ctx, loc).centerPoint();
            if (screen.x == -1) {
                continue;
            }
            for (final GroundItem groundItem : ctx.groundItems.select(check).at(loc)) {
                final String name = groundItem.name();
                String s = "";
                s += groundItem.id();
                if (!name.isEmpty()) {
                    s += " " + name;
                }
                final int stack = groundItem.stackSize();
                if (stack > 1) {
                    s += " (" + stack + ")";
                }
                final int ty = screen.y - tHeight * (++d) + tHeight / 2;
                final int tx = screen.x - metrics.stringWidth(s) / 2;
                render.setColor(Color.green);
                render.drawString(s, tx, ty);
            }
        }
    }
}
Also used : Player(org.powerbot.script.rt4.Player) FontMetrics(java.awt.FontMetrics) GroundItem(org.powerbot.script.rt4.GroundItem) ArrayList(java.util.ArrayList) Tile(org.powerbot.script.Tile) Point(java.awt.Point) Point(java.awt.Point) TileMatrix(org.powerbot.script.rt4.TileMatrix)

Aggregations

Tile (org.powerbot.script.Tile)3 FontMetrics (java.awt.FontMetrics)2 Point (java.awt.Point)2 ArrayList (java.util.ArrayList)2 TileMatrix (org.powerbot.script.rt6.TileMatrix)2 GroundItem (org.powerbot.script.rt4.GroundItem)1 Player (org.powerbot.script.rt4.Player)1 TileMatrix (org.powerbot.script.rt4.TileMatrix)1 GroundItem (org.powerbot.script.rt6.GroundItem)1 Player (org.powerbot.script.rt6.Player)1 Projectile (org.powerbot.script.rt6.Projectile)1