RSObjects¶
This page is about RSObjects which are an interface for interacting with game objects.
TRSObject¶
Main type to handle RSObjects.
TRSObjectArray¶
Array of TRSObject.
RSObject.Construct¶
function TRSObject.Construct(walker: PRSWalker; size: TVector3; coordinates: TPointArray; uptext: TStringArray = []): TRSObject; static;
function TRSObject.Construct(json: TJSONItem): TRSObject; static; overload;
Constructors to create your TRSObject.
Assuming you create the RSObject
manually, the constructor will provide you
with a fully built TRSObject
without a finder.
You may optionally assign one later if you want:
{$I WaspLib/osrs.simba}
var
obj: TRSObject;
begin
Map.Setup([ERSChunk.VARROCK]);
obj := new TRSObject(@Map.Walker, [1,1,7], [[8648,36686]], ['Bank booth']);
//obj.Finder.Colors += $FFFFFF;
end;
The json
version of the function expects a specific json structure which is
the one that Map JSONs provide:
{$I WaspLib/osrs.simba}
var
obj: TRSObject;
begin
Map.Setup([ERSChunk.VARROCK]);
//Item[0] because this returns a JSON array. For more info read Map JSONs documentation.
obj := new TRSObject(ObjectsJSON.GetByName('bank', 1).Item[0]);
end;
RSObjectArray.Create¶
function TRSObjectArray.Create(json: TJSONItem): TRSObjectArray; static; overload;
Constructor function to build your TRSObjectArray.
This only accepts a json
array and it expects a specific json structure which is
the one that Map JSONs provide.
Example:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObject.Create(ObjectsJSON.GetByName('bank'));
end;
RSObject.GetCuboidArray¶
function TRSObject.GetCuboidArray(me: TPoint; angle: Single = $FFFF): TCuboidArray;
Internal function that returns an array of cuboids of the object if it’s coordinates are visible on the MainScreen.
Example:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
cuboids: TCuboidArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
cuboids := objs[1].GetCuboidArray(Map.Position());
ShowOnTarget(cuboids);
end.

RSObject.FindOnMainScreen¶
function TRSObject.FindOnMainScreen(cuboidArray: TCuboidArray): T2DPointArray;
Internal TRSObject method responsible for filtering a TCuboidArray by what’s visible in the mainscren.
This is meant to filter TRSObject.GetCuboidArray so targets that are outside of the mainscreen are filtered out.
You will probably never need to use this directly.
RSObject.FindEx¶
function TRSObject.FindEx(me: TPoint; out cuboids: TCuboidArray; out atpa: T2DPointArray): Boolean;
Internal TRSObject method used to find a RSObject. If found returns true, if not returns false.
You also have RSObject.Find to find objects, this version of the method
is internal because it returns extra information about the found objects for
internal use, like it’s cuboids
for example.
This also returns an atpa
containing the colors of the object that were found
assuming the object has a TColorFinder setup.
If not, the cuboids area are returned as the match.
This extra information is easy to see when you debug your object with
ShowOnTarget(TRSObject)
:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
ShowOnTarget(objs[1]);
end.

As you can see, this image is very similar to the one in RSObject.GetCuboidArray, they differ however in the fact that this one, aside from the cuboids also shows the object colors that were found within the cuboids.
This object colors is what’s returned through the atpa
and is what would be
clicked if you use RSObject.Click for example.
Assuming your RSObject
does not have a TColorFinder setup, this is what
it would look like:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
objs[1].Finder := []; //removing the finder for this example.
ShowOnTarget(objs[1]);
end.

RSObject.Find¶
function TRSObject.Find(out atpa: T2DPointArray): Boolean;
TRSObject method used to find a RSObject.
This returns True/False if the object was found and it’s atpa
which cointains
the colors of it that were found.
For more information on this refer to RSObject.FindEx, it’s an internal function but is user within this one and will go into more detail.
RSObject.FindFrom¶
function TRSObject.FindFrom(position: TPoint; out atpa: T2DPointArray): Boolean;
This is similar to RSObject.Find but differs from it in that you can set
your position
.
This is only useful when you want to predict an object position as if you were somewhere else you are not.
What you use this for is up to you but an example use case is to pre-hover
objects before you reach a position
you know you will be at in the future.
For example, imagine a slow agility obstacle on an agility course. Imagine you
want to click the obstacle and hover the next. You know where you will be after
you get through the current obstacle so you can use this to set your position
to where you will be after the current obstacle and hover the next one:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
atpa: T2DPointArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
objs[1].Finder := [];
while True do
begin
ShowOnTarget(atpa);
objs[1].FindFrom([8912,36742], atpa);
end;
end.

