PDA

View Full Version : [OSR] Walking & positioning system



slacky
02-12-2015, 06:48 PM
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 (https://github.com/WarPie/RSWalker/blob/master/maps/world.png) loaded), tho all my tests are with memory scanning enabled, and that increases the speed and accuracy.


"Memory scanning"?
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:

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.
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.
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).
Using that 200x200 minimap, we cross-correlate it with the "world map" (a map image loaded when you initialized RSWalker).
-- 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 (https://github.com/SRL/SRL/), and requires a Simba 1.2 build (https://github.com/slackydev/Simba/releases/tag/Simba-1.2.0-rc6_fixes) which you just use instead of your regular Simba (place it in the same old folder).

{$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();

{$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 :p


Other notes

As of version 1, RSWalker requires you to use SRL (https://github.com/SRL/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 (https://github.com/TheTS/SPSToolbox/tree/2), 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):
http://i.imgur.com/SJcX0EM.png
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

Download it: https://github.com/slackydev/RSWalker/releases (Download the one tagged: Latest release)
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

Myke
02-12-2015, 06:52 PM
Awesome I will test this out tomorrow after work and update how I get along. Looks amazing

Floor66
02-12-2015, 07:35 PM
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 :-)

rj
02-12-2015, 07:59 PM
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?)

slacky
02-12-2015, 08:11 PM
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.

The Mayor
02-12-2015, 08:11 PM
Nice work slacky and Olly!

kingarabian
02-12-2015, 09:05 PM
Great job!

Maybe hybrid scripts can come back from the dead now.

Olly
02-12-2015, 09:33 PM
RS3 will come eventually too. But that's dead easy compared to this. :p

ineedbot
02-12-2015, 09:51 PM
Looks intriguing! I'll have to have a look at this! Nice job.

EDIT:
I am very impressed! http://i60.tinypic.com/177d4l.png
Drop dead accurate!

Hoodz
02-12-2015, 09:59 PM
finally!

Shatterhand
02-12-2015, 10:57 PM
Looks promising, good job.

Flight
02-12-2015, 11:06 PM
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.

slacky
02-13-2015, 01:41 AM
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:

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):
http://i.imgur.com/Nf09DTD.png

Myke
02-13-2015, 11:10 AM
awesome^


25022

Frement
02-13-2015, 11:14 AM
I smell KYAB.

Flight
02-13-2015, 02:00 PM
I smell KYAB.

AFAIK KYAB was reflection-based, the first.

Frement
02-13-2015, 09:07 PM
AFAIK KYAB was reflection-based, the first.

I'm aware, but same concept :)

slacky
02-13-2015, 10:56 PM
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.

ineedbot
02-13-2015, 11:18 PM
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.

Harrier
02-13-2015, 11:36 PM
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?)

ineedbot
02-13-2015, 11:54 PM
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.

Frement
02-14-2015, 12:23 AM
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.

Ross
02-14-2015, 12:46 AM
RS3 will come eventually too. But that's dead easy compared to this. :p

Really looking forward to it!

slacky
02-14-2015, 12:48 AM
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

ineedbot
02-16-2015, 07:02 PM
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.

Verfy
02-17-2015, 09:16 AM
Hey man good job!

I tried your walking system but I can't find out what's wrong, maybe it's only because it's in beta state but I'll post this anyway.

I tried calling single procedure that would walk my path fron varrock bank to fountain. My script looks like this:


program walk;
{$DEFINE SMART}
{$DEFINE WALKER}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.Simba}
var
MyPlayer : TReflectLocalPlayer;

procedure DeclarePlayer;
begin
MyPlayer.Username := '';
MyPlayer.Password := '';
MyPlayer.Pin := '';
MyPlayer.Active := True;
end;

procedure w_ClickMouse(box:TBox; btn:Int32); override;
begin
MouseBox(box, btn); //call a click-mousefunction from the include you use
end;

procedure walkmypath;
var
RSW : TRSWalker;
toWaterPath : TPointArray;
begin
RSW.Init('surface', 'softclaymap.jpg', w_GetClientPID());
Writeln('RSW is set up');
toWaterPath := [Point(117, 119), Point(121, 120), Point(125, 121), Point(130, 122), Point(137, 123),
Point(140, 123), Point(147, 121), Point(154, 121), Point(158, 121), Point(164, 123), Point(169, 123),
Point(173, 126), Point(179, 126), Point(184, 127), Point(188, 129), Point(193, 127), Point(201, 130),
Point(207, 129), Point(213, 130)];

RSW.WalkPath(toWaterPath);

RSW.Free();
end;

begin
initAL();
Reflect.Setup;

DeclarePlayer;
MyPlayer.Login;
/////////////////

walkmypath;
end.


I get acces violation and "base" tab opens @ line 137

Paired with SMART[1752]
[AL] Startup complete!
[10:11:06:041] [Reflection] [Status] Successfully setup!
Error: Access violation at line 137
Execution failed.
The following DTMs were not freed: [0]
The following bitmaps were not freed: [0, 1, 2, 3, 4, 5]



procedure TRSPosFinder.Init(PID:Int32);
begin
with Self do
begin
matchAlgo := TM_CCOEFF_NORMED;
scanRatio := 8;
numSamples := 100;
process := PID;

if PID >= 0 then scan.Init(process); //LINE 137
addr := 0;
bufferW := 512;
bufferH := 512;
end;
end;


Script works until it comes to RSW.WalkPath, same is with RSW.GetMyPos, I haven't tried others yet tho

slacky
02-18-2015, 05:44 AM
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.
Yeah, I am aware. The change is so small tho so it will not affect the positioning in any way.. I am waiting for GE (should be exist within 2 weeks) before I do any update to the varrock area.
Tho thanks for grabbing the map, appriciate it.

slacky
02-18-2015, 05:59 AM
Hey man good job!

I tried your walking system but I can't find out what's wrong, maybe it's only because it's in beta state but I'll post this anyway.
Script works until it comes to RSW.WalkPath, same is with RSW.GetMyPos, I haven't tried others yet tho
Issue is that you are using SMART, yet you initalize with "w_GetClientPID". You should grab the PID from SMART (or target SMART manually with Simba):


{$IFDEF SMART}
RSW.Init('surface', 'softclaymap.jpg', OS_SMART.ID); //Grab the PID from SMART
{$ELSE}
Walker.Init('surface', 'softclaymap.jpg', w_getClientPID()); //Not using SMART.. Grab the client targeted with Simba.
{$ENDIF}


PS: I would recommend only creating the walker once.. and reusing the instance.. Loading the map you use over and over again isn't really optimal.
So somthing like this, perhaps:

program walk;
{$DEFINE SMART}
{$DEFINE WALKER}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.Simba}

var
MyPlayer: TReflectLocalPlayer;
RSW: TRSWalker;

procedure DeclarePlayer;
begin
MyPlayer.Username := '';
MyPlayer.Password := '';
MyPlayer.Pin := '';
MyPlayer.Active := True;
end;

//this is not needed with AeroLib anymore..
(*procedure w_ClickMouse(box:TBox; btn:Int32); override;
begin
MouseBox(box, btn);
end;*)

procedure WalkMyPath;
var
toWaterPath: TPointArray;
begin
toWaterPath := [
Point(117, 119), Point(121, 120), Point(125, 121), Point(130, 122), Point(137, 123), Point(140, 123),
Point(147, 121), Point(154, 121), Point(158, 121), Point(164, 123), Point(169, 123), Point(173, 126),
Point(179, 126), Point(184, 127), Point(188, 129), Point(193, 127), Point(201, 130), Point(207, 129),
Point(213, 130)
];

RSW.WalkPath(toWaterPath);
end;


procedure OnTermination();
begin
RSW.Free();
end;

begin
initAL();
Reflect.Setup;

{$IFDEF SMART}
RSW.Init('surface', 'softclaymap.jpg', OS_SMART.ID);
{$ELSE}
Walker.Init('surface', 'softclaymap.jpg', w_getClientPID());
{$ENDIF}
Writeln('RSW is set up');

DeclarePlayer;
MyPlayer.Login;
/////////////////

WalkMyPath();
end.

That should work.

Verfy
02-20-2015, 02:01 PM
Issue is that you are using SMART, yet you initalize with "w_GetClientPID". You should grab the PID from SMART (or target SMART manually with Simba):
...


Thanks for your response, but I have another problem :) I did everything like you said but now when I call RSW.Init('surface', 'miningmap.png', OS_SMART.ID); debug says RSW: Invalid map. I hvae tried verious extensions like .png, .jpg and .bmp but I can't find any of them to work I tried putting "\" and "/" in front of map name and still, no success. Tried changing from 'surface' to 'custom' even tho I don't know difference between them. I'm saving my maps in OSRWalker/maps and I also tried AeroLib/maps/ which I think is right but doesn't work:) And as I checked I think the right extention is .png

Figured that one out, I didn't have to use the extention in string like it said in tut :)

...but I tried running it loads and everything except walk the path :/

Flight
02-20-2015, 02:29 PM
Thanks for your response, but I have another problem :) I did everything like you said but now when I call RSW.Init('surface', 'miningmap.png', OS_SMART.ID); debug says RSW: Invalid map. I hvae tried verious extensions like .png, .jpg and .bmp but I can't find any of them to work I tried putting "\" and "/" in front of map name and still, no success. Tried changing from 'surface' to 'custom' even tho I don't know difference between them. I'm saving my maps in OSRWalker/maps and I also tried AeroLib/maps/ which I think is right but doesn't work:) And as I checked I think the right extention is .png

Figured that one out, I didn't have to use the extention in string like it said in tut :)

If you're having issues it's probably because the way RSW is called in AeroLib is different from this tutorial. Slacky shouldn't have to help with issues like that, if you have problems you can post on the AeroLib thread or PM me directly.

Using the code I'm quoting you with, here's what you would do for setting up RSW:

