# Thread: [OSR] Walking & positioning system

1. ## t

Originally Posted by Kasi
Link order matters a lot. Especially with the GNU linker. You should also probably put your files before the libraries and omit the header file. That command does seem quite butchered.
That is definitely the incorrect way to do it; linking options must be before targets. As for dependencies inside the libraries themselves - that's why I kept the order given in the Code::Blocks file. I messed with it some more besides after looking for the dependencies inside of OpenCV but I didn't have much luck. The .hpp probably shouldn't be in the compiler invocation, but I really wanted to use $^. It makes no difference. 2. Originally Posted by R0b0t1 That is definitely the incorrect way to do it; linking options must be before targets. As for dependencies inside the libraries themselves - that's why I kept the order given in the Code::Blocks file. I messed with it some more besides after looking for the dependencies inside of OpenCV but I didn't have much luck. The .hpp probably shouldn't be in the compiler invocation, but I really wanted to use$^. It makes no difference.
Where do you learn this stuff? it's so damn incorrect. Spreading false info is bad too. You should stop. Or at least google and do your own research when others are trying to help you. You won't learn much in that mindset.

It does not matter where most linking options go. I never once spoke about general linking options in my post. Only libraries. Specifically the use of "-l"

Libraries should NOT be before the object files. Here is why:

-llibrary
-l library
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIX compliance and is not recommended.)

It makes a difference where in the command you write this option; the linker searches and processes libraries and object files in the order they are specified. Thus, ‘foo.o -lz bar.o’ searches library ‘z’ after file foo.o but before bar.o. If bar.o refers to functions in ‘z’, those functions may not be loaded.

The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.

The directories searched include several standard system directories plus any that you specify with -L.

Normally the files found this way are library files—archive files whose members are object files. The linker handles an archive file by scanning through it for members which define symbols that have so far been referenced but not defined. But if the file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -l option and specifying a file name is that -l surrounds library with ‘lib’ and ‘.a’ and searches several directories.
Source 2. https://sourceware.org/binutils/docs/ld/Options.html
-l namespec
--library=namespec
Add the archive or object file specified by namespec to the list of files to link. This option may be used any number of times. If namespec is of the form :filename, ld will search the library path for a file called filename, otherwise it will search the library path for a file called libnamespec.a.

On systems which support shared libraries, ld may also search for files other than libnamespec.a. Specifically, on ELF and SunOS systems, ld will search a directory for a library called libnamespec.so before searching for one called libnamespec.a. (By convention, a .so extension indicates a shared library.) Note that this behavior does not apply to :filename, which always specifies a file called filename.

The linker will search an archive only once, at the location where it is specified on the command line. If the archive defines a symbol which was undefined in some object which appeared before the archive on the command line, the linker will include the appropriate file(s) from the archive. However, an undefined symbol in an object appearing later on the command line will not cause the linker to search the archive again.
Different compiler. Same GNU LD Linker.
Finally, please do not fall into the all-too-common trap of placing any "-l<name>" specification before the name of any source or object module which requires it. Where the source file bar.c has dependencies on the library archive libfoo.a, the command:
$gcc -lfoo bar.c is incorrect, and will surely lead to "undefined reference" errors. The correct form for this command is:$ gcc bar.c -lfoo
Also, please do not be misled into the belief that this is a peculiarity of MinGW; it is a common requirement of the GNU linker, on all platforms which use it, and indeed of UNIX linkers in general, that libriaries must be specified after the names of all dependent modules. Please resist any temptation to report failure to support the former (incorrect) usage as a MinGW bug, for it is no such thing. If any other user attempts to convince you that the incorrect form works perfectly well on GNU/Linux (for example), then please politely refer them to the GCC Manual, and to the GNU Binutils Manual, point out that such usage is definitively incorrect.
I took the liberty of highlighting some key parts since i know you have a problem with reading documentation.
Last edited by Kasi; 12-31-2017 at 09:45 PM.

3. I referenced information from all of the sections you quoted in my post. If I order the arguments like the documentation requests the project does not compile when linked statically or dynamically. When attempting to link statically, I receive more link errors with the "proper" order.

