Class Reachable


  • public class Reachable
    extends java.lang.Object
    Utility class for determining reachable areas, pathfinding around obstacles, and calculating interaction points for NPCs and objects.
    • Constructor Summary

      Constructors 
      Constructor Description
      Reachable​(rs.kreme.ksbot.api.KSContext ctx)
      Creates a new ReachableArea instance
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canMelee​(net.runelite.api.coords.WorldArea first, net.runelite.api.coords.WorldArea other)
      Checks if two areas are in melee distance of each other Considers walls and obstacles between the areas
      boolean canTravelInDirection​(net.runelite.api.coords.WorldArea w1, int dx, int dy)
      Checks if travel is possible in a specific direction from an area
      boolean canTravelInDirection​(net.runelite.api.coords.WorldArea w1, int dx, int dy, java.util.function.Predicate<? super net.runelite.api.coords.WorldPoint> extraCondition)
      Checks if travel is possible in a specific direction from an area with an additional custom condition
      java.util.List<net.runelite.api.coords.WorldPoint> findSafePath​(net.runelite.api.coords.WorldPoint npcLocation, int npcSize, java.util.Collection<DangerousTile> dangerous)
      Finds a safe path to an NPC that avoids dangerous areas
      net.runelite.api.Point getComparisonPoint​(net.runelite.api.coords.WorldArea first, net.runelite.api.coords.WorldArea other)
      Gets the closest point on the first area to the second area Used for determining interaction points between areas
      java.util.List<net.runelite.api.coords.WorldPoint> getHitSquares​(net.runelite.api.coords.WorldPoint npcLoc, int npcSize, int thickness, boolean includeUnder)
      Gets all tiles within a specified distance of a square NPC or object
      java.util.List<net.runelite.api.coords.WorldPoint> getHitSquares​(net.runelite.api.coords.WorldPoint npcLoc, int width, int height, int thickness, boolean includeUnder)
      Gets all tiles within a specified distance of an NPC or object
      java.util.List<net.runelite.api.coords.WorldPoint> getInteractable​(net.runelite.api.coords.WorldArea locatableArea)
      Gets all tiles that can interact with the specified area (melee range)
      boolean isInteractable​(net.runelite.api.coords.WorldArea locatableArea)
      Checks if any tile in the specified area can be interacted with
      boolean isObstacle​(net.runelite.api.coords.WorldPoint worldPoint)
      Checks if a tile is an obstacle based on its collision flag
      • Methods inherited from class java.lang.Object

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

      • Reachable

        public Reachable​(rs.kreme.ksbot.api.KSContext ctx)
        Creates a new ReachableArea instance
        Parameters:
        ctx - The script context
    • Method Detail

      • isInteractable

        public boolean isInteractable​(net.runelite.api.coords.WorldArea locatableArea)
        Checks if any tile in the specified area can be interacted with
        Parameters:
        locatableArea - The area to check for interactability
        Returns:
        true if any tile in the area can be interacted with
      • getInteractable

        public java.util.List<net.runelite.api.coords.WorldPoint> getInteractable​(net.runelite.api.coords.WorldArea locatableArea)
        Gets all tiles that can interact with the specified area (melee range)
        Parameters:
        locatableArea - The area to find interttaction tiles for
        Returns:
        List of tiles that can interact with the specified area
      • canMelee

        public boolean canMelee​(net.runelite.api.coords.WorldArea first,
                                net.runelite.api.coords.WorldArea other)
        Checks if two areas are in melee distance of each other Considers walls and obstacles between the areas
        Parameters:
        first - The first area
        other - The second area
        Returns:
        true if the areas can melee each other
      • getHitSquares

        public java.util.List<net.runelite.api.coords.WorldPoint> getHitSquares​(net.runelite.api.coords.WorldPoint npcLoc,
                                                                                int width,
                                                                                int height,
                                                                                int thickness,
                                                                                boolean includeUnder)
        Gets all tiles within a specified distance of an NPC or object
        Parameters:
        npcLoc - Location of the NPC or object
        width - Width of the NPC or object
        height - Height of the NPC or object
        thickness - Distance from the NPC or object edges to include
        includeUnder - Whether to include tiles underneath the NPC/object
        Returns:
        List of tiles within the specified range
      • getHitSquares

        public java.util.List<net.runelite.api.coords.WorldPoint> getHitSquares​(net.runelite.api.coords.WorldPoint npcLoc,
                                                                                int npcSize,
                                                                                int thickness,
                                                                                boolean includeUnder)
        Gets all tiles within a specified distance of a square NPC or object
        Parameters:
        npcLoc - Location of the NPC or object
        npcSize - Size of the NPC or object (both width and height)
        thickness - Distance from the NPC or object edges to include
        includeUnder - Whether to include tiles underneath the NPC/object
        Returns:
        List of tiles within the specified range
      • getComparisonPoint

        public net.runelite.api.Point getComparisonPoint​(net.runelite.api.coords.WorldArea first,
                                                         net.runelite.api.coords.WorldArea other)
        Gets the closest point on the first area to the second area Used for determining interaction points between areas
        Parameters:
        first - The first area
        other - The second area
        Returns:
        The closest point on the first area to the second area
      • isObstacle

        public boolean isObstacle​(net.runelite.api.coords.WorldPoint worldPoint)
        Checks if a tile is an obstacle based on its collision flag
        Parameters:
        worldPoint - The world point to check
        Returns:
        true if the point is an obstacle
      • canTravelInDirection

        public boolean canTravelInDirection​(net.runelite.api.coords.WorldArea w1,
                                            int dx,
                                            int dy)
        Checks if travel is possible in a specific direction from an area
        Parameters:
        w1 - The starting area
        dx - X direction (positive = east, negative = west)
        dy - Y direction (positive = north, negative = south)
        Returns:
        true if travel is possible
      • canTravelInDirection

        public boolean canTravelInDirection​(net.runelite.api.coords.WorldArea w1,
                                            int dx,
                                            int dy,
                                            java.util.function.Predicate<? super net.runelite.api.coords.WorldPoint> extraCondition)
        Checks if travel is possible in a specific direction from an area with an additional custom condition
        Parameters:
        w1 - The starting area
        dx - X direction (positive = east, negative = west)
        dy - Y direction (positive = north, negative = south)
        extraCondition - Additional condition that must be true for all tiles
        Returns:
        true if travel is possible
      • findSafePath

        public java.util.List<net.runelite.api.coords.WorldPoint> findSafePath​(net.runelite.api.coords.WorldPoint npcLocation,
                                                                               int npcSize,
                                                                               java.util.Collection<DangerousTile> dangerous)
        Finds a safe path to an NPC that avoids dangerous areas
        Parameters:
        npcLocation - The location of the NPC
        npcSize - The size of the NPC
        dangerous - Collection of dangerous tiles to avoid
        Returns:
        List of world points forming a path to the NPC