SCAR Code:
program New;
{.include SRL/SRL.scar}
var
x, y, DTM: Integer;
function Loading: Boolean;
var
Load, x, y: integer;
begin
Load := BitmapFromString(29, 3, 'beNr7/x8CGFABsiCagv+oAJ' +
'd6kowlnk0TYwEHnoCA');
if FindBitmap(Load, x, y) then Result:=True else Result:=False;
FreeBitmap(Load);
end;
function OpenMap: Boolean;
var
a: Integer;
begin
Mouse(530, 130, 20, 20, true);
a:=0;
Wait(1000);
repeat
Wait(1500+Random(1000));
a:=a+1;
until(not(Loading))or(a=15);
if(a>14)then
begin
WriteLn('Error: Could not open map: Loading for too long');
Result:=False;
Exit;
end;
Result:=True;
end;
procedure CloseMap;
begin
Mouse(740, 10, 15, 15, True);
Wait(2000 + Random(1000));
end;
function FindAngle(L, D: Tpoint):Extended;
var
TrigAngle: Integer;
begin
if(L.x=D.x)then //if must go perfect n or s
begin
if(L.y>D.y)then //if go p north
begin
Result:=0;
Exit;
end else //if go p south
begin
Result:=180;
Exit;
end;
end;
if(L.y=D.y)then //if must go perfect e or w
begin
if(L.x>D.x)then //if go p west
begin
Result:=270;
Exit;
end else //if go p east
begin
Result:=90;
Exit;
end;
end;
TrigAngle:=Round(Degrees(ArcTan(Abs(D.y-L.y)/Abs(D.x-L.x))));
if(L.y>D.y)then //if need go north (destination higher than location
begin
if(L.x<D.x)then Result:=90-TrigAngle; //If need go NorthEast
if(L.x>D.x)then Result:=270+TrigAngle; //if need go NorthWest
end;
if(L.y<D.y)then //if need go south
begin
if(L.x<D.x)then Result:=90+TrigAngle; //if need go SouthEast
if(L.x>D.x)then Result:=270-TrigAngle; //If need southwest
end;
end;
function ChangeZoom(CurrentZoom, Zoom: Integer): Boolean;
var
ColCheck: array[0..1] of integer;
begin
if(CurrentZoom=Zoom)then Exit;
ColCheck[0]:=GetColor(565, 342);
ColCheck[1]:=GetColor(565, 373);
Mouse(562, 472, 27, 17, True);
Wait(100 + Random(100));
if(ColCheck[0]=GetColor(565, 342))and(ColCheck[1]=GetColor(565, 373))then
begin
Result:=False;
Exit;
end;
case(Zoom)of
37: Mouse(562, 340, 27, 17, True);
50: Mouse(562, 371, 27, 17, True);
75: Mouse(562, 402, 27, 17, True);
100: Mouse(562, 433, 27, 17, True);
end;
Mouse(562, 472, 27, 17, True);
Result:=True;
end;
function FindBRCorner(x, y: integer): Tpoint;
var
EdgeCol: integer;
begin
EdgeCol:=GetColor(x, y);
repeat
begin
x:=x+1;
end;
until(not(GetColor(x+1, y)=EdgeCol));
repeat
begin
y:=y+1;
end;
until(not(GetColor(x, y+1)=EdgeCol));
Result.x:=x;
Result.y:=y;
end;
function MoveMap(x, y: integer): boolean;
var
Cx, Cy, x1, y1, x2, y2: Integer;
BR, Change: Tpoint;
begin
Mouse(670, 470, 27, 17, True);
Wait(400 + Random(100));
if(not(FindColorTolerance(x2, y2, 255, 605, 310, 760, 460, 5)))then
begin
Result:=False;
Exit;
end;
BR:=FindBRCorner(x2, y2);
Change.x:=x-x2;
Change.y:=y-y2;
Cx:=(BR.x-x2)/4;
Cy:=(BR.y-y2)/4;
MMouse(x2+Cx, y2+Cy, 2*Cx, 2*Cy);
GetMousePos(x1, y1);
HoldMouse(x1, y1, True);
GetMousePos(x1, y1);
x2:=x1+Change.x-5+Random(10);
y2:=y1+Change.y-5+Random(10);
MMouse(x2, y2, 10, 10);
Wait(100+Random(100));
GetMousePos(x1, y1);
ReleaseMouse(x1, y1, True);
Result:=True;
end;
procedure AngleWalk(Degrees, Radius: Integer);
var
x1, y1, Quad, Angle, x, y: Integer;
begin
Angle:=Round(rs_GetCompassAngleDegrees+Degrees);
if(Angle>=360)then Angle:=Angle-360;
if(Angle<0)then Angle:=Angle+360;
case Angle of
0..90: Quad:=1;
91..179: Quad:=2;
180..270: Quad:=3;
271..359: Quad:=4;
end;
y:= Round((cos(Radians(Angle))) * Radius);
x:= Round((sin(Radians(Angle))) * Radius);
case Quad of
1:
begin
y1:=MMCY-y
x1:=MMCX+x
end;
2:
begin
y1:=MMCY+x
x1:=MMCX+y
end;
3:
begin
y1:=MMCY+y
x1:=MMCX-x
end;
4:
begin
y1:=MMCY-x
x1:=MMCX-y
end;
end;
MouseFlag(x, y, 0, 0);
end;
function WorldMAPWalk(DestinationDTM: Integer; MLx, MLy: Integer): Boolean;
var
RDis, Trav, TDis, Dis, Angle, x, y, a: integer;
MC, Loc, Des: Tpoint;
Check, Stop: Boolean;
begin
MC.x:=MSX2/2;
MC.y:=MSY2/2;
for a:=0 to 5 do
begin
if(DTMRotated(DestinationDTM, x, y, MMX1, MMY1, MMX2, MMY2))then
begin
MakeCompass('n');
MouseFlag(x, y, 10, 10);
WriteLn('Arrived at destination');
Result:=True;
Exit;
end;
Wait(500);
end;
repeat
begin
if(not(OpenMap))then
begin
Result:=False;
Exit;
end;
Check:=False;
if(DTMRotated(DestinationDTM, x, y, 0, 0, 764, 502))then
begin
Des.x:=x;
Des.y:=y;
Angle:=Round(FindAngle(MC, Des));
Dis:=Distance(MC.x, MC.y, Des.x, Des.y);
Check:=True;
CloseMap;
end else
begin
Mouse(670, 470, 27, 17, True);
Wait(400 + Random(100));
if(not(FindColorTolerance(x, y, 255, 605, 310, 760, 460, 5)))then
begin
Result:=False;
Exit;
end;
Loc.x:=x;
Loc.y:=y;
Des.x:=MLx;
Des.y:=MLy;
Dis:=(Distance(x, y, MLx, MLy)*455)/8;
Angle:=Round(FindAngle(Loc, Des));
MoveMap(MLx, MLy);
Wait(2000+Random(1000));//IdleTime(2000, 1000, 7);
CloseMap;
end;
WriteLn(Floattostr(Angle));
case Dis of
0..400: RDis:=Dis;
401..899: RDis:=Round(Dis/2+50)+Random(100);
900..1600: RDis:=Round((Dis/2)+Random(100));
else RDis:=800+Random(100);
end;
Trav:=0;
repeat
begin
case RDis-Trav of
(0-10)..10:Stop:=True;
0..75:
begin
TDis:=RDis-Trav;
AngleWalk(Angle-4+Random(8), TDis);
end;
76..120:
begin
TDis:=Round(((RDis-Trav)/2)-5+Random(10));
AngleWalk(Angle-4+Random(8), TDis);
end;
else
begin
TDis:=45+Random(30);
AngleWalk(Angle-5+Random(10), TDis);
end;
end;
Trav:=Trav+TDis;
end;
until(Stop);
if(Check)then
begin
MakeCompass('n');
for a:=0 to 5 do
begin
if(DTMRotated(DestinationDTM, x, y, MMX1, MMY1, MMX2, MMY2))then
begin
if(Distance(MMCX, MMCY, x, y)>20)then MouseFlag(x, y, 10, 10);
WriteLn('Arrived at destination');
Result:=True;
Exit;
end;
Wait(250+Random(500));
end;
Check:=False;
end;
end;
until(false);
end;
begin
SetupSRL;
ActivateClient;
DTM := DTMFromString('78DA639CCDC0C0B0950105E46426836946289' +
'F710690B886AAE6CC9933A86A3611A1662790388FAAC6D3551655' +
'CD5420B112BF3900E6A51026');
WorldMAPWalk(DTM, 698, 373);
end.