n3ss3s
10-18-2007, 08:02 AM
Yeh, Im trying to do lil mage tower demon caster as a side project, but its not very interesting so I thought I just release the finder...
I left the function that got me the good color instead of just putting the color there if someone wants to find out how to get very good middle of light and dark ;)
Umm finding the demon takes 78 milliseconds (time of one FindColors), so use this baby with health and care ;)
Function GetRed: Integer; // Very useful for getting middle of light and dark
Var
HSL: Array of Array of Extended;
Var
H, S, L: Extended;
Var
Colors: TIntegerArray;
Var
C: Integer;
Begin
Colors := [3162500, 5700];
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);
Result := HSLToColor(H, S, L);
End;
Function FindLDemon(Var GDX, GDY: Integer): Boolean;
Var
X, Y, I, C, CTS, D: Integer;
Var
TPA: TPointArray;
Begin
If(Not(LoggedIn))Then Exit;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
D := GetRed;
FindColorsTolerance(TPA, D, MSX1, MSY1, MSX2, MSY2, 20);
MiddleTPAEx(TPA, X, Y);
FindColorsTolerance(TPA, D, X - 20, Y - 20, X + 20, Y + 20, 15);
If(GetArrayLength(TPA) >= 20)Then
Begin
MiddleTPAEx(TPA, GDX, GDY);
Result := True;
End Else
Begin
GDX := 0;
GDY := 0;
End;
ColorToleranceSpeed(CTS);
End;
End;
Enjoy!
You may use these but only if you credit me ;)
I left the function that got me the good color instead of just putting the color there if someone wants to find out how to get very good middle of light and dark ;)
Umm finding the demon takes 78 milliseconds (time of one FindColors), so use this baby with health and care ;)
Function GetRed: Integer; // Very useful for getting middle of light and dark
Var
HSL: Array of Array of Extended;
Var
H, S, L: Extended;
Var
Colors: TIntegerArray;
Var
C: Integer;
Begin
Colors := [3162500, 5700];
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);
Result := HSLToColor(H, S, L);
End;
Function FindLDemon(Var GDX, GDY: Integer): Boolean;
Var
X, Y, I, C, CTS, D: Integer;
Var
TPA: TPointArray;
Begin
If(Not(LoggedIn))Then Exit;
Begin
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
D := GetRed;
FindColorsTolerance(TPA, D, MSX1, MSY1, MSX2, MSY2, 20);
MiddleTPAEx(TPA, X, Y);
FindColorsTolerance(TPA, D, X - 20, Y - 20, X + 20, Y + 20, 15);
If(GetArrayLength(TPA) >= 20)Then
Begin
MiddleTPAEx(TPA, GDX, GDY);
Result := True;
End Else
Begin
GDX := 0;
GDY := 0;
End;
ColorToleranceSpeed(CTS);
End;
End;
Enjoy!
You may use these but only if you credit me ;)