SCAR Code:
program New;
{.include SRL/SRL.scar}
var
x: Array[0..2] of Integer;
function ColorCheck(Color: Integer; Smart: Boolean): Boolean;
var
Dots, W, H, x, y : Integer;
begin
Dots := BitmapFromString(17, 15, 'beNpjYPgPAwxEA2pp+W9' +
'm9o+HB1nkHxjgNASoXkHhDxvbS1T1QPDmzRusWoDmA9V/ZGA4h6oF' +
'qP7SpUs47GG8ycCwB8yAizx69Ojo0aNIIlh0Ycgy4lVPMmDn5mOgG' +
'fj3T/jfPz6S1P/5w/T1K8Pdu8RqAaoHordvGc6cId4eRqD5YPUkhS' +
'RxIQ8AaQdf5g==');
GetBitmapSize(Dots, W, H);
SetTargetBitmap(Dots);
if(FindColorTolerance(x, y, Color, 0, 0, W, H, 10)or(Color=65536)or(Color=0))then Result:=False
else Result:=True;
FreeBitmap(Dots);
if(Smart)then SetTargetDC(SmartGetDC)
else ResetDC;
end;
function FindGoodPoint(x1, y1, x2, y2, PtNum: Integer; UsedCoords: TPointArray; Smart: Boolean; var Color: Integer):TPoint; //finds good coords, duh!
var
y, x, a: Integer;
begin
for y:=y1 to y2 do
for x:=x1 to x2 do
begin
Result.x:=x;
Result.y:=y;
Color:=GetColor(x, y);
if(ColorCheck(Color, SMART))then
for a:=0 to PtNum-1 do
if(UsedCoords[a].x<>x)and(UsedCoords[a].y<>y)then Exit;
end;
Result.x:=-1;
Result.y:=-1;
end;
{*******************************************************************************
function CheckMovement(MinPoints, MaxPoints: Integer): Integer;
By: Macrosoft
Description: NumberOfPoints is the amount of referance points
you would like the function the use. The higher
this is set, the more accurate, but also the
more slow.
For Result[0]:
Returns 0 if stuck.
Returns 1 if not moving.
Returns 2 if moving.
For Result[1]:
Returns the number of points used.
Returns 0 if not enough points were able to be made.
*******************************************************************************}
function CheckMovement(MinPoints, MaxPoints: Integer; SMART: Boolean): array of Integer;
var
RPoint: array of Tpoint;
RColor: array of Integer;
S, NColor, a, PtsUsed: Integer;
begin
SetArrayLength(Result, 2);
SetArrayLength(RPoint, MaxPoints);
SetArrayLength(RColor, MaxPoints);
for a:=0 to MaxPoints-1 do
begin
RPoint[a]:=FindGoodPoint(570, 33, 683, 135, a, RPoint, SMART, RColor[a]);
if(RPoint[a].x=-1)then Break;
end;
if(a+1<MinPoints)then
begin
WriteLn('Not enough points were found');
Result[1]:=0;
Exit;
end;
SetArrayLength(RPoint, a+1);
SetArrayLength(RColor, a+1);
SetArrayLength(NColor, a+1);
Wait(300);
PtsUsed:=a;
for a:=0 to PtsUsed do
begin
NColor:=GetColor(RPoint[a].x, RPoint[a].y);
if(not(NColor=RColor[a]))then
begin
if(ColorCheck(NColor, SMART))then
begin
Result[0]:=2;
WriteLn('We are moving!');
Result[1]:=PtsUsed+1;
WriteLn(IntToStr(PtsUsed)+' points used');
Exit;
end;
end else
begin
if(S=15)then s:=0 else
begin
Wait(150);
a:=a-1;
S:=S+1;
end;
end;
end;
if(FlagPresent)then
begin
WriteLn('We are stuck');
Result[0]:=0;
end else
begin
WriteLn('We have stopped!');
Result[0]:=1;
end;
Result[1]:=PtsUsed+1;
WriteLn(IntToStr(PtsUsed)+' points used');
end;
{*******************************************************************************
function WaitForStop(SMART: Boolean): Integer;
By: Macrosoft
Description: Waits until the character stops moving.
NumOfPts is the amount of referance points
you would like the function the use. The higher
this is set, the more accurate, but also the
more slow.
Returns 1 if you are caught on something and the flag
remains while you are still
Returns 2 if stopped.
*******************************************************************************}
function WaitForStop(MinPts, MaxPts: Integer; Smart: Boolean): Integer;
var
Strikes, SStrk: Integer;
i: array of Integer;
begin
SStrk:=0;
Strikes:=0;
SetArrayLength(i, 2);
repeat
begin
i:=CheckMovement(MinPts, MaxPts, Smart);
if(i[1]=0)then
begin
WriteLn('Error with CheckMovement');
Result:=0;
end;
if(i[0]=1)then Strikes:=Strikes+1 else Strikes:=0;
if(i[0]=0)then SStrk:=SStrk+1 else SStrk:=0;
end;
until(Strikes=2)or(SStrk=2);
if(SStrk=2)then
begin
Writeln('You are caught on something!');
Result:=1;
Exit;
end;
Writeln('Walked to destination!');
Result:=2;
end;
begin
SetupSRL;
ActivateClient;
CheckMovement(2, 4, False);
end.