This is why it's important to attempt what someone is doing when providing help. Attempting to help people without trying what they are doing can be insulting, because you're implying that they are not capable of understanding what they have read. Manuals and documentation are often wrong.

4. Originally Posted by R0b0t1
@slacky, I PMed @Brandon but he seems to be away. He might get back to me after the holidays, but if you remember anything else in the meantime it will help.

I think I was able to port MatchTempl forward to OpenCV 3.4.0, but I still receive strange linking errors
Hmm.. I wasn't home for the holidays. I have quite a bit of messages to now sift through lol. Just got to yours.

On OSX, I used the following command to build it just now (I cloned your repository, couldn't find @slacky's original repo).. It works:

Code Code:
g++ -Wall -std=c++11 -DBUILD_DLL -shared \-I/Users/brandon/Desktop/Intermediate/include/opencv \-I/Users/brandon/Desktop/Intermediate/include \-L/Users/brandon/Desktop/Intermediate/lib \-L/users/brandon/Desktop/Intermediate/share/OpenCV/3rdparty/lib \\-lopencv_dnn -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_core -llibtiff -llibpng -llibjpeg -llibjasper -lIlmImf -llibwebp -llibprotobuf -lippicv -lippiw -littnotify -lzlib -framework Accelerate -framework Cocoa -framework OpenCL \ \-o libMatchTempl.dylib main.cpp MatchTempl.cpp

This is my linker flags (for OpenCV 3.4.0.. They removed legacy, contrib, ts, etc.. or I forgot to compile those, but not necessary anyway):
C++ Code:
-lopencv_dnn -lopencv_ml -lopencv_objdetect -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_imgproc -lopencv_flann -lopencv_core -llibtiff -llibpng -llibjpeg -llibjasper -lIlmImf -llibwebp -llibprotobuf -lippicv -lippiw -littnotify -lzlib //MacOS Specific:-framework Accelerate -framework Cocoa -framework OpenCL//Windows Specific:-luser32-lVfw32-lcomctl32//Linux Specific:-fPIC

For Windows Mingw32, you need also the flags to statically link the library against the dynamic library (plugin): -static --static-libgcc --static-libstdc++
For optimizations, you can add: -O2 or -O3 and -s.
For C++11: -std=c++11
For Architecture if using multi-arch compiler: -m32 or -m64.

The OSX build I can't upload to villavu (it's 24mb).. it's here (again, it's built off of your repo - cloned): https://mega.nz/#!hFVBQbZA!08Megwbk1...GoJQBB-VS5EzQM
I used -O3 and -s.. Built on MacOS-High-Sierra 10.13.2.

OpenCV 3.4.0 is what I used. I built it with CMake statically by unchecking: BUILD_SHARED_LIBS, BUILD_TESTS, BUILD_PERF_TESTS, WITH_1394, WITH_FFMPEG. I also added flags: CMAKE_OSX_ARCHITECTURES = x86_64 and CMAKE_INSTALL_PREFIX = /Users/brandon/Desktop/Intermediate.

That will make it build all files to a directory of my choosing on my desktop called "Intermediate".. I didn't want to screw with my /usr/local dir.

Then I hit generate in CMake to create the makefile and then compiled it with make install. Once it was done, all the libraries and 3rdParty libraries resided in "/Users/brandon/Desktop/Intermediate" and I just linked against all the files in that folder and the shared lib folder.

Compiled in roughly 8-10 minutes
Exact same steps above for Linux. Windows is just different in its linker flags and that's about it..
Last edited by Brandon; 01-01-2018 at 03:04 AM.

5. @Brandon: Thank you, but I still can't link MatchTempl statically on Windows for some reason. It links fine against the OpenCV shared objects. For OpenCV 3.4.0, the "world" file builds properly, so it may be a good idea to distribute that. I will try to cross build from Linux.

@slacky: Do you have any comment on the above? Is there any reason you elected to statically link MatchTempl to OpenCV?

It might be a good idea to package OpenCV for Simba in any case.

6. The Minor - But big update:
It's worth mentioning I, as Aerolib has forked it's own version and stuck with it, recently decided to just specialize my release of RSW towards SRL, reduced the maintenance cost for me - it has also moved completely to Simba 1.2RC.

