SRL Archive - Research & Development Lounge

World Walker


Gu3st...

2010-01-24 06:56:16

UPDATED 14th of May 2011!

{$DEFINE Test_worldwalker_v2} // Remove this line if you plan on including it.
{$IFDEF Test_worldwalker_v2}
{$i SRL/SRL.scar}
{$ENDIF}

function IsWorldMapUp : Boolean;
var
tmp : String;
begin
Result := GetMMLevels('hp', tmp) = -1;
end;

procedure CloseWorldMap;
var
T : Integer;
begin
if not IsWorldMapUp then Exit;
Mouse(746, 15, 4, 4, True); // Click the close map button
T := GetSystemTime + 15000;
while (IsWorldMapUp) and (GetSystemTime < T) do
Wait(200+Random(500));
end;

function OpenWorldMap : Boolean;
var
T : Integer;
begin
Result := IsWorldMapUp;
if Result or (not LoggedIn) then Exit;
MouseBox(526, 124, 559, 157, mouse_Left); // Click the world map icon
Wait(3000);
T := GetSystemTime + 15000;
// GetColor = wait for loading worldmap is complete
while (GetColor(230, 196) = 1118604) and (GetSystemTime < T) do
Wait(500+Random(1500));
Result := GetSystemTime < T;
end;

function IsWorldMapMinimapUp : Boolean;
begin
Result := InRange(CountColor(clBlack, 609, 311, 757, 460), 6000, 10000);
end;

function OpenWorldMapMinimap : Boolean;
begin
Result := IsWorldMapMinimapUp;
if Result then Exit;
MouseBox(667, 470, 697, 490, mouse_Left);
Result := IsWorldMapMinimapUp;
end;

function SetWorldMapScale(Percent : Integer) : Boolean;
var
Percents : TIntegerArray;
curPercent, tarPercent : Integer;
begin
Result := False;
if not IsWorldMapUp then Exit;
Percents := [200, 100, 75, 50, 37];
case CountColor(clWhite, 704, 470, 740, 489) of
66: CurPercent := 0;
62: CurPercent := 1;
49: CurPercent := 2;
52: CurPercent := 3;
47: CurPercent := 4;
else
Exit;
end;
if not InIntArrayEx(Percents, tarPercent, Percent) then Exit;
while tarPercent <> curPercent do
begin
if tarPercent < curPercent then
begin
Dec(curPercent);
MouseBox(743, 465, 756, 478, mouse_Left)
end else
begin
Inc(curPercent);
MouseBox(743, 481, 756, 494, mouse_Left);
end;
Wait(100+Random(150));
end;
Result := True;
end;

function GetWorldMapPos(CloseTheWorldMap : Boolean) : TPoint;
var
X, Y : Integer;
begin
Result := Point(-1, -1);
if OpenWorldMap then
if OpenWorldMapMinimap then
if SetWorldMapScale(200) then
if FindColorTolerance(X, Y, 255, 609, 311, 757, 460, 5) then
begin
Result.X := X - 608; // Turn them into coordinates relative to the worlmap's minimap
Result.Y := Y - 310;
end;
if CloseTheWorldMap then CloseWorldMap;
end;

function WalkWorldMapPointFrom(sP, eP : TPoint; SafeMode : Boolean) : Boolean;
var
MapDistance, I : Integer;
RealAngle, Angle : Extended;
WalkPoint : TPoint;
begin
WriteLn('WalkWorldMapPointFrom: Walking from ' + ToStr(sP) + ' to ' + ToStr(eP));

Result := False;
if (not LoggedIn) and (not IsWorldMapUp) then Exit;
if IsWorldMapUp then CloseWorldMap;

if sP.X = -1 then
begin
Result := False;
Exit;
end;

if (sP.X = eP.X) and (sP.Y = eP.Y) then
begin
Result := True;
Exit;
end;

MapDistance := maxInt; //Just setting it to something > 1 so the while..do loop will not fail
while MapDistance > 1 do
begin
WriteLn('WalkWorldMapPointFrom: Walking from ' + ToStr(sP) + ' to ' + ToStr(eP));
MapDistance := Round(Distance(sP.X, sP.Y, eP.X, eP.Y) * 1.0);
RealAngle := Degrees(ArcTan2(sP.Y - eP.Y, sP.X - eP.X)) + 180.0;
while RealAngle > 360.0 do RealAngle := RealAngle - 360.0;

