Interface MouseManager


public interface MouseManager
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    click(int x, int y)
    Dispatches a mouse press event at the specified canvas coordinates.
    Gets a random click point for interacting with an automated menu's target.
    Gets the current mouse movement strategy.
    void
    move(int x, int y)
    Dispatches a mouse move event to the specified canvas coordinates.
    void
    Moves the mouse cursor along a predefined path of points using default parameters.
    void
    moveAlongPath(List<Point> points, int baseDelay, int delayVariation, boolean easeMovement, double easeStrength, boolean fatigueEnabled, double fatigueMultiplier)
    Moves the mouse cursor along a predefined path with custom movement parameters.
    void
    moveTo(Point point)
    Moves the mouse cursor from its current position to the specified target point.
    void
    moveTo(AutomatedMenu automatedMenu)
    Moves the mouse cursor to the interaction point of an automated menu.
    void
    Dispatches a mouse release event.
    resamplePath(List<Point> points, int targetPointCount)
    Resamples a path of points to contain a specific number of evenly distributed points.
    resamplePath(List<Point> points, Point targetPoint)
    Resamples a path of points based on the distance to a target point.
    void
    setMouseMovementStrategy(@NotNull MouseMovementStrategy mouseMovementStrategy)
    Sets the mouse movement strategy for all mouse-based interactions.
  • Method Details

    • setMouseMovementStrategy

      void setMouseMovementStrategy(@NotNull @NotNull MouseMovementStrategy mouseMovementStrategy)
      Sets the mouse movement strategy for all mouse-based interactions.

      The strategy determines how the mouse cursor moves from its current position to interaction targets. Available strategies include:

      • Bezier curve movement (default, natural-looking)
      • Linear movement (direct path)
      • Direct/instant movement (teleports cursor)

      Parameters:
      mouseMovementStrategy - the mouse movement strategy (must not be null)
      See Also:
    • getMouseMovementStrategy

      MouseMovementStrategy getMouseMovementStrategy()
      Gets the current mouse movement strategy.
      Returns:
      the current mouse movement strategy
    • move

      void move(int x, int y)
      Dispatches a mouse move event to the specified canvas coordinates.

      This is a low-level method that directly dispatches a MOUSE_MOVED event to the game canvas. Coordinates are automatically translated if the canvas is in stretched mode. For path-based movement using the configured MouseMovementStrategy, use moveTo(Point) instead.

      Parameters:
      x - the target x-coordinate on the canvas
      y - the target y-coordinate on the canvas
      See Also:
    • click

      void click(int x, int y)
      Dispatches a mouse press event at the specified canvas coordinates.

      This is a low-level method that directly dispatches a MOUSE_PRESSED event to the game canvas at the given coordinates. Coordinates are automatically translated if the canvas is in stretched mode. This method does not move the cursor before clicking; use move(int, int) first if movement is needed.

      Parameters:
      x - the x-coordinate to click
      y - the y-coordinate to click
      See Also:
    • release

      void release()
      Dispatches a mouse release event.

      This is a low-level method that dispatches a MOUSE_RELEASED event to the game canvas. Should be called after click(int, int) to complete a full click cycle, or to end a drag operation.

      See Also:
    • resamplePath

      List<Point> resamplePath(List<Point> points, Point targetPoint)
      Resamples a path of points based on the distance to a target point.

      The number of points in the resampled path is calculated based on the distance from the current mouse position to the target point, using the configured path density and minimum path points settings from StormConfig.

      Parameters:
      points - the original path of points to resample
      targetPoint - the target endpoint used to calculate the resampling density
      Returns:
      a new list of points with density based on distance to target
      See Also:
    • resamplePath

      List<Point> resamplePath(List<Point> points, int targetPointCount)
      Resamples a path of points to contain a specific number of evenly distributed points.

      Points are redistributed along the path's total length to achieve even spacing. The first and last points of the original path are always preserved. If the original path already has more points than requested, or if the path has fewer than 2 points, the original path is returned unchanged.

      Parameters:
      points - the original path of points to resample
      targetPointCount - the desired number of points in the resampled path (minimum 2)
      Returns:
      a new list of points with even spacing, or the original path if resampling is not needed
    • moveAlongPath

      void moveAlongPath(List<Point> points)
      Moves the mouse cursor along a predefined path of points using default parameters.

      The mouse will follow the specified path sequentially, dispatching move events at each point. Movement timing, easing, and fatigue parameters are taken from StormConfig.

      Parameters:
      points - the path of points to follow
      See Also:
    • moveAlongPath

      void moveAlongPath(List<Point> points, int baseDelay, int delayVariation, boolean easeMovement, double easeStrength, boolean fatigueEnabled, double fatigueMultiplier)
      Moves the mouse cursor along a predefined path with custom movement parameters.

      This method provides fine-grained control over the mouse movement behavior including timing, easing, and fatigue simulation for more realistic movements.

      Easing: When enabled, movement is slower at the start and end of the path, and faster in the middle, creating a more natural acceleration/deceleration curve.

      Fatigue: When enabled, movement gradually slows down based on the total distance traveled, simulating human fatigue over long mouse movements.

      Parameters:
      points - the path of points to follow
      baseDelay - the base delay in milliseconds between point movements
      delayVariation - the maximum random variation (in ms) added to the base delay
      easeMovement - whether to apply ease-in-out to the movement (slower at edges, faster in middle)
      easeStrength - the strength of the easing effect (higher values = more pronounced slowing at edges)
      fatigueEnabled - whether to simulate fatigue (gradual slowdown based on distance traveled)
      fatigueMultiplier - the multiplier controlling fatigue intensity (higher = more slowdown over distance)
    • moveTo

      void moveTo(Point point)
      Moves the mouse cursor from its current position to the specified target point.

      This method generates a movement path using the currently configured MouseMovementStrategy, resamples it for smooth movement based on distance, and then executes the movement using configured timing parameters.

      Parameters:
      point - the target point to move to
      See Also:
    • moveTo

      void moveTo(AutomatedMenu automatedMenu)
      Moves the mouse cursor to the interaction point of an automated menu.

      The target position is determined by calling getClickPoint(AutomatedMenu) on the client thread, then the mouse is moved using the currently configured MouseMovementStrategy. After the movement completes, the menu's moveMouse flag is set to false.

      Parameters:
      automatedMenu - the automated menu to move to
      See Also:
    • getClickPoint

      Point getClickPoint(AutomatedMenu menu)
      Gets a random click point for interacting with an automated menu's target.

      The click point is determined using the following priority:

      1. The menu's explicit click point, if set
      2. A random point within the target TileObject's clickbox (for game objects, walls, etc.)
      3. A random point within the target Actor's convex hull (for NPCs and players)
      4. A random point on the canvas as fallback
      The returned point is clamped to valid canvas coordinates.

      Parameters:
      menu - the automated menu to get the click point for
      Returns:
      a point suitable for clicking to interact with the menu's target