As you can see on the gif above, the objects debug match the object exactly when you are at the right coordinate.
For this I also recommend to not have a TColorFinder
setup because it will
only match when you are at the right position.
RSObject._UpTextCheck¶
function TRSObject._UpTextCheck(out shouldExit: Boolean): Boolean;
Internal TRSObject
helper method that is used by all hovering methods.
You probably don’t need to use this directly.
RSObject.PreHover¶
function TRSObject.PreHover(me: TPoint; attempts: Integer = 2): Boolean;
To understand what this does it’s recommended to read RSObject.FindFrom.
This method basically uses RSObject.FindFrom and asynchronously moves the mouse to one of the matches.
RSObject._ClickHelper¶
function TRSObject._ClickHelper(leftClick: Boolean): Boolean;
Internal TRSObject
helper method that is used by other clicking methods.
You probably don’t need to use this directly.
This is what’s responsible for deciding if we click a target we are hovering or not.
RSObject._SelectHelper¶
function TRSObject._SelectHelper(action: TStringArray): Boolean;
Internal TRSObject helper method that is used by other select methods.
You probably don’t need to use this directly.
This is what is responsible for deciding if we just left click a target we are hovering or right click it and choose an option.
RSObject.Hover¶
function TRSObject.Hover(action: TStringArray = []; attempts: Integer = 2): Boolean;
Method used to hover a TRSObject target if it’s found on the mainscreen.
Example:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
atpa: T2DPointArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
objs[1].Hover();
end.

RSObject.WalkHover¶
function TRSObject.WalkHover(action: TStringArray = []; attempts: Integer = 2): Boolean;
Method used to walk towards and hover a TRSObject
target if it’s found on the
mainscreen.
Example:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
atpa: T2DPointArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
objs[1].WalkHover();
end.

In the gif above the function exited true before we finished walking which is why it’s not hovering the bank after we finished walking.
The way this works is that if we successfully hover the bank while walking it returns true.
RSObject.Click¶
function TRSObject.Click(leftClick: Boolean = True; attempts: Integer = 2): Boolean;
Method used to click a TRSObject
target if it’s found on the mainscreen.
Example:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
atpa: T2DPointArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
objs[1].Click();
end.

RSObject.Select¶
function TRSObject.Select(action: TStringArray; attempts: Integer = 2): Boolean;
Method used to select an option on a TRSObject
target if it’s found on the
mainscreen.
Through action
you can specify the interaction you are looking for.
If this interaction is the uptext when you hover the object WaspLib will simply
left click it.
Example:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
atpa: T2DPointArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
objs[1].Select(['Collect']);
end.

RSObject.WalkClick¶
function TRSObject.WalkClick(leftClick: Boolean = True; attempts: Integer = 2): Boolean;
Method used to walk towards and click a TRSObject
target if it’s found on the
mainscreen.
Example:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
atpa: T2DPointArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
objs[1].WalkClick();
end.

RSObject.WalkSelect¶
function TRSObject.WalkSelect(action: TStringArray; attempts: Integer = 2): Boolean;
Method used to walk towards and select an option on a TRSObject
target if it’s
found on the mainscreen.
Through action
you can specify the interaction you are looking for.
If this interaction is the uptext when you hover the object WaspLib will simply
left click it.
Example:
{$I WaspLib/osrs.simba}
var
objs: TRSObjectArray;
atpa: T2DPointArray;
begin
Map.Setup([ERSChunk.VARROCK]);
objs := TRSObjectArray.Create(ObjectsJSON.GetByAction('Bank'));
objs[1].WalkSelect(['Collect']);
end.

RSObject.DistanceTo¶
function TRSObject.DistanceTo(pt: TPoint): Double;
Returns the distance of an object to you. Because RSObjects can have multiple coordinates, only the closest one is considered for the calculation.
This is useful to for example, compared which of 2 objects are closest to you.
Example:
me := Map.Position();
if bankBooth.DistanceTo(me) < bankChest.DistanceTo(me) then
bankBooth.WalkClick()
else
bankChest.WalkClick();
RSObjectArray.ClosestIndex¶
function TRSObjectArray.ClosestIndex(pt: TPoint): Integer;
Returns the index of the TRSObjectArray
which is closest to you.
Uses RSObject.DistanceTo on each of the indices of the current
TRSObjectArray
and returns the closest index.
TImage.DrawObject¶
procedure TImage.DrawObject(obj: TRSObject);
Helper method to debug TRSObjects.
ShowOnTarget TRSObject¶
procedure ShowOnTarget(obj: TRSObject); overload;
Shows an image of the target with the TRSObject
drawn on it.