Code:
program YewChopper;
{.Include srl/srl.scar}
{.Include srl/srl/Misc/SmartColors.scar}
{ To do list
Break out of loops
Animation IsTreeDown
BankYews;
Progress Report
Multiplayer
Failsafes
Antiban
Antirandoms
}
const
// Indexes
OBJ_YEW = 0;
OBJ_BANK = 1;
NORTH_TREE = 0;
SOUTH_TREE = 1;
var
x, y : Integer;
TreeSymbol, MyRoadColor : Integer;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Pin := '';
// Integers[0] := 1000;
// Strings[1] := 'iron';
// Booleans[1] := True;
end;
end;
procedure MakeObjects;
begin
MakeObjEx(OBJ_YEW, 1461824, 3, 0.06, 0.72, ['hop', 'own', 'ew' ], ['hop']);
SetupSmartColorsDetailsEx(OBJ_YEW, 5, 20, 7, 35, 5, 5, 3, 20);
MakeObjEx(OBJ_BANK, 7370363, 4, 0.19, 0.23, ['ank', 'ooth' ], ['quickly', 'qui', 'kly']);
SetupSmartColorsDetailsEx(OBJ_BANK, 5, 20, 7, 25, 5, 15, 2, 20);
end;
function ACTreeSymbol: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.26, 0.46);
FindColorsSpiralTolerance(MMCX, MMCY, arP, 556549, MMX1, MMY1, MMX2, MMY2, 4);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result. T');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 5.68) and (X <= 9.73) and (Y >= 11.19) and (Y <= 19.16) and (Z >= 2.22) and (Z <= 3.40) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
function ACRoadColor: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
X, Y, Z: Extended;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(22.46, 0.46);
FindColorsSpiralTolerance(MMCX, MMCY, arP, 8555396, MMX1, MMY1, MMX2, MMY2, 1);
if (Length(arP) = 0) then
begin
Writeln('Failed to find the color, no result. R');
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToXYZ(arC[i], X, Y, Z);
if (X >= 22.35) and (X <= 23.60) and (Y >= 24.06) and (Y <= 24.56) and (Z >= 24.94) and (Z <= 27.15) then
begin
Result := arC[i];
Writeln('AutoColor = ' + IntToStr(arC[i]));
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
function CurrentTree : Integer;
begin
Result := SOUTH_TREE;
if FindColorSpiral(x, y, MyRoadColor, MMX1, 45, MMX2, MMY2) then
Result := NORTH_TREE;
end;
function TransferTree : Boolean;
var
ym : Integer;
begin
case CurrentTree of
NORTH_TREE : begin
x := MMCX;
y := 150;
ym := - 12;
end;
SOUTH_TREE : begin
x := MMCX;
y := 15;
ym := 15;
end;
end;
Result := FindColorSpiral(x, y, TreeSymbol, MMX1, MMY1, MMX2, MMY2);
if Result then
Mouse(x + 5, y + ym , 2, 2, True)
else
WriteLn('No tree symbol found!');
end;
function BankToTrees : Boolean;
begin
x := MMCX;
y := MMCY;
Result := FindColorSpiral(x, y, TreeSymbol, MMX1, MMY1, MMX2, MMY2);
if (Result) then
begin
Mouse(x + 5, y + 17, 2, 2, True);
end;
end;
function Chop : Boolean;
var
TempCTS, TPALength : Integer;
TPA : TPointArray;
begin
Result := False;
repeat
repeat
Wait(1000 + Random(200));
until SmartColorsEx(OBJ_YEW);
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.06, 0.72);
repeat
Wait(1000 + Random(200));
FindColorsTolerance(TPA, 1461824, MSX1, MSY1, MSX2, MSY2, 3);
TPALength := Length(TPA);
until (TPALength < 10);
ColorToleranceSpeed(TempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
TransferTree;
until InvFull;
Result := True;
end;
function TreesToBank : Boolean;
var
BankDTM : Integer;
begin
Result := False;
BankDTM := DTMFromString('78DA63AC646260486000034608C5F0E70F130' +
'32B94FF1F0818416A2270AB018B83D4041250530B54E38B5F0D00' +
'08EF0F4B');
case CurrentTree of
NORTH_TREE : Mouse(631, 46, 4, 4, True); // Blind Click for now
SOUTH_TREE : Mouse(663, 28, 4, 4, True);
end;
repeat
Wait(2000 + Random(1000));
until DTMRotated(BankDTM, x -10, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 2, 2, True);
Flag;
FreeDTM(BankDTM);
end;
function Bank : Boolean;
begin
Result := False;
SmartColorsEx(OBJ_BANK);
end;
begin
ClearDebug;
SetupSRL;
//DeclarePlayers;
//LoginPlayer;
ActivateClient;
Wait(2000);
TreeSymbol := ACTreeSymbol;
MyRoadColor := ACRoadColor;
MakeObjects;
{repeat
BankToTrees;
Chop;
TreesToBank;
Bank;
until False;}
Bank;
end.