masquerader
2006-03-04 17:40:44
seeing as i dont want to use radial walk for everything (even though it is awesome, its a bit hard to use sometimes), and stupid3000's road walking functions are like 2 years old, i figured i would write some new ones:
it uses tpointarrays just because i think theyre cool :p
it helps it click more in the middle of the road than edge
(for now) i wrote 3 functions: roadwalk2, march, and roadwalkintersection
roadwalk2 just walks one click (about 40 pixels) in the direction
march walks until the end of the road in the direction and
roadwalkintersection walks in the direction until an intersection leading in another direction
i suppose i could write functions with color/bitmap/dtm searching if you guys wanted
let me know what you think :)
function averagetpointarray(tpoints:tpointarray):tpoint;
var
i:integer;
begin
for i:= 0 to getarraylength(tpoints)-1 do
begin
result.x:=result.x+tpoints[i].x;
result.y:=result.y+tpoints[i].y;
end;
result.x:=result.x/getarraylength(tpoints);
result.y:=result.y/getarraylength(tpoints);
end;
procedure minimapsection(direction:string; var x1,y1,x2,y2:integer);
begin
x1:=570;
y1:=5;
x2:=725;
y2:=165;
case lowercase(direction) of
'east': x1:=688;
'south': y1:=118;
'west': x2:=608;
'north': y2:=38;
else begin
writeln('invalid direction: '+direction);
terminatescript;
end;
end;
end;
function clickroad(x1,y1,x2,y2:integer):boolean;
var
points:tpointarray;
spot:tpoint;
begin
findcolorstolerance(points,roadcolor,x1,y1,x2,y2,0);
if(getarraylength(points)>0)then
begin
spot:=averagetpointarray(points);
mouse(spot.x,spot.y,1,1,true);
wait(250+random(100));
flag;
result:=true;
end else
result:=false;
end;
function roadwalk2(direction:string):boolean;
var
x1,y1,x2,y2:integer;
begin
minimapsection(direction,x1,y1,x2,y2);
if(clickroad(x1,y1,x2,y2))then
result:=true
else
begin
writeln('no road leading '+direction);
result:=false;
end;
end;
procedure march(direction:string);
var
x1,y1,x2,y2:integer;
begin
minimapsection(direction,x1,y1,x2,y2);
repeat
wait(500+random(250))
until(not(clickroad(x1,y1,x2,y2)));
writeln('road leading '+direction+' ended');
end;
function roadwalkintersection(direction, intersection:string):boolean;
var
x1,y1,x2,y2:integer;
x3,y3,x4,y4:integer;
begin
minimapsection(direction,x1,y1,x2,y2);
minimapsection(intersection,x3,y3,x4,y4);
while(clickroad(x1,y1,x2,y2)) do
begin
if(clickroad(x3,y3,x4,y4))then
begin
writeln('found road leading off '+intersection);
result:=true;
exit;
end;
end;
writeln('road leading '+direction+' ended without finding intersection going '+intersection);
result:=false;
end;it uses tpointarrays just because i think theyre cool :p
it helps it click more in the middle of the road than edge
(for now) i wrote 3 functions: roadwalk2, march, and roadwalkintersection
roadwalk2 just walks one click (about 40 pixels) in the direction
march walks until the end of the road in the direction and
roadwalkintersection walks in the direction until an intersection leading in another direction
i suppose i could write functions with color/bitmap/dtm searching if you guys wanted
let me know what you think :)