Resource [Snippet] Areas and Walking

Discussion in 'Tutorials & Resources' started by Salvation, Mar 31, 2014.

  1. Simple but very useful for traversing large distances from area to area on OSRS (compatible with RS3):
    Code (Text):
    1.  
    2. public class Areas {
    3.  
    4.     public static Coordinate getRandomCoordinate(final Area area) {
    5.         final Coordinate bottom_left = area.getBottomLeft();
    6.         return bottom_left.derive(Random.nextInt(area.getWidth()), Random.nextInt(area.getHeight()));
    7.     }
    8.  
    9.     public static boolean stepTowards(final Area area) {
    10.         final Player player = Players.getLocal();
    11.         if (player == null) {
    12.             return false;
    13.         }
    14.  
    15.         final Coordinate start = player.getPosition();
    16.         final Coordinate destination = getRandomCoordinate(area);
    17.  
    18.         if (Environment.isOSRS()) {
    19.             final LinePath path = new LinePath(start, destination);
    20.             return path.step(true);
    21.         } else {
    22.             final GlobalPathBuilder builder = new GlobalPathBuilder(start, destination);
    23.             builder.useObjects(false);
    24.  
    25.             final GlobalPath path = builder.generatePath();
    26.             return path.step(true);
    27.         }
    28.     }
    29. }
     
    Qosmiof2, Arbiter and Booch like this.

Share This Page

Loading...