SCAR Code:
function AutoColorThings(What: String): Integer;
var
i, Red, Green, Blue, GoodColor, TestColor: Integer;
RMG, RMB, GMB: Integer;
P: array of TPoint;
R: array of Integer;
begin
case Lowercase(What) of
'dirt':
begin
GoodColor := 1388628;
R := [57, 100, 14, 43, 21, 50];
end;
'stone':
begin
GoodColor := 4211519;
R := [0, 20, 0, 20, 0, 20];
end;
'bstone':
begin
GoodColor := 3756678;
R := [57, 106, 43, 69, 18, 73];
end;
end;
FFlag(0);
FindColorsSpiralTolerance(MMCX, MMCY, P, GoodColor, MMX1, MMY1, MMX2, MMY2, 50);
for i := 0 to High(P) do
begin
if rs_OnMiniMap(P[i].x, P[i].y) then
begin
TestColor := GetColor(P[i].x, P[i].y);
ColorToRGB(TestColor, Red, Green, Blue);
RMB := Red - Blue;
RMG := Red - Green;
GMB := Green - Blue;
if (RMB < 0) then
RMB := (RMB * RMB) - RMB;
if (RMG < 0) then
RMG := (RMG * RMG) - RMG;
if (GMB < 0) then
GMB := (GMB * GMB) - GMB;
if InRange(RMB, R[0], R[1]) then
if InRange(RMG, R[2], R[3]) then
if InRange(GMB, R[4], R[5]) then
if GetColor(P[i].x + 1, P[i].y + 1) = TestColor then
if GetColor(P[i].x, P[i].y + 2) = TestColor then
if GetColor(P[i].x + 2, P[i].y) = TestColor then
if GetColor(P[i].x, P[i].y + 1) = TestColor then
if GetColor(P[i].x + 1, P[i].y) = TestColor then
if GetColor(P[i].x + 2, P[i].y + 1) = TestColor then
if GetColor(P[i].x + 1, P[i].y + 2) = TestColor then
begin
Result := TestColor;
Writeln('Found color: ' + IntToStr(TestColor));
Exit;
end;
end;
end;
Result := 0;
Writeln('Could not autocolor ' + What);
end;