{$IFDEF SMART}
RSW.Init('surface', 'miningmap', OS_SMART.ID);
{$ELSE}
RSW.Init('surface','miningmap', w_getClientPID());
{$ENDIF}


Notice ".png" is not included when setting up because AL will automatically (and only) load PNG map images. Again, if anyone who is using RSW with AeroLib and has issues don't bother Slacky, it's not his responsibility to fix it. You can post on the AeroLib thread or contact me directly.

slacky
02-27-2015, 11:41 AM
My experiment to speed up memory-scanning in OSBuddy seems to have failed after the GE update (some? class members shift order).

There are always some consistencies, so should not be too hard to work in an "adaptive" solution, this does however mean that initialization might get slower (the first scan). I'll look at it soon.

Athylus
03-04-2015, 04:18 PM
I finally got it to work slacky. But something isnt clear to me. Do we substract the non-walkable pixels from our height and width we want to walk to?

slacky
03-10-2015, 06:46 PM
But something isnt clear to me. Do we substract the non-walkable pixels from our height and width we want to walk to?
No.

Athylus
03-12-2015, 04:08 PM
Yeah I just picked a piece of map from google, but I should've used the map picker. It's working now. Love this, thanks!

The_Prince
03-22-2015, 05:31 AM
This looks very nice I'm trying to use it on a rsps and the script to get my position works fine, but I seem to be lost when it comes to actually walking.. any tips?

Harrier
03-22-2015, 07:30 AM
This looks very nice I'm trying to use it on a rsps and the script to get my position works fine, but I seem to be lost when it comes to actually walking.. any tips?
This is for OSRS only....

The_Prince
03-22-2015, 08:30 AM
Well that's a shame it looked very promising when it could give me my world position. What is the reasoning for it not working, minimap issues? I don't have it set up correctly so I actually cannot say whether it does work or not.

With this part in my code


//we need to override the rswalker's ClickMouse as it doesn't have it's own mouse-methods.
procedure w_clickMouse(box:TBox; btn:Int32); override;
begin
MouseBox(box, mouse_left); //call a click-mousefunction from the include you use
end;

I get this error "No default value for parameter 3", which has something to do with box.

Kyle
03-22-2015, 01:09 PM
Well that's a shame it looked very promising when it could give me my world position. What is the reasoning for it not working, minimap issues? I don't have it set up correctly so I actually cannot say whether it does work or not.

With this part in my code


//we need to override the rswalker's ClickMouse as it doesn't have it's own mouse-methods.
procedure w_clickMouse(box:TBox; btn:Int32); override;
begin
MouseBox(box, mouse_left); //call a click-mousefunction from the include you use
end;

I get this error "No default value for parameter 3", which has something to do with box.

What include are you including in that script?

The_Prince
03-23-2015, 07:09 AM
What include are you including in that script?

SRL-OSR/SRL.simba

Edit: Just after posting that reply I realised that I was using the srl-6 MouseBox syntax, I changed my include and its better now.

Edit2: Wow this works amazingly well.

BigRedJapan
03-26-2015, 10:16 AM
@Slacky

Flight gave me a really interested function so that i would be able to pin point my locations better but its not working..


function pointsInDist(Pt1, Pt2: TPoint; Dist: Integer): Boolean;
begin
result := (distance(Pt1.X, Pt1.Y, Pt2.X, Pt2.Y) <= Dist);
end;

Ive put in:


pointsInDist(Point(231,121), Point(232,123), Walker.getMyPos(), 3);

Janilabo
03-26-2015, 10:58 AM
@Slacky

Flight gave me a really interested function so that i would be able to pin point my locations better but its not working..


function pointsInDist(Pt1, Pt2: TPoint; Dist: Integer): Boolean;
begin
result := (distance(Pt1.X, Pt1.Y, Pt2.X, Pt2.Y) <= Dist);
end;

Ive put in:


pointsInDist(Point(231,121), Point(232,123), Walker.getMyPos(), 3);There is a good reason - function accepts 3 parameters (Pt1, Pt2, Dist) but you have used 4 (Point(231,121), Point(232,123), Walker.getMyPos(), 3).
So, as you can see, you have an extra TPoint there (I would guess (231,121) or (232,123)).

BigRedJapan
03-26-2015, 04:21 PM
oh, just realized that. so when i make the box how will it know that i am in the box if it cant read my pos but only has the pos of the box??? and its distance

slacky
03-30-2015, 10:12 AM
oh, just realized that. so when i make the box how will it know that i am in the box if it cant read my pos but only has the pos of the box??? and its distance
It doesn't take a box. It measures the distance between TWO points (using euclidean distance), and then checks if the distance is less then the given max-distance (last param).
>> PointsInDist(I_AM_HERE, I_WANT_TO_BE_HERE, THO_I_ALLOW_THIS_MUCH_VARIATION);
>> PointsInDist(Walker.getMyPos(), [231,121], 12);

liams007
05-03-2015, 12:15 AM
Hey, I just updated AeroLib and manually installed RSWalker to try to use this script https://villavu.com/forum/showthread.php?t=112904
which starts off

program DaviAutoSmeltr;
{$DEFINE SMART}
{$DEFINE WALKER}
{$I AeroLib/AeroLib.simba }

and keep getting the error message "exception in Script: Unknown compiler directives at 6:3." Guessing it's referring to {$DEFINE WALKER}, and I don't know how to get around this. Any ideas would be greatly appreciated :P

Flight
05-03-2015, 01:13 AM
Hey, I just updated AeroLib and manually installed RSWalker to try to use this script https://villavu.com/forum/showthread.php?t=112904
which starts off

program DaviAutoSmeltr;
{$DEFINE SMART}
{$DEFINE WALKER}
{$I AeroLib/AeroLib.simba }

and keep getting the error message "exception in Script: Unknown compiler directives at 6:3." Guessing it's referring to {$DEFINE WALKER}, and I don't know how to get around this. Any ideas would be greatly appreciated :P

AeroLib comes with this walking system already, you don't need to install it once more. Have you made sure to set your Simba's interpreter to Lape? (Script > Interpreter > Lape) Also if you're having issues with a script then you should be asking for assistance in that thread or from the scripter directly; the problem you're having is not directly because of this walking system.

honeyhoney
05-07-2015, 06:57 PM
Would it be possible to have a function output the bitmap it has read from memory? Potentially this could make the creation of custom maps easier.

slacky
05-07-2015, 07:50 PM
Would it be possible to have a function output the bitmap it has read from memory? Potentially this could make the creation of custom maps easier.
I've actually written a thingy for that: https://github.com/WarPie/RSWalker/blob/master/maps/MapGrabber.simba

honeyhoney
05-08-2015, 05:27 PM
I've actually written a thingy for that: https://github.com/WarPie/RSWalker/blob/master/maps/MapGrabber.simba


Thanks! Sorry for not digging around in the code before asking :blushing:

xujnea
05-10-2015, 04:02 PM
Is there a way to add camera movement while walking? It seems i can't find solution and walking with same camera position everytime looks very botish. I tried adding this,but no luck so far :/ Any ideas?


procedure RandomCam

var
RC : timer;

begin
RC.start
begin
if(RC.timeElapsed > (1000 * (random(6)))) then
begin
WriteLn('Performing antiban');
case random(8) of
0: RandomKeys0;
1: RandomKeys1;
2: RandomKeys2;
3: RandomKeys3;
4: hoverSkill('random', false);
5: RandomKeys4;
6: RandomKeys5;
7: RandomKeys6;
8: RandomKeys7;
end;
end;
end;
end;

slacky
05-10-2015, 11:45 PM
Is there a way to add camera movement while walking? It seems i can't find solution and walking with same camera position everytime looks very botish. I tried adding this,but no luck so far :/ Any ideas?
...
Yes there are ways to add movement like that. You'd have to hook the "onMoveEvent", and do shit in there.


procedure WhileMoving(Sender:TObject; pos:TPoint);
begin
//.. do shit here (Sender is the TRSWalker instance, pos is where we are now)
end;


var
RSW:TRSWalker;
path:TPointArray;
begin
RSW.Init(...);
...
RSW.onMoveEvent := @WhileMoving;
...
end.

I will however NOT help you make such a function. Since it's mostly unrelated to RSWalker, and more related to general OSR-"scripting" you'd have to ask for help elsewhere.

Btw, I've never really been one to move the camera while walking.. So does that make ME a bot? Also, moving the camera randomly doesn't make much more sense..

Unfold
05-20-2015, 12:06 AM
I'm really confused. Every time I run my script, the position of my character changes.. Not sure what i'm doing wrong.



//i declare that
Walker.init('surface', 'WorldMap');
Walker.skipClose := 4;
Walker.minRunEnergy := 35;
Walker.walkStyle := wsSPS;


writeln(Walker.GetMyPos());



Edit:

Okay, It's displaying different positions at different angles. Is there any way to display the same position at all angles.

slacky
06-29-2015, 03:57 PM
I'm really confused. Every time I run my script, the position of my character changes.. Not sure what i'm doing wrong.

Okay, It's displaying different positions at different angles. Is there any way to display the same position at all angles.
I don't remember if I ever answered this... But here it goes (just so that everybody knows):
>> Walker.anyAngle := True;

This is covered in the "How to use in a script"-section.

AFools
08-13-2015, 10:16 AM
Is this up to date and working??

Error: Access violation at line 153 " if PID >= 0 then scan.Init(process); "

I haven't previously had trouble.

slacky
08-16-2015, 05:34 PM
Is this up to date and working??

Error: Access violation at line 153 " if PID >= 0 then scan.Init(process); "

I haven't previously had trouble.
That will happen if/when you pass an invalid Process ID to it.

AFools
08-19-2015, 10:35 AM
Sir; I am Lost >.<




program DebugMyPos;
{$I OSRWalker/Walker.simba}

var
RSW:TRSWalker;

