Welcome to The "Official" Guide to The "Unofficial" Reflection Include for Osr
Since there hasn't been an official reflection include for simba in a few years, I’m sure there are a lot of people who aren't sure exactly how to use reflection to help increase the accuracy and efficiency of a color script. Furthermore the reflection include that we are currently working is written differently than previous versions. This compelled me to make a detailed guide to help increase the amount of scripts posted. I will break the guide down into three sections:
- How to download, setup and get reflection working with simba
- How to use the various functions within the include
- Antirandoms
Since the include is still very new, we are constantly adding new functions and trying different idea's. As such, there is a good chance that there may be a few bugs. Please post here if any are found. Also, if there are any functions that you would like to see be added, or anything that you think could be changed, let one of us know!
Downloading and setup:
Well the most important part is to download and get the include setup properly to run with simba!
The first step is to go to github where the include is posted, which is found
here
After that, you are going to want to download the .zip file from:
I suggest saving it to your desktop, so it is easier to find once you go to extract it. From where ever you decide to save the .zip, you are going to want to extract is using your favorite unzip program (.7zip or Winrar work fine.)
You will want to extract it to Simba/Includes/SRL-OSR/SRL.
Once there, you will need to rename it to "reflection" without the "". Your /SRL folder should now look like:
To test that everything was download properly you can run:
Simba Code:
program R_Test;
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}
{$I SRL-OSR/SRL/Reflection/Reflection.simba}
begin
setupsrl;
SetupReflection;
end.
You shouldn't get any errors, and it will either say that you are up to date with reflection or that a update has been downloaded!
Writing Scripts With Reflection:
Now that everything is downloaded and running properly, you can begin to start scripting using reflection functions!
So, as you saw in the Test example, in order to use any of the functions, you must include
Simba Code:
{$I SRL-OSR/SRL/Reflection/Reflection.simba}
under
at the top of your script.
You also must call
in your main loop
BEFORE . This checks if there are any updates that need to be downloaded (Which it will do automatically.)
Tiles:
Most of the functions in here are used in other functions throughout the include, but some of them are still very useful for different things.
Simba Code:
function R_TileToMs(Tp: Tpoint): Tpoint;
Another usefull function, it returns the tpoint of the current tile that we are standing on. This can be used to just determine where we are for use with other functions, or you can write your own within your script with it.
The rest of the tile functions are fairly self explanatory, but if you want me to go over any, just let me know.
MapWalk:
By far the most important reason that one will choose to use reflection, is the ability that it has to be used for mapwalking features. For the most part, reflection walking "should" be 100% accurate and won't fail. The reason I say "should" is because stuff happens, and it is still good to use failsafes.
The first function is simply
Simba Code:
R_WalkPath(Path: TPointArray): boolean;
this function will walk along a path designated by the TPointArray in the parameters. In order to know the points in order to walk, we can use a great tool written by @
Turpinator. This tool can be found it reflection/tools. What this does, is when the script is started, each time you enable SMART, a new point is made.
This array of points can then be used with R_WalkPath in order to walk along it.
An example of a path from Varock East bank to the west bank:
Simba Code:
R_WalkPath([Point(3245, 3429), Point(3231, 3429), Point(3216, 3428), Point(3206, 3428), Point(3195, 3429), Point(3185, 3429), Point(3184, 3437)]);
It is
VERY important to know, each point must be showing on the minimap from the previous point, so you can't "skip" points when making a path.
Simba Code:
R_BlindWalk(P: TPoint): Boolean;
This simply, makes a array of points from our current location to the final point, and walks it using R_WalkPath. This is great to use when you need to walk a straight line. It will
NOT go around walls/obstacles.
The last MapWalk function is
Simba Code:
R_TileOnMM(Tile: TPoint): boolean;
This returns true if the given point is on the Minimap. Usefull mainly for Failsafes.
Player:
Another nice feature of reflection, is being able to get data about your player without switching tabs or any other method. Most of these are self explainitory, so I will only discuss some in which may need more explanation.
Returns True if our player is animating.
Npc:
For this section, the best way I think to explain it, is to write a small example script of a monster killing snippet.
Simba Code:
procedure AttGuard;
var
Guard: TNPC;
Tp : Tpoint;
begin
if R_FindNpc('Guard', Guard) then // Loads the record for Guard.
begin
if Guard.InCombat then // if he is in combat, don't attack, since we are on a loop, This acts as a wait also
exit;
Tp := Guard.Tile; //Get guard tile location
Tp := R_TileToMs(Tp); //Changes Tile into a Onscreen Point
Mmouse(Tp.x, Tp.y, 0, 0);
if R_WaitUptext('Guard', 200) then
ClickMouse2(Mouse_Left);
while (Guard.InCombat) and (R_InFight) do // waits until guard is dead to move on
wait(500);
end;
end;
So, that's a very basic example of how you can go about using reflection to interact and find npc's quickly. When You call R_FindNpc it stores the entire record of the npc into the TNPC record. So from calling the one function, you are able to get the following data from the npc:
Simba Code:
Type TNPC = Record
Name: String;
Tile: TPoint;
Index, Level, NpcID: Integer;
Animation, HitPoints: Integer;
Interacting: Integer;
InCombat: Boolean;
end;
Using that one function to be able to call all those individual procedures from withing the variable makes it very powerful. You just need to keep in mind, that you must R_FindNpc right before you want any of the data from it that isn't static, such as location. Being that the TNPC is a variable, it changes, so it is very important to keep that in mind.
For all the npc functions, the value that you enter to search for the npc, is what is called a "variant." So you can either enter in the npc's name, or the ID of the npc. Either way will work
Addition NPC info courtesy from @Krazy_Meerkat:
There are several functions you can use, but you must know that npc's are returned in a TNPC format. So it is always wise to declare a variable as a TNPC or TNPCArray;
Simba Code:
var
man: TNPC;
men: TNPCArray;
So now, when using npc functions, you can store the npc. There are a few npc functions and they don't all work the same..
Simba Code:
Men:= R_GetNpcs('Man'); //returns a TNPCArray of all npc's named 'Man' in the area (sorted by player distance), I stored it into Men for this example.
if R_FindNpc('Man', Man) then //looks for npcs named 'Man' and stores the closest one in the TNPC Man. Boolean function, returns true if found, false if not.
Man:= R_FindFreeNpc('man'); //looks for the closest npc named 'Man' which isn't in combat and returns the TNPC (I stored this into Man).
R_InteractingNpc //returns the tnpc of any npc your player is interacting with, this means you can use it like R_InteractingNpc.HitPoints
Finally, when you want to call record information from your npc, you treat the TNPC array as an array of npcs as follows:
Simba Code:
for i:= 0 to high(men) do
if men[i].HitPoints > 0 then
dosomething;
The TNPC is treated as singular, so you can just call the record info:
Misc:
Most of the functions in here are used for other functions throughout the include. There are however, some that are quite useful for many things. They are:
Simba Code:
R_GetSettingArray
R_GetSetting
R_GetPlayerName
R_GetUptext
R_ChooseOption
These are for various "setting's" within the runescape client. By using R_GetSetting, you can determine if your character is running, casting spells, auto retaliating, and many more. I will go into more detail on the use of this later, because tbh, there are so many, I don't know enough of them yet.
I also only wrote one of the uptext functions and choose options, as these are used the exact same way as SRL except with using reflection, they are now 100% accurate
Objects:
In runecape there are 4 different types of objects, all of which our include now supports! They are GameObjects, WallObjects, Boundaries, and FloorDecoration. These are defined as constants and
should be called in scripts as such!
Simba Code:
OBJ_GAME = 0;
OBJ_WALL = 1;
OBJ_FLOORDECORATION = 2;
OBJ_BOUNDARY = 3;
As of now, there are only three functions that should be called in scripts related to objects, they are:
Simba Code:
function R_GetAllObjects(ObjType: integer): TRSObjectArray;
function R_GetObjectAt(ObjType: integer; Tile: TPoint): TRSObject;
function R_GetObjectsDistance(ObjType, Distance: integer): TRSObjectArray;
They should be pretty self explanatory so I won't go into any detail on the specifics of each function, but feel free to ask if you have any questions. When any of the functions are called, it returns either a TRSObject or a TRSObjectArray. Within a TRSObject is contained the "ID," "Tile," and "ObjectType." I will soon be adding to this list a few more param's but for now, I believe those to be the most useful!
Now, on what each of the objects are... They seem to vary
a lot throughout Runescape, but here is a general rule of thumb that I have found, but you will still wan't to check yourself for each one!:
GameObject: Most interactable objects that are
not on walls: Bank booths, chests, crates, some non interactable such as crates and rocks.
WallObject: Most interactable objects on walls and decoration on walls: Doors, levers, pictures, windows, ect....
Boundaries: Anything "Wall like" that blocks our path: Walls, fences, some doors and gates.
FloorDecoration: Anything on floor that doesn't fall into a category above: Some Rocks, bushes, stones ect....