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