Package com.kraken.api.service.movement
Class MovementService
- java.lang.Object
-
- com.kraken.api.service.movement.MovementService
-
public class MovementService extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description MovementService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<net.runelite.api.coords.WorldPoint>applyVariableStride(java.util.List<net.runelite.api.coords.WorldPoint> densePath)Converts a dense path (every tile) into a strided path of "waypoint" tiles.java.util.List<net.runelite.api.coords.WorldPoint>applyVariableStride(java.util.List<net.runelite.api.coords.WorldPoint> densePath, VariableStrideConfig config)Converts a dense path (every tile) into a strided path of "waypoint" tiles.voidmoveTo(net.runelite.api.coords.LocalPoint point)Moves the player to a specified LocalPoint.voidmoveTo(net.runelite.api.coords.WorldPoint point)Moves the player to the specified WorldPoint, handling instanced areas conversion when necessary.booleantraversePath(net.runelite.api.Client client, java.util.List<net.runelite.api.coords.WorldPoint> path)Traverses a given path made up of waypoints, attempting to successfully move the player to each WorldPoint in the sequence.booleantraversePath(net.runelite.api.Client client, java.util.List<net.runelite.api.coords.WorldPoint> path, java.util.function.Consumer<java.lang.String> onWaypointReached)Traverses a given path made up of waypoints, attempting to successfully move the player to each WorldPoint in the sequence.booleantraversePath(net.runelite.api.Client client, java.util.List<net.runelite.api.coords.WorldPoint> path, java.util.function.Consumer<java.lang.String> onWaypointReached, java.util.function.Consumer<java.lang.String> onDestinationReached)Traverses a given path made up of waypoints, attempting to successfully move the player to each WorldPoint in the sequence.
-
-
-
Method Detail
-
moveTo
public void moveTo(net.runelite.api.coords.WorldPoint point)
Moves the player to the specified WorldPoint, handling instanced areas conversion when necessary. This method ensures accurate movement by checking if the player is within an instance and applying the respective LocalPoint to WorldPoint conversion.The operation involves:
- Converting the given WorldPoint to handle instanced logic if the player is in an instance.
- Obtaining a click position on the game canvas for the target point.
- Sending interaction packets to queue both mouse clicks and movement commands.
- Parameters:
point- The WorldPoint representing the destination to move towards.
-
moveTo
public void moveTo(net.runelite.api.coords.LocalPoint point)
Moves the player to a specified LocalPoint. This method accounts for whether the player is within an instance and converts the LocalPoint to a WorldPoint to enable movement. If the current top-level world view is an instance, additional conversion logic is applied to ensure accuracy.The method performs the following actions:
- Converts the provided LocalPoint to a WorldPoint, handling instance logic if needed.
- Determines the clickbox for the target WorldPoint to simulate a mouse click.
- Queues packets to notify the game client of the movement and corresponding mouse interaction.
- Parameters:
point- The LocalPoint representing the target destination to move towards.
-
applyVariableStride
public java.util.List<net.runelite.api.coords.WorldPoint> applyVariableStride(java.util.List<net.runelite.api.coords.WorldPoint> densePath)
Converts a dense path (every tile) into a strided path of "waypoint" tiles. Tiles are based around a variable stride configuration which computes a Gaussian distribution for the length of each stride to take.- Parameters:
densePath- The dense path with which to apply variable strides.- Returns:
- A list of WorldPoint representing the strided path.
-
applyVariableStride
public java.util.List<net.runelite.api.coords.WorldPoint> applyVariableStride(java.util.List<net.runelite.api.coords.WorldPoint> densePath, VariableStrideConfig config)Converts a dense path (every tile) into a strided path of "waypoint" tiles. Tiles are based around a variable stride configuration which computes a Gaussian distribution for the length of each stride to take.- Parameters:
densePath- The dense path with which to apply variable strides.config- A variable stride configuration where the mean, min, max, and std dev can be configured to produce unique strides when traversing paths.- Returns:
- A list of WorldPoint representing the strided path.
-
traversePath
public boolean traversePath(net.runelite.api.Client client, java.util.List<net.runelite.api.coords.WorldPoint> path)Traverses a given path made up of waypoints, attempting to successfully move the player to each WorldPoint in the sequence. This method moves the player towards the target waypoints and handles retries for unreachable points. The traversal stops if any waypoint cannot be reached after multiple attempts.- Parameters:
client- The client instance used to interact with the game world and manage player movement.path- A list of WorldPoint objects representing the waypoints to traverse in sequence.- Returns:
trueif the path was successfully traversed to the end, orfalseif any waypoint could not be reached after retries.
-
traversePath
public boolean traversePath(net.runelite.api.Client client, java.util.List<net.runelite.api.coords.WorldPoint> path, java.util.function.Consumer<java.lang.String> onWaypointReached)Traverses a given path made up of waypoints, attempting to successfully move the player to each WorldPoint in the sequence. This method moves the player towards the target waypoints and handles retries for unreachable points. The traversal stops if any waypoint cannot be reached after multiple attempts.- Parameters:
client- The client instance used to interact with the game world and manage player movement.path- A list of WorldPoint objects representing the waypoints to traverse in sequence.onWaypointReached- A functional interface invoked when a waypoint in the path is reached- Returns:
trueif the path was successfully traversed to the end, orfalseif any waypoint could not be reached after retries.
-
traversePath
public boolean traversePath(net.runelite.api.Client client, java.util.List<net.runelite.api.coords.WorldPoint> path, java.util.function.Consumer<java.lang.String> onWaypointReached, java.util.function.Consumer<java.lang.String> onDestinationReached)Traverses a given path made up of waypoints, attempting to successfully move the player to each WorldPoint in the sequence. This method invokes movement commands and uses retries if a waypoint fails to be reached. It aborts if a waypoint cannot be reached after multiple attempts.The method performs the following tasks for each waypoint in the path:
- Sends a movement command to the client to move towards the target waypoint.
- Calculates a dynamic timeout based on distance and walking speed, with a buffer for path variance.
- Waits for the player to reach the waypoint within the allowed timeout.
- Retries the movement command up to two times if the waypoint is not reached within the timeout.
- Aborts and returns failure if retries are exhausted for any waypoint.
- Parameters:
client- The client instance used to interact with the game world and retrieve the player's location.path- A list of WorldPoint objects representing the sequence of waypoints to traverse.onWaypointReached- A functional interface invoked when a waypoint is reachedonDestinationReached- A functional interface invoked when the paths final destination is reached- Returns:
trueif the path was successfully traversed to the end,falseif any waypoint could not be reached after retries.
-
-