procedure TRSWalker.DebugPos();
var
TPA:TPointArray;
BMP:Integer;
W,H,_:Int32;
loc,glob:TPoint;
begin
loc := self.finder.GetLocalPos(True); //find local pos
self.UpdateGlobalStart(loc); //find a piece of the local map in the provided world map
glob.x := loc.x + self.global.x; //offset
glob.y := loc.y + self.global.y;

//when loading a new chunk there is chance it will fail at first attempet
//so just ignore it.. and it will fix it self next call.. simple as that.
if PointInBox(loc,TBox([70,70,440,440])) then
begin
BMP := CreateBitmap(0,0);
DrawMatrixBitmap(BMP,self.localMap);
GetBitmapSize(BMP,W,H);

DrawTPABitmap(BMP, TPAFromLine(loc.x-69,loc.y,loc.x+69,loc.y), $00FF00);
DrawTPABitmap(BMP, TPAFromLine(loc.x,loc.y-69,loc.x,loc.y+69), $00FF00);
DrawTPABitmap(BMP, TPAFromCircle(loc.x,loc.y,69), $0022FF);

TPA := TPAFromText('Global Pos: '+ToString(glob), 'SmallChars07',_,_);
OffsetTPA(TPA,Point(55,35));
DrawTPABitmap(BMP, TPA, $00FF00);

DisplayDebugImgWindow(W,H);
DrawBitmapDebugImg(BMP);
FreeBitmap(BMP);
end;
end;

procedure OnTerminate();
begin RSW.Free(); end;

var
loc:TPoint;
t:UInt32;
begin
RSW.Init('world.png', w_getClientPID()); //big map, takes a while for Simba to load it.
AddOnTerminate('OnTerminate');
//RSW.anyAngle := True;

while 1 do
RSW.DebugPos();

end;

I simply trying to use the debug position posted.. many months ago i didnt have this trouble....


I am completely lost. i have tried every version you have posted


Thank you in advanced

Ben

iownyou23
09-16-2015, 06:20 AM
That will happen if/when you pass an invalid Process ID to it.

Hello Slacky,

I ran into a problem with one file. When I save the folder I downloaded, it doesn't keep libMatchTempl.dll. When I try to provide admin permission it said destination folder access denied.. I tried changing a few things in the properties security tab but still no luck... The scripts won't run with this file missing. Do you know what I should do? Thanks!

Edit: Here is the error message I receive btw:
C:\Simba\Includes\RSWalker.rar: Cannot create C:\Simba\Includes\OSRWalker\libMatchTempl.dll
Access is denied.

herolym
09-18-2015, 03:14 PM
same issue.


{$I OSRWalker/Walker.simba}

var
RSW:TRSWalker;
t:UInt32;
begin
RSW.Init('world.png', w_GetClientPID());
//RSW.Init('world.png', 393828,-1);
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.


Compiled successfully in 844 ms.
Error: Access violation at line 156
Execution failed.

procedure TRSPosFinder.Init(PID:Int32);
begin
with Self do
begin
matchAlgo := CV_TM_CCOEFF_NORMED;
scanRatio := 8;
numSamples := 100;
process := PID;

if PID > 0 then scan.Init(process);///line156
addr := 0;
bufferW := 512;
bufferH := 512;
end;
end;

slacky
09-22-2015, 03:24 AM
Err..
If anyone is getting the above error `Access Violation` in the initialization-procedure you should check Simbas console. It should have more info.
The console will most likely say `TMemScan.Init -> PID XXXX does not exist` and give a trace-back.
Be sure to always run Simba as administrator if you ever run into trouble.

It's most likely that the Process-ID you are passing doesn't exist, or you simply don't have access to it, I can add more error-handling so that we can know for sure exactly why windows' OpenProcess fails.
1. Try re-selecting your target with Simba.
2. If that didn't solve it, restart the RS-client, and reselect the target (with simba).
3. Still here? Make sure you are running Simba as administrator. And repeat the steps above.

slacky
09-22-2015, 05:11 AM
So yeah here it is.. a updated version that prints the error to the debug-box.. since some people don't check the console.
https://github.com/WarPie/RSWalker/releases/tag/0.6

The above still stands tho, you need to have full access to the RS-client, but the error as to why it fails will be simpler to notice.


same issue.

...
RSW.Init('world.png', w_GetClientPID());
//RSW.Init('world.png', 393828, -1);


If you actually tried to use that stuff commented out there you should know that would likely go to hell - at best..
1. the PID is normally just a number with 3-5 decimals (I suspect that what you have there was an invalid PID)
2. ScanRatio of -1? You should not touch that parameter - leave it blank :)

PS: In the latest versions (not default in AeroLib yet) all you really need to do to initialize is to call
>> RSW.Init('world.png');
As long as you use AeroLib or the "hybrid" OSR include I've worked on, then shit will be automatically detected. More precisely, it will then detect SMART if you use SMART, and fall back to w_GetClientPID if SMART isn't defined.



Hello Slacky,

I ran into a problem with one file. When I save the folder I downloaded, it doesn't keep libMatchTempl.dll. When I try to provide admin permission it said destination folder access denied.. I tried changing a few things in the properties security tab but still no luck... The scripts won't run with this file missing. Do you know what I should do? Thanks!

Edit: Here is the error message I receive btw:
C:\Simba\Includes\RSWalker.rar: Cannot create C:\Simba\Includes\OSRWalker\libMatchTempl.dll
Access is denied.
Be sure to close all your instances of Simba before you try to copy that in there. If Simba has that DLL loaded you can't overwrite it on Windows - sux.

iownyou23
09-24-2015, 02:34 AM
So yeah here it is.. a updated version that prints the error to the debug-box.. since some people don't check the console.
https://github.com/WarPie/RSWalker/releases/tag/0.6

The above still stands tho, you need to have full access to the RS-client, but the error as to why it fails will be simpler to notice.


If you actually tried to use that stuff commented out there you should know that would likely go to hell - at best..
1. the PID is normally just a number with 3-5 decimals (I suspect that what you have there was an invalid PID)
2. ScanRatio of -1? really? You should not touch that parameter - leave it blank.

PS: In the latest versions all you really need to do to initialize is to call
>> RSW.Init('world.png');
As long as you use AeroLib or the "hybrid" OSR include I've worked on, then shit will be automatically detected. More precisely, it will then detect SMART if you use SMART, and fall back to w_GetClientPID if SMART isn't defined.



Be sure to close all your instances of Simba before you try to copy that in there. If Simba has that DLL loaded you can't overwrite it on Windows - sux.

Thank you for the reply slacky. I tried closing out Simba but it still did not work. :/ Once I extract the .rar file, sometimes I See the dll file for a second or two then poof, it just disappears. I keep getting Access Denied

slacky
09-24-2015, 04:36 AM
Thank you for the reply slacky. I tried closing out Simba but it still did not work. :/ Once I extract the .rar file, sometimes I See the dll file for a second or two then poof, it just disappears. I keep getting Access Denied
That's just crazy. AFICT the issue is unrelated to both Simba, and RSWalker. But you clearly do not have permission to do that for some reason, why? Idk. Try to login as Administrator if you have such a user, and your user doesn't have the same rights. Just make sure you actually have the rights to that folder (properties -> security).

neeger
09-27-2015, 10:36 AM
What's the best way to integrate this when using dungeon and surface in one script?
Have to make one custom map where are the segment of surface and the dungeon map?
Where can one find dungeon maps?

slacky
09-27-2015, 10:44 AM
What's the best way to integrate this when using dungeon and surface in one script?
Have to make one custom map where are the segment of surface and the dungeon map?
You do it as described in the initial post, but I'd go with two walkers, one for underground, and one for above ground.


Where can one find dungeon maps?
You have to make the map yourself, a good place to start is to run the MapGrabber.simba located in the maps-folder, while you are in the dungeon, it will store map-pieces which you will have to combine into a bigger map.

maxlvs
10-29-2015, 01:15 AM
iam wondering if there could be a video made in the proper instructions to get and a small demo on how to walk

slacky
12-08-2015, 10:29 PM
iam wondering if there could be a video made in the proper instructions to get and a small demo on how to walk
I don't really do videos, they take too much time while being extremely boring to make. Perhaps someone else would wanna do this.

Botmeplss2
04-01-2016, 08:42 AM
This doesnt seem to be accurate.. People who are on the minimap affect the result of the co-ordinates. Do you know this happens or is this a bug?

Harrier
04-01-2016, 10:18 AM
This doesnt seem to be accurate.. People who are on the minimap affect the result of the co-ordinates. Do you know this happens or is this a bug?
Well, it's colour. It's nearly impossible for it to be 100% accurate, but it's within 5 pixels at most normally.

slacky
04-01-2016, 07:23 PM
This doesnt seem to be accurate.. People who are on the minimap affect the result of the co-ordinates. Do you know this happens or is this a bug?
Considering the other thread you started relates to some private server, I have to assume you are using RSWalker on one. RSWalker ment for OldSchool Runescape, and only Oldschool runescape, not for any RSPS.
If it works (somewhat) on a private server then that's just "luck", and the quality of it maybe be heavily reduced, features might not work, and the world map will be rendered nearly useless, as it for Oldschool runescape, not some RSPS.

The walking is quite accurate on OSRS, even in cases where there's a notable amount of players, to a limit obviously, as it's relying on colors to pinpoint your position. As harrier said, it's normally within a few pixels of where you actually are.


... so if the "world" image doesn't really match, and at the same time as there is a lot of players around then you are pretty much f***ed, if the private server is very similar to official OSRS then you might get away with just building your own world map for the RSPS, for this you can use the mapgrabber shipped with RSWalker.