The Major Update:
I've written a rudimentary web-walking system for RSWalker, including a basic tool to add nodes and paths, both are in it's most basic state atm.
The tool can be found here: https://github.com/slackydev/SlackGU...s/Webber.simba
It requires the release of Simba 1.2 that's found in my signature. Since it contains fixes for forms that are needed.

Functionality to support this has been added to RSWalker. The existing web requires you to load the map world.png. So keep that in mind, members area might be iffy.
Usage is very simple, all you need is to gather a single point, of where you want to walk to, and whoop, it will work.

> RSW.WebWalk(Point(4697,3575));

To gather a single point like the above, you don't really need to load up a path making tool, just walk to wherever you wish to walk.. and do WriteLn RSW.GetMyPos; for that location.
There are also some basic default points added: https://github.com/slackydev/RSWalke...er/world.graph

Blind walking
A lot of people have wanted "blindwalking". That is now supported by default in RSW.WalkPath, all you do is to supply it a single point, or even a partial path.. the length between the points in the path no longer matter as well..

A path like that will now work just fine..

Finally a lot of other changes has been made as well, here are the noteworthy:
anyAngle and walkStyle is no longer a thing.
skipClose is now the NORM of how close you are before we click towards our next point, so it can click while further away than that.
Last edited by slacky; 03-27-2018 at 12:38 AM.

7. Very cool, and I mean it.
Does it generate points inbetween the nodes based on BenLand100's splines or something, or does it generate a straight line?

8. Originally Posted by Joopi

Very cool, and I mean it.
Does it generate points inbetween the nodes based on BenLand100's splines or something, or does it generate a straight line?
It's a straight line, the only randomness comes from whatever you pass on to the function, by default +/-6px (which is a lot in terms of tiles) per click point, which is also randomized (where on the line it clicks), and any inaccuracy RSW will naturally provide.
An auto generated randmized curved line might have side-effects that are questionable, it may end up simply too far off path, causing you to walk around large areas (click on the other side of a fence, a river etc). If it's just supposed to be "a little off", then it's no better than what we already do.

Fyi, benland doesn't have any spline function. His mouse path function is not an spline, nor is it a beizer-curve, it's just a nicely randomized line function.
Last edited by slacky; 02-10-2018 at 11:48 AM.

9. Good. That's what I was hoping for too. Only reason I asked was due to the conversation you (and Olly) had with BenLand100

10. Very nice Slacky! Web-walking is such a useful tool, I remember the concept Marpis was working towards before with SPS-based web-walking that never got off the ground. I tried accomplishing this by going a slightly different route in AeroLib also using RSWalker. Though my method is over-complicated to how I should have done it. I'm sure pleased to see some progressive work towards this tool, it's a HUGE part of color-based scripting, regardless of which library utilizes it. Nicely done.

11. So, the nodes I currently have added looks like this: https://i.imgur.com/JcrMbjJ.jpg, some of the members nodes might actually not be walkable, but hopefully they are.

12. Using the tool mentioned above (webber.simba), a web is quite easy to make, so you start by launching it, it will automatically load the world-map, then you basically start anywhere you'd by doing a left-click there, and then you create some more nodes around it by clicking in whatever direction.

