SCAR Code:
Function SpySkillObj(Var Ox, Oy: Integer; ObjColors: TIntegerArray; Width,
Height, E: Integer): Boolean;
SCAR Code:
//*------------------------------------------*\\
//*-------- Bwuahahahaa, ITS ALIVE! ---------*\\
//*------------------------------------------*\\
Function SpySkillObj(Var Ox, Oy: Integer; ObjColors: TIntegerArray; Width,
Height, E: Integer): Boolean;
Var
HSL: Array of Array of Extended;
C, Le, I, Color, X: Integer;
TPA, TPA2: TPointArray;
Time, CTS: Integer;
Semi: Extended;
PerC: Integer;
TB: TBox;
TP: TPoint;
H, S, L: Extended;
Colors: TIntegerArray;
Begin
If Not LoggedIn Then Exit;
Time := GetSystemTime; // Saves current time in ms to Time
CTS := GetColorToleranceSpeed; // Saves current CTS to CTS
If Not GetArrayLength(ObjColors) = 0 Then
Begin
If GetArrayLength(ObjColors) Mod 2 = 0 Then
// ^^ If hard to explain, try the mod a lil so you know, like 8 mod 2 etc..
Begin
Le := GetArrayLength(ObjColors) - 1;
Writeln('Color array length was even...');
End Else
Begin
Le := GetArrayLength(ObjColors) - 2;
Writeln('Color array length was odd...');
End;
Color := ObjColors[0]; // for "default"
Try
// below calculates the middle of two colors.
For I := 0 To Le Do
Begin
Colors := [Color, ObjColors[i + 1]];
SetArrayLength(HSL, 2);
SetArrayLength(HSL[0], 3);
SetArrayLength(HSL[1], 3);
For C := 0 To 1 Do
Begin
ColorToHSL(Colors[c], HSL[c][0], HSL[c][1], HSL[c][2]);
End;
H := HSL[1][0] - ((HSL[1][0] - HSL[0][0])/4);
S := HSL[1][1] - ((HSL[1][1] - HSL[0][1])/4);
L := HSL[1][2] - ((HSL[1][2] - HSL[0][2])/2);
Color := HSLToColor(H, S, L);
End;
Except
Writeln('Could not use crazy professor formula');
End;
End Else
Begin
Color := ObjColors[0];
End;
ColorToleranceSpeed(1); // Uses RGB for color comparison
FindColorsSpiralTolerance(MSCX, MSCY, TPA, Color, 20, 20, MSX2 - 20, MSY2 - 20, 5);
TPA := ReArrangeAndShortenArrayEx(TPA, Width, Height);
// Rearranges and shortens TPA so that there is only one point per "square"
// - the Round(wi....)
Le := GetArrayLength(TPA) - 1;
For X := 0 To Le Do
Begin
TP := TPA[x];
TB.x1 := TP.x - Round(Width / 2);
TB.y1 := TP.y - Round(Height / 2);
TB.x2 := TP.x + Round(Width / 2);
TB.y2 := TP.y + Round(Height / 2);
FindColorsSpiralTolerance(TP.x, TP.x, TPA2, Color, TB.x1, TB.y1, TB.x2, TB.y2, 10);
// Now we calculate percent of the color in the box
Semi := GetArrayLength(TPA2) / (Width * Height);
PerC := Round(Semi * 100);
If PerC > E Then
// ^^ Checks if the colors percent in box is greater than E
Begin
// Then we take middle of the TPA2 and save it to Ox and Oy, result true.
If MiddleTPAEx(TPA2, Ox, Oy) Then
Begin
Result := True;
Break;
End;
End;
End;
ColorToleranceSpeed(CTS); // Sets color comparison back to original
Writeln('Finding took: '+IntToStr(GetSystemTime - Time));
End;