Turpinator
04-01-2016, 07:36 PM
Considering the other thread you started relates to some private server, I have to assume you are using RSWalker on one. RSWalker ment for OldSchool Runescape, and only Oldschool runescape, not for any RSPS.
If it works (somewhat) on a private server then that's just "luck", and the quality of it maybe be heavily reduced, features might not work, and the world map will be rendered nearly useless, as it for Oldschool runescape, not some RSPS.

The walking is quite accurate on OSRS, even in cases where there's a notable amount of players, to a limit obviously, as it's relying on colors to pinpoint your position. And so if the worldmap doesn't really match, at the same time as there is a lot of players around then you are fucked..

This one time, I used a Phillips Screwdriver on a JIS Screw; it didnt work very well and would cam out. I called the manufacturer of the screwdriver to complain, but they didnt seem to care. Perhaps you should adopt this philosophy.

guerr
04-01-2016, 07:48 PM
Ive been using RSW and its 99.9% accurate. Have you made custom map for your script?

Botmeplss2
04-02-2016, 12:39 AM
Considering the other thread you started relates to some private server, I have to assume you are using RSWalker on one. RSWalker ment for OldSchool Runescape, and only Oldschool runescape, not for any RSPS.
If it works (somewhat) on a private server then that's just "luck", and the quality of it maybe be heavily reduced, features might not work, and the world map will be rendered nearly useless, as it for Oldschool runescape, not some RSPS.

The walking is quite accurate on OSRS, even in cases where there's a notable amount of players, to a limit obviously, as it's relying on colors to pinpoint your position. As harrier said, it's normally within a few pixels of where you actually are.


... so if the "world" image doesn't really match, and at the same time as there is a lot of players around then you are pretty much f***ed, if the private server is very similar to official OSRS then you might get away with just building your own world map for the RSPS, for this you can use the mapgrabber shipped with RSWalker.



Thanks the server im using isnt similiar to 07. I just was asking for help with walking and people said rswalker... so i presumed it worked with servers since i posted in rsps hel too thanks though maybe SPS is a better solution.

I used the map grabber to grab my own map and the issue i said above is happening. wen players take over space of min map the co-ordinates change signficantly reducing the accuracy by 90%

honeyhoney
05-27-2016, 10:42 PM
https://github.com/WarPie/RSWalker/blob/master/Walker.simba#L297 waits for a negative amount of time (indefinitely). I don't really follow what's going on, I did have to remove that wait to get things working otherwise it would just hang on that wait.

Turpinator
05-27-2016, 11:19 PM
https://github.com/WarPie/RSWalker/blob/master/Walker.simba#L297 waits for a negative amount of time (indefinitely). I don't really follow what's going on, I did have to remove that wait to get things working otherwise it would just hang on that wait.

Uh oh, slacky;... using GetTimeRunning() instead of GetTickCount64(). Shame on you.

slacky
05-29-2016, 06:02 PM
https://github.com/WarPie/RSWalker/blob/master/Walker.simba#L297 waits for a negative amount of time (indefinitely). I don't really follow what's going on, I did have to remove that wait to get things working otherwise it would just hang on that wait.
As Turpinator hinted, it's overflowing due to your PC having higher uptime then normal, I'll see if I can update it at some point. Replacing it with GetTickCount64 works, rebooting your PC also works.


Uh oh, slacky;... using GetTimeRunning() instead of GetTickCount64(). Shame on you.
I did that because idgaf, reboot your PC, and quit your whining...

honeyhoney
05-30-2016, 07:39 PM
As Turpinator hinted, it's overflowing due to your PC having higher uptime then normal, I'll see if I can update it at some point.

Cheers. Totally aware of that issue I just didn't put 2 and 2 together.

Edit: I'm not actually sure that is the issue. Take a look:


st := GetTimeRunning() + 60;
if Assigned(@self.onMoveEvent) then
self.onMoveEvent(@self, pos);

Wait( Min(1, st-GetTimeRunning()));


Scenario:
GetTimeRunning() is 1000ms
st is therefore set to 1060ms
the onMoveEvent takes 200ms
GetTimeRunning() is now 1200ms
st - GetTimeRunning() is equal to -140
The minimum value of 1 or -140 is -140
The script then executes Wait(-140) which results in an indefinite wait.

It looks to me, irrespective of any overfolow issues, if the onMoveEvent takes longer than 60ms you're always going to end up waiting for an indefinite (negative) amount of time.

slacky
05-30-2016, 08:01 PM
Cheers. Totally aware of that issue I just didn't put 2 and 2 together.

Edit: I'm not actually sure that is the issue. Take a look:


st := GetTimeRunning() + 60;
if Assigned(@self.onMoveEvent) then
self.onMoveEvent(@self, pos);

Wait( Min(1, st-GetTimeRunning()));


Scenario:
GetTimeRunning() is 1000ms
st is therefore set to 1060ms
the onMoveEvent takes 200ms
GetTimeRunning() is now 1200ms
st - GetTimeRunning() is equal to -140
The minimum value of 1 or -140 is -140
The script then executes Wait(-140) which results in an indefinite wait.

It looks to me, irrespective of any overfolow issues, if the onMoveEvent takes longer than 60ms you're always going to end up waiting for an indefinite (negative) amount of time.
Indeed. It should call Max(), no idea how I ended up using Min :p you can change that manually for now, i'll fix it with the next commit I make, and then update Releases.

tls
05-30-2016, 08:03 PM
Indeed. It should call Max(), no idea how I ended up writing Min :p you can change that manually for now, i'll fix it with the next commit I make, and then update the Releases.

Or do the subtraction in the right order (current - cached).

slacky
05-30-2016, 08:24 PM
Or do the subtraction in the right order (current - cached).
No, the order is correct. The idea is simply that it should never wait longer than 60ms, if the peroson who hooked onMoveEvent also added a wait, or did a lot of processing (going beyond 60ms) then we should not wait more than 1ms.
Currently it's only waiting 1ms (at best) for the normal cases, which is a big oops, and in the case of negative numbers it waits for A LONG time, because using Min :P


start := GetTimeRunning() + 60; // time plus 60ms
<user inserts whatever code> // takes unknown amount of time
Wait( Max(1, start-GetTimeRunning())); // wait at most 60ms from when timer started, and at min 1ms.


If I just changed the order of subtraction it would go negative for all the cases when onMoveEvent doesn't take up 60ms or more. That would really go to hell.

edgy
06-01-2016, 03:01 PM
Hey Slacky,

i've been lurking on this for a while and u seem very knowledgable about opencv..
Im making my own rs bot to learn how to code, and have been learning opencv this week.
Ive managed to succesfully detect my minimap pos using matchtemplate, but have alot of difficulties finding things on the mainscreen specifically sand crabs, as there is too much rotation etc involved.
Do you think this is doable with opencv?or should i just scan for pixel colors and do some sort of clustering based on that.
Would love some input!

thx

Polar Xpress
06-01-2016, 07:30 PM
Hey Slacky,

i've been lurking on this for a while and u seem very knowledgable about opencv..
Im making my own rs bot to learn how to code, and have been learning opencv this week.
Ive managed to succesfully detect my minimap pos using matchtemplate, but have alot of difficulties finding things on the mainscreen specifically sand crabs, as there is too much rotation etc involved.
Do you think this is doable with opencv?or should i just scan for pixel colors and do some sort of clustering based on that.
Would love some input!

thx

Obviously I'm not slacky, but you may be able to find the sand crabs based on color separation. I haven't actually went and looked at the sand crabs yet, but if they are like the rock crabs they probably have darker shading around the bottom (and possibly one side) for the rounding of the model. I'd guess that that coloring is probably relatively unique compared to the rest of the sand in the area, so you may be able to locate them based on that.

Basically, the color at the bottom of the sand crab, once converted from RGB color to HSV, will have a lower V than the surrounding sand since it's shaded darker. If you can find a good threshold, I would think you could probably find the crab.

It may be a little bit tricky though, because the shading sometimes isn't very apparent at every compass angle and you'd have to ensure the area of shading is big enough to not detect little rounded sandy pebbles that I'm sure they probably placed on the beach. In my head this idea sounds reasonable, although I'm not 100% confident it would work well enough to be practical, but like I said, I'm not slacky and I haven't used opencv for a little while, so my opinion very well might not carry any weight.

If you did want to try to find them based on color separation, this link may be a good place to look at for reference:
http://opencv-srf.blogspot.ro/2010/09/object-detection-using-color-seperation.html

And even if it doesn't work out, never hurts to learn new things!

Also, maybe I'm wrong, but it may be best to create a new thread if you wanted to have a discussion on this just so this thread doesn't get caught up in a discussion that isn't entirely on the topic of the original post.