for I := 0 to MapDistance do
begin
Angle := RealAngle - rs_GetCompassAngleDegrees;
WalkPoint := RotatePoint(Point(MMCX + 50, MMCY), Radians(Angle), MMCX, MMCY);
Mouse(WalkPoint.X-2, WalkPoint.Y-2, 4, 4, True);
RunEnergy(30);
while IsMoving do
if InRange(FlagDistance,2, 20) then
Break
else
Wait(100);
end;

while IsMoving do
Wait(1000);

if SafeMode then
sP := GetWorldMapPos(True)
else
Break;

if sP.X = -1 then
begin
Result := False;
Exit;
end;
if (sP.X = eP.X) and (sP.Y = eP.Y) then
begin
Result := True;
Exit;
end;
end;
Result := True;
end;

function WalkWorldMapPoint(TargetPoint : TPoint; SafeMode : Boolean) : Boolean;
var
CurrentLocation : TPoint;
begin
Result := False;
if (not LoggedIn) and (not IsWorldMapUp) then Exit;

CurrentLocation := GetWorldMapPos(True);
Result := WalkWorldMapPointFrom(CurrentLocation, TargetPoint, SafeMode);
end;

function WalkWorldMapString(SearchString : String; SafeMode : Boolean) : Boolean;
var
CurrentLocation, TargetLocation : TPoint;
begin
Result := False;
if (not LoggedIn) and (not IsWorldMapUp) then Exit;

if OpenWorldMap then
if OpenWorldMapMinimap then
if SetWorldMapScale(200) then
begin
CurrentLocation := GetWorldMapPos(False);
if CurrentLocation.X = -1 then
begin

end;
MouseBox(98, 472, 320, 487, mouse_Left);
TypeSend(SearchString);
Wait(1000+Random(500));
TargetLocation := GetWorldMapPos(True);
Result := WalkWorldMapPointFrom(CurrentLocation, TargetLocation, SafeMode);
end;
end;

function WalkWorldMapPath(TargetPoints : TPointArray) : Boolean;
var
H, I : Integer;
begin
Result := False;
H := High(TargetPoints);
for I := 0 to H do
if not WalkWorldMapPoint(TargetPoints[I], False) then Break;
Result := True;
end;

function WalkWorldMapWeb(TargetConstant : Integer) : Boolean;
begin
// Not yet made.
Result := False;
end;

{$IFDEF Test_worldwalker_v2}
begin
SetupSRL;
//WriteLn(GetWorldMapPos(False));
WalkWorldMapString('arket', True);
WalkWorldMapString('d Exc', True);
WriteLn(GetWorldMapPos(True));
end.
{$ENDIF}

Example on use:
WalkWorldMapString('d Exc', True);
This will walk to the GE.

The position (86, 62) is where the GE is on the mini-map in the map interface.

Here is an outdated sample video showing the script while walking:
http://www.youtube.com/watch?v=-lyzYBmrwF8

Start logged in

Sex

2010-01-24 06:59:35

This is damn sexy. I'll be sure to test it later.

Edit: It walked from Falador to the top right corner of the Grand Exchange..

Naum

2010-01-24 07:06:19

Haha nice work man :).
I used the exact same principle in mine. However, does it, like mine would, tend to screw up when there's an obstacle such as a wall in the way?

Gu3st...

2010-01-24 07:27:38

From: Naum
Haha nice work man :).
I used the exact same principle in mine. However, does it, like mine would, tend to screw up when there's an obstacle such as a wall in the way?
Yeah, I know a solution though. Did you make one too? O_o

It's very simple math used in the script. It will walk towards the point until it can see the location at the minimap (the one with a compass), so it might "screw" up sometimes, as it doesn't use any symbols / DDTMs / BMPs / colors to check if it is near the point

Naum

2010-01-24 07:28:48

From: Zyt3x
Yeah, I know a solution though. Did you make one too? O_o

