Class Calculations
This class contains methods for checking collision flags, determining walkability between tiles, detecting walls and doors, and performing breadth-first search pathfinding to determine which tiles can be reached from a source location.
The collision system uses bitwise flags from CollisionDataFlag to
determine movement restrictions. Walls are detected both through collision flags
and by examining wall objects on tiles.
Example usage:
// Check if a tile is blocked
if (Calculations.isObstacle(client, targetPoint)) {
// Cannot walk to this tile
}
// Check if we can interact with a locatable object
if (Calculations.isInteractable(client, playerLocation, gameObject)) {
// Object is reachable
}
// Check if a specific tile is walkable
if (Calculations.isWalkable(client, playerLocation, destination)) {
// Can walk to destination
}
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanWalk(net.runelite.api.coords.Direction direction, int startFlag, int endFlag) Determines if movement is possible in a specific direction.static booleancheck(int flag, int checkFlag) Checks if a specific flag bit is set in a collision flag.static intgetCollisionFlag(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint point) Gets the collision flag for a specific world point.static net.runelite.api.coords.WorldPointgetNeighbour(net.runelite.api.coords.Direction direction, net.runelite.api.coords.WorldPoint source) Gets the neighboring world point in the specified direction.static List<net.runelite.api.coords.WorldPoint> getNeighbours(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, Locatable locatableDestination) Gets all walkable neighboring tiles from a source point.static List<net.runelite.api.coords.WorldPoint> getVisitedTiles(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, net.runelite.api.coords.WorldPoint worldPoint) Performs a breadth-first search to find all tiles visited when pathfinding from source to a world point.static List<net.runelite.api.coords.WorldPoint> getVisitedTiles(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, net.runelite.api.coords.WorldPoint destination, Locatable locatableDestination) Performs a breadth-first search to find all tiles visited when pathfinding from source to destination.static List<net.runelite.api.coords.WorldPoint> getVisitedTiles(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, Locatable locatable) Performs a breadth-first search to find all tiles visited when pathfinding from source to a locatable object.static booleanChecks if there is a closed door between two adjacent tiles.static booleanisInteractable(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, Locatable locatable) Checks if a locatable object can be interacted with from the source location.static booleanisObstacle(int endFlag) Checks if a collision flag indicates a full movement block.static booleanisObstacle(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint worldPoint) Checks if a world point is a full obstacle that blocks movement.static booleanisWalkable(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, net.runelite.api.coords.WorldPoint worldPoint) Checks if a world point can be walked to from the source location.static booleanisWalled(net.runelite.api.coords.Direction direction, int startFlag) Checks if there is a wall blocking movement in the specified direction.static booleanChecks if there is a wall object blocking movement between two adjacent tiles.
-
Constructor Details
-
Calculations
public Calculations()
-
-
Method Details
-
check
public static boolean check(int flag, int checkFlag) Checks if a specific flag bit is set in a collision flag.- Parameters:
flag- the collision flag value to checkcheckFlag- the specific bit(s) to check for- Returns:
trueif the checkFlag bit(s) are set in flag,falseotherwise
-
isObstacle
public static boolean isObstacle(int endFlag) Checks if a collision flag indicates a full movement block.- Parameters:
endFlag- the collision flag to check- Returns:
trueif the flag indicates a full obstacle,falseotherwise
-
isObstacle
public static boolean isObstacle(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint worldPoint) Checks if a world point is a full obstacle that blocks movement.- Parameters:
client- the game clientworldPoint- the world point to check- Returns:
trueif the tile at the world point is a full obstacle,falseotherwise- Throws:
IllegalStateException- if collision maps are not loaded
-
getCollisionFlag
public static int getCollisionFlag(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint point) Gets the collision flag for a specific world point.If the point is not within the loaded scene, returns
CollisionDataFlag.BLOCK_MOVEMENT_FULLindicating it is blocked.- Parameters:
client- the game clientpoint- the world point to get the collision flag for- Returns:
- the collision flag value for the specified point
- Throws:
IllegalStateException- if collision maps or collision data are not loaded
-
isWalled
public static boolean isWalled(net.runelite.api.coords.Direction direction, int startFlag) Checks if there is a wall blocking movement in the specified direction.Uses direction-specific collision flag bits to determine if a wall exists on the edge of a tile in the given direction.
- Parameters:
direction- the direction to check for a wallstartFlag- the collision flag of the source tile- Returns:
trueif there is a wall blocking the specified direction,falseotherwise- Throws:
IllegalArgumentException- if direction is not a cardinal direction
-
isWalled
Checks if there is a wall object blocking movement between two adjacent tiles.This method examines the wall object on the source tile and its orientation to determine if it blocks movement to the destination tile.
- Parameters:
source- the source tiledestination- the destination tile- Returns:
trueif a wall object blocks movement between the tiles,falseotherwise
-
isDoored
Checks if there is a closed door between two adjacent tiles.A closed door is a wall object that has an "Open" action and blocks movement between the tiles.
- Parameters:
source- the source tiledestination- the destination tile- Returns:
trueif there is a closed door between the tiles,falseotherwise
-
canWalk
public static boolean canWalk(net.runelite.api.coords.Direction direction, int startFlag, int endFlag) Determines if movement is possible in a specific direction.Movement is blocked if the destination tile is a full obstacle or if there is a wall blocking the direction.
- Parameters:
direction- the direction of movementstartFlag- the collision flag of the source tileendFlag- the collision flag of the destination tile- Returns:
trueif movement is possible in the specified direction,falseotherwise
-
getNeighbour
public static net.runelite.api.coords.WorldPoint getNeighbour(net.runelite.api.coords.Direction direction, net.runelite.api.coords.WorldPoint source) Gets the neighboring world point in the specified direction.- Parameters:
direction- the direction to the neighborsource- the source world point- Returns:
- the world point one tile in the specified direction from source
- Throws:
IllegalArgumentException- if direction is not a cardinal direction
-
getNeighbours
public static List<net.runelite.api.coords.WorldPoint> getNeighbours(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, Locatable locatableDestination) Gets all walkable neighboring tiles from a source point.If a locatable destination is provided, tiles that are part of the destination's area are included even if they would normally be blocked, allowing interaction with game objects.
- Parameters:
client- the game clientsource- the source world pointlocatableDestination- optional destination object for special handling, may benull- Returns:
- a list of walkable neighboring world points
-
getVisitedTiles
public static List<net.runelite.api.coords.WorldPoint> getVisitedTiles(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, net.runelite.api.coords.WorldPoint destination, Locatable locatableDestination) Performs a breadth-first search to find all tiles visited when pathfinding from source to destination.The search stops when the destination is reached or when
MAX_ATTEMPTED_TILEShave been checked.- Parameters:
client- the game clientsource- the starting world pointdestination- the target world point, may benullif locatableDestination is providedlocatableDestination- optional destination object for special handling, may benullif destination is provided- Returns:
- a list of visited world points during pathfinding, or an empty list if the destination is not in the scene or on a different plane
-
getVisitedTiles
public static List<net.runelite.api.coords.WorldPoint> getVisitedTiles(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, Locatable locatable) Performs a breadth-first search to find all tiles visited when pathfinding from source to a locatable object.This is a convenience method for compatibility that delegates to
getVisitedTiles(Client, WorldPoint, WorldPoint, Locatable).- Parameters:
client- the game clientsource- the starting world pointlocatable- the target locatable object- Returns:
- a list of visited world points during pathfinding
-
getVisitedTiles
public static List<net.runelite.api.coords.WorldPoint> getVisitedTiles(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, net.runelite.api.coords.WorldPoint worldPoint) Performs a breadth-first search to find all tiles visited when pathfinding from source to a world point.This is a convenience method for compatibility that delegates to
getVisitedTiles(Client, WorldPoint, WorldPoint, Locatable).- Parameters:
client- the game clientsource- the starting world pointworldPoint- the target world point- Returns:
- a list of visited world points during pathfinding
-
isInteractable
public static boolean isInteractable(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, Locatable locatable) Checks if a locatable object can be interacted with from the source location.An object is interactable if pathfinding from the source can reach the object's world location.
- Parameters:
client- the game clientsource- the starting world point (typically player position)locatable- the object to check interactability for- Returns:
trueif the object can be interacted with from the source,falseotherwise
-
isWalkable
public static boolean isWalkable(net.runelite.api.Client client, net.runelite.api.coords.WorldPoint source, net.runelite.api.coords.WorldPoint worldPoint) Checks if a world point can be walked to from the source location.A point is walkable if pathfinding from the source can reach it.
- Parameters:
client- the game clientsource- the starting world point (typically player position)worldPoint- the destination to check walkability for- Returns:
trueif the destination can be walked to from the source,falseotherwise
-