Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Resource [Snippet] Areas and Walking

First Bot Author
Joined
Aug 7, 2013
Messages
262
Simple but very useful for traversing large distances from area to area on OSRS (compatible with RS3):
Code:
public class Areas {

    public static Coordinate getRandomCoordinate(final Area area) {
        final Coordinate bottom_left = area.getBottomLeft();
        return bottom_left.derive(Random.nextInt(area.getWidth()), Random.nextInt(area.getHeight()));
    }

    public static boolean stepTowards(final Area area) {
        final Player player = Players.getLocal();
        if (player == null) {
            return false;
        }

        final Coordinate start = player.getPosition();
        final Coordinate destination = getRandomCoordinate(area);

        if (Environment.isOSRS()) {
            final LinePath path = new LinePath(start, destination);
            return path.step(true);
        } else {
            final GlobalPathBuilder builder = new GlobalPathBuilder(start, destination);
            builder.useObjects(false);

            final GlobalPath path = builder.generatePath();
            return path.step(true);
        }
    }
}
 
Top