SCAR Code:
program SpaceInvaders;
Procedure Mouse(x, y: Integer; click, left: Boolean);
var i: Integer;
begin
movemousesmooth(x, y);
wait(30);
if not click then
exit;
getmousepos(x, y);
holdmouse(x, y, left);
for i := 0 to 3 do
wait(20+random(10));
getmousepos(x, y);
ReleaseMouse(x, y, left);
end;
Function InHomeScreen: Boolean;
begin
result := CountColor(255, 180, 222, 224, 244) = 256;
end;
Procedure StartGame;
var
x, y: Integer;
begin
wait(100);
if InHomeScreen then
begin
mouse(250, 284, false, false);
wait(200);
if not CountColor(65331, 136, 272, 359, 292) > 100 then
begin
getmousePos(x, y);
mouse(x, y, true, true);
wait(100);
end;
mouse(250, 284, true, true);
end;
end;
Function ProjectileInRange: Boolean;
var TPA: TPointArray;
begin
If InHomeScreen then exit;
Result := FindColorsTolerance(TPA, 16777215, 0, 246, 500, 283, 0);
end;
Function GetMyPos: TPoint;
var
TPA: TPointArray;
begin
If InHomeScreen then exit;
if FindColorstolerance(TPA, 65331, 0, 335, 500, 375, 0) then
middleTPAEX(TPA, Result.x, Result.y);
end;
Function NearestCover: TPoint;
var
TPA: TPointArray;
ATPA: Array of Array of TPoint;
i, x, y, LowestDistance, Mark: Integer;
Distances: TIntegerArray;
MyPos: TPoint;
begin
If InHomeScreen then exit;
MyPos := GetMyPos;
FindColorsTolerance(TPA, 65331, 61, 285, 440, 332, 0);
ATPA := TPAtoATPAEx(TPA, 110 - 61, 322 - 285);
For i := 0 to high(ATPA) do
begin
if Length(ATPA[i]) > 200 then
begin
middleTPAEx(ATPA[i], x, y);
SetArrayLength(Distances, Length(Distances) + 1);
Distances[i] := Distance(MyPos.x, MyPos.y, x, y);
end;
end;
LowestDistance := distances[0];
For i := 0 to high(Distances) do
if Distances[i] < LowestDistance then
LowestDistance := Distances[i];
For i := 0 to high(Distances) do
if Distances[i] = LowestDistance then
middleTPAEx(ATPA[i], Result.x, Result.y);
end;
Procedure MoveToNearest;
var
Nearest, MyPos: TPoint;
Keyz: Byte;
begin
Nearest := NearestCover;
MyPos := GetMyPos;
If Nearest.x > MyPos.x then
keyz := VK_Right
else
keyz := VK_Left;
KeyDown(keyz);
repeat
wait(50);
MyPos := GetMyPos;
until MyPos.x = NearestCover.x;
KeyUp(keyz);
end;
var
Point: TPoint;
begin
//ActivateClient;
MoveToNearest;
end.