SCAR Code:
{*******************************************************************************
function FindCoins(var X, Y: Integer; Area: string): Boolean;
By: ZephyrsFury
Description: Finds coins in Area and stores the coords in x and y.
*******************************************************************************}
function FindCoins(var X, Y: Integer; Area: string): Boolean;
var
B: TBox;
CTS, I, J, H, L: Integer;
Pts, tPts: TPointArray;
ATPA: T2DPointArray;
V: array [0..1] of TVariantArray;
begin
case Lowercase(Area) of
'inv', 'inventory': B := IntToBox(MIX1, MIY1, MIX2, MIY2);
'bank': B := IntToBox(MBx1, MBy1, MBx2, MBy2);
'trade': B := IntToBox(323, 73, 509, 302);
'your trade': B := IntToBox(9, 73, 196, 302);
end;
V[0] := [1606307, 4, 0.09, 1.32]; //Darker colour (top of coins)
V[1] := [2209251, 8, 0.04, 1.08]; //Lighter colour (rest of the coins)
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetLength(tPts, 0);
try
for I := 0 to 1 do
begin
SetColorSpeed2Modifiers(V[I][2], V[I][3]);
FindColorsTolerance(Pts, V[I][0], B.X1, B.Y1, B.X2, B.Y2, V[I][1]);
if (Length(Pts) < 10) then Exit;
ATPA := SplitTPAEx(Pts, 10, 10);
h := High(ATPA);
L := High(tPts) + 1;
SetLength(tPts, L + h + 1);
for J := 0 to H do
tPts[L + j] := MiddleTPA(ATPA[J]);
end;
ATPA := SplitTPAEx(tPts, 20, 20);
H := High(ATPA);
for I := 0 to H do
if (High(ATPA[I]) = 1) then
Break;
if (I > H) then Exit;
Result := True;
MiddleTPAEx(ATPA[I], X, Y);
finally
ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
end;