Package rsb.methods

Class Calculations


public class Calculations extends MethodProvider
Game world and projection calculations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int[]
     
    static final int[]
     

    Fields inherited from class rsb.methods.MethodProvider

    methods
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the angle to a given tile in degrees anti-clockwise from the positive x axis (where the x-axis is from west to east).
    boolean
    canReach(RSTile dest, boolean isObject)
    checks whether a given RSTile is reachable.
    static Point
    convertRLPointToAWTPoint(net.runelite.api.Point point)
     
    double
    distanceBetween(net.runelite.api.Point curr, net.runelite.api.Point dest)
    Calculates the distance between two points.
    double
    Returns the diagonal distance (hypot) between two RSTiles.
    int
    Returns the diagonal distance to a given RSCharacter.
    int
    Returns the diagonal distance to a given RSObject.
    int
    Returns the diagonal distance to a given RSTile.
    net.runelite.api.Point
     
    getTileBoundsPoly(Positionable positionable, int additionalHeight)
     
    Will return the closest tile that is on screen to the given tile.
    net.runelite.api.Point
    groundToScreen(int x, int y, int height)
    Returns the screen location of a given point on the ground.
    int
    pathLengthBetween(RSTile start, RSTile dest, boolean isObject)
    Returns the length of the path generates between two RSTiles.
    int
    pathLengthTo(RSTile dest, boolean isObject)
    Returns the length of the path generated to a given RSTile.
    boolean
    pointOnScreen(net.runelite.api.Point check)
    Checks whether a point is within the rectangle that determines the bounds of game screen.
    double
    random(double min, double max)
    Returns a random double in a specified range
    int
    tileHeight(int x, int y)
    Returns the height of the ground at the given location in the game world.
    boolean
    Checks whether a given tile is on the minimap.
    boolean
    Checks whether the centroid of a given tile is on the screen.
    net.runelite.api.Point
    Returns the Point on screen where a given tile is shown on the minimap.
    net.runelite.api.Point
    Returns the screen location of the south-west corner of the given tile.
    net.runelite.api.Point
    tileToScreen(RSTile tile, double dX, double dY, int height)
    Returns the screen location of a Tile with given 3D x, y and height offset values.
    net.runelite.api.Point
    tileToScreen(RSTile tile, int height)
    Returns the screen location of a Tile with a given 3D height offset.
    net.runelite.api.Point
    worldToMinimap(double x, double y)
    Returns the screen Point of given absolute x and y values in the game's 3D plane.
    net.runelite.api.Point
    worldToScreen(int x, int y, int z)
    Returns the screen location of a given 3D point in the game world.
    net.runelite.api.Point
    worldToScreen(int x, int y, int plane, int z)
    Returns the screen location of a given 3D point in the game world.

    Methods inherited from class rsb.methods.MethodProvider

    random, random, random, sleep

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SIN_TABLE

      public static final int[] SIN_TABLE
    • COS_TABLE

      public static final int[] COS_TABLE
  • Method Details

    • tileOnMap

      public boolean tileOnMap(RSTile t)
      Checks whether a given tile is on the minimap.
      Parameters:
      t - The Tile to check.
      Returns:
      true if the RSTile is on the minimap; otherwise false.
      See Also:
    • tileOnScreen

      public boolean tileOnScreen(RSTile t)
      Checks whether the centroid of a given tile is on the screen.
      Parameters:
      t - The RSTile to check.
      Returns:
      true if the RSTile is on the screen; otherwise false.
    • tileToMinimap

      public net.runelite.api.Point tileToMinimap(RSTile t)
      Returns the Point on screen where a given tile is shown on the minimap.
      Parameters:
      t - The RSTile to check.
      Returns:
      Point within minimap; otherwise new Point(-1, -1).
    • pointOnScreen

      public boolean pointOnScreen(net.runelite.api.Point check)
      Checks whether a point is within the rectangle that determines the bounds of game screen. This will work fine when in fixed mode. In resizable mode it will exclude any points that are less than 253 pixels from the right of the screen or less than 169 pixels from the bottom of the screen, giving a rough area.
      Parameters:
      check - The point to check.
      Returns:
      true if the point is within the rectangle; otherwise false.
    • distanceBetween

      public double distanceBetween(net.runelite.api.Point curr, net.runelite.api.Point dest)
      Calculates the distance between two points.
      Parameters:
      curr - The first point.
      dest - The second point.
      Returns:
      The distance between the two points, using the distance formula.
      See Also:
    • random

      public double random(double min, double max)
      Returns a random double in a specified range
      Overrides:
      random in class MethodProvider
      Parameters:
      min - Minimum value (inclusive).
      max - Maximum value (exclusive).
      Returns:
      The random double generated.
    • getTileOnScreen

      public RSTile getTileOnScreen(RSTile tile)
      Will return the closest tile that is on screen to the given tile.
      Parameters:
      tile - Tile you want to get to.
      Returns:
      RSTile that is onScreen.
    • angleToTile

      public int angleToTile(RSTile t)
      Returns the angle to a given tile in degrees anti-clockwise from the positive x axis (where the x-axis is from west to east).
      Parameters:
      t - The target tile
      Returns:
      The angle in degrees
    • tileToScreen

      public net.runelite.api.Point tileToScreen(RSTile tile, double dX, double dY, int height)
      Returns the screen location of a Tile with given 3D x, y and height offset values.
      Parameters:
      tile - RSTile for which the screen location should be calculated.
      dX - Distance from bottom left of the tile to bottom right. Ranges from 0-1;
      dY - Distance from bottom left of the tile to top left. Ranges from 0-1;
      height - Height offset (normal to the ground) to return the Point at.
      Returns:
      Point based on position on the game plane; otherwise new Point(-1, -1).
    • tileToScreen

      public net.runelite.api.Point tileToScreen(RSTile tile, int height)
      Returns the screen location of a Tile with a given 3D height offset.
      Parameters:
      tile - RSTile for which the screen location should be calculated.
      height - Height offset (normal to the ground) to return the Point at.
      Returns:
      Point based on position on the game plane; if null new Point(-1, -1).
      See Also:
    • tileToScreen

      public net.runelite.api.Point tileToScreen(RSTile tile)
      Returns the screen location of the south-west corner of the given tile.
      Parameters:
      tile - RSTile for which the screen location should be calculated.
      Returns:
      Center Point of the RSTile at a height of 0; if null new Point(-1, -1).
      See Also:
    • distanceTo

      public int distanceTo(RSCharacter c)
      Returns the diagonal distance to a given RSCharacter.
      Parameters:
      c - The destination character.
      Returns:
      Distance to RSCharacter.
      See Also:
    • distanceTo

      public int distanceTo(RSObject o)
      Returns the diagonal distance to a given RSObject.
      Parameters:
      o - The destination object.
      Returns:
      Distance to RSObject.
      See Also:
    • distanceTo

      public int distanceTo(RSTile t)
      Returns the diagonal distance to a given RSTile.
      Parameters:
      t - The destination tile.
      Returns:
      Distance to RSTile.
    • distanceBetween

      public double distanceBetween(RSTile curr, RSTile dest)
      Returns the diagonal distance (hypot) between two RSTiles.
      Parameters:
      curr - The starting tile.
      dest - The destination tile.
      Returns:
      The diagonal distance between the two RSTiles.
      See Also:
    • pathLengthTo

      public int pathLengthTo(RSTile dest, boolean isObject)
      Returns the length of the path generated to a given RSTile.
      Parameters:
      dest - The destination tile.
      isObject - true if reaching any tile adjacent to the destination should be accepted.
      Returns:
      true if reaching any tile adjacent to the destination should be accepted.
    • pathLengthBetween

      public int pathLengthBetween(RSTile start, RSTile dest, boolean isObject)
      Returns the length of the path generates between two RSTiles.
      Parameters:
      start - The starting tile.
      dest - The destination tile.
      isObject - true if reaching any tile adjacent to the destination should be accepted.
      Returns:
      true if reaching any tile adjacent to the destination should be accepted.
    • canReach

      public boolean canReach(RSTile dest, boolean isObject)
      checks whether a given RSTile is reachable.
      Parameters:
      dest - The RSTile to check.
      isObject - True if an instance of RSObject.
      Returns:
      true if player can reach specified Object; otherwise false.
    • worldToMinimap

      public net.runelite.api.Point worldToMinimap(double x, double y)
      Returns the screen Point of given absolute x and y values in the game's 3D plane.
      Parameters:
      x - x value based on the game plane.
      y - y value based on the game plane.
      Returns:
      Point within minimap; otherwise new Point(-1, -1).
    • groundToScreen

      public net.runelite.api.Point groundToScreen(int x, int y, int height)
      Returns the screen location of a given point on the ground. This accounts for the height of the ground at the given location.
      Parameters:
      x - x value based on the game plane.
      y - y value based on the game plane.
      height - height offset (normal to the ground).
      Returns:
      Point based on screen; otherwise new Point(-1, -1).
    • tileHeight

      public int tileHeight(int x, int y)
      Returns the height of the ground at the given location in the game world.
      Parameters:
      x - x value based on the game plane.
      y - y value based on the game plane.
      Returns:
      The ground height at the given location; otherwise 0 .
    • worldToScreen

      public net.runelite.api.Point worldToScreen(int x, int y, int z)
      Returns the screen location of a given 3D point in the game world.
      Parameters:
      x - x value on the game plane.
      y - y value on the game plane.
      z - z value on the game plane.
      Returns:
      Point based on screen; otherwise new Point(-1, -1).
    • worldToScreen

      public net.runelite.api.Point worldToScreen(int x, int y, int plane, int z)
      Returns the screen location of a given 3D point in the game world.
      Parameters:
      x - x value on the game plane.
      y - y value on the game plane.
      plane - the game level (plane) value.
      z - z value on the game plane.
      Returns:
      Point based on screen; otherwise new Point(-1, -1).
    • getTileBoundsPoly

      public Polygon getTileBoundsPoly(Positionable positionable, int additionalHeight)
    • getRandomPolyPoint

      public net.runelite.api.Point getRandomPolyPoint(Polygon polygon)
    • convertRLPointToAWTPoint

      public static Point convertRLPointToAWTPoint(net.runelite.api.Point point)