SRL Archive - Test corner

FindLadderColor;


_ChArMz

2007-06-08 14:32:40

program New;

function FindLadderColor : Integer;
var
tPoints, Points : TPointArray;
tColors : TIntegerArray;
i, c : Integer;
Hue, Saturation, Luminance : Extended;
begin
Result := 0;
FindColorsTolerance(tPoints, 10837, MMX1, MMY1, MMX2, MMY2, 50);
for i := 0 to GetArrayLength(tPoints) - 1 do
if rs_OnMiniMap(tPoints[i].x, tPoints[i].y) then
begin
c := c + 1;
SetArrayLength(Points, c + 1);
Points[c] := tPoints[i];
end
tColors := GetColors(Points);
for i := 0 to GetArrayLength(tColors) - 1 do
begin
ColorToHSL(tColors[i], Hue, Saturation, Luminance);
if (Hue > 5.5) and
(Hue < 10.5) and
(Saturation > 55.0) then
begin
if CountColor(tColors[i], Points[i].x - 5, Points[i].y - 5, Points[i].x + 5, Points[i].y + 5) > 15 then
begin
Result := tColors[i];
Break;
end
end
end
if Result > 0 then
WriteLn('LadderColor = '+IntToStr(Result))
else
WriteLn('Unable to find ladder color.');
end;

begin
ClearDebug;
FindLadderColor;
end.

FOR DIVI

Test Please, I Just Made This Real Fast :D

Wizzup?

2007-06-08 14:46:37

I love the code. :)
Can't test ATM, will later. :)

BTW: You might want to remove colors that are already found?

Function NumberDoesntExist(Ar2: Array Of Integer; Number: Integer): Boolean;

Var
I: Integer;
Begin
Result := False;
For I := 0 To GetArrayLength(Ar2) - 1 Do
If Ar2[I] = Number Then
Exit;
Result := True;
End;

Function ShrinkArray(YourArray: Array Of Integer): Array Of Integer;

Var
I: Integer;

Begin
SetArrayLength(Result, 0);
For I := 0 To GetArrayLength(YourArray) - 1 Do
Begin
If NumberDoesntExist(Result, YourArray[I]) Then
Begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[GetArrayLength(Result) - 1] := YourArray[I];
End;
End;
End;

Boreas

2007-06-08 14:54:15

Works, and fast too. Lumby, varry, fally, draynor, port sarim. First and second login (its stable anyway). Nice job!

_ChArMz

2007-06-08 16:43:08

Cool Functions Wizzup, I Will Add Them Later

Thank You For Testing Boreas :P

me_ntal

2007-06-10 04:47:33

Wow, *pinch*