edgy
06-02-2016, 12:57 PM
Thanks alot for the answer. ill go try it out now!
And yeah ur right i should probably create my own thread..initially i just wanted to pm slacky but i am not allowed to pm yet :(.

Sup m8
06-06-2016, 01:37 PM
This is very cool, great you share the code! Much respect!

Rishi
08-29-2016, 05:00 PM
This is amazing!

I just have one problem that I can't seem to fix or figure out why. I have two areas, a dark/underground area and a light green area in a custom map. When I run my script for 4h+, they'll be a point where .getMyPos will return a pos that is completely off and cause my bot to die. For example, if I am in the underground area, it will say I am in the above ground area.

- The map is large and takes in account fort the non-walkable area.

- I've also set minmatch to around 0.8 and logged for incorrect positions.

I'm still unable to figure out what's wrong? Any idea? Thanks!

Joopi
08-29-2016, 05:06 PM
Does your map include the underground area? it might cause some bad matches due to the border between normal level and underground

Rishi
08-29-2016, 05:10 PM
Does your map include the underground area? it might cause some bad matches due to the border between normal level and underground

Yeah the custom map includes both areas. I put a large black space/border between the normal level and underground in the map. Still no luck.

Dan the man
12-21-2016, 12:02 AM
Hi all,

I am trying to get this working on a script, but every time I run the script, I get this error:
Error: Exception ('TRSPosFinder.UpdateAddr: Unable to locate bitmap') at line 231

I have tried using the Walker include that is built into Aerolib and downloading the walker from this thread, both with the same result.

Any ideas on what could be triggering it?

Sample map below:


program WalkerExample;
{$DEFINE WALKER}
{$i AeroLib/AeroLib.Simba}


procedure w_ClickMouse(box:TBox; btn:Int32); override;
begin
MouseBox(box, btn); //call a click-mousefunction from the include you use
end;

var
RSW:TRSWalker;
path:TPointArray;

begin
initAL;
RSW.Init('WorldMap');
WriteLn('RSW is setup!');
WriteLn(RSW._GetPos());
RSW.Free();

end.


I also tried pasting the example script from the first post into Simba with the same result.

Joopi
12-21-2016, 11:20 AM
Are you on linux, or any other OS than windows?
I don't think memoryscanning will work on any of those, atleast not yet.

Also try loading "YourMapName.png" instead of "YourMapName"

Harrier
12-21-2016, 01:26 PM
Stop using _GetPos and check what PID rswalker is targeting.
Edit: and make sure you selected the client since you're not using SMART

Dan the man
12-21-2016, 09:31 PM
Are you on linux, or any other OS than windows?
I don't think memoryscanning will work on any of those, atleast not yet.

Also try loading "YourMapName.png" instead of "YourMapName"

Tried WorldMap and WorldMap.png on both the Aerolib and stand alone include with the same result.

I am running Windows 7 64bit.


Stop using _GetPos and check what PID rswalker is targeting.
Edit: and make sure you selected the client since you're not using SMART

I was actually using GetMyPos() with the same result. The script up there is the last attempt, and I thought I would try something else.

I have also ensured the client is selected in all of my tests.

Could external factors have something to do with this?
I am running it from my office at work, but the network has network blocks to certain websites. Example: I can load up OSBuddy, but I cannot access any world menu (in login screen or ingame).

Harrier
12-21-2016, 09:46 PM
Tried WorldMap and WorldMap.png on both the Aerolib and stand alone include with the same result.

I am running Windows 7 64bit.



I was actually using GetMyPos() with the same result. The script up there is the last attempt, and I thought I would try something else.

I have also ensured the client is selected in all of my tests.

Could external factors have something to do with this?
I am running it from my office at work, but the network has network blocks to certain websites. Example: I can load up OSBuddy, but I cannot access any world menu (in login screen or ingame).
Stop using OSBuddy and use the official client, OSBuddy eats ram so it takes too long for rswalker to find the map bitmap (or disable memory reading).

Dan the man
12-21-2016, 10:11 PM
Stop using OSBuddy and use the official client, OSBuddy eats ram so it takes too long for rswalker to find the map bitmap (or disable memory reading).

Firewall at work blocks any pages on the Runescape domain; know of any alternative download links? I'll give it a try on official client.

Cheers.

fre
12-24-2016, 03:52 PM
I get this error after a while:
Error while reading stream: Unable to open file.

Is this because i use the script twice at the same time?

Harrier
12-24-2016, 07:19 PM
I get this error after a while:
Error while reading stream: Unable to open file.

Is this because i use the script twice at the same time?

Are you constantly loading and freeing RSWalker? Otherwise RSWalker should only load a file once when it starts.

fre
12-30-2016, 08:30 AM
Are you constantly loading and freeing RSWalker? Otherwise RSWalker should only load a file once when it starts.

Yes i am loading and freeing RSWalker. Because i use different regions and floors.

This error popped up.


Error: Exception ('TRSPosFinder.UpdateAddr: Unable to locate bitmap') at line 231
refers to this line

RaiseException(erException, 'TRSPosFinder.UpdateAddr: Unable to locate bitmap');

slacky
12-30-2016, 04:50 PM
Yes i am loading and freeing RSWalker. Because i use different regions and floors.
Just don't do that. Create several instances of RSW instead.
I believe the issue comes from Simba trying to load the map in both your scripts at the exact same time.

Just have two walkers (or more) in your script, create the walkers you need only once, and free them only once.

fre
12-30-2016, 06:17 PM
Just don't do that. Create several instances of RSW instead.
I believe the issue comes from Simba trying to load the map in both your scripts at the exact same time.

Just have two walkers (or more) in your script, create the walkers you need only once, and free them only once.

I use one procedure for map walking.
So i should create multiple TRSWalker instances for each map/region i use AND each script?

slacky
12-31-2016, 01:23 AM
I use one procedure for map walking.
So i should create multiple TRSWalker instances for each map/region i use AND each script?

First, I assume you have two or more maps, since you talk about "regions". So yeah, 1 RSW instance per map you load. Setup both walkers in the initialization part of your script, store the variables globally, so that you can use it anywhere in your script..

A prototype example (written on the go):

var
WalkUG, Walk: TRSWalker;

procedure OnTerminate();
begin
WriteLn('Script terminated');
WalkUG.Free();
Walk.Free();
end;

procedure DoStuffUnderground();
begin
** do stuff **
WalkUG.WalkPath([Point(123, 123), Point(111, 111)]);
end;

procedure DoStuffElsewhere();
begin
** do stuff **
Walk.WalkPath([Point(333, 333), Point(366, 366)]);
end;

procedure InitWalkers();
begin
Walk.Init('world.png');
Walk.walkStyle := wsSPS;
Walk.anyAngle := True;

WalkUG.Init('underground.png');
WalkUG.walkStyle := wsSPS;
WalkUG.anyAngle := True;

AddOnTerminate('OnTerminate');
end;

begin
InitWalkers();
repeat
** do stuff **
DoStuffUnderground();
DoStuffElsewhere();
end;
end.

fre
01-01-2017, 09:26 PM
So, i took your advice.
I made multiple RSW instances and defined them globally.
Works so far.
Thx for the help.

fre
01-16-2017, 09:54 PM
So walking to paths works if the minimap is the same as the one i used to make my maps.
I noticed jagex has 2 or 3 versions of the world map with few pixels difference.

So when my player is walking a path and cannot get it's location i want to save the piece of the map.
Then i can add this piece to my collection :)


if not Result then
begin
Debug('Failed to walk path, setting compas north.');
setCompass('n');
Inc(Loop);

//self.blindWalk(Path[0]);
if Loop > 1 then
begin
//While 1 = 1 do
Debug('Failed to walk path again, taking snap of memory map.');
finder.Init(w_GetClientPID());
finder.GetLocalPos();
bmp := CreateBitmap(1,1);
DrawMatrixBitmap(bmp, finder.localMap);
CropBitmap(bmp, 52,52, 511-52,511-52);
//ShowBitmap(bmp);
Wait(100);
//action := WaitKey([VK_RETURN,VK_BACK], 1500);
//if (Action = VK_RETURN) then
begin
SaveBitmap(bmp,FILEPATH+PREFIX+ToStr(i)+'.png');
WriteLn('Saved '+FILEPATH+PREFIX+ToStr(i)+'.png');
inc(i);
end;
FreeBitmap(bmp);
//WS_switchWorlds(randomWorld(Players[currentPlayer].Member));
end;
GoTo Start;
end;

i get this error

Error: TMemScan.Init -> The parameter is incorrect.
at line 159

Flight
01-20-2017, 05:55 PM
Hey Slacky I've got a question for you: have you compiled this with the newest version of Simba (https://villavu.com/forum/showthread.php?t=116951)? If so, what have you changed? I'm having errors (Variable expected) particularly at this line in Base.pas:
LibCV.MatchTemplate(large, sub, self.matchAlgo);
Or any time referring to LibCV. I figure this is just an issue with Lape in the most recent Simba but I've tried everything I can think of to no avail. Do you have any suggestions to point me in the right direction?

Edit:
I've made progress and have it working now for the most part through a bit of sloppy modification. However I believe I have a memory leak somewhere as over time while the walker is in use Simba accumulates memory. And after X amount of times ran and stopped the map file cannot be loaded, as if it's still in use, AKA something is not being freed. I'll continue how I can but as I said before, my knowledge with Lape is quite limited.

slacky
01-22-2017, 06:59 AM
Hey Slacky I've got a question for you: have you compiled this with the newest version of Simba (https://villavu.com/forum/showthread.php?t=116951)? If so, what have you changed? I'm having errors (Variable expected) particularly at this line in Base.pas:
LibCV.MatchTemplate(large, sub, self.matchAlgo);
Or any time referring to LibCV. I figure this is just an issue with Lape in the most recent Simba but I've tried everything I can think of to no avail. Do you have any suggestions to point me in the right direction?

Edit:
I've made progress and have it working now for the most part through a bit of sloppy modification. However I believe I have a memory leak somewhere as over time while the walker is in use Simba accumulates memory. And after X amount of times ran and stopped the map file cannot be loaded, as if it's still in use, AKA something is not being freed. I'll continue how I can but as I said before, my knowledge with Lape is quite limited.

For the first one, I guess it's because I have the function declaration wrong, causing lape to get crancky:
> function TLibCV.MatchTemplate(image, templ:T2DIntArray; matchAlgo: cvCrossCorrAlgo; normalize:Boolean=False): T2DFloatArray; overload;
should be the following, I think.
> function TLibCV.MatchTemplate(image, templ:T2DIntArray; matchAlgo: cvCrossCorrAlgo; normalize:Boolean=False): T2DFloatArray;
Note the trailing "overload" that should not be there.

For the second problem, that is a Simba/Lape integration issue that causes all plugins to leak, like they did som years ago.. The patch that was added a few years ago wasn't enabled in that Simba RC.
I am not sure if Simba has updated the lape repositry to the latest commit, if it has, then it's just a matter of recompiling Simba. You can bug Olly; in order to get a new RC out which would have the fix needed.

I had a fixed version on my server.. But I no longer have it, I am not sure who downloaded it before I lost it, perhaps riwu; has a copy (I can't remember who I've linked it to, but his name pops up in my head). Olly might also have a version, or another version that has the fix.

