Class Walking


  • public class Walking
    extends java.lang.Object
    A class containing every method you need to walk anywhere in the game.

    Some important terminology:

    • Region: An in game region is a grid of 64x64 tiles
    • Global: The global pathfinder (WebFinder) is used to find paths outside of the loaded regions
    • Local: The local pathfinder (LocalPathFinder is used only for paths within the loaded regions

    Generally you shouldn't need to use the pathfinders directly assuming our web contains a path. Most walking in game can be accomplished simply with a call to walk(Tile) which will take one step towards the goal tile. You can call walk(Tile) repeatedly in your script's onLoop until you're close to your destination:

    
     Tile destination = new Tile(3270, 3167);
    
     if (destination.distance() > 5 && Walking.shouldWalk()) {
         Walking.walk(destination);
     }
     
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canWalk​(Tile destination)
      Returns whether you are able to walk to the tile, only works with local tiles.
      static boolean canWalk​(Entity destination)
      Checks whether you can walk to a given entity using local walk.
      static boolean clickTileOnMinimap​(Tile tile)
      Clicks a tile on the minimap
      static Tile getClosestTileOnMap​(Tile tile)
      Returns the closest tile on the minimap to offset given tile.
      static Tile getDestination()
      Gets destination tile (red mini map flag).
      static int getDestinationDistance()
      Gets the distance from the destination
      static int getMinimapTargetSize()  
      static int getRunEnergy()
      Gets the current run energy
      static int getRunThreshold()
      Gets energy level which run will be toggled when using default walk methods.
      static boolean isNoClickWalkEnabled()
      Checks whether the setting for no click walk is enabled or not
      static boolean isRunEnabled()
      Checks whether running is currently enabled via playerSettings.
      static boolean isStaminaActive()  
      static void reset()  
      static void setGangplankHandling​(boolean active)
      Sets whether the walker should check for gangplanks before walking
      static void setMinimapTargetSize​(int sizeInPx)
      Sets the size of MiniMapTileDestination's target area when minimap walking
      static void setObstacleSleeping​(boolean shouldSleep)
      Sets whether the walker should sleep after interacting with an obstacle Setting this to false may result in spam clicking obstacles
      static void setRunThreshold​(int runThreshold)
      Sets energy level which run will be toggled when using default walk methods.
      static boolean shouldHandleGangplanks()
      Gets whether the walker should check for gangplanks before walking
      static boolean shouldObstacleSleep()
      Gets whether the walker should sleep after interacting with an obstacle
      static boolean shouldWalk()
      Calls shouldWalk(4) See shouldWalk(int)
      static boolean shouldWalk​(int distance)
      Returns whether you should walk - if you're moving, it'll check if your distance to destination is less than specified
      static void toggleNoClickWalk​(boolean toggle)  
      static boolean toggleRun()
      Turns on/off run.
      static boolean walk​(int x, int y)
      Walks to the tile at (x, y, 0)
      static boolean walk​(int x, int y, int z)
      Walks to the tile at (x, y, z)
      static boolean walk​(Tile tile)
      Walks to the given tile, using a combination of web and local pathfinders, handling obstacles along the way as necessary.
      static boolean walk​(Entity entity)
      Walks to the tile (or the nearest walkable tile) of the entity.
      static boolean walk​(Locatable locatable)
      Walks to the given Locatable, using a combination of web and local pathfinders, handling obstacles along the way as necessary.
      static boolean walkExact​(Tile tile)
      Attempts to walk to the exact tile
      static boolean walkOnScreen​(Tile tile)
      Clicks on a tile on the main game screen
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • walk

        public static boolean walk​(int x,
                                   int y)
        Walks to the tile at (x, y, 0)
        Parameters:
        x - The x position of the tile
        y - The y position of the tile
        Returns:
        True if successfully moved
      • walk

        public static boolean walk​(int x,
                                   int y,
                                   int z)
        Walks to the tile at (x, y, z)
        Parameters:
        x - The x position of the tile
        y - The y position of the tile
        z - The z position of the tile
        Returns:
        True if successfully moved
      • walk

        public static boolean walk​(Entity entity)
        Walks to the tile (or the nearest walkable tile) of the entity.
        Parameters:
        entity - Entity to walk to.
        Returns:
        True if successfully moved
      • walk

        public static boolean walk​(Tile tile)
        Walks to the given tile, using a combination of web and local pathfinders, handling obstacles along the way as necessary.

        If you find any obstacles that aren't handled, take a look at LocalPathFinder and WebFinder for adding custom obstacles or web nodes.

        Example usage:

         
         Tile tile = new Tile(1500, 1500);
         if (Walking.shouldWalk(5) && Walking.walk(tile)) {
             Sleep.sleep(1000, 1500);
         }
         
         
        Parameters:
        tile - the destination tile.
        Returns:
        true if the client made progress or reached the tile
      • walk

        public static boolean walk​(Locatable locatable)
        Walks to the given Locatable, using a combination of web and local pathfinders, handling obstacles along the way as necessary.

        If you find any obstacles that aren't handled, take a look at LocalPathFinder and WebFinder for adding custom obstacles or web nodes.

        Example usage:

         
         Tile tile = new Tile(1500, 1500);
         if (Walking.shouldWalk(5) && Walking.walk(tile)) {
             Sleep.sleep(1000, 1500);
         }
         
         
        Parameters:
        locatable - the destination
        Returns:
        true if the client made progress or reached the tile
      • clickTileOnMinimap

        public static boolean clickTileOnMinimap​(Tile tile)
        Clicks a tile on the minimap
        Parameters:
        tile - tile to click on
        Returns:
        true if clicked on successfully
      • walkOnScreen

        public static boolean walkOnScreen​(Tile tile)
        Clicks on a tile on the main game screen

        Note: This method will not handle obstacles like walk(Tile) does, it'll only click on the tile

        Parameters:
        tile - the tile to click on screen
        Returns:
        true if successfully interacted with Tile
      • walkExact

        public static boolean walkExact​(Tile tile)
        Attempts to walk to the exact tile
        Parameters:
        tile - Tile to walk to
        Returns:
        true if successfully interacted with Tile
      • shouldWalk

        public static boolean shouldWalk​(int distance)
        Returns whether you should walk - if you're moving, it'll check if your distance to destination is less than specified
        Parameters:
        distance - Distance to check from destination
        Returns:
        True if distance to current destination is less than specified, True if not moving, else false.
      • shouldWalk

        public static boolean shouldWalk()
        Calls shouldWalk(4) See shouldWalk(int)
        Returns:
        true if it should walk or not based off movement and distance to the destination flag
      • toggleRun

        public static boolean toggleRun()
        Turns on/off run.
        Returns:
        true if run setting was successfully changed.
      • isRunEnabled

        public static boolean isRunEnabled()
        Checks whether running is currently enabled via playerSettings.
        Returns:
        true if the run option is enabled.
      • getRunEnergy

        public static int getRunEnergy()
        Gets the current run energy
        Returns:
        0 to 100
      • getClosestTileOnMap

        public static Tile getClosestTileOnMap​(Tile tile)
        Returns the closest tile on the minimap to offset given tile.
        Parameters:
        tile - The destination tile.
        Returns:
        Returns the closest tile to the destination on the minimap.
      • getRunThreshold

        public static int getRunThreshold()
        Gets energy level which run will be toggled when using default walk methods.
        Returns:
        runThreshold the energy level which you would like to start running.
      • setRunThreshold

        public static void setRunThreshold​(int runThreshold)
        Sets energy level which run will be toggled when using default walk methods.
        Parameters:
        runThreshold - the energy level which you would like to start running.
      • getDestinationDistance

        public static int getDestinationDistance()
        Gets the distance from the destination
        Returns:
        Distance from destination, -1 if there is no destination
      • getDestination

        public static Tile getDestination()
        Gets destination tile (red mini map flag).
        Returns:
        Your player's destination, null if not moving
      • canWalk

        public static boolean canWalk​(Tile destination)
        Returns whether you are able to walk to the tile, only works with local tiles.
        Parameters:
        destination - Tile to check if you can walk to
        Returns:
        True if able to find a path, false if not local or unable to find a path to tile.
      • canWalk

        public static boolean canWalk​(Entity destination)
        Checks whether you can walk to a given entity using local walk.
        Parameters:
        destination - Entity to check against
        Returns:
        True if able to find a path to entity, false if entity is null, not local, or not able to find a path
      • setObstacleSleeping

        public static void setObstacleSleeping​(boolean shouldSleep)
        Sets whether the walker should sleep after interacting with an obstacle Setting this to false may result in spam clicking obstacles
      • shouldObstacleSleep

        public static boolean shouldObstacleSleep()
        Gets whether the walker should sleep after interacting with an obstacle
      • setGangplankHandling

        public static void setGangplankHandling​(boolean active)
        Sets whether the walker should check for gangplanks before walking
      • shouldHandleGangplanks

        public static boolean shouldHandleGangplanks()
        Gets whether the walker should check for gangplanks before walking
      • isStaminaActive

        public static boolean isStaminaActive()
      • getMinimapTargetSize

        public static int getMinimapTargetSize()
      • setMinimapTargetSize

        public static void setMinimapTargetSize​(int sizeInPx)
        Sets the size of MiniMapTileDestination's target area when minimap walking
        Parameters:
        sizeInPx - The length of one side of a square for minimap tile destinations
        Throws:
        java.lang.IllegalArgumentException - when given a non-positive size
      • reset

        public static void reset()
      • isNoClickWalkEnabled

        public static boolean isNoClickWalkEnabled()
        Checks whether the setting for no click walk is enabled or not
      • toggleNoClickWalk

        public static void toggleNoClickWalk​(boolean toggle)