Resource [Snippet] Areas and Walking

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

  1. Salvation

    Salvation First Bot Author

    Joined:
    Aug 7, 2013
    Messages:
    257
    Likes Received:
    64
    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.
  2. qiqiqiqi

    Joined:
    Apr 21, 2017
    Messages:
    1
    Likes Received:
    0
  3. Jux7apose

    Joined:
    Mar 28, 2017
    Messages:
    178
    Likes Received:
    42
    Is there any instance or reason to use this rather than WebPath?
     
  4. Geashaw

    Joined:
    Jan 8, 2015
    Messages:
    1,402
    Likes Received:
    248
    Check the post date, and laugh at the person above you.
     
    sickness0666 likes this.
  5. Jux7apose

    Joined:
    Mar 28, 2017
    Messages:
    178
    Likes Received:
    42
    Welp.
     

Share This Page

Loading...