Harrier
01-22-2017, 10:12 AM
For the first one, I belive it's because I have the function declaration wrong, causing lape to get cracky:
> function TLibCV.MatchTemplate(image, templ:T2DIntArray; matchAlgo: cvCrossCorrAlgo; normalize:Boolean=False): T2DFloatArray; overload;
should be the following, I think.
> function TLibCV.MatchTemplate(image, templ:T2DIntArray; matchAlgo: cvCrossCorrAlgo; normalize:Boolean=False): T2DFloatArray;
Note the trailing "overload" that should not be there.

For the second problem, that is a Simba/Lape integration issue that causes all plugins to leak, like they did som years ago.. The patch that was added a few years ago wasn't enabled in that Simba RC.
I am not sure if Simba has updated the lape repositry to the latest commit, if it has, then it's just a matter of recompiling Simba. You can bug Olly; in order to get a new RC out which would have the fix needed.

I had a fixed version on my server.. But I no longer have it, I am not sure who downloaded it before I lost it, perhaps riwu; has a copy (I can't remember who I've linked it to, but his name pops up in my head). Olly might also have a version, or another version that has the fix.
RC6 has the plugin leak fix.

slacky
01-22-2017, 10:40 AM
I noticed jagex has 2 or 3 versions of the world map with few pixels difference.
It's not 2-3 different version.. there is MANY thousands, automatically generated on the go. The difference is the colors.. they vary almost every time you load the chunk, each color channel can easily vary with at least +/-15, for three channels that adds up to 27000 unique versions.
And only to complicate tasks even more; the minimap automatically scales, going up to like 125% size, at the same time as it rotates +/- 25 degrees relative to the compass, on top of that there is dots from NPC's, characters, items and so on flocking up on the tiny minimap. Having several different maps for the same location is likely not going to help you, you might have be unfortunate with one map pick, but that's something I have yet to experience.

RSWalker should be able to handle most of these antibot measures just fine, it makes it a little less accurate, but that's usually it.

I noticed you said in another thread that walking is impossible without reflection. That is BS. I have had bots nearly walk all over runescape surface. Only in special scenarios has the positioning failed me, for example wilderness is really hard since it's all just gray. However, if the goal is to hit an exact tile, then you are going the wrong way about it.


As for your code, I would assume it fails because you never free a finder, you just keep on creating finder after finder in what looks to be a loop.. Windows will get VERY angry at you for doing that, every time you create a finder you ask windows for another handle to the application, and it will only give you so many handles. The handles has to be free'd once you are done with them.
However.. it's unreasonable to create the finder over and over again anyway. Create it once. Done. You don't need a new one that is exactly equal to the one you already have.

slacky
01-22-2017, 11:08 AM
...
Did you test this with Simba 1.2 RC6 (https://villavu.com/forum/showthread.php?t=116951), according to Harrier it has the leak-fix which wasn't in the rc5. I wasn't aware that a rc6 had been released.

Flight
01-22-2017, 02:50 PM
Did you test this with Simba 1.2 RC6 (https://villavu.com/forum/showthread.php?t=116951), according to Harrier it has the leak-fix which wasn't in the rc5. I wasn't aware that a rc6 had been released.

I did indeed. I surely wasn't accusing Simba of being the culprit, especially considering the work-around I made with RSWalker to, for starters, combat the compiling issue in the newest version. I'm positive I went wrong somewhere and something I did was not being freed, even while double-checking everything; I try to be strict when it comes to freeing objects.

So what I'll do now is return to the version of RSW I had previously and make the simple adjustment you posted above and we'll go from there. I sure do appreciate not only the help but the explanation as to why. As always your posts are helpful and informative, Slacky.

Edit:
Renaming LibCV to TLibCV and removing the overload just brought me back to the same compile error. What would you think about appointing a TLibCV as a variable included with the TRSPosFinder? So when used later in Base.pas we'd just do, for example:
mat := self.cv.MatchTemplate(large, sub, self.matchAlgo);
Assuming:

TRSPosFinder = record
cv: TLibCV;
ect....

Which is basically what I did for my previous work around, and it was functioning correctly. However doing that brings an issue of function TRSWalker.FindChunk( which also directly uses LibCV rather than calling it through the TRSPosFinder. Perhaps we could change that line to use the finder's TLibCV as such:
corr := finder.cv.MatchTemplate(worldSample, locSample, finder.matchAlgo);
Do you see any problem with doing that?

slacky
01-23-2017, 05:28 AM
I did indeed. I surely wasn't accusing Simba of being the culprit, especially considering the work-around I made with RSWalker to, for starters, combat the compiling issue in the newest version. I'm positive I went wrong somewhere and something I did was not being freed, even while double-checking everything; I try to be strict when it comes to freeing objects.
Simba is the culprit, or rather lape.. The leakfix that exists in lape is somehow not enabled in rc6. The new way of enabling it exists within lpffi itself and that is the one part of lape I do not like looking at, I just know it worked as it should when I made my "own" rc6 by enabling the leapfix in a different way. nielsie95;


So what I'll do now is return to the version of RSW I had previously and make the simple adjustment you posted above and we'll go from there. I sure do appreciate not only the help but the explanation as to why. As always your posts are helpful and informative, Slacky.
Go grab this release, it works around the leak issue in lape, also supports Simba 1.2rc (should be backwards compatible as well):
https://github.com/WarPie/RSWalker/releases/tag/0.7c
- It's not the same as what's in the repository (the source code hosted at github) - grab the RSWalker.rar


What would you think about appointing a TLibCV as a variable included with the TRSPosFinder? So when used later in Base.pas we'd just do, for example:
mat := self.cv.MatchTemplate(large, sub, self.matchAlgo);
I dont understand why you wanna make it a local variable / don't want it to be a global variable. like it's now (https://github.com/WarPie/RSWalker/blob/master/matchTempl.pas#L16). The reason it uses the "LibCV" prefix is solely because I wanna avoid include-conflicts. Having it as a local variable to the finder-recrod would honestly only be an irritation, having to create a variable every time you (outside the finder and outside the walker) wanna use the MatchTemplate function, and like for no reason, it's just a dummy variable anyway.. it holds no information.

Flight
01-23-2017, 12:09 PM
I dont understand why you wanna make it a local variable / don't want it to be a global variable. like it's now (https://github.com/WarPie/RSWalker/blob/master/matchTempl.pas#L16). The reason it uses the "LibCV" prefix is solely because I wanna avoid include-conflicts. Having it as a local variable to the finder-recrod would honestly only be an irritation, having to create a variable every time you (outside the finder and outside the walker) wanna use the MatchTemplate function, and like for no reason, it's just a dummy variable anyway.. it holds no information.

I did that because the version of RSWalker I have never had LibCV: TLibCV = nil;, which was giving the previous compile error. I'm surprised it compiled at all before RC6, but since it did I assumed how you had it was correct. That's why I did any other alternative just to fix the first issue: the compile error. Anyways that should fix the problem I'm having I assume, thanks for your help. Sorry to clutter your thread with the posts, next time I'll drop you a PM if you'd prefer.

slacky
01-23-2017, 06:53 PM
I did that because the version of RSWalker I have never had LibCV: TLibCV = nil;, which was giving the previous compile error. I'm surprised it compiled at all before RC6, but since it did I assumed how you had it was correct. That's why I did any other alternative just to fix the first issue: the compile error. Anyways that should fix the problem I'm having I assume, thanks for your help. Sorry to clutter your thread with the posts, next time I'll drop you a PM if you'd prefer.
Yeah I see now, impossible to remember all previous versions of RSW. But, that trick still works, just have to declare it's methods as static (constref works but it's incorrect for this) so that is has no "self"-variable.

type namespace = type Pointer;

function namespace.Foo():Int32; static;
begin
//self doesn't exist because tihs method is static.
Result := 10;
end;

begin
WriteLn( namespace.Foo() );
end.


I don't mind you using this thread at all, I prefer it.

Twinki
05-02-2017, 03:08 PM
Note for those wanting to use Memscanning with OSBuddy: It only works with the OSBuddy 32bit version.

You can get it from their cdn; http://cdn.rsbuddy.com/live/f/loader/OSBuddy.exe

The Java/Cross Platform version should also work, just make sure you're using 32bit Java.

fre
05-22-2017, 09:09 PM
Is it possible to find out in what map you are.
For example in a world map or in a dungeon?

Because if i init a map World.init or Dungeon.init it will just give my pos relative to this map.
So i cannot check if i am truly in this location?

Thx for any replies.

slacky
05-27-2017, 04:46 PM
Is it possible to find out in what map you are.
For example in a world map or in a dungeon?

Because if i init a map World.init or Dungeon.init it will just give my pos relative to this map.
So i cannot check if i am truly in this location?

Thx for any replies.
No, not really.. It can be done in some cases, but it's a bit complex. I'd recommend that you just keep track in your script. Like if you walked down into a dungeon, or teleported into one, then set the global variable to whatever level you are at. Something like this pseudocode.

var
CurWorldLevel: Int32 = 1; //1 assuming script starts at world level (dungeon would be 0)

procedure ClimbDownLadder();
begin
... do stuff
CurWorldLevel := 0; //0 = dungeon
end;


procedure ClimbUpLadder();
begin
... do stuff
CurWorldLevel := 1; //back to world
end;

procedure WalkSomePath();
begin
if CurWorldLevel = 0 then
Dungeon.WalkPath(...)
else
World.WalkPath(...)
end;

And so just continuously keep track over what level you are on.


However it can be detected at runtime, but it's really so much more involved and might not be reliable, the steps would involve searching with both World and Dungeon map for your pos, and whichever ones returned the best match determines if you are bellow or above ground level. I will not walk your through it you'd just have to look into the source code for that, and I can't recall exactly how I've implemented it all, might need to modify RSW slighlty for it.

nenci494
05-30-2017, 08:25 PM
EDIT: seems like starting simba as admin fixed it :)


hey, first of all good job, this is by far the best walking method ( at least for a noobi like me :P).
It all worked kind of well until today. Everytime i try to init my map (using world.Init('mymap.png');) i get Error: TMemScan.Init -> PID `5` does not exist (Access is denied) at line 160
Execution failed. this error. propably on my side but you guys got any suggestions what i am doing wrong?
Ill ad my script, which i use to get the points for my path so you can tell me if im doing something wrong.
Would confuse me hard, cuz yesterday everything work fine :)
thanks


{$DEFINE SMART}
{$i AeroLib/AeroLib.Simba}
{$i Reflection/Reflection.simba}
{$I RSWalker/Walker.simba}

var
tester: TRSWalker;
MyPlayer: TReflectLocalPlayer;



procedure test;
var
world: TRSWalker;

begin
world.Init('world.png');
writeLn(world.GetMyPos());
end;

begin
InitAL;
Reflect.Setup;
LoginPlayer(False);
while 1 do
begin
test;
sleep(2000);
end;
end.

fre
06-02-2017, 05:41 PM
Why use RSWalker when you use Reflection?

dotdotdot
06-05-2017, 10:49 AM
Allow me to make an educated guess..
a noobi like me

Eduard
07-31-2017, 09:18 AM
Hello Slacky,

first off I would like to thank you for this awesome utility / include that you have written.

Perhaps i'm not looking deep enough but I manage to face some problems sometimes.

When I am stopping/starting the script in order to improve my script by live debugging and testing failsafes I often have to force a restart from Simba and restart the script in order to get my walking procedures working again. Sometimes the script does run and I don't get any compile errors, but it just shuts down completely by giving me an succesfully execute return value even though I just called the walker function.

Here's a snippit of how I call ur Walker function:



procedure GotoBank;
begin
if (GetCurrentState = 2) then
begin
Walker.Init('WorldMap');
Walker.anyAngle := True;
if (Walker.GetMyPos.x = 2263) and (Walker.GetMyPos.y = 4072) then
begin
ProgressReportEduard('[Walker] - We are at the bank!');
end
else
begin
ProgressReportEduard('[Walker] - Walking to the bank!');
Walker.blindWalk(Point(2263, 4072));
while (isPlayerWalking) do
Wait(randomrange(500, 1000));
end;
Walker.Free;
end;
end;



I also tend to have this function called in my main loop by calling it with AddOnTerminate();


procedure MemoryPrevention;
begin
Walker.free;
end;



Is it perhaps the fact that I run simba 1100 or am I doing something else wrong. If I start the script and just let it run it will never give me that problem, it's only when i'm editing stuff and I am changing things in the script while running/terminating it.

thanks!

Dan the man
07-31-2017, 10:32 AM
Are you running Simba as an administrator?
I also noticed that I have to drag the cross-hair to the RS client a few times in between botting sessions to get it to work sometimes.

slacky
07-31-2017, 12:55 PM
Is it perhaps the fact that I run simba 1100 or am I doing something else wrong. If I start the script and just let it run it will never give me that problem, it's only when i'm editing stuff and I am changing things in the script while running/terminating it.

So a few points:
Note that you setup RSW every single time you walk to the bank. That's actually bad practice, best is to setup RSW _one time_ and one time only, and that is at the setup/startup portion of the script, this is notably better considering setting up RSW with the whole world map, that takes like 10 seconds.. so now when you go to the bank it will have to wait quite a while before it even starts walking.

Further more: "(Walker.GetMyPos.x = 2263) and (Walker.GetMyPos.y = 4072)" that's asking for your script to fail. The walker can't be pixel perfect. It's actually impossible, too many possible changes, in addition to that we compare downsampled images. Note that these coordinates are not tiles either, 1 tile is 4x4 pixels, so you are actually asking "am I on this exact fraction of this tile?", and that's not a thing, you best test if you are within some box/area, or within X distance from that point.

Eduard
07-31-2017, 06:41 PM
Thanks so I could basicly setup the walker with init() once on startup and then running the procedures without having to call it again.
Also, I thought it was pixel accurate, I know understand that it's not, i'll adjust accordingly.

Thanks for the reply!

jokerface25
07-31-2017, 11:21 PM
Hey Slacky, I'm experiencing some issues with RSWalker im not sure what I'm doing wrong, could you have a look at this and tell me if anything is out of order? Thanks :)


program Walking;
//{$DEFINE SMART}
{$DEFINE Walker}
{$i AeroLib/AeroLib.Simba}




var
BronzePick:TItem;
pnt:tpoint;
RSW: TRSWalker;
path: TPointArray;


Procedure Login
begin
Me.Active := True;
Me.Name := '';
Me.Pass := '';
Me.Member := False;
end;

Procedure LoadItem;

begin
BronzePick.DTM := DTMFromString('mAAEAAHic42FgYOADYkYgZgNiTgYIYAZiVi BmAWJuIBYFYgkgFoaqZWRAAEkgFgdiESDmBWIOKGaH6k/w1EHShRsbKCiAaUkG0gBhk1ExMgAAhTYCZA==');
end;

Procedure UseItem;
Begin
if BronzePick.InInventory then
WriteLn('Found Item in Invetory yeah!');
if Bronzepick.interact(Mouse_Left) then
WriteLn('We have the pick!');

end;
procedure Move

begin
pnt := [331,162];
HumanMMouse(pnt, 5, 5);
GameTab(TAB_INV);
GameTab(TAB_STATS);
end;



begin
initAl();
Login;
if (not isLoggedIn()) then
loginPlayer(false);
LoadItem;
UseItem;
Move;
RSW.Init('WorldMap');
RSW.walkStyle := wsSPS;
RSW.anyAngle := True;
RSW.skipClose := 15;
path := [Point(4536,2943),Point(4518,2907),Point(4494,2847)];
RSW.WalkPath(path);

RSW.Free();


end.


This is the error message I get everytime, the walker was working at first but it seemed to stop after a few uses.

Error: Out of memory at line 93
Execution failed.
The following DTMs were not freed: [0]
The following bitmaps were not freed: [0, 1, 2]

If you could help I'd really appreciate it! Thanks

Flight
08-01-2017, 01:34 PM
Hey Slacky, I'm experiencing some issues with RSWalker im not sure what I'm doing wrong, could you have a look at this and tell me if anything is out of order? Thanks :)


