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.