RSWalker is a original creation of slacky, later improved by Olly and SRL-T has some modifications to it made by myself but the core of it all is still more or less the same.
This tutorial will be more on explaining how walker works than actual usage of it, it's important to understand how it works to understand what to look for when issues arise.
Also keep in mind that when you use WaspLib, certain walker related things work differently, e.g. you main map, for starters is different.
So let's begin with going to the following directories:
In both of those you will have a
Open them and look at them both, you will notice they are different.
When you are using SRL/SRL-T only you will be using the first one and if you are using WaspLib you will be using the second one. This is important because your coordinates are relative to your map but more on that soon.
Anyway, moving on. In those directories you also have a
maps directory. This is where you should party your external maps if you ever need any.
I'm going to assume you will be using WaspLib so let's focus on it's map and it's walker folder. If you want to use SRL only, most things will still apply anyway just that you will be using SRL map.
The way walker works to put it very simple is like so:
- Take a screenshot of the minimap
- Search for that image in your loaded map
This is a extremely simple explanation and if it uses all sort of tricks to work but that's really the gist of it. In another tutorial I'll be going in depth on all the process walker goes through to get your position which is very useful to know to debug issues but for now this explanation should be good enough.
So when you do something like
RSW.GetMyPos() to get your position, the coordinates your receive are actually just the pixel X and Y your position is at in the loaded map.
This also means you can get coordinates of stuff without being in the game. Open the map in paint, photoshop, gimp, whatever, ... Go to the place you want to get the coordinate of and the pixel X and Y of that spot is your coordinate.
Another thing you should keep in mind is that this process is slow. In fact, this is one of the biggest bottlenecks in our Simba scripts. Everything is done in milliseconds but using walker to get your position can easily take up to 100/150ms and will be very dependent on your CPU too.
Walker speed is proportional to the map size you load. Why you may ask? Say that have 2 maps, map A that is 1000x1000 pixels and map B that is 10.000x10.000 pixels. If you look at the total amount of pixels each one has:
- map A is 10k total pixels
- map B is 100k total pixels
Map B is 10 times larger than map A and without any tricks it would be literally 10 times slower. This is because to find our minimap in the middle of more pixels. In other words, we need to find our needle (minimap) in the middle of more straws (map).
So it's good whenever possible to keep your maps small. But you also have to be aware that they can't be so small that the tiniest error will mess it up. If your map is extremely narrow to the areas you need and you accidentally walk outside of it, your script will be completely lost.
Personally I keep a radius of 80 pixels of wherever I need to walk to, this is because the minimap has a 75 pixel radius and I add extra 5 for safety. Having extra is alright and you can add 1k pixels padding easily without even noticing a difference in performance with your naked eye.
Now with that explained we can go onto our first trick walker has and the only one I'll cover during this tutorial. Because it's slow to search our minimap on the
map loaded, we often and by default use downscaling.
Imagine the map A and B example. Imagine we downscale the maps by 2. We now have a total of:
- map A 5k pixels
- map B 50k pixels We just made our maps twice as fast to search. Because we downscaled them, we also need to downscale our minimap when searching our position because otherwise our normal scale minimap would not match anything on our downscaled map. However, while this increases speed exponential, it also increases false negatives. Because pixels get crammed together, details are lost and that decreases accuracy.
So downscaling is a tradeoff between speed and accuracy. By default we downscale things by 8 but if you ever have problems with wrong positions, one thing you should try is to decrease the downscaling!
Jut to emphasize this more, here is an example of minimap at normal scale vs downscaled by 8:
As you can see, the downscaled version lost a lot of details and I also zoomed it so you could even see it in the first place.
With all this out of the way what I wanted for this tutorial is covered.
In a future tutorial we will go over a basic walker script and go over some of the walker methods.