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.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, MovementService movement, 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.
-
-
-
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. Logic: Start with a stride of 5, increase by 1 every step, cap at 12.- Parameters:
densePath- The dense path with which to apply variable strides.- Returns:
- A list of WorldPoint representing the strided path.
-
traversePath
public boolean traversePath(net.runelite.api.Client client, MovementService movement, java.util.List<net.runelite.api.coords.WorldPoint> path) throws java.lang.InterruptedExceptionTraverses 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.movement- The MovementService instance responsible for managing player movement commands.path- A list of WorldPoint objects representing the sequence of waypoints to traverse.- Returns:
trueif the path was successfully traversed to the end,falseif any waypoint could not be reached after retries.- Throws:
java.lang.InterruptedException- If the thread running the method is interrupted during execution.
-
-