SCAR Code:
{------------------------------------------------------------------------------]
[ function FastFindLadderColor: Integer; ]
[ by: Nielsie95 ]
[ Description: Returns the current color of the ladder. ]
{------------------------------------------------------------------------------}
function FastFindLadderColor: Integer;
var
i, c, n, bmp, Handle, cts:Integer;
p: TPointArray;
ca: TIntegerArray;
pa: T2DPointArray;
W, H, S, L: Extended;
begin
if (not LoggedIn) then Exit;
bmp := BitmapFromString(MMX2 - MMX1, MMY2 - MMY1, '');
CopyClientToBitmap(bmp, MMX1, MMY1, MMX2, MMY2);
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
Handle := GetClientWindowHandle;
SetTargetBitmap(bmp);
FindColorsSpiralTolerance(MMCX - MMX1, MMCY - MMY1, p, 79973, 0, 0, MMX2 - MMX1, MMY2 - MMY1, 55);
pa := SplitTPAEx(p, 2, 2);
n := Length(pa) -1;
SortATPAFromSize(pa, 32, True);
for i := 0 to n do
if (Length(pa[i]) > 15) and (Length(pa[i]) < 42) then
begin
c := FastGetPixel(bmp, pa[i][0].x, pa[i][0].y);
//WriteLn(IntToStr(c)+' '+IntToStr(Length(pa[i])));
ColorToHSL(c, H, S, L);
if (H < 11.0) and (H > 4.5) then
if (L < 30.0) and (L > 10.0) then
begin
ca := GetColors(pa[i]);
ClearSameIntegers(ca);
if (Length(ca) = 1) then
begin
p := ReArrangeTPA(pa[i], 0, Length(pa[i]), True, True);
w := Abs(p[0].x - p[Length(p) -2].x);
p := ReArrangeTPA(pa[i], 0, Length(pa[i]), False, True);
h := Abs(p[0].y - p[Length(p) -2].y);
WriteLn('Color: '+IntToStr(c)+'w: '+FloatToStr(w)+' h: '+ FloatToStr(h));
WriteLn('ratio: '+FloatToStr(MaxE(w, h) div MinE(w, h)));
if (MaxE(w, h) div MinE(w, h) >= 1.12) and (MaxE(w, h) div MinE(w, h) <= 1.8) then
begin
Result := c;
Break;
end;
end;
end;
end;
SetLength(p, 0);
SetLength(pa, 0);
SetClientWindowHandle(Handle);
FreeBitmap(bmp);
ColorToleranceSpeed(cts);
end;
{------------------------------------------------------------------------------]
[ procedure ToRange; ]
[ by: Itschris917 ]
[ Description: Walks to the range. ]
{------------------------------------------------------------------------------}
procedure ToRange;
var
rx, ry: Integer;
begin
if not LoggedIn then Exit;
MakeCompass('N');
DoomDebug('Going to Range.');
if (Random(25) <= 12) then
begin
Writeln('Used ladder');
if FindColorSpiralTolerance(rx, ry, FastFindLadderColor, MMX1, MMCY, MMX2, MMY2, 0) then
begin
Mouse(rx - 15, ry - 10, 2, 2, True);
while FlagPresent do
Randoms;
WeAreAtRange;
Exit;
end;
end else
begin
Writeln('Going outside of door first.');
if RadialRoadWalk(AutoColorDirtRoad, 235, 208, 49, -2, -2) then
begin
Writeln('Used RRW because FirstTime = False');
while FlagPresent do
Randoms;
WeAreAtRange;
OpenDoor('outside');
Exit;
end;
end;