program Walking;
//{$DEFINE SMART}
{$DEFINE Walker}
{$i AeroLib/AeroLib.Simba}




var
BronzePick:TItem;
pnt:tpoint;
RSW: TRSWalker;
path: TPointArray;


Procedure Login
begin
Me.Active := True;
Me.Name := '';
Me.Pass := '';
Me.Member := False;
end;

Procedure LoadItem;

begin
BronzePick.DTM := DTMFromString('mAAEAAHic42FgYOADYkYgZgNiTgYIYAZiVi BmAWJuIBYFYgkgFoaqZWRAAEkgFgdiESDmBWIOKGaH6k/w1EHShRsbKCiAaUkG0gBhk1ExMgAAhTYCZA==');
end;

Procedure UseItem;
Begin
if BronzePick.InInventory then
WriteLn('Found Item in Invetory yeah!');
if Bronzepick.interact(Mouse_Left) then
WriteLn('We have the pick!');

end;
procedure Move

begin
pnt := [331,162];
HumanMMouse(pnt, 5, 5);
GameTab(TAB_INV);
GameTab(TAB_STATS);
end;



begin
initAl();
Login;
if (not isLoggedIn()) then
loginPlayer(false);
LoadItem;
UseItem;
Move;
RSW.Init('WorldMap');
RSW.walkStyle := wsSPS;
RSW.anyAngle := True;
RSW.skipClose := 15;
path := [Point(4536,2943),Point(4518,2907),Point(4494,2847)];
RSW.WalkPath(path);

RSW.Free();


end.


This is the error message I get everytime, the walker was working at first but it seemed to stop after a few uses.

Error: Out of memory at line 93
Execution failed.
The following DTMs were not freed: [0]
The following bitmaps were not freed: [0, 1, 2]

If you could help I'd really appreciate it! Thanks

I've had the issue of running out of memory before while using RSWalker, especially when loading "WorldMap". In my own experience I found it's from loading and freeing a large map multiple times with a single instance of Simba. This may be caused from testing & running a script that loads such a large map file, and even though you free it correctly in your example script you're still getting that error. And while I can't explain the cause, I can recommend simply saving your script and restarting Simba itself. You don't have to close out your SMART (if you're using it), just a simple restart of Simba to free anything that's chewing up memory.

Also after looking at the script I notice you're not freeing the BronzePick.DTM. Don't forget, all DTMs and Bitmaps must be freed when the script terminates. That's probably not the issue you're running into in this case, but it could contribute.

jokerface25
08-01-2017, 04:09 PM
I've had the issue of running out of memory before while using RSWalker, especially when loading "WorldMap". In my own experience I found it's from loading and freeing a large map multiple times with a single instance of Simba. This may be caused from testing & running a script that loads such a large map file, and even though you free it correctly in your example script you're still getting that error. And while I can't explain the cause, I can recommend simply saving your script and restarting Simba itself. You don't have to close out your SMART (if you're using it), just a simple restart of Simba to free anything that's chewing up memory.

Also after looking at the script I notice you're not freeing the BronzePick.DTM. Don't forget, all DTMs and Bitmaps must be freed when the script terminates. That's probably not the issue you're running into in this case, but it could contribute.

Well it seemed to fix it for now :) Hopefully it continues to work! Thanks Flight.

R0b0t1
12-26-2017, 03:22 AM
Do you have build instructions? I was able to link MatchTempl against OpenCV 2.4.9 dynamically, but there are issues with static linking. I will add the exact failures here on Monday, but regardless it would help to know how you produced your binaries (mostly MatchTempl).

