Package rsb.methods
Class Calculations
java.lang.Object
rsb.methods.MethodProvider
rsb.methods.Calculations
Game world and projection calculations.
-
Field Summary
FieldsFields inherited from class rsb.methods.MethodProvider
methods
-
Method Summary
Modifier and TypeMethodDescriptionint
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
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
distanceBetween
(RSTile curr, RSTile dest) 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
distanceTo
(RSTile t) Returns the diagonal distance to a given RSTile.net.runelite.api.Point
getRandomPolyPoint
(Polygon polygon) getTileBoundsPoly
(Positionable positionable, int additionalHeight) getTileOnScreen
(RSTile tile) 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 rangeint
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
tileToScreen
(RSTile tile) 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
-
Field Details
-
SIN_TABLE
public static final int[] SIN_TABLE -
COS_TABLE
public static final int[] COS_TABLE
-
-
Method Details
-
tileOnMap
Checks whether a given tile is on the minimap.- Parameters:
t
- The Tile to check.- Returns:
true
if the RSTile is on the minimap; otherwisefalse
.- See Also:
-
tileOnScreen
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; otherwisefalse
.
-
tileToMinimap
Returns the Point on screen where a given tile is shown on the minimap.- Parameters:
t
- The RSTile to check.- Returns:
Point
within minimap; otherwisenew 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; otherwisefalse
.
-
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 classMethodProvider
- Parameters:
min
- Minimum value (inclusive).max
- Maximum value (exclusive).- Returns:
- The random
double
generated.
-
getTileOnScreen
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
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
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 thePoint
at.- Returns:
Point
based on position on the game plane; otherwisenew Point(-1, -1)
.
-
tileToScreen
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 thePoint
at.- Returns:
Point
based on position on the game plane; if nullnew Point(-1, -1)
.- See Also:
-
tileToScreen
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 nullnew Point(-1, -1)
. - See Also:
-
distanceTo
Returns the diagonal distance to a given RSCharacter.- Parameters:
c
- The destination character.- Returns:
- Distance to
RSCharacter
. - See Also:
-
distanceTo
Returns the diagonal distance to a given RSObject.- Parameters:
o
- The destination object.- Returns:
- Distance to
RSObject
. - See Also:
-
distanceTo
Returns the diagonal distance to a given RSTile.- Parameters:
t
- The destination tile.- Returns:
- Distance to
RSTile
.
-
distanceBetween
Returns the diagonal distance (hypot) between two RSTiles.- Parameters:
curr
- The starting tile.dest
- The destination tile.- Returns:
- The diagonal distance between the two
RSTile
s. - See Also:
-
pathLengthTo
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
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
checks whether a given RSTile is reachable.- Parameters:
dest
- TheRSTile
to check.isObject
- True if an instance ofRSObject
.- Returns:
true
if player can reach specified Object; otherwisefalse
.
-
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; otherwisenew 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; otherwisenew 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; otherwisenew 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; otherwisenew Point(-1, -1)
.
-
getTileBoundsPoly
-
getRandomPolyPoint
-
convertRLPointToAWTPoint
-