SRL Archive - SRL Archives

[Easy walking] ScanWalk!


EvilChicken!

2009-01-18 20:29:42

function ScanWalk(Direction: Char; Color: Integer; Step, FlagDist: Byte): Boolean;
var
X, Y, MX1, MY1, MX2, MY2, Col: Integer;

begin
Result := False;
if (not LoggedIn) or (Color < 0) then exit;

MX1 := MMX1;
MY1 := MMY1;
MX2 := MMX2;
MY2 := MMY2;

case UpperCase(Direction) of
'N': MY2 := MMY1;
'W': MX2 := MMX1;
'S': MY1 := MMY2;
'E': MX1 := MMX2;
else
begin
srl_Warn('ScanWalk', '"' + Direction + '" is an invalid direction', -2);
Exit;
end;
end;

if Step = 0 then Step := 1;
Col := Color;

repeat
case UpperCase(Direction) of
'N': IncEx(MY2, Step);
'W': IncEx(MX2, Step);
'S': DecEx(MY1, Step);
'E': DecEx(MX1, Step);
end;
try
if FindColor(X, Y, Col, MX1, MY1, MX2, MY2) then
begin
MouseFlag(X, Y, 0, 0, FlagDist);
Result := True;
Exit;
end;
Wait(3);
except
Exit;
end;
until (MX1 <= MMX1) and (MX2 >= MMX2) and (MY1 <= MMY1) and (MY2 >= MMY2);
end;

Really simple, yet highly effective method of walking.
It "scans" the minimap, from "direction" direction entered, towards the other end of the minimap, for the "Color" color.

Usage:
ScanWalk('N', FindLumbyRoadColor, 10, 20 + Random(20));

^^^ That would walk north using the found Lumbridge road color (if any results) with a step of 10 and 20 + Random(20) flagDistance.

Step is the "steps" it takes for each new color search. If it doesn't find the color the first search, it adds/takes "step" amount from the X/Y coords. SRL members should be able to understand the function better by reading it, as I'm not really good at explaining ..

I really like this way of walking, because it works as a sort of "webwalk", you can repeat walking in one direction, i.e. north, without requiring to acquire any compass radials/scan area degrees et cetera. All that this function needs, is that the compass is facing north.

That means that if you need to walk up a road that doesn't bend more than 80 degrees, you can just do something like:
repeat
ScanWalk('N', FindVarrockRoadColor, 15, 10 + Random(40));
until FindSymbol(X, Y, 'water')

That would continue to walk up a road until a water symbol is found.
And, if using that, you don't need to worry too much about flagdistance, which has it's benefits.

If somebody wants to see it, I have a script that walks from Lumbridge to Varrock using this technique that I could post. It's nothing advanced at all, just for demonstrating the usage of this function.

And a final note, try not to use too small values in "step", as that could make the function click outside the minimap.

NiCbaZ

2009-01-18 21:06:10

Wow very nice :), only will work with autocolor tho? is there a findcolortol? so the tol can be user defined , so it all doesnt need to be autocolored?

EvilChicken!

2009-01-19 00:25:57

You could edit the function to use tolerance, but it would severely slow it down (because as you can see it makes a search every 3rd millisecond) and I anyway don't see how that would come useful?

I would mainly use this on roads.
Maybe along with an edited version of this, that function could be used to walk from anywhere, to anywhere.

n3ss3s

2009-01-21 10:37:41

When I introduced this to the world as the almighty DirectionScanner it got no appreciation :mad:

EvilChicken!

2009-01-22 10:57:47

N3s, I hope that was a joke? xD

n3ss3s

2009-01-23 09:39:51

Well the code maybe wasn't so glamorous but the idea was :)

MylesMadness

2009-01-24 09:04:58

Can we put this in non srl members scripts?

Pyro

2009-01-24 17:12:46

Lol nice evil chicken. You should see my old scripts :P. Ive never used radialwalk in my life. I have ALWAYS used the walking like you do here.

Ofcourse mine was a bit messier, and we didnt have inc aswell back then.

Nice work :)

Sir R. M8gic1an

2009-01-25 13:41:01

this is rather cool, but wouldn't it come down to the same thing as

repeat
RadialWalk(stuff,stuff,stuff....);
until(FindSymbol(blah))

?

or like having a for loop in there increasing the radius and(perhaps) start angle and end angle ?

~RM

Kyle Undefined

2009-01-25 15:35:27

Good job EC. Is this more reliable than RadialWalk? Since you're pointing out in what direction you want to walk in.

~Camo

MylesMadness

2009-01-25 16:19:28

From: Camo¤Kyle
Good job EC. Is this more reliable than RadialWalk? Since you're pointing out in what direction you want to walk in.

~Camo
If your using one of those RadicalwalkNorth that work at any angle no.

EvilChicken!

2009-01-25 18:01:48

From: n3ss3s
Well the code maybe wasn't so glamorous but the idea was :)


Appealing code is more than half the basis of people's first impression of your idea :p

From: Mylesmadness
Can we put this in non srl members scripts?


You're asking for permission, or do you want me to move this thread?
(If so, then to what section?)

From: Pyro
Lol nice evil chicken. You should see my old scripts :P. Ive never used radialwalk in my life. I have ALWAYS used the walking like you do here.

Ofcourse mine was a bit messier, and we didnt have inc aswell back then.

Nice work :)


Why, thankyou! Glad to hear that I'm not alone..

From: Rasta Magician
this is rather cool, but wouldn't it come down to the same thing as

repeat
RadialWalk(stuff,stuff,stuff....);
until(FindSymbol(blah))

?

or like having a for loop in there increasing the radius and(perhaps) start angle and end angle ?

~RM


With RadialWalk, you always have all the angles and other things that might confuse new scripters. With this function, you just enter a direction, then it just walks that direction.


You could easily make a function that would make this function appliable for all compass directions, it would be something like this:

function ConvertComDegrees: Char;
var
Deg: Extended; // Is it? .. not a huge difference anyway.
begin
if not LoggedIn then exit;
case Round(RS_GetCompassAngleDegrees) of // Probably wrong, but you get the point..?
0..90: Result := 'N';
91..180: Result := 'W';
181..270: Result := 'S';
271..360: Result := 'E';
end;
end;

noidea

2009-01-25 19:23:57

RadialWalk was the very first SRL thing I learned. I didn't ever have trouble with it. I new it before Mouse().

MylesMadness

2009-01-25 21:43:41

From: EvilChicken!
You're asking for permission, or do you want me to move this thread?
(If so, then to what section?)
I mean if I make a script with this function can I release the script to junior members?

EvilChicken!

2009-01-26 03:56:04

From: Mylesmadness
I mean if I make a script with this function can I release the script to junior members?


Sure, feel free to do that :3


Moved to jr. members.