Hints:
- To focus in on a node (so that it's blue) just click it, if you wanna create a node AND move to it at once, you can double click (first click will create the node, second click will focus in on it).
- To connect a node to other near by nodes you hold SHIFT when you click on whatever node you wish to connect the current node to. The same goes if you wanna disconnect it from some node.
- Dragging a node / moving it will need you to first focus on it (click it, so it's blue), the drag it wherever.

When creating the web you wanna avoid adding pathways over trees, and fences, etc so just keep that in mind.
You also wanna cover as much area as possible (be detailed, lots of nodes). Because our character will have to hook onto the web wherever he is, so it's best if there is a web near him to hook onto.

Finally, before you close the tool, be sure to COPY that web. The web can be edited by altering the final lines of webber.simba, and pasting it there.
Find:
Simba Code:
Graph.Nodes := [[...]];Graph.Paths := [[...]];
And just paste in your current web over those lines, and save and/or run.

In the top of the file, you find the path to the map-image, if you wanna load a different map, then just place that string (text).

https://github.com/slackydev/SlackGU...s/Webber.simba
Last edited by slacky; 02-12-2018 at 03:10 PM.

13. great work @slacky!

14. Added a map builder to RSWalker, so basically all you have to do is to target RS and start it, then you just run around and it will piece together a map from your location.
It can extend on an already existing map as well, as long as you start in a location that's on that map.

It's not in any release as of right now, but you can copy it from:
https://github.com/slackydev/RSWalke...pBuilder.simba

Here's the result of me just running a quick trip: Varrock->Taverly->Fally->Lumbridge->Varrock.
https://i.imgur.com/PcnIMo5.png
Pretty easy map generation, should work for all types of areas, dungeons and whatnots.

Just a rare reminder to anyone and everyone: RSWalker relies on you using 32bit Java for runescape, and Simba 32bit (Windows only).
Last edited by slacky; 04-15-2018 at 12:57 AM.

15. Release 1.1

Recent changes and additions (some present in earlier releases):
• Now using my own https://github.com/slackydev/MatchTemplate instead of OpenCV to do FFT based template matching. Makes it a lot simpler to compile on other platforms, and also lighter weight.
• Support multi-platform (without memscan), binaries are not compiled for other platforms, and is untested.
• Call move event while waiting for player movement to end.
• World map builder. Builds the map automatically as you walk around. Using memscan.
• Overhauled portions of the world map
• Webwalking can randomly choose suboptimal paths.
• Webwalking world graph atm: https://i.imgur.com/Yx3dBqG.jpg
• Various tweaks and fixes

Originally Posted by R0b0t1
@slacky: Do you have any comment on the above? Is there any reason you elected to statically link MatchTempl to OpenCV?
I just found it cleaner to minimalize the number of binaries required, and the size, and to keep it's purpose / name clear. I didn't really want to use OpenCV for this, but at the time that was the only way for me to get it done quickly enough (walking was sorely needed for OSRS).
Now OpenCV is no longer used in RSWalker, as I finally decided it was time to move away from any such a dependency (Hard to compile C/C++ stuff), and keep it purely in FPC & Lape, I have recreated MatchTemplate in FPC - a long with all the formulas that OpenCV offered CCORR, CCOEFF, SQDIFF and the normalized variants of them.
Last edited by slacky; 04-17-2018 at 07:24 AM.

16. Registered User
Join Date
May 2015
Posts
2
Mentioned
0 Post(s)
Quoted
1 Post(s)
Thanks for the great library slacky!

It seems that RSWalker goes haywire when at the grand exchange.
GetMyPos loop while Web Walking to the middle of the GE does this
Code:
{X = 4578, Y = 2485}
{X = 4568, Y = 2485}
{X = 4555, Y = 2485}
{X = 4528, Y = 2485}
{X = 4557, Y = 1472}
{X = 3100, Y = 2228} // bad values when in the GE crowd
{X = 3100, Y = 2228}
{X = 3099, Y = 2227}
and WebWalk returns false of course. I'm guessing the crowd on the minimap messes up RSW's position detection.

Any suggestions for a workaround/fix would be appreciated.

17. Good work Slacky and thank you for you contribution.

I'm trying to get away from reflection walking right now due to the lack of maintenance towards it. So after a couple of days fiddling with this I have some issues and questions.

RSWalker is supposed to be close to reflection in a way that the players location is memorized on the loaded map right, correct?

For example, say coordinates (123, 123) is the static location of one of the NPCs in Varrock, specifically on the map provided. Theoretically when we load the this particular map and do a blindWalk to that point, WITH that point being present on the minimap, it should always be able to walk to it without flaw. Right?

Right now I'm having trouble in that blindWalk is not walking my player to the static points associated with the map. It keeps taking me to a different point depending on where the player is located. I used mapgrabber for the current map I'm using.

18. @kingarabian;
The map loaded into memory is based on where you were the last time a chunk was loaded (i.e. where you logged in or you ran far enough so it loaded a new chunk). The chunk will most likely be different each time, unless you happen to stand on the exact same tile when you log in.

But I don't think this is the root of the problem. If I recall correctly then RSWalker requires a map larger than a single chunk. I'm not sure about the reason for this, but you can make it easy for yourself by just combining multiple chunks into a larger piece. You could as well probably "optimize" RSWalker to work on a single chunk, but this is rather pointless if you ask me.

19. Originally Posted by Joopi
@kingarabian;
The map loaded into memory is based on where you were the last time a chunk was loaded (i.e. where you logged in or you ran far enough so it loaded a new chunk). The chunk will most likely be different each time, unless you happen to stand on the exact same tile when you log in.

But I don't think this is the root of the problem. If I recall correctly then RSWalker requires a map larger than a single chunk. I'm not sure about the reason for this, but you can make it easy for yourself by just combining multiple chunks into a larger piece. You could as well probably "optimize" RSWalker to work on a single chunk, but this is rather pointless if you ask me.
Say I'm at the VWM and I make a TBox within the mine to detect whether the player is at the mine or not. Using .getMyPos, I can detect whether my player is in that designated TBox. However when the player is outside the mine for whatever reason and I need the player to walk back, despite the TBox being visible on the MM, using .blindWalk it does not click the correct given point that would be situated within the TBox. Instead its clicking MS coords elsewhere.

In reflection, we would define a polygon with mining tile coordinates then do something like:
Simba Code:
Varpolgyon : TPointArray := [[4500, 3500], [4200,3300]]; if pointInPolygon(reflect.player.getTile, polygon) then begin  Writeln('in Mine'); end else  reflect.player.walkToTile(4200, 3500);

This would walk the player back to the mine. But in my case using RSWalker, using the mine's TBox coordinates it still doesn't walk my player back. So I'm thinking the coordinates are not static with the given map so if the player moves, everything changes or there's something else wrong. Maybe I'll try a bigger map but I am using the recommended mapgrabber.simba script which prints them out precise.

20. @kingarabian; you could try turning off MS walking to begin with (Walker.ScreenWalker variable)

if your problem persists I can try to teamview or something. Though I'm probably only available on weekends.

21. @Joopi;

Thanks for your responses and help. Turns out the problem was in the RSWalker that's forked in AeroLib. The stand alone version that Slacky maintains on this thread works flawlessly. Too bad Flight hasn't been on in 5 months, as this version of RSWalker is not compatible with Aerolib.

22. SRL Member
Join Date
Feb 2013
Posts
465
Mentioned
6 Post(s)
Quoted
221 Post(s)
for anyone that gets the following error:
"Runtime error: "Access violation" at line 209, column 41 in file "C:\Simba\Includes\RSWalker\Walker.simba""
You need to remove the -1 in the initialization eg replace
Walk.Init('world.png', -1);
with
Walk.Init('world.png');

23. SRL Junior Member
Join Date
Aug 2019
Posts
30
Mentioned
0 Post(s)
Quoted
1 Post(s)
Originally Posted by wthomas
for anyone that gets the following error:

You need to remove the -1 in the initialization eg replace with
Thanks for the help ill try that fix.

24. SRL Junior Member
Join Date
Feb 2012
Location
Florida
Posts
193
Mentioned
1 Post(s)
Quoted
6 Post(s)

1. What is the difference between RS Walker onMove, and OnWalk. What should i use each for. I was thinking of throwing waits/antibans in there occasionally.
2. Does WalkPath introduce any randomness or does it click the same path every time.
3. Has anyone ported Slacky's webber script to Simba 1.3?

25. Registered User
Join Date
Apr 2019
Posts
6
Mentioned
0 Post(s)
Quoted
1 Post(s)
Originally Posted by LordJashin

1. What is the difference between RS Walker onMove, and OnWalk. What should i use each for. I was thinking of throwing waits/antibans in there occasionally.
2. Does WalkPath introduce any randomness or does it click the same path every time.
3. Has anyone ported Slacky's webber script to Simba 1.3?
1: onMove happens constantly while you are moving. onWalk occurs each time you start walking to a new point/waypoint in your path.
2: WalkPath randomizes waypoints but not the destination point.
3: Maybe? Dunno, I'm sure someone has . You can add points and paths manually, it's not so bad.