Page 1 of 7 123 ... LastLast
Results 1 to 25 of 152

Thread: [OSR] Walking & positioning system

  1. #1
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    968
    Mentioned
    142 Post(s)
    Quoted
    582 Post(s)

    Default [OSR] Walking & positioning system

    Presenting RSWalker (RSW)

    What is RSW?

    • It can give you the pixel/point where you are standing (on the world map) with decent accuracy.
    • It allows you to walk long distances as well as short once.
    • It uses image-processing to locate your position (image cross-correlation) (color)
    • It does not use reflection, and works without SMART.
    • It can, if preferred scan through your memory to find a map-chunk of the area your are in (works in official client, as well as in SMART) this is used to speed it up.
    • It's quite fast!


    Motivation

    First of SPS doesn't really work for OSR, and some has turned to use some proto-typeish code I wrote some time ago (the so-called SEWalker) which ain't that much better then SPS. Due to this I figured I had to try to make something that works well, and the fact that @Olly kept bugging me about writing a new walker weighted in a bit, I guess.

    The performance was better than what I initially expected (before I started working on it): Every test I've ran seems to have been able to quite precisely pinpoint my position (we are talking off by a few tiles at worst), and if I recall correctly it used around 50-60ms on my computer to find my world-position (yes, with the whole world map loaded), tho all my tests are with memory scanning enabled, and that increases the speed and accuracy.


    "Memory scanning"?

    Some boring text..
    The idea was simple, many of us has used tools like Cheat-Engine to find stored values in a single-player games (then modify it eg to get a bit more money ingame). RSW uses the same technique as Cheat-Engine uses to search through the memory owned by any process for a particular value (it doesn't modify anything). This is quite straight forward, and I believe it's fairly safe to do so, you are just parsing through your computes own RAM, right (no fancy-schmacy stuff).

    The steps we take:
    1. Search for a bitmap in the client using for example known information like the images size, then store it's address. This search must be insensitive to changes like reordering of class-fields.
    2. Grab your ingame minimap (the normal way), and cross-correlates that image to the chunk we grabbed from the clients memory.
      -- Proceed to extract the best highest rated match from the cross-correlation. Call it our "local position",
      -- This is quite useless by itself since it's varies.
    3. We crop out a 200x200 bitmap around the "local position" from the chunk we grabbed (This gives us a nice looking ~200x200 bitmap around our player).
    4. Using that 200x200 minimap, we cross-correlate it with the "world map" (a map image loaded when you initialized RSWalker).
    5. -- Again, we proceed to extract the highest rated match. The result of this is our global position.


    The the correlation of our new 200x200 minimap to the world map only happens every time the image in the clients memory is changed, this saves us a lot of time.



    How to use in a script

    So, version 1 and beyond will be specialized towards SRL, and requires a Simba 1.2 build which you just use instead of your regular Simba (place it in the same old folder).
    delphi Code:
    {$I SRL/OSR.simba}
    {$I RSWalker/Walker.simba}

    var
      RSW: TRSWalker;
      path: TPointArray;
    begin
      //How to init depends on your usage:
      //* Default    : RSW.Init('world.png');            { Automatic detection }
      //* if SMART   : RSW.Init('world.png', SMART.PID); { or whatever it's named in your include }
      //* no memscan : RSW.Init('world.png', -1);
      RSW.Init('world.png');
      AddOnTerminate(@RSW.Free); // automatic free once script shuts down

      //alternative setup (default works fine tho)
      RSW.skipClose := 25;    //how close to the target point before we try to click the next point.
     
      path := [Point(4171, 3457), Point(4136, 3444)]; //some path
    end.


    Use it to get your world position

    Should be quite simple:
    1. initialize it with the world bitmap you have (there is one shipped with RSW: `world.png`)
    2. call MyWalker.GetMyPos();
    delphi Code:
    {$I SRL/OSR.simba}
    {$I RSWalker/Walker.simba}

    var
      RSW:TRSWalker;
      t:UInt32;
    begin
      RSW.Init('world.png');
      WriteLn('RSW is setup!');

      // The first scan is a lot slower then the next scans, it's used to setup stuff..
      t := GetTimeRunning();
      WriteLn('I am here: ', RSW.GetMyPos(), ' used: ', GetTimeRunning()-t,'ms');

      // scan again.. this time it will be pretty much "instant".. same for all of the future times.
      t := GetTimeRunning();
      WriteLn('I am here: ', RSW.GetMyPos(), ' used: ', GetTimeRunning()-t,'ms');

      // one more time to prove my point..:
      t := GetTimeRunning();
      WriteLn('I am still here: ', RSW.GetMyPos(), ' used: ', GetTimeRunning()-t,'ms');

      RSW.Free();
    end.
    You should keep in mind that the bitmap `world.png` is very large, you might wanna crop out a smaller part of that bitmap around where you want to use it, both to save memory, and to speed up initialization of your script. Tho it's not needed, I use the whole world map all the time


    Other notes

    • As of version 1, RSWalker requires you to use SRL
    • MemScan only works on Windows (with 32bit Simba), and with Lape as your interpreter, and 32bit Java.
    • Path making is done in the same way as with SPS. Open any SPS path-making tool, load your map, make a path, copy the path to your script... done.
    • Supports "blindwalk" in the WalkPath function, so you can for example supply it a single point of where you want to walk to that's far away.
    • There now exists handling for loading particular "map pieces" (like sps does). I have yet to document this.
    • It's shipped with a script to grab world map pieces so you create your own custom maps, it's located in the folder `maps` under the name `MapGrabber.simba`.
    • With mem-scanning enabled you must provide a map that's extra large, it has a 100px radius which will be "non-walkable", while without mem-scanning it has an extra 55px which is "non-walkable" (or there-about):

      Your path must be outside the "none-walkable" area, if it's not, then you need a larger map.



    Credits

    A thanks to @Olly, he was the one who "manually" (using CheatEngine) parsed through the memory and came across the minimap-buffer, once he found it, and told me about it I started playing around with this idea; Make the search for it "automatic"... And after a little back and forward, some playing around and so on, this walker was created. I didn't really focus on writing pretty code, as it wasn't like super-interesting, just knew we needed something reliable.


    Download, and install it

    1. Download it: https://github.com/slackydev/RSWalker/releases (Download the one tagged: Latest release)
    2. Extract it to your `Includes`-Folder (usually located in `C:\Simba\`)


    A nice and useful path making tool: https://github.com/TheTS/SPSToolbox/tree/2
    Last edited by slacky; 05-19-2018 at 06:19 AM. Reason: Keep up with changes!
    !No priv. messages please

  2. #2
    Join Date
    Dec 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    Awesome I will test this out tomorrow after work and update how I get along. Looks amazing

  3. #3
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Great effort! I'll be sure to test this out. If it really works as good as you've experienced so far I could really see this as backup method for when Reflection is out :-)
    Ce ne sont que des gueux


  4. #4
    Join Date
    Sep 2010
    Posts
    5,754
    Mentioned
    136 Post(s)
    Quoted
    2738 Post(s)

    Default

    This looks nice, so just to be clear - let's say I want to use this for a RSPS. I would have to 1) have the bitmap I want to use, and 2) I would need the pid of the client correct? How does one go about getting this pid (I can just loop through Tprocess thing?)

  5. #5
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    968
    Mentioned
    142 Post(s)
    Quoted
    582 Post(s)

    Default

    Quote Originally Posted by Robert View Post
    This looks nice, so just to be clear - let's say I want to use this for a RSPS. I would have to 1) have the bitmap I want to use, and 2) I would need the pid of the client correct? How does one go about getting this pid (I can just loop through Tprocess thing?)
    w_GetClientPID() returns the PID of the window you have targeted with Simba. If you use SMART and don't wanna target SMART with Simba, you use smarts own SmartGetClientPID(smartInstance). You also don't HAVE to use the memory scanning tho, it can be ignored if you only have like a 500x500 bitmap, maybe even as large as 1000x1000, then just pass `-1` as the PID.

    Pretty sure this is covered in the initial post.

    However it's not designed for anything else the oldschool runescape, so your RSPS has to have the minimap placed in the exact same spot as the official rs07-game for it to work, unless you think about modifying the source. If the RSPS is very modified it might not even find the map-buffer, that is if it has a different than 512x512.
    Last edited by slacky; 02-12-2015 at 08:53 PM.
    !No priv. messages please

  6. #6
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,700
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

  7. #7
    Join Date
    Aug 2007
    Location
    Hawaii
    Posts
    3,852
    Mentioned
    7 Post(s)
    Quoted
    142 Post(s)

    Default

    Great job!

    Maybe hybrid scripts can come back from the dead now.
    Last edited by kingarabian; 02-12-2015 at 09:09 PM.
    Faith is an oasis in the heart which will never be reached by the caravan of thinking.

  8. #8
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,063
    Mentioned
    289 Post(s)
    Quoted
    1088 Post(s)

    Default

    RS3 will come eventually too. But that's dead easy compared to this.

  9. #9
    Join Date
    Aug 2007
    Posts
    527
    Mentioned
    20 Post(s)
    Quoted
    262 Post(s)

    Default

    Looks intriguing! I'll have to have a look at this! Nice job.

    EDIT:
    I am very impressed!
    Drop dead accurate!

  10. #10
    Join Date
    Sep 2012
    Location
    Netherlands
    Posts
    2,729
    Mentioned
    192 Post(s)
    Quoted
    1461 Post(s)

    Default

    finally!

  11. #11
    Join Date
    Jan 2012
    Posts
    1,103
    Mentioned
    18 Post(s)
    Quoted
    210 Post(s)

  12. #12
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,318
    Mentioned
    264 Post(s)
    Quoted
    1394 Post(s)

    Default

    I added this last night and actually did integrate it with AeroLib. I'd like to set it up in the style you used with SEWalker; I think it was neatly written. Yes I did run into some compatibility issues with SimbaExt and, to avoid a mess of "IFDEFINE"/"ELSE", I just replaced the neat, time-saving functions (from SimbaExt) with the original stock Simba functions. Not as tidy as before but this way SimbaExt wouldn't be required to run AL (as SEW being the primary dependent).

    It's worked wonderfully for me so far, very accurate and very fast. You've done an amazing job again, Slacky.

    Current project:
    [Scripts / AeroLib Rev. 2]


    Did you know?
    J1407b, dubbed "Saturn on steriods", has a ring system 200 times larger than Saturn's own rings.
    #teampixel

  13. #13
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    968
    Mentioned
    142 Post(s)
    Quoted
    582 Post(s)

    Default

    Quote Originally Posted by ineedbot View Post
    Looks intriguing! I'll have to have a look at this! Nice job.
    You can debug the local position with the Test2.simba script found in the tests (that is after a couple of modifications). Tho this will only show the local position, but this pos is normally the outcome position only offset based on the loaded worldmap.. but let's not get in to more detail about that.

    So, for debugging of your current position this will do:
    Simba Code:
    var
      RSW:TRSWalker;
    begin
      RSW.Init('world.png');
      AddOnTerminate(@RSW.Free);
      while 1 do
        RSW.DebugPos();
    end;

    Debugs made with a modified version of the above + some photoshop (to make it in to one image):
    Last edited by slacky; 02-08-2018 at 02:39 AM. Reason: Update example (think it works)
    !No priv. messages please

  14. #14
    Join Date
    Dec 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    awesome^


    5e11a65706.png

  15. #15
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,074
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    I smell KYAB.
    There used to be something meaningful here.

  16. #16
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,318
    Mentioned
    264 Post(s)
    Quoted
    1394 Post(s)

    Default

    Quote Originally Posted by Frement View Post
    I smell KYAB.
    AFAIK KYAB was reflection-based, the first.

    Current project:
    [Scripts / AeroLib Rev. 2]


    Did you know?
    J1407b, dubbed "Saturn on steriods", has a ring system 200 times larger than Saturn's own rings.
    #teampixel

  17. #17
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,074
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    AFAIK KYAB was reflection-based, the first.
    I'm aware, but same concept
    There used to be something meaningful here.

  18. #18
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    968
    Mentioned
    142 Post(s)
    Quoted
    582 Post(s)

    Default

    Quote Originally Posted by Frement View Post
    I'm aware, but same concept
    I do not see how you can make that claim. It does indeed read the memory which is in a way related to everything in programming (not just reflection), reflection does what I do in a quite different way. I search for a value (width*height), and see if referenced somewhere else in the mem, a place that should hold two other values (width and height) to figure out if it's a bitmap-like structure. If it is.. I know I have a bitmap.. This concept can be used more generally, it's not limited to Java-applications.

    Reflection on the other hand just "asks java" to look up some variables based on the variables name.
    Last edited by slacky; 02-13-2015 at 10:59 PM.
    !No priv. messages please

  19. #19
    Join Date
    Aug 2007
    Posts
    527
    Mentioned
    20 Post(s)
    Quoted
    262 Post(s)

    Default

    I am having trouble with using OSBuddy and RSWalker accuracy. No biggie, I can use the original client, but OSBuddy has somethings that can be useful.

  20. #20
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    Quote Originally Posted by ineedbot View Post
    I am having trouble with using OSBuddy and RSWalker accuracy. No biggie, I can use the original client, but OSBuddy has somethings that can be useful.
    Think more info could be helpful. I'm using OSBuddy atm and I'm getting 1-4 pixels out at max (Do you have any plugins that could be messing with it?)
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  21. #21
    Join Date
    Aug 2007
    Posts
    527
    Mentioned
    20 Post(s)
    Quoted
    262 Post(s)

    Default

    Quote Originally Posted by Hawker View Post
    Think more info could be helpful. I'm using OSBuddy atm and I'm getting 1-4 pixels out at max (Do you have any plugins that could be messing with it?)
    When the map loads a new area on OSBuddy, it takes maybe 20 seconds for it to return to normal. Often i get 'Error: Image buffer can't be found at line 71' On MemScan

    On original client, it works just fine and fast.

  22. #22
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,074
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    I do not see how you can make that claim. It does indeed read the memory which is in a way related to everything in programming (not just reflection), reflection does what I do in a quite different way. I search for a value (width*height), and see if referenced somewhere else in the mem, a place that should hold two other values (width and height) to figure out if it's a bitmap-like structure. If it is.. I know I have a bitmap.. This concept can be used more generally, it's not limited to Java-applications.

    Reflection on the other hand just "asks java" to look up some variables based on the variables name.
    I meant more in regards to the functionality.
    There used to be something meaningful here.

  23. #23
    Join Date
    Jan 2012
    Location
    East Coast
    Posts
    732
    Mentioned
    81 Post(s)
    Quoted
    363 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    RS3 will come eventually too. But that's dead easy compared to this.
    Really looking forward to it!

  24. #24
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    968
    Mentioned
    142 Post(s)
    Quoted
    582 Post(s)

    Default

    Quote Originally Posted by ineedbot View Post
    I am having trouble with using OSBuddy and RSWalker accuracy. No biggie, I can use the original client, but OSBuddy has somethings that can be useful.
    Yeah, I noticed that. It's not that it doesn't work, but memory-scanning is horribly slow on OSBuddy for some reason. I think I can speed it up, but that requires me to rewrite some internal processing stuff. I'll look in to it when/if I feel up for it.
    OSBuddy can add up to another ~500MB of memory to scan through on top of the >150MB from the client it self, and that can also mean a bunch of new "almost" matches in memory, and I have to check all these "false-positives" every scan.

    You can use it with a smaller part of the world map, and disable memory scanning by passing `0` as PID to the init-procedure.
    To do so, just open the `world.png` in any image editor, and crop out the area you need (pluss the extra of at least 55px radius of "nonwalkable" area, see topic post), save it, and load it in to the walker. Tho keep in mind that without the memscanning, it could turn slow if your custom map is very large, I would _guess_ that up to 1000x1000 image would work.

    Hope this helps!


    Edit:
    A new version is available. It solves the OSBuddy issue, but it will be a few times slower at updating in OSBuddy since it uses MUCH more mem then the official client.
    - https://github.com/WarPie/RSWalker/releases/tag/0.32
    Last edited by slacky; 04-30-2016 at 01:09 AM. Reason: Updated to match newer RSWalker
    !No priv. messages please

  25. #25
    Join Date
    Aug 2007
    Posts
    527
    Mentioned
    20 Post(s)
    Quoted
    262 Post(s)

    Default

    Great work, seems to run great now on OSBuddy, one small thing; they recently opened up a back door at varrock west bank. And I noticed on your world map there, seems to be outdated.
    Attached Images Attached Images

Page 1 of 7 123 ... LastLast

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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