SRL Archive - SRL Archives

WalkRoad, Works VERY well


dontpanic

2007-02-01 19:32:58

I made a procedure called WalkRoad. What it does is very simple, but it does it very reliably. It walks along the road you are currently standing on in a direction a certain distance away from the center of the minimap, however it will ONLY click on the road you are currently on, so it doesnt matter if the minimap is tilted up to 90 degrees.

I would appreciate feedback on this if you test it.

procedure UpdateRoadColor;
var
CurTol:integer;
begin
if(FindMMColor(x,y,RoadColor)) then Exit;
repeat
CurTol:=CurTol+1;
until(FindColorTolerance(x,y,RoadColor,MMCX-20,MMCY-20,MMCX+20,MMCY+20,CurTol));
RoadColor:=GetColor(x,y);
WriteLn('New RoadColor: '+inttostr(RoadColor));
end;

function WalkRoad(dir:string;dist:integer):boolean;
var
DistOut,rx,ry:integer;
begin
UpdateRoadColor;
DistOut:=3;
repeat
DistOut:=DistOut+1;
if(DistOut)=30 then Exit;
until FindColor(rx,ry,RoadColor,MMCX-DistOut,MMCY-DistOut,MMCX+DistOut,MMCY+DistOut);
if(dir='N') then begin
repeat
DistOut:=0;
repeat
DistOut:=DistOut+1;
if(DistOut=15) then Exit;
until FindColor(rx,ry,RoadColor,rx-DistOut,ry-1,rx+DistOut,ry-1);
until(abs(ry-MMCY)>=dist);
end;
if(dir='S') then begin
repeat
DistOut:=0;
repeat
DistOut:=DistOut+1;
if(DistOut=15) then Exit;
until FindColor(rx,ry,RoadColor,rx-DistOut,ry+1,rx+DistOut,ry+1);
until(distance(rx,ry,MMCX,MMCY)>=dist);
end;
if(dir='E') then begin
repeat
DistOut:=0;
repeat
DistOut:=DistOut+1;
if(DistOut=15) then Exit;
until FindColor(rx,ry,RoadColor,rx+1,ry-DistOut,rx+1,ry+DistOut);
until(distance(rx,ry,MMCX,MMCY)>=dist);
end;
if(dir='W') then begin
repeat
DistOut:=0;
repeat
DistOut:=DistOut+1;
if(DistOut=15) then Exit;
until FindColor(rx,ry,RoadColor,rx-1,ry-DistOut,rx-1,ry+DistOut);
until(distance(rx,ry,MMCX,MMCY)>=dist);
end;
Mouse(rx,ry,1,1,true);
FFlag(10);
Result:=True;
end;

Avaphi

2007-02-01 19:57:31

Nice job mate ++Rep

mage of begu

2007-03-01 09:24:38

So the distance works like in RadialRoadWalk…20-72…?

Ejjman

2007-03-01 16:36:43

From: mage of begu
So the distance works like in RadialRoadWalk…20-72…?


Dun think so

It says if(DistanceOut = 15)then Exit;

dontpanic

2007-03-01 18:08:59

The distance is like radialwalk. The distance out thing is something else, it is how far it looks to each side to find the road (if your walking north, how far it looks east and west incase of a curve / slope /etc)

mage of begu

2007-03-04 05:18:52

From: dontpanic
The distance is like radialwalk. The distance out thing is something else, it is how far it looks to each side to find the road (if your walking north, how far it looks east and west incase of a curve / slope /etc)


Can you please post me an example if i want to walk "North" and half way in minimap…what should i put there…!

Wizzup?

2007-03-04 06:45:51

This might work..
But the best way is to copy an area around the flag to the debug window, then preform get colors.
You can easily lose the roadcolor, or find other colors that are close to the road instead.

dontpanic

2007-03-09 14:53:54

I use the same stuff as radialroadwalk for getting the roadcolor.
@mage of begu: WalkRoad('N',40);

mage of begu

2007-03-11 08:41:58

From: dontpanic
I use the same stuff as radialroadwalk for getting the roadcolor.
@mage of begu: WalkRoad('N',40);


Thanks…i try this one..! Hope it works good…;)

EDIT: Ok so i tested it…in my east varrock atominer/banker…and didnt work good :( if road is like "~" it cant walk the road…! if you can fix it then i think its good…! ;)

m0u53m4t

2007-03-17 06:41:26

Its good, but doesn't work in fally well. When a new tile loads the road colour changes and the script picks up some dirt in the park, not the road :p

I had problems with it drifting, so I modded it myself. I've taken my own method of going different directions though :p. If you try it in the mines or something now, it goes straight instead of drifting east:

program New;
{.Include SRL/SRL.Scar}

procedure UpdateRoadColor(x1, y1, x2, y2:integer);
var
CurTol,cx,cy:integer;
begin
if(FindColor(cx,cy,RoadColor,x1 ,y1 , x2, y2)) then Exit;
repeat
CurTol:=CurTol+1;
until(FindColorTolerance(x,y,RoadColor,x1 ,y1 , x2, y2,CurTol));
RoadColor:=GetColor(x,y);
WriteLn('New RoadColor: '+inttostr(RoadColor));
end;

function WalkRoad(dir:string;dist,curve:integer):boolean;
var
DistOut,Dist2,Scanned,rx,ry:integer;
begin
Dist2 := Dist

MakeCompass(dir)

UpdateRoadColor(598,25,716,60)
Repeat
For DistOut := 0 to Curve do
Begin
Scanned := Scanned + 1
If FindColor(rx,ry,RoadColor,MMCX-DistOut,MMCY-Dist2,MMCX+DistOut,MMCY-Dist2+4) then Break
End;
Dist2 := Dist2 - 2
Until ((Dist2 < Dist/5) or (FindColor(rx,ry,RoadColor,MMCX-DistOut,MMCY-Dist2,MMCX+DistOut,MMCY-Dist2+4)))


Writeln('Scanned ' + Inttostr(scanned) + ' images to decide where to walk.')

If (((not (rx = 0)) and (not (ry = 0)))) then
begin
Status('Walking along road on MM')
Mouse(rx,ry,4,4,true);
Status('Waiting for flag')
FFlag(10)
Status('Flag Reached')
Result := True
End;
end;

It can now even cope with entering Fally with the colour changes, because of the search area for updateroadcolor.

dontpanic

2007-03-17 13:41:26

Thanks, that looks like it will work a lot better. I havent tested yet though cause i gotta make a new army since mine got banned :S

m0u53m4t

2007-03-18 05:12:08

I tested mine, and it can walk straight through fally and through port sarim until the road ends without losing the road :p