SCAR Code:
Function FindTreeColor: Integer;
var
TPA, TestTPA: TPointArray;
ATPA: T2DPointArray;
H, S, L: Extended;
i, TestColor, R, G, B, AL, BlackListCol: Integer;
begin
Result := -1;
BlackListCol := -1;
if FindMMColorsSpiralTolerance(TPA, 1528609, 70) then
begin
AL := high(TPA);
For i := 0 to AL do
begin
TestColor := GetColor(TPA[i].x, TPA[i].y);
if TestColor <> BlackListCol then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
if InRange(R - B, 4, 50) then
if InRange(R - G, -65, -30) then
if InRange(G - B, 50, 87) then
if L < 28 then
if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
begin
FindColorsSpiralTolerance(mmcx, mmcy, TestTPA, TestColor, mmx1, mmy1, mmx2, mmy2, 0);
if Length(TestTPA) > 0 then
begin
ATPA := TPAtoATPAEx(TestTPA, 11, 10);
SortATPAFrom(ATPA, Point(mmcx, mmcy));
if not InRange(Length(ATPA[0]), 21, 28) then
if Length(ATPA[0]) < 30 then
begin
srl_Warn('FindTreeColor', 'TreeColor = ' + IntToStr(TestColor), warn_Debug);
Result := TestColor;
exit;
end else
begin
ColorToHSL(TestColor, H, S, L);
if L > 24 then
BlackListCol := TestColor;
end;
end;
end;
end;
end;
end;
srl_Warn('FindTreeColor', 'Could''t find TreeColor', warn_Debug);
Result := -1;
end;
- EvilChicken Style :p
SCAR Code:
Function FindTreeColor: Integer;
var
TPA, TestTPA: TPointArray;
ATPA: T2DPointArray;
H, S, L: Extended;
i, TestColor, GC, R, G, B, AL, BlackListCol: Integer;
begin
GC := 1528609;
BlackListCol := -1;
FindColorsSpiralTolerance(mmcx, mmcy, TPA, GC, mmx1, mmy1, mmx2, mmy2, 70);
If Length(TPA) < 1 then
begin
writeln('Couldn''t find tree color!');
Result := -1;
exit;
end;
FilterPointsPie(TPA, 0, 360, 0, 72, MMCX, MMCY);
//DebugTPA(TPA, '');
AL := GetArrayLength(TPA);
For i := 0 to AL - 1 do
begin
If RS_OnMiniMap(TPA[i].x, TPA[i].y) then
begin
TestColor := GetColor(TPA[i].x, TPA[i].y);
if TestColor <> BlackListCol then
begin
ColorToRGB(TestColor, R, G, B);
ColorToHSL(TestColor, H, S, L);
if InRange(R - B, 4, 50) then
if InRange(R - G, -65, -30) then
if InRange(G - B, 50, 87) then
if L < 28 then
if GetColor(TPA[i].x - 1, TPA[i].y) = TestColor then
if GetColor(TPA[i].x, TPA[i].y + 1) = TestColor then
if GetColor(TPA[i].x, TPA[i].y - 1) = TestColor then
begin
FindColorsSpiralTolerance(mmcx, mmcy, TestTPA, TestColor, mmx1, mmy1, mmx2, mmy2, 0);
if Length(TestTPA) > 0 then
begin
ATPA := TPAtoATPAEx(TestTPA, 11, 10);
SortATPAFrom(ATPA, Point(mmcx, mmcy));
if not InRange(Length(ATPA[0]), 21, 28) then
if Length(ATPA[0]) < 30 then
begin
writeln('Tree colour = '+ Inttostr(TestColor));
Result := TestColor;
exit;
end else
begin
ColorToHSL(TestColor, H, S, L);
if L > 24 then
BlackListCol := TestColor;
end;
end;
end;
end;
end;
end;
writeln('Couldn''t find tree color!');
Result := -1;
end;
- Original