Search in sources :

Example 1 with Landscape

use of org.powerbot.bot.rt4.client.Landscape 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;
}
Also used : Landscape(org.powerbot.bot.rt4.client.Landscape) Tile(org.powerbot.script.Tile) Client(org.powerbot.bot.rt4.client.Client)

Aggregations

Client (org.powerbot.bot.rt4.client.Client)1 Landscape (org.powerbot.bot.rt4.client.Landscape)1 Tile (org.powerbot.script.Tile)1