Here is the mirror (https://github.com/R030t1/Simba-MatchTempl) that I am working from. The main addition is a Makefile. I am targetting x86_64.

Unrelated to this thread, but if you could add some more explicit instructions for using your produced Simba builds, that would be helpful.


$ mingw32-make.exe
x86_64-w64-mingw32-g++ -Wall -std=c++11 -DBUILD_DLL -shared -Iopencv/build/install/include -Lopencv/build/install/x64/mingw/staticlib -Lopencv/build/3rdparty/lib -luser32 -lopencv_calib3d249 -lopencv_contrib249 -lopencv_core249 -lopencv_features2d249 -lopencv_flann249 -lIlmImf -llibtiff -llibpng -llibjpeg -llibjasper -lzlib -lopencv_gpu249 -lopencv_highgui249 -lopencv_imgproc249 -lopencv_legacy249 -lopencv_ml249 -lopencv_nonfree249 -lopencv_objdetect249 -lopencv_ocl249 -lopencv_photo249 -lopencv_stitching249 -lopencv_superres249 -lopencv_video249 -lopencv_videostab249 -lcomctl32 -lvfw32 -o libMatchTempl.dll main.cpp MatchTempl.cpp MatchTempl.hpp
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x8a): undefined reference to `cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x2af): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x2c2): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x2de): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x611): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x627): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x63c): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x65c): undefined reference to `cv::matchTemplate(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x685): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x69e): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x6b7): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text+0 x6f6): undefined reference to `cv::normalize(cv::_InputArray const&, cv::_OutputArray const&, double, double, int, int, cv::_InputArray const&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text$_ ZN2cv3MatD1Ev[_ZN2cv3MatD1Ev]+0x36): undefined reference to `cv::fastFree(void*)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text$_ ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x11f): undefined reference to `cv::Mat::copySize(cv::Mat const&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text$_ ZNK2cv3Mat5cloneEv[_ZNK2cv3Mat5cloneEv]+0x2b): undefined reference to `cv::_OutputArray::_OutputArray(cv::Mat&)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text$_ ZNK2cv3Mat5cloneEv[_ZNK2cv3Mat5cloneEv]+0x3b): undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text$_ ZN2cv3Mat6createEiii[_ZN2cv3Mat6createEiii]+0x90): undefined reference to `cv::Mat::create(int, int const*, int)'
C:\Cygwin64\tmp\ccl9rggZ.o:MatchTempl.cpp:(.text$_ ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x48): undefined reference to `cv::Mat::deallocate()'
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [Makefile:76: all] Error 1

slacky
12-26-2017, 12:34 PM
You need to have a talk with Brandon regarding that. IIRC he helped me with the static build.

R0b0t1
12-28-2017, 09:44 PM
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:


$ mingw32-make.exe
x86_64-w64-mingw32-g++ -Wall -std=c++11 -DBUILD_DLL -shared -Iopencv/build/install/include -Lopencv/build/install/x64/mingw/staticlib -Lopencv/build/3rdparty/lib -luser32 -lcomctl32 -lvfw32 -lIlmImf -llibjasper -llibjpeg -llibpng -llibprotobuf -llibtiff -llibwebp -lopencv_aruco340 -lopencv_bgsegm340 -lopencv_bioinspired340 -lopencv_calib3d340 -lopencv_ccalib340 -lopencv_core340 -lopencv_datasets340 -lopencv_dnn340 -lopencv_dpm340 -lopencv_face340 -lopencv_features2d340 -lopencv_flann340 -lopencv_fuzzy340 -lopencv_highgui340 -lopencv_img_hash340 -lopencv_imgcodecs340 -lopencv_imgproc340 -lopencv_line_descriptor340 -lopencv_ml340 -lopencv_objdetect340 -lopencv_optflow340 -lopencv_phase_unwrapping340 -lopencv_photo340 -lopencv_plot340 -lopencv_reg340 -lopencv_rgbd340 -lopencv_saliency340 -lopencv_shape340 -lopencv_stereo340 -lopencv_stitching340 -lopencv_structured_light340 -lopencv_superres340 -lopencv_surface_matching340 -lopencv_text340 -lopencv_tracking340 -lopencv_video340 -lopencv_videoio340 -lopencv_videostab340 -lopencv_xfeatures2d340 -lopencv_ximgproc340 -lopencv_xobjdetect340 -lopencv_xphoto340 -lzlib -o libMatchTempl.dll main.cpp MatchTempl.cpp MatchTempl.hpp
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text+0 x5d): undefined reference to `cv::imread(cv::String const&, int)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text+0 x294): undefined reference to `cv::cvtColor(cv::_InputArray const&, cv::_OutputArray const&, int, int)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text+0 x5f4): undefined reference to `cv::noArray()'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text+0 x65d): undefined reference to `cv::matchTemplate(cv::_InputArray const&, cv::_InputArray const&, cv::_OutputArray const&, int, cv::_InputArray const&)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text+0 x71a): undefined reference to `cv::normalize(cv::_InputArray const&, cv::_InputOutputArray const&, double, double, int, int, cv::_InputArray const&)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZN2cv6StringC1EPKc[_ZN2cv6StringC1EPKc]+0x51): undefined reference to `cv::String::allocate(unsigned long long)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZN2cv6StringD1Ev[_ZN2cv6StringD1Ev]+0x11): undefined reference to `cv::String::deallocate()'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZN2cv3MatC1EiiiPvy[_ZN2cv3MatC1EiiiPvy]+0x122): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZN2cv3MatC1EiiiPvy[_ZN2cv3MatC1EiiiPvy]+0x207): undefined reference to `cv::error(int, cv::String const&, char const*, char const*, int)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZN2cv3MatD1Ev[_ZN2cv3MatD1Ev]+0x36): undefined reference to `cv::fastFree(void*)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZNK2cv3Mat5cloneEv[_ZNK2cv3Mat5cloneEv]+0x3b): undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZN2cv3Mat6createEiii[_ZN2cv3Mat6createEiii]+0x90): undefined reference to `cv::Mat::create(int, int const*, int)'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x48): undefined reference to `cv::Mat::deallocate()'
C:\Cygwin64\tmp\ccG5K8IR.o:MatchTempl.cpp:(.text$_ ZN2cv3MataSEOS0_[_ZN2cv3MataSEOS0_]+0xe9): undefined reference to `cv::fastFree(void*)'
collect2.exe: error: ld returned 1 exit status
mingw32-make: *** [Makefile:135: all] Error 1

If you look at the Makefile (https://github.com/R030t1/Simba-MatchTempl/blob/master/Makefile) I created, the libraries that contain at least some of these functions are being linked in (e.g. cv::matchTemplate is in opencv_imgproc340). OpenCV has been reorganized since 2.4.9; notably, the external contributions produce their own libraries and are not all one object. Certain other libraries seem to have been combined with each other or removed. If you could look at MatchTempl and see which libraries are actually required it would help. What used to be there seems to be sufficient, but I link against all available libraries, which is what the Code::Blocks project seems to have been doing.

Kasi
12-29-2017, 05:36 AM
What used to be there seems to be sufficient, but I link against all available libraries, which is what the Code::Blocks project seems to have been doing.

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.

R0b0t1
12-31-2017, 05:00 PM
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.

Kasi
12-31-2017, 09:32 PM
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:


Source 1. https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options


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


Source 3. http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use
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.

R0b0t1
12-31-2017, 09:55 PM
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.

Brandon
01-01-2018, 01:45 AM
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:


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):

-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.
For ALL Linkers, order matters!


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!08Megwbk1TAEaQGpSN5eCvIiYyeGfGoJQBB-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 :D
Exact same steps above for Linux. Windows is just different in its linker flags and that's about it..

R0b0t1
01-29-2018, 06:22 PM
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.

slacky
02-10-2018, 09:53 AM
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 (https://github.com/SRL/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/SlackGUI/blob/master/tests/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.
https://image.prntscr.com/image/4M75HFXtRxGrY58n18h1DQ.png

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/RSWalker/blob/master/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..
https://image.prntscr.com/image/YoERTRolTS6vu-nlCc3_YQ.png
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.

Joopi
02-10-2018, 10:43 AM
:cartman:
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?

slacky
02-10-2018, 11:28 AM
:cartman:
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.

Joopi
02-10-2018, 01:06 PM
Good. That's what I was hoping for too. Only reason I asked was due to the conversation you (and Olly) had with BenLand100 :p

Flight
02-10-2018, 03:41 PM
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. :thumbsup:

slacky
02-10-2018, 04:45 PM
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.

slacky
02-12-2018, 02:56 PM
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.

https://media.giphy.com/media/26DN9RQYECd4GQ5xK/giphy.gif

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 (https://github.com/slackydev/SlackGUI/blob/e32addde3b9490b72935ea159cedd47564f95a93/tests/Webber.simba#L667-L668), and pasting it there.
Find:

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/SlackGUI/blob/master/tests/Webber.simba
Download the whole repositiory (https://github.com/slackydev/SlackGUI/), place it in your Includes folder.

Hoodz
02-13-2018, 08:51 PM
great work slacky!

slacky
03-27-2018, 12:32 AM
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/RSWalker/blob/master/maps/MapBuilder.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).

slacky
04-15-2018, 12:55 AM
Release 1.1 (https://github.com/slackydev/RSWalker/releases/tag/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



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.

b_a_n_a_n_a_s
08-28-2018, 08:30 PM
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

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

kingarabian
09-21-2018, 08:17 AM
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.

Joopi
09-21-2018, 10:01 AM
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.

kingarabian
09-21-2018, 10:15 AM
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:

Var
polgyon : 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.

Joopi
09-21-2018, 04:28 PM
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.

kingarabian
09-21-2018, 08:02 PM
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.