It's very simple math used in the script. It will walk towards the point until it can see the location at the minimap (the one with a compass), so it might "screw" up sometimes, as it doesn't use any symbols / DDTMs / BMPs / colors to check if it is near the point


I did… once:p.

http://theworldwalker.googlecode.com/svn/trunk/

I abandoned it ages ago, like with most of my projects :p.

But, seriously nice job on it, get on msn :)

Gu3st...

2010-01-24 07:32:57

From: Naum
I did… once:p.

http://theworldwalker.googlecode.com/svn/trunk/

I abandoned it ages ago, like with most of my projects :p.

But, seriously nice job on it, get on msn :)


I am on msn, you're not… :p
nice name for your function btw xD

mixster

2010-01-24 07:47:31

How much have you tested the "IsMapUp", "OpenMap" and "GetMapPos" functions? If they're reliable, would you mind me using them for an update to my old SPAM/S (my world walker)?

To fix the "only walk when facing North" bug/feature, you would have to get the current direction as an angle and rotate the direction where you are to click by that much. ie if you're maths works out that you need to walk at a 235 degree angle and the map is currently offset by 30 degrees, then you would have to walk at a 265 degrees angle instead - I can provide a drawing that shows you why if you're still unsure what I mean or unsure why you need to.

Also, the accuracy of this is quite low because of how much the overview of the world map is compressed. The actual fullsize RS map, which I believe is a 1:1 ratio of the in game world map at 100%, is something like 4000px wide where as this is a lot less, so you can see there is a lot of room for error, so just something to look out for.

Awkwardsaw

2010-01-24 08:28:38

do you mind if i use this in a script? :D

when bugs are fixed/ let me edit a few :)

also, how do you get the points to walk to?

Gu3st...

2010-01-24 11:08:20

From: mixster
How much have you tested the "IsMapUp", "OpenMap" and "GetMapPos" functions? If they're reliable, would you mind me using them for an update to my old SPAM/S (my world walker)?

To fix the "only walk when facing North" bug/feature, you would have to get the current direction as an angle and rotate the direction where you are to click by that much. ie if you're maths works out that you need to walk at a 235 degree angle and the map is currently offset by 30 degrees, then you would have to walk at a 265 degrees angle instead - I can provide a drawing that shows you why if you're still unsure what I mean or unsure why you need to.

Also, the accuracy of this is quite low because of how much the overview of the world map is compressed. The actual fullsize RS map, which I believe is a 1:1 ratio of the in game world map at 100%, is something like 4000px wide where as this is a lot less, so you can see there is a lot of room for error, so just something to look out for.
Thanks, weird I didn't think of that..
This wasn't as hard to make as I though and I only used ~3 hours in total of time to script.
I haven't tested the functions much at all, but if you add some more color checks then I think they'll be quite reliable :)
I made it walk thought the whole f2p world without errors, started at wizards tower, walked to black knights fortress, lumber mill in varrock, then back to wizards tower

From: Awkwardsaw
do you mind if i use this in a script? :D

when bugs are fixed/ let me edit a few :)

also, how do you get the points to walk to?
Use it, abuse it, do whatever you want with it :P
To get points: find the point where you want it to walk (via the mini mini map, the one in the img) and hit CTRL + ALT + P to get the coords.

EDIT: Fixed walking, now it can walk with a compass angle other than 0

Smarter Child

2010-02-02 21:41:32

how do you get the exact point?

Blumblebee

2010-02-02 22:20:47

you should try to make it walk on a road colour as much as possible. Scan the MM for a particular working autocolor, if present then it would walk in relation to it. That would help it avoid obstacles (however it would probably mess everything else up :/)

Bad Boy JH

2010-02-02 22:42:36

Is the co-ordinates exact? because if they are close, ie a couple of spots wide, is it possible to have one where you input the co-ordinates or origin and destination, meaning you don't have to open the world map every time? would make it less detectable, and then would be used more often, there needs to be a way to make it so it doesn't open the worldmap…

Sex

2010-02-03 03:49:56

The map has to be opened to calculate the path..

mixster

2010-02-03 08:39:15

