SCAR Code:
function FindWillow(var fx, fy: Integer): Boolean;
var
x, y: Integer;
TPA, xTPA: TPointArray;
ATPA: T2DPointArray;
I, H: Integer;
Colors: TIntegerArray;
begin
Result := False;
if not LoggedIn then Exit;
if Random(5) = 0 then
MakeCompass(IntToStr(RandomRange(180, 360)));
Colors := [4355164, 3297881]; // 9811876 6587509
ColorToleranceSpeed(3);
SetColorspeed3Modifiers(1);
for I := 0 to 1 do
begin
FindColorsTolerance(xTPA, Colors[I], MSX1, MSY1, MSX2, MSY2, 2);
//Wait(200);
//DebugTPA(TPA, IntToStr(I));
TPA := CombineTPA(xTPA, TPA);
end;
if High(TPA) = -1 then
Exit;
ATPA := SplitTPA(TPA, 10);
SortATPAFrom(ATPA, Point(MSCX, MSCY));
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
//DebugATPA(ATPA, 'WillowEx');
H := High(ATPA);
Debug('FindWillow: Found ' + IntToStr(H + 1) + ' possible Trees.');
for I := 0 to H do
begin
if High(TPA) <= 199 then Continue;
MiddleTPAEx(ATPA[I], x, y);
MMouse(x, y, 4, 4);
Wait(RandomRange(80, 150));
if IsUpText('illow') then
begin
Result := True;
GetMousePos(fx, fy);
Debug('FindWillow: Found Willow at ' + IntToStr(fx) + ', ' + IntToStr(fy));
Break;
end;
end;
ColorToleranceSpeed(2);
end;
function TrackWillow(fx, fy: Integer): TBox;
var
Pts: TPointArray;
sL: Integer;
begin
if not LoggedIn then Exit;
SetColorSpeed2Modifiers(0.38, 1.05);
FindColorsTolerance(Pts, 3035202, fx - 10, fy - 10, fx + 10, fy + 10, 12);
if Random(RandomRange(4, 7)) = 0 then
begin
Mouse(fx, fy, 0, 0, False);
Wait(80 + Random(50));
ChooseOption('hop');
end else
Mouse(fx, fy, 0, 0, True);
while IsMoving(150) and LoggedIn do
begin
Wait(10);
MiddleTPAEx(Pts, fx, fy);
FindColorsTolerance(Pts, 3035202, fx - 10, fy - 10, fx + 10, fy + 10, 12);
Inc(sL);
if sL mod 30 = 0 then Debug('TrackWillow: Willow Moved To ' + IntToStr(fx) + ', ' + IntToStr(fy));
end;
Wait(Random(30));
Result := GetTPABounds(Pts);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
function AreWeChopping: Boolean;
var
CoordsTPA: TPointArray;
Ints: TIntegerArray;
RInt, I, fx, fy: Integer;
begin
Result := False;
if not LoggedIn then Exit;
CoordsTPA := [Point(MSCX - 5, MSCY), Point(MSCX, MSCY - 5), Point(MSCX + 5, MSCY),
Point(MSCX, MSCY + 5), Point(MSCX, MSCY)];
Ints := GetColors(CoordsTPA);
Wait(100 + Random(50));
for I := 0 to 4 do
if FindColor(fx, fy, Ints[I], CoordsTPA[I].x - 2, CoordsTPA[I].y - 2, CoordsTPA[I].x + 2, CoordsTPA[I].y + 2) then
Inc(RInt);
Result := RInt < 5;
end;
function ChopTheTrees: Boolean;
var
x, y, C, TC: Integer;
Pts: TPointArray;
B: TBox;
iC, iCTime: Integer;
begin
Result := False;
if not LoggedIn then Exit;
Debug('ChopTheTrees');
SetAngle(True);
SetRun(False);
while (not InvFull) and LoggedIn do
begin
if not FindWillow(x, y) then
begin
Debug('Could not find tree to chop.');
Inc(TC);
if TC < 3 then
begin
Wait(RandomRange(1000, 1500));
Continue;
end;
Reason('Could not find tree to chop.');
LogOut;
Exit;
end;
TC := 0;
B := TrackWillow(x, y);
SetColorSpeed2Modifiers(0.38, 1.05);
FindColorsTolerance(Pts, 3035202, B.x1, B.y1, B.x2, B.y2, 12);
C := Length(Pts);
//Debug(IntToStr(C) + ' occurances of Tree Color found, before waiting.');
iC := InvCount;
iCTime := GetTimeRunning + 15000;
while (AreWeChopping or (Length(Pts) > (C - 10))) and (not InvFull) do
begin
Status('ChopTheTrees: Waiting while chopping...');
if Random(3) = 0 then
SleepAndMoveMouse(400 + Random(100))
else
Wait(RandomRange(400, 500));
if Random(4) = 0 then
FindRandoms;
FindColorsTolerance(Pts, 3035202, B.x1, B.y1, B.x2, B.y2, 12);
if Random(8) = 0 then
AntiBan;
if not AreWeChopping then
Wait(200);
if BirdsNestCheck then Break;
if GetTimeRunning > iCTime then
if iC = InvCount then
Break
else
begin
iC := InvCount;
iCTime := GetTimeRunning + 15000;
end;
end;
SetColorSpeed2Modifiers(0.2, 0.2);
Wait(RandomRange(200, 600));
end;
Result := True;
end;