SRL Archive - Test corner

Road Walking


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:

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 :)

Avaphi

2006-06-18 18:40:10

I think its fantastic, Seeing as RRW is broken :eek: It seems these would work… really…really Good. :cool: Makes some more functions ! :D

Jagex_Fagex

2006-06-19 02:18:11

they look sweet, i also like walkers with a distance like AngleWalk. it helps if your just walking small distances

Wizzup?

2006-06-19 02:41:28

Very good indeed. :-)

Cheesehunk

2006-06-19 18:31:55

<3 Masquader, but RoadWalking works fine for me:
[PHP]Procedure WalkToStore;
var SX,SY: integer;
begin
if not LoggedIn then Exit;

MarkTime(Mark);
Players[CurrentPlayer].Loc:='To Store';
if CheeseDebug then writeln('Walking to store…');
RadialRoadWalk(RoadColor,20,90,45,0,1);
LinearRoadWalk(RoadColor,90,35,0,0);
repeat
if (not (Loggedin)) then break;
if(TimeFromMark(Mark)>120000) then begin Logout; Exit; end
RadialRoadWalk(RoadColor,410,335,45,0,0);
FindRandoms;
until FindColor(x,y,RockColor,625,20,720,80);

repeat
if (not (Loggedin)) then break;
if(TimeFromMark(Mark)>360000) then begin Logout; Exit; end;
RadialRoadWalk(RoadColor,120,45,47,0,-1);
FindRandoms;
until FindColor(x,y,WaterColor,660,10,720,80);

RadialRoadWalk(RoadColor,45,100,45,0,0);
repeat
if (not (Loggedin)) then break;
if(TimeFromMark(Mark)>420000) then begin Logout; Exit; end;
RadialRoadWalk(RoadColor,190,115,40,0,0);
FindRandoms;
until(FindColor(x,y,HouseColor,590,100,700,155));

if FindColor(SX,SY,HouseColor,590,100,700,155) then
begin
case (Random(2)+1) of
1: begin wait(250+random(250)) Mouse(SX,SY,10,10,true) end
2: begin wait(250+random(250)) ClickMMColor(HouseColor) end
end;
WWait(4000+random(2000));
FFlag(2+random(2));
OpenDoor;
end;
Players[CurrentPlayer].Loc:='Store';
if CheeseDebug then writeln('We are now at the store');

end;

//*************************************************************************//

Procedure WalkToDraynorBank;
var BX,BY:integer;

begin
if not LoggedIn then Exit;

MarkTime(Mark);
if CheeseDebug then writeln('Walking to bank…');
Players[CurrentPlayer].Loc:='To Bank';
OpenDoor;
RadialRoadWalk(RoadColor,0,45,45,-1,1);
repeat
if (not (Loggedin)) then break;
if(TimeFromMark(Mark)>120000) then begin Logout; Exit; end
RadialRoadWalk(RoadColor,390,320,40,-1,1);
FindRandoms;
until(FindColor(x,y,HouseColor,633,4,715,41));

repeat
if (not (Loggedin)) then break;
if(TimeFromMark(Mark)>240000) then begin Logout; Exit; end
RadialRoadWalk(RoadColor,250,330,45,0,0);
until(FindColor(x,y,RockColor,596,2,689,45));

repeat
if (not (Loggedin)) then break;
if(TimeFromMark(Mark)>240000) then begin Logout; Exit; end
RadialRoadWalk(RoadColor,240,320,45,0,0);
until(FindColor(x,y,RoadColor,594,113,689,162));

RadialRoadWalk(RoadColor,190,250,50,0,0);
repeat
if (not (Loggedin)) then break;
if(TimeFromMark(Mark)>240000) then begin Logout; Exit; end
RadialRoadWalk(RoadColor,160,240,40,1,1);
until (FindColor(BX,BY,BankColor,MMX1,MMY1,MMX2,MMY2) or FindColor(BX,BY,House2Color,576,22,608,90))


Mouse(BX+random(5),BY+random(2),3,3,true);
BoredWhileFlagExistsDist(5+random(2));
PerfectNorth;
Flag;
DTM3Flag(DB1,DB2,DB3,true);
PerfectNorth;
end;[/PHP]
:p

WT-Fakawi

2006-06-19 19:21:09

I vaguely get the feeling of dejavu :D

N1 Chuck. Good to see this :D

masquerader

2006-06-29 02:10:40

From: Cheesehunk
<3 Masquader, but RoadWalking works fine for me:

yeah, but i think the value in this is say… walking from falador to rimmington
i think you can do it in like 2 lines :p

roadwalkintersection('south, 'west');
roadwalkintersection('west', 'south');

the various march and intersecion things are handy for long distances along roads :)

cheesehunk, where is that code from?

edit: dude this sucks, its been 3 months and now i dont even remember what my own code does :p

Wizzup?

2006-06-29 02:17:44

From: masquerader
yeah, but i think the value in this is say… walking from falador to rimmington
i think you can do it in like 2 lines :p

roadwalkintersection('south, 'west');
roadwalkintersection('west', 'south');

the various march and intersecion things are handy for long distances along roads :)

cheesehunk, where is that code from?

edit: dude this sucks, its been 3 months and now i dont even remember what my own code does :p


Welcome back. :D

By The Way, your trade.scar rocks. :)

masquerader

2006-06-29 02:56:34

From: Wizzup?
Welcome back. :D

By The Way, your trade.scar rocks. :)

heh, why?
the only cool thing in there is checkitem (sweetest unused function ever)

Wizzup?

2006-06-29 03:07:50

From: masquerader
heh, why?
the only cool thing in there is checkitem (sweetest unused function ever)


:)

[php]// *************************** //

Function HandleTrade:Boolean;

Var
TradeMark : LongInt;

Begin

If AcceptTrade Or TradeScreen Then
Begin
Result := True;
Wait(1000+Random(501));
TraderName := GetTraderName;

ClickAllItemsBmpMaskTolWait('ffer', OreMask, 20, 25, 30+Random(30));
Wait(1000+Random(501));

Accept;
MarkTime(TradeMark)
While (Not PlayerAccepted) And (TimeFromMark(TradeMark) < 20000) Do Wait(1000+Random(501));
If TimeFromMark(TradeMark) > 20000 Then Decline;
Accept;
MarkTime(TradeMark)
While (TradeScreen2) And (TimeFromMark(TradeMark) < 20000) Do Wait(1000+Random(501));
If TimeFromMark(TradeMark) > 20000 Then Decline;
If TimeFromMark(TradeMark) < 20000 Then TypeSend('No Problem '+TraderName)
Else TypeSend('Nvm '+TraderName)
Trades := Trades +1;
CloseWindow;

End;
End;[/php]

I'm going to try to implent this into my powerminer, it needs testing though, it's based on your functions. :D