From: Blumblebee
you should try to make it walk on a road colour as much as possible. Scan the MM for a particular working autocolor, if present then it would walk in relation to it. That would help it avoid obstacles (however it would probably mess everything else up :/)


I believe this method is more to be used by producing several, smaller walks - a bit like radial walking blindly in the right direction rather than intelligently walking long distances.

Gu3st...

2010-02-03 08:41:56

From: Smarter Child
how do you get the exact point?

I'll make a short vid/gif or something :)

From: Blumblebee
you should try to make it walk on a road colour as much as possible. Scan the MM for a particular working autocolor, if present then it would walk in relation to it. That would help it avoid obstacles (however it would probably mess everything else up :/)

It is one of our plans :) (me and Naum)
E: As mixster said, it wont be made so that it has to walk on roads, but if there is a road in that direction then why not click it? :p

From: Bad Boy JH
Is the co-ordinates exact? because if they are close, ie a couple of spots wide, is it possible to have one where you input the co-ordinates or origin and destination, meaning you don't have to open the world map every time? would make it less detectable, and then would be used more often, there needs to be a way to make it so it doesn't open the worldmap…
There is ways, but they all include making the whole MM into one gigantic bitmap, and each time JaGeX updated their worldmap we would have to update it. :/

Cartmann

2010-02-03 16:32:25

There is ways, but they all include making the whole MM into one gigantic bitmap, and each time JaGeX updated their worldmap we would have to update it. :/

Couldn't you make an updater for that? Like Method did with reflection

Smarter Child

2010-02-03 18:27:23

From: Cartmann
Couldn't you make an updater for that? Like Method did with reflection


Reflection is different. I am not sure it is that easy with the world map(color).

@ Zyt3x - Thanks, I'm definitely gonna use this in a script. [would be amazing in quest runners :D]

game over

2010-02-04 00:51:46

I'll be sure to test it, i have a lot of level 3 accounts i wont mind losing lol :P

Gu3st...

2010-02-04 10:47:01

From: game over
I'll be sure to test it, i have a lot of level 3 accounts i wont mind losing lol :P
I used this on my main. No worries, you wont be banned for opening the world map ;)

Bad Boy JH

2010-02-04 23:19:19

Could be useful for such things as when you are lost…

Gu3st...

2010-02-05 07:48:36

From: Bad Boy JH
Could be useful for such things as when you are lost…
Or if you want to walk to somewhere ;) :rolleyes:

Awkwardsaw

2010-02-05 08:52:18

maby add pre determined coords on the world map?

like banks, mining spots, ect.

B_Varr_East := point(x, y); //east varr bank
B_Varr_West := point(x, y); //west varr bank
M_Varr_East //east varr mining spot
M_Varr_west //ect. :)

? :)

Gu3st...

2010-02-05 10:41:03

From: Awkwardsaw
maby add pre determined coords on the world map?

like banks, mining spots, ect.

B_Varr_East := point(x, y); //east varr bank
B_Varr_West := point(x, y); //west varr bank
M_Varr_East //east varr mining spot
M_Varr_west //ect. :)

? :)
Yeah smart idea, will do :)

Also, I've made a new version that includes using the search bar to find points.
I'll upload it

Floor66

2010-02-05 16:44:28

Sweeet! This is really advanced walking imo.

Gu3st...

2010-02-05 18:24:49

From: Floor66
Sweeet! This is really advanced walking imo.
Not at all, tbh :)
It's (very) simple trigonometry really

EDIT: Updated first post with updated script

Gu3st...

2011-05-14 08:07:15

Updated the script :)

Bobzilla69

2011-05-14 08:11:39

failed for me.

it didnt search for the text, but did set the % of map.

Edit:

got it work by adding a small wait at line 69, before you do if not inintarrayex

Gu3st...

2011-05-14 08:19:15

From: Bobzilla69
failed for me.

it didnt search for the text, but did set the % of map
What did you test?

WalkWorldMapString('d Exc', True);?

Bobzilla69

2011-05-14 08:20:26

yes

Gu3st...

2011-05-14 08:23:18

From: Bobzilla69
yes
Okay I found the problem… Hold on

E: I fixed it now.. Test it please? :)