Page 1 of 3 123 LastLast
Results 1 to 25 of 74

Thread: [OSR][Reflection]Basic Scripting and Setup Guide

  1. #1
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default [OSR][Reflection]Basic Scripting and Setup Guide

    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!

    Include thread: http://villavu.com/forum/showthread.php?t=107479

    Developers: elfyyy, Krazy Meerkat & Frement





    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
    Simba Code:
    {$I SRL-OSR/SRL.Simba}
    at the top of your script.

    You also must call
    Simba Code:
    SetupReflection;
    in your main loop BEFORE
    Simba Code:
    SetupSrl
    . 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.
    Simba Code:
    R_GetTileGlobal

    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.
    Simba Code:
    R_IsAnimating:Boolean





    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:
    Simba Code:
    R_TileToMs(man.tile);





    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....

    Last edited by Kyle; 01-14-2015 at 08:03 PM.
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  2. #2
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Anti Randoms:

    We are now at the point in the include in which is the reason that I started working on this project in the first place, to be able to have accurate random solvers that allow us to use skilling scripts without constantly worrying about failing a random. As of this moment, I just committed the new antirandoms.simba.

    The randoms that should be working are as follows:

    ALL talking randoms that don't use an interface e.g Sandwhich Lady isn't solved.
    Combat Randoms
    Mime
    Drill Demon
    Freaky Forester





    Now is the time that we can really use any info about how the solvers are working currently and we could also really use accounts that are stuck in any randoms that we could use! Please don't post a bug report on a random that fails that isn't on this list, but please do post if one fails that is on it, and if you know where/how it failed!

    We changed the name of the random function to be more consistent with SRL:
    Simba Code:
    R_FindNormalRandoms
    This will call all reflection detectors/solvers for the ones we have done, and will use SRL's for the one's we have not yet done.

    Simba Code:
    function R_FNRWait(Time, WaitPerLoop: integer)
    This can be called instead of the normal wait/sleep and will check for reflection randoms every waitperloop up to the Time. For Example:
    Simba Code:
    R_FNRWait(5000, 100)
    Will wait 5000ms while calling R_FindNormalRandoms every 100ms. Note: The lower your waitperloop is, the higher the cpu usage will be!

    Constants:

    Simba Code:
    R_RunAwayDirection := 'random';
      R_Reincarnate := False;
      R_CombatRandoms := True;

    For the combat random's the're are those three constants. What is unique about this include unlike the previous one's is that for the combat detection it doesn't just runaway immediatley when you're in combat, it will only do so if you are in combat with an actual random. So this means that you can keep R_CombatRandoms set to 'False' and still run a combat script! R_Reincarnate if set to true will allow you're player to die and not logg out upon death.



    So again, your feedback is key to us getting all randoms solved. If you get stuck in a random and don't mind letting us use it for a little bit, please get in touch with either me or Meerkat on here or through Skype!
    Last edited by Kyle; 03-06-2014 at 04:22 PM.
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  3. #3
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    I'll help write up some guides/code when I get home. Reserving this post because I'll edit it.

    Going to start learning that lape stuff and write the actual include now.

  4. #4
    Join Date
    Jul 2007
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thanks , this will be useful

  5. #5
    Join Date
    Feb 2013
    Location
    United States
    Posts
    53
    Mentioned
    2 Post(s)
    Quoted
    12 Post(s)

    Default

    Incredible. Thank you for your efforts, I am looking forward to trying this out.
    Last edited by vizzyy; 01-31-2014 at 05:54 AM.

  6. #6
    Join Date
    Feb 2013
    Location
    United States
    Posts
    53
    Mentioned
    2 Post(s)
    Quoted
    12 Post(s)

    Default

    Using the coordinate finder within the include/tools/ it only ever spits out the same coordinate over and over for me no matter where I move or restart the script.

    "[Point(-174199997, 1075589826)]"
    Smart command prompt says "field not found ca.hs"

  7. #7
    Join Date
    Jan 2014
    Posts
    58
    Mentioned
    1 Post(s)
    Quoted
    37 Post(s)

    Default

    "Error: Out Of Range at line 46" in the Reflection NPC.simba file.
    Any clue what the problem might be?

    Edit: And to add, in case it wasn't apperant, this happens when I search for an NPC using R_FindNpc.

  8. #8
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Quote Originally Posted by lollol012 View Post
    "Error: Out Of Range at line 46" in the Reflection NPC.simba file.
    Any clue what the problem might be?

    Edit: And to add, in case it wasn't apperant, this happens when I search for an NPC using R_FindNpc.
    Hmm, never had that happen before... Care to add me on skype and show me how and when that occurred? Thanks man, my skype is above by my avatar.

    EDIT: I assume you recently downloaded it for the googlecode. Thanks a lot for mentioning that error. We changed some stuff on npc's but didn't have it auto update to other people, so I didn't catch it. It was a simple fix and should be good to go now! Post back if anything else has any bugs!
    Last edited by Kyle; 02-03-2014 at 09:00 PM.
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  9. #9
    Join Date
    Jan 2014
    Posts
    58
    Mentioned
    1 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    Hmm, never had that happen before... Care to add me on skype and show me how and when that occurred? Thanks man, my skype is above by my avatar.

    EDIT: I assume you recently downloaded it for the googlecode. Thanks a lot for mentioning that error. We changed some stuff on npc's but didn't have it auto update to other people, so I didn't catch it. It was a simple fix and should be good to go now! Post back if anything else has any bugs!
    No problem. Always my.. erm.. pleasure to find errors
    I assume I'll have plenty of opportunities to find errors in the future =P

  10. #10
    Join Date
    Jan 2013
    Location
    Finland
    Posts
    130
    Mentioned
    1 Post(s)
    Quoted
    30 Post(s)

    Default

    Threw you a PM, but will post here also.

    I do have latest hooks and latest reflection, script did work before.
    Now the problem comes with walking and path maker.

    Path maker is giving these "strange" X/Y locations (Which dont work) and when using old ones it starts to walk totally wrong direction(S) and is not working fine.

    What could be wrong?

  11. #11
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Hooks updated to Revision 38
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  12. #12
    Join Date
    Jan 2014
    Posts
    58
    Mentioned
    1 Post(s)
    Quoted
    37 Post(s)

    Default

    Following the latest updates, Mapwalking is broken again. Here is an example of what a point and what PAthMaker returns (and obviously R_WalkPath doesn't work):

    Earlier saved point and what it shows now: Point(3272, 3167) --> [Point(880358903, -1328997390)]

  13. #13
    Join Date
    Feb 2013
    Location
    United States
    Posts
    53
    Mentioned
    2 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by lollol012 View Post
    Following the latest updates, Mapwalking is broken again. Here is an example of what a point and what PAthMaker returns (and obviously R_WalkPath doesn't work):

    Earlier saved point and what it shows now: Point(3272, 3167) --> [Point(880358903, -1328997390)]
    We must patiently wait for new hooks.

  14. #14
    Join Date
    Sep 2008
    Posts
    754
    Mentioned
    8 Post(s)
    Quoted
    275 Post(s)

    Default

    Excellent tutorial, keep up the great work :-).

    Hope to see item support as well.. If we somehow can get a really easy 1 click setup for Simba + oldschool + osrs reflection includes at the same time... it would be amazing and encourage much more needed users to these boards.

  15. #15
    Join Date
    Oct 2007
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Im confused, I just setup reflection and ran the test script + a R_walkpath function and everything worked well.
    After a runescape update im trying to run the exact same script but im getting an error:
    Math error at line 103 in the file: 'Tiles.simba'.
    Anyone know what can fix this?

  16. #16
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by svenno View Post
    Im confused, I just setup reflection and ran the test script + a R_walkpath function and everything worked well.
    After a runescape update im trying to run the exact same script but im getting an error:
    Math error at line 103 in the file: 'Tiles.simba'.
    Anyone know what can fix this?
    hooks are probably outdated. btw try to run the script after you have logged in (if the hooks are fixed) and tell me if the error still occurs. i found out that if im not logged in i will get that error, but if im logged in it works fine. i think it can be fixed with a simple change in the function that causes the error. im sure elfyyy and meerkat can fix it.

  17. #17
    Join Date
    Oct 2007
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by hoodz View Post
    hooks are probably outdated. btw try to run the script after you have logged in (if the hooks are fixed) and tell me if the error still occurs. i found out that if im not logged in i will get that error, but if im logged in it works fine. i think it can be fixed with a simple change in the function that causes the error. im sure elfyyy and meerkat can fix it.
    I tried the script while logged out and while logged in but i get the same error..
    To be sure i also put in the login from srl.

    The script
    begin
    DeclarePlayers;
    setupsrl;
    SetupReflection;
    if (not LoggedIn) then
    LogInPlayer;
    R_WalkPath([Point(3184, 3437), Point(3185, 3429), Point(3195, 3429),Point(3206, 3428),Point(3216, 3428), Point(3231, 3429), Point(3245, 3429) ]);
    end.
    I discovered my extensions were disabled for some reason... so i enabled them, updated srl through simba and tried to update the plugins through simba but thats giving errors.. Could it be that my plugins are wrong?

  18. #18
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Yeah the hooks are outdated as of now. The reason the error occurs is because it uses the distance formula, and when the hooks are wrong, it is multiplying a very large number under a radical, and it doesn't like to take the square root of it so it errors. I can fix it, but until we get a proper way to check if the hooks are wrong, I will keep it as it kills the scripts that use reflection.
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  19. #19
    Join Date
    Oct 2007
    Posts
    23
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    So it is outdated because of the runescape update?
    In that case in happy to have it all setup correctly, because it worked before the update

  20. #20
    Join Date
    Feb 2006
    Location
    Australia
    Posts
    628
    Mentioned
    15 Post(s)
    Quoted
    105 Post(s)

    Default

    Quote Originally Posted by elfyyy View Post
    Yeah the hooks are outdated as of now. The reason the error occurs is because it uses the distance formula, and when the hooks are wrong, it is multiplying a very large number under a radical, and it doesn't like to take the square root of it so it errors. I can fix it, but until we get a proper way to check if the hooks are wrong, I will keep it as it kills the scripts that use reflection.
    I added a proper way to check if the hooks are wrong but elfyyy removed it because "too many scripts(Hoodz) have SetupSrl after SetupReflection."
    Last edited by Krazy_Meerkat; 02-20-2014 at 02:23 PM.

  21. #21
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,752
    Mentioned
    193 Post(s)
    Quoted
    1468 Post(s)

    Default

    Quote Originally Posted by Krazy_Meerkat View Post
    I added a proper way to check if the hooks are wrong but elfyyy removed it because "too many scripts(Hoodz) have SetupSrl after SetupReflection."
    do i have to change it? just ask me. btw get on skype

  22. #22
    Join Date
    Oct 2006
    Posts
    6,752
    Mentioned
    95 Post(s)
    Quoted
    532 Post(s)

    Default

    Hooks updated to Revision 41
    “The long-lived and those who will die soonest lose the same thing. The present is all that they can give up, since that is all you have, and what you do not have, you cannot lose.” - Marcus Aurelius

  23. #23
    Join Date
    Jan 2014
    Posts
    58
    Mentioned
    1 Post(s)
    Quoted
    37 Post(s)

    Default

    Reflection mapwalking doesn't seem to work for me atm. Also it says something about "D" not being used when debugging, dunno if it's related.

  24. #24
    Join Date
    Feb 2013
    Location
    Narnia
    Posts
    615
    Mentioned
    8 Post(s)
    Quoted
    252 Post(s)

    Default

    Quote Originally Posted by lollol012 View Post
    Reflection mapwalking doesn't seem to work for me atm. Also it says something about "D" not being used when debugging, dunno if it's related.
    post your walking method code. whats it doing wrong? if it says Hint: variable D is not being used or something like that its no big deal. that just means you made a variable "D" and you havent used it anywhere in ur script

    View my OSR Script Repository!


    Botted to max
    Guides: How to Report Bugs to the Scripter
    ~~~~ Moved to Java. Currently Lurking ~~~~

  25. #25
    Join Date
    Jan 2014
    Posts
    58
    Mentioned
    1 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by Sk1nyNerd View Post
    post your walking method code. whats it doing wrong? if it says Hint: variable D is not being used or something like that its no big deal. that just means you made a variable "D" and you havent used it anywhere in ur script
    Oh ya, it was in my own include lol.

    Anyway, it doesn't work atm when I try to walk in Yanille.


    Procedure WalkToPortal;
    begin
    R_WalkPath([Point(2612, 3092), Point(2604, 3094)]);
    R_WalkPath([Point(2597, 3097), Point(2585, 3097)]);
    R_WalkPath([Point(2576, 3094), Point(2562, 3092)]);
    R_WalkPath([Point(2555, 3097), Point(2546, 3095)]);
    end;
    Doesn't work individually either.

    I'll clarify, this is the path from the bank to the house portal.
    I also found a new one with path_maker, it didn't work either.

Page 1 of 3 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •