Fixed Standards and Some Changes
program ForestExterminator;
{$DEFINE SMART}
{$I SRL\SRL.scar}
{$I SRL\SRL\misc\Reports.scar}
{$I SRL\SRL\misc\Debug.scar}
{=========================================================================]
[ ]
[ ]
[ NAME : Forest Exterminator ]
[ WRITER : Bobzilla69 ]
[ CATEGORY : Woodcutting ]
[ DESCRIPTION : Cuts Trees/Oaks/Willows and Yews ]
[ USAGE : Start in Draynor Bank, ]
[ with axe in inventory or equiped ]
[ NOTES : There can be a problem with all trees being ]
[ cut so it will log out due to not finding tree ]
[ CONTACT : PM me on SRL-Forums or post in thread ]
[ THANKS : I would like to Thank R!ch!e for exsplaining ]
[ his MineOre procedure from M!ne used in my ]
[ FindTreeTPA and CutTreeprocedure and ]
[ all other help R!ch!e provided. ]
[ Thanks to NCDS for helping me by suggesting ]
[ a TPA walking method ]
[ Thanks to BobboHobbo for giving me an idea ]
[ from your Draynor Willow cutter banker, used ]
[ Changed ischopping to suite me. ]
[ ]
[=========================================================================]
[ Instructions ]
[=========================================================================]
[ 1. Have character in Draynor bank with axe equiped or in inventory ]
[ 2. Fill out DeclarePlayers. ]
[ (For further instructions on how to fill it out, visit this thread: ]
[ [url]http://www.villavu.com/forum/showthread.php?t=5410[/url]) ]
[ 3. Designed to be used with SMART and Simba ]
[ 4. Start script and enjoy, dont forget to post a proggy! ]
[=========================================================================}
var
DebugTheTPA, DebugReport: boolean;
procedure DeclarePlayers;
var
I: integer;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
DebugTheTPA := False; //True if you want to see TPA debug
DebugReport := False; //This will include Debugs taken from script and incldude into proggress report(extending report alot) not recommended for long runs, only for 1-3 loads
with Players[0] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none)
Active := True; //Player Active?
Strings[0] := ''; //Tree that will be chopped (If blank will be AutoDetected)
Integers[0] := 1; //Loads to do
Booleans[0] := False; //Do Breaks?
Booleans[1] := False; //Rerun after Loads?
Integers[1] := 0; //Woodcutting Level (Use this if autodetection doesn't work!)
end;
{with Players[1] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none)
Active := True; //Player Active?
Strings[0] := ''; //Tree that will be chopped (If blank will be AutoDetected)
Integers[0] := 1; //Loads to do
Booleans[0] := False; //Do Breaks?
Booleans[1] := False; //Rerun after Loads?
Integers[1] := 0; //Woodcutting Level (Use this if autodetection doesn't work!)
end;}
for I := 0 to HowManyPlayers - 1 do
with Players[I] do
begin
BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
Strings[1] := '';
Banked := 0;
Worked := 0;
end;
end;
{------------------------------------end of setup------------------------------}
type
TTree = record
Col, Tol, Cut, Light: Integer;
HMod, SMod: Extended;
UpText: TStringArray;
Tree: string;
end;
var
Working: integer;
x, y: integer;
LoadsDone: boolean;
//auto colors a selection of items
function MyFindColor(What: string; Where:boolean): integer; //on minimap(true) or main screen (false)
var
I, J, TheColor, Red, Green, Blue, color,
bL, bH, gL, gH, rL, rH, colTol: integer;
colorArray: TPointArray;
begin
case lowercase(What) of
'bank': begin
color := 5533565;
bL := 77;
bH := 91;
gL := 104;
gH := 117;
rL := 118;
rH := 131;
colTol:= 11; //use to alter tollerance
end;
'stall': begin
color := 6184290;
bL := 89;
bH := 98;
gL := 89;
gH := 97;
rL := 93;
rH := 102;
colTol:= 7; //use to alter tollerance
end;
'water': begin
color := 10983825;
bL := 162;
bH := 171;
gL := 148;
gH := 158;
rL := 140;
rH := 149;
colTol:= 7; //use to alter tollerance
end;
'road': begin
color := 7237234;
bL := 105;
bH := 115;
gL := 106;
gH := 113;
rL := 109;
rH := 118;
colTol:= 7;
end;
'rock': begin
color := 5855833;
bL := 85;
bH := 93;
gL := 86;
gH := 94;
rL := 85;
rH := 93;
colTol:= 6;
end;
end;
Result := 0;
if Where then
FindColorsTolerance(colorArray, color, MMX1, MMY1, MMX2, MMY2, colTol)
else
FindColorsTolerance(colorArray, color, MSX1, MSY1, MSX2, MSY2, colTol);
J := High(colorArray);
for I := 0 to J do
if ((rs_OnMinimap(colorArray[I].x, colorArray[I].y)) or (not (Where))) then
begin
TheColor := GetColor(colorArray[i].x, colorArray[i].y);
ColorToRGB(TheColor, Red, Green, Blue);
if (InRange(Blue, bL, bH) and InRange(Green, gL, gH) and InRange(Red, rL, rH)) then
begin
Result := TheColor;
WriteLn(What + ' Colour Found: ' + IntToStr(TheColor));
Exit;
end;
end;
end;
procedure Write(WhatsHappening: string); //idea from M!ne by R!ch!e
begin
Writeln(WhatsHappening);
Players[CurrentPlayer].Strings[1] := Players[CurrentPlayer].Strings[1] + WhatsHappening + #13#10;
end;
procedure LogoutWhy(Why: string); //idea from BobboHobbo script
begin
Write(Why);
//Players[CurrentPlayer].Strings[1] := Players[CurrentPlayer].Strings[1] + Why + #13#10;
Players[CurrentPlayer].Active := False; //Set player inactive
Logout;
end;
function SetupTree: TTree;
begin
case Lowercase(Players[CurrentPlayer].Strings[0]) of
'tree': begin
with Result do //Loads tree into Result: TTree;
begin
Col := 4025442; //Colour
Tol := 5; //Tolerance
Cut := 8000; //Cut Time (This should not be here.... Use a function to detect cutting)
Light := 8000; //Light Time (Nether should this... Same as above)
HMod := 0.04; //Hue
SMod := 1.57; //Saturation
UpText := ['hop down Tree', 'own Tree', 'ree']; //Uptext
Tree := 'Tree'; //Name of Tree
end;
end;
'oak': begin
with Result do
begin
Col := 6202005;
Tol := 5;
Cut := 15000;
Light := 8000;
HMod := 0.10;
SMod := 1.58;
UpText := ['hop down Oak', 'own Oak', 'ak'];
Tree := 'Oak';
end;
end;
'willow': begin
with Result do
begin
Col := 4088154;
Tol := 4;
Cut := 20000;
Light := 8000;
HMod := 0.25;
SMod := 1.57;
UpText := ['hop down Willow', 'own Willow', 'illow'];
Tree := 'Willow';
end;
end;
'yew': begin
with Result do
begin
Col := 6070418;
Tol := 10;
Cut := 30000;
Light := 8000;
HMod := 0.13;
SMod := 0.12;
UpText := ['hop down Yew', 'own Yew', 'ew'];
Tree := 'Yew';
end;
end;
end;
end;
function LoadDTM(What: string): string;
begin
case LowerCase(What) of
'log': Result := 'mggAAAHicY2NgYBCEYhkglgBiNijmhdIcQCwOleMB4gQPLSDJhIFTGLADRhwYAgCmhgIF'; //logs (max tolerance)
'braxe': Result := 'mbQAAAHicY2VgYNBkYWBQBmIDINYFYnUgnsPIwDAbiOcB8SIgng/E9gYyQNVMKJiLARMwYsFgAABuXQSn'; //bronze axe
'iaxe': Result := 'mggAAAHicY2NgYLBjYmBwAGIXIHYGYmsgNgfit0C5V0D8Bog/APF7IH4NxJbm5kCSCQOzMmAHjDgwBAAA6D8H0w=='; //iron axe
'blaxe': Result := 'mggAAAHicdcrbCgAQFETRQy6hk1Lk/7/ULt6wa83TBBFpKOiYGKgI8HCI55Ogqqy9ZHlnPnYLVU8A4Q=='; //black axe
'saxe': Result := 'mggAAAHicY2NgYNAGYl0gNgRiPSBWB2IVII4F4igonQTE8UAcDcThIcFAkgkDczFgB4w4MAQAAJOfBFE='; //steel axe
'maxe': Result := 'mggAAAHicY2NgYFgOxAuAeBUQr4XSS4CYDYhZgZgFiNmBmAeIOYHY0NATSDJhYC4G7IARB4YAABIJBOM='; //mithril axe
'aaxe': Result := 'mggAAAHicY2NgYDABYh0gNgdiSyhtAMRsQMwKxCxAzA7E3EDMCZK3B6lgwsAgtdgAIw4MAQDXOwIq'; //adamant axe
'raxe': Result := 'mggAAAHicY2NgYDgFxIeB+BwQXwDis0B8HIjZgJgViFmAmAOIeYCYE4itPfyAJBMG5mLADhhxYAgAAH10Bd0='; //rune axe
end;
end;
procedure ProgressReport;
var
I :integer;
begin
Writeln(#13#10);
SRLProgressReport(ResultDebugBox, 'Forest Exterminator', 'Bobzilla69', '1.25',
['TimeRunning', 'Active Players'],
[TimeRunning, PlayersActive]);
SRLPlayerReport(ResultDebugBox, 0, false, [True, True, false, false, false, true], ['Tree Cutting'], [], [], [0], [] );
Writeln(#13#10'Please post bugs and report at [url]http://villavu.com/forum/showthread.php?p=739347'#13#10);[/url]
if (DebugReport) then
begin
for I := 0 to (HowManyPlayers - 1) do
begin
if (not (Players[I].Strings[1] = '')) then
begin
WriteLn(Players[I].Nick + #13#10'Debug of what happened'#13#10);
WriteLn(Players[I].Strings[1]);
end;
end;
end
end;
procedure ScriptTerminate;
begin
FreeSRLBitmaps;
ProgressReport;
end;
procedure CheckLevels;
begin
Wait(200);
if (not (LoggedIn)) then
Exit;
if (Players[CurrentPlayer].Integers[1] = 0) then
Players[CurrentPlayer].Integers[1] := GetSkillInfo('woodcutting', True);
case (Players[CurrentPlayer].Integers[1]) of
1..14: Players[CurrentPlayer].Strings[0] := 'Tree';
15..29: Players[CurrentPlayer].Strings[0] := 'Oak';
30..59: Players[CurrentPlayer].Strings[0] := 'Willow';
60..99: Players[CurrentPlayer].Strings[0] := 'Yew';
end;
Players[CurrentPlayer].Strings[1] := Players[CurrentPlayer].Strings[1] + Players[CurrentPlayer].Strings[0] +' was auto detected to be trained on.'#13#10;
end;
procedure CheckLogged;
var
breakFor: integer;
begin
if (PlayersActive >= 1) then
begin
if (Players[CurrentPlayer].Integers[1] = 0) then
Exit;
Logout;
if (Players[CurrentPlayer].Booleans[0]) then
begin
breakFor := 240000 + RandomRange(90000, 150000);
Write('Taking Break for: ' + MsToTime(breakFor, Time_Short));
Wait(breakFor);
end;
end;
if (LoadsDone) then
begin
LoadsDone := False;
Exit;
end;
if (not (LoggedIn)) then
begin
Write('Player not logged in Switching to next');
Write('Choosing Next Player');
Players[CurrentPlayer].Strings[1] := Players[CurrentPlayer].Strings[1] + 'Player Failed, Please Post Proggress report and location logged out'#13#10;
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked + TimeFromMark(working);
Players[CurrentPlayer].Active := False;
Logout;
end;
end;
procedure AntiBan;
var
MousePos: TPoint;
begin
FindNormalRandoms;
GetMousePos(MousePos.x, MousePos.y);
case random(100) of //30% chance something will happen
0..5: PickupMouse;
10..15: HoverSkill('random', False);
20..25: GameTab(RandomRange(tab_Combat, tab_Notes));
30..35: Wait(500 + Random(1500));
40..45: RandomAngle(1);
50..55: BoredHuman;
end;
GameTab(Tab_Inv);
MMouse(MousePos.x, MousePos.y, 2, 2);
end;
procedure WalkToBank;
var
MiddleOfTPA: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
TreeSetup: TTree;
begin
if (not (LoggedIn)) then
Exit;
TreeSetup := SetupTree;
Write('Walking to Bank from: ' + TreeSetup.Tree + '.');
case LowerCase(TreeSetup.Tree) of
'tree': begin
//at trees, loking for rock at top right hand side. shoudl walk to above pen
if FindColorsPie(TPA, MyFindColor('rock', True), 15, 0, 360, 5, 45, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA := MiddleTPA(TPA);
if (DebugTheTPA) then
DebugTPA(TPA, '');
Mouse(MiddleOfTPA.x - 10 , MiddleOfTPA.y + 55, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 1 Complete');
Flag;
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 1, Logging out...');
Exit;
end;
//try to use stalls to place you near bank
if FindColorsPie(TPA, MyFindColor('stall', True), 15, 140, 240, 40, 70, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY) then
begin
MiddleOfTPA := MiddleTPA(TPA);
if (DebugTheTPA) then
DebugTPA(TPA, '');
Mouse(MiddleOfTPA.x + 5, MiddleOfTPA.y + 8, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 2 Complete');
Flag;
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 2, Logging out...');
Exit;
end;
//should place in bank, using bankers as refrence
if FindColorsPie(TPA, 1179390, 15, 90, 210, 35, 85, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA := MiddleTPA(TPA);
if (DebugTheTPA) then
DebugTPA(TPA, '');
Mouse(MiddleOfTPA.x + 8, MiddleOfTPA.y -3, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 3 Complete');
FFlag(5);
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 3, Logging out...');
Exit;
end;
end;
'oak': begin
MakeCompass('N');
//use rocks and offsetting to end up near pen
if FindColorsTolerance(TPA, MyFindColor('rock', True), MMCX, MMY1, MMX2, MMCY, 15)then
begin
ATPA := SplitTPAEx(TPA, 8, 8);
SortATPAFromFirstPoint(ATPA, Point(MMCX, MMCY));
MiddleTPAEx(ATPA[0], x , y);
Mouse(x + 30, y + 46, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 1 Complete');
Wait(3000);
Flag;
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 1, Logging out...');
Exit;
end;
//Stalls Middle to bank
if FindColorsPie(TPA, MyFindColor('stall', True), 15, 90, 230, 5, 55, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA := MiddleTPA(TPA);
Mouse(MiddleOfTPA.x + 5, MiddleOfTPA.y + 8, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 2 Complete');
Flag;
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 2, Logging out...');
Exit;
end;
//should place in bank, using bankers as refrence
if FindColorsPie(TPA, 1179390, 15, 90, 210, 40, 85, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA := MiddleTPA(TPA);
Mouse(MiddleOfTPA.x + 8, MiddleOfTPA.y -5, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 3 Complete');
FFlag(5);
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 3, Logging out...');
Exit;
end;
end;
'willow': begin
MakeCompass('N');
if FindColorsPie(TPA, 1179390, 15, 0, 60, 30, 85, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA := MiddleTPA(TPA);
Mouse(MiddleOfTPA.x + 8, MiddleOfTPA.y -3, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 1 Complete');
FFlag(5);
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 1, Logging out...');
Exit;
end;
end;
'yew': begin
MakeCompass('N');
if FindColorsPie(TPA, MyFindColor('rock', True), 15, 60, 180, 30, 60, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA:= MiddleTPA(TPA);
Mouse(MiddleOfTPA.x - 15, MiddleOfTPA.y , 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 1 Complete');
Flag;
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 1, Logging out...');
Exit;
end;
//use rocks and offsetting to end up near pen
if FindColorsTolerance(TPA, MyFindColor('rock', True), mmcx, mmy1, mmx2, mmcy, 15)then
begin
ATPA := SplitTPAEx(TPA, 8, 8);
SortATPAFromFirstPoint(ATPA, Point(MMCX, MMCY));
MiddleTPAEx(ATPA[0], x , y);
Mouse(x + 30, y + 46, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 2 Complete');
Wait(3000); //in case flag go off map
Flag;
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 2, Logging out...');
Exit;
end;
//Stalls Middle to bank
if FindColorsPie(TPA, MyFindColor('stall', True), 15, 90, 230, 5, 55, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA := MiddleTPA(TPA);
Mouse(MiddleOfTPA.x + 5, MiddleOfTPA.y + 8, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 3 Complete');
Flag;
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 3, Logging out...');
Exit;
end;
//should place in bank, using bankers as refrence
if FindColorsPie(TPA, 1179390, 15, 90, 210, 40, 85, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA := MiddleTPA(TPA);
Mouse(MiddleOfTPA.x + 8, MiddleOfTPA.y -5, 5, 5, True);
Write('Walking to Bank from: ' + TreeSetup.Tree + '. Step 4 Complete');
FFlag(5);
end else
begin
LogoutWhy('Walking to bank from: ' + TreeSetup.Tree + '. Failed during Step 4, Logging out...');
Exit;
end;
end;
end;
Wait(500 + Random(500)); //screen settle
Write('Walking to bank from: ' + TreeSetup.Tree + ' Complete.');
end;
procedure WalkToTrees;
var
MiddleOfTPA: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
TreeSetup: TTree;
begin
if (not (LoggedIn)) then
Exit;
TreeSetup := SetupTree;
Write('Walking to tree: ' + TreeSetup.Tree);
case Lowercase(TreeSetup.Tree) of
'tree': begin
MakeCompass('N');
//from bank to middle of stalls
if FindColorsPie(TPA, MyFindColor('stall', True), 15, -130, -25, 5, 70, mmx1, mmy1, mmcx, mmcy, mmcx, mmcy) then
begin
MiddleOfTPA := MiddleTPA(TPA);
Mouse(MiddleOfTPA.x - 5, MiddleOfTPA.y , 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 1 Complete');
Flag;
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 1, Logging out...');
Exit;
end;
//at stalls uses middle of stalls and offset to walk behind to pen
if FindColorsPie(TPA, MyFindColor('stall', True), 15, 0, 360, 5, 30, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA:= MiddleTPA(TPA);
Mouse(MiddleOfTPA.x - 10, MiddleOfTPA.y - 52, 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 2 Complete');
Flag;
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 2, Logging out...');
Exit;
end;
end;
'oak': begin
MakeCompass('N');
//from bank to middle of stalls
if FindColorsPie(TPA, MyFindColor('stall', True), 15, -130, -25, 5, 70, mmx1, mmy1, mmcx, mmcy, mmcx, mmcy) then
begin
MiddleOfTPA := MiddleTPA(TPA);
Mouse(MiddleOfTPA.x - 5, MiddleOfTPA.y , 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 1 Complete');
Flag;
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 1, Logging out...');
Exit;
end;
//at stalls uses middle of stalls and offset to walk behind to pen
if FindColorsPie(TPA, MyFindColor('stall', True), 15, 0, 360, 5, 30, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA:= MiddleTPA(TPA);
Mouse(MiddleOfTPA.x - 10, MiddleOfTPA.y - 52, 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 2 Complete');
Flag;
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 2, Logging out...');
Exit;
end;
//rock near oak's to walk to oak's
if FindColorsTolerance(TPA, MyFindColor('rock', True), MMX1, MMY1, MMCX, MMCY, 15)then
begin
ATPA := SplitTPAEx(TPA, 8, 8);
SortATPAFromFirstPoint(ATPA, Point(MMCX, MMCY));
MiddleTPAEx(ATPA[0], x , y);
Mouse(x - 22, y + 24, 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 3 Complete');
Wait(3000); //in case flag go off map
Flag;
Write('Walking Complete');
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 3, Logging out...');
Exit;
end;
end;
'willow': begin
MakeCompass('S');
if FindColorsPie(TPA, MyFindColor('rock', True), 15, 0, 60, 50, 80, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY) then
begin
MiddleOfTPA:= MiddleTPA(TPA);
Mouse(MiddleOfTPA.x - 25, MiddleOfTPA.y + 15, 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 1 Complete');
Flag;
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 1, Logging out...');
Exit;
end;
end;
'yew': begin
MakeCompass('N');
//from bank to middle of stalls
if FindColorsPie(TPA, MyFindColor('stall', True), 15, -130, -25, 5, 70, mmx1, mmy1, mmcx, mmcy, mmcx, mmcy) then
begin
MiddleOfTPA := MiddleTPA(TPA);
Mouse(MiddleOfTPA.x - 5, MiddleOfTPA.y , 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 1 Complete');
Flag;
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 1, Logging out...');
Exit;
end;
//at stalls uses middle of stalls and offset to walk behind to pen
if FindColorsPie(TPA, MyFindColor('stall', True), 15, 0, 360, 5, 30, MMX1, MMY1, MMX2, MMY2, MMCX, MMCY)then
begin
MiddleOfTPA:= MiddleTPA(TPA);
Mouse(MiddleOfTPA.x - 10, MiddleOfTPA.y - 52, 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 2 Complete');
Flag;
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 2, Logging out...');
Exit;
end;
//rock near oak's to walk to oak's
if FindColorsTolerance(TPA, MyFindColor('rock', True), MMX1, MMY1, MMCX, MMCY, 15)then
begin
ATPA := SplitTPAEx(TPA, 8, 8);
SortATPAFromFirstPoint(ATPA, Point(MMCX, MMCY));
MiddleTPAEx(ATPA[0], x , y);
Mouse(x - 22, y + 24, 5, 5, True);
Write('Walking to Tree: ' + TreeSetup.Tree + '. Step 3 Complete');
Wait(3000); //in case flag go off map
Flag;
Write('Walking Complete');
end else
begin
LogoutWhy('Walking to Tree: ' + TreeSetup.Tree + '. Failed during Step 3, Logging out...');
Exit;
end;
end;
end;
Wait(500 + Random(500));
Write('Walking to tree: ' + TreeSetup.Tree + ' Complete.');
end;
Function MyOpenBank: boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
I, J: integer;
begin
Result := BankScreen;
if (Result) then
Exit;
MakeCompass('W');
Wait(300);
FindColorsTolerance(TPA, MyFindColor('bank', False), MSX1, MSY1, MSX2, MSCY, 5);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
J := High(ATPA);
for I := 0 to J do //from 0 first entry in array to highest entry in ATPA
begin
MiddleTPAEx(ATPA[I], x, y); //find middle of array entry
MMouse(x, y, 2, 2);
if WaitUpTextMulti(['ooth', 'ank booth'], 400) then
begin
Mouse(x, y, 0, 0, False);
Wait(200);
WaitOption('uickl', 400);
Flag;
Wait(2000 + Random(800));
if (PinScreen) then
begin
InPin(Players[CurrentPlayer].Pin);
Wait(100);
end;
Result := BankScreen;
end;
end;
end;
procedure BankIt;
var
BankLoop, DTM: integer;
begin
if (not (LoggedIn)) then
Exit;
BankLoop := 0;
repeat
Wait(300);
Inc(BankLoop);
until((BankLoop > 5) or (MyOpenBank))
if (not (BankScreen)) then
OpenBank('db', True, False);
if ((BankLoop >= 5) or (not (BankScreen))) then
begin
LogoutWhy('Finding bank took more that 5 attempts, logging out');
Exit;
end;
DTM := DTMFromString(LoadDTM('log'));
try
if FindDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, False);
ChooseOption('All'); //ChooseOption('All '+TreeSetup.Tree);
Wait(1500 + Random(500)); //incase of lagg
end else
LogoutWhy('Logs not found in inventory logging out');
finally
FreeDTM(DTM);
end;
Inc(Players[CurrentPlayer].Banked);
CloseBank;
MakeCompass('N');
SetAngle(True);
end;
procedure WeStillChopping; //idea from BH - Draynor Willow Cutter
var
T, CutTime, ChopX, ChopY: integer;
TreeSetup: TTree;
begin
Flag;
Wait(200 +Random(200)); //allows player more time to reach tree after flag disapears
GetMousePos(ChopX, ChopY);
if ((not (LoggedIn)) or (Invfull)) then
Exit;
TreeSetup := SetupTree;
T := GetSystemTime;
CutTime := TreeSetup.Cut + Random(10000); //how long to cut for
MMouse(ChopX, ChopY, 2, 2);
Write('Chopping Tree started');
repeat
if (not (FindBlackChatMessage('swing your hatchet'))) then //if not this the w cut logs, so we do uptext check
if (not (IsUpTextMultiCustom(TreeSetup.UpText))) then //if no uptext then we might have cut tree
Break;
Wait(500 + random(200));
if (Invfull) then
Break;
Antiban;
until ((GetSystemTime - T > CutTime) or (not LoggedIn)) //exit repeat if we reach cut time
FindNormalRandoms;
if (GetSystemTime - T > CutTime) then
Writeln('Took longer then ' + IntToStr(CutTime) + ' to chop down the tree.');
if (not (LoggedIn)) then
Writeln('Player not logged in');
if (Invfull) then
WriteLn('Invfull starting banking');
end;
function CutTreesTPA: Boolean; //Thanks to R!ch!e for explaining this. This is a mix of R!ch!e's M!ne MineOre Procedure and BH Draynor Willow Cutter FindWillowTPA
var
I, J: Integer;
TreeTPA: TPointArray;
TreeATPA: T2dPointArray;
TreeSetup: TTree;
begin
if (not (LoggedIn)) then
Exit;
TreeSetup := SetupTree;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(TreeSetup.HMod, TreeSetup.SMod);
try
Write('Attempting to Find ' + TreeSetup.Tree);
FindColorsSpiralTolerance(MSCX, MSCY, TreeTPA, TreeSetup.Col, MSX1, MSY1, MSX2, MSY2, TreeSetup.Tol);
TreeATPA := SplitTPAEx(TreeTPA, 12, 12); //TPAtoATPAex( 20, 20)
if (DebugTheTPA) then
begin
DebugATPABounds(TreeATPA);
Wait(2000);
end;
if (Length(TreeATPA) = 0) then
Exit;
SortATPAFromFirstPoint(TreeATPA, Point(MSCX, MSCY)); //sort TPA acording to main screen center point
if (DebugTheTPA) then
begin
Write('ATPA After Sort');
DebugATPA(TreeATPA, '');
end;
J := High(TreeATPA);
for I := 0 to J do //from 0 first entry in array to J highest entry
begin
MiddleTPAEx(TreeATPA[I], x, y);//find middle of array entry
MMouse(x, y, 3, 3);
Wait(300);
if WaitUpTextMulti(TreeSetup.UpText, 400) then
begin
Mouse(x, y, 0, 0, True);
Flag;
Result := True;
Exit;
Wait(500 + Random(1500));
end;
end;
FindNormalRandoms;
finally
SetColorSpeed2Modifiers(0.2, 0.2); // Sets the modifiers back to default, (0.2, 0.2).
ColorToleranceSpeed(1); // Sets the CTS back to the default, 1.
end;
end;
procedure CutTrees; //Thanks to R!ch!e for explaining procedure.
var
Fail: Integer;
TreeSetup: TTree;
begin
if (not (LoggedIn)) then
Exit;
TreeSetup := SetupTree;
Write('Attempting to Cut ' + TreeSetup.Tree);
repeat
if (not (CutTreesTPA)) then
begin
Write('Could not find tree Trying Failsafe Finder');
if FindObj(x, y, TreeSetup.Tree, TreeSetup.Col, TreeSetup.Tol) then //use normal find object function as failsafe
begin
Write('Found ' + TreeSetup.Tree + ' using FindObj');
Mouse(x, y, 0, 0, True);
end else
begin
Write('Could not find ' + TreeSetup.Tree + ' using Colour or FindObj ');
Inc(Fail); //failsafe so ther is no infinate loop, after 15 fails script terminates
Wait(1500 + Random(500)) //incase all trees are cut down ,otherwise its instant failsafe activation (increase if hight population of cutters)
if (Fail > 15) then
begin
Write('Script failed to find ' + TreeSetup.Tree);
Write('Even after 15 attempts');
Fail := 0; //Resetting for next player
LogoutWhy('Could not find tree');
end;
end;
end;
WeStillChopping;
until((InvFull) or (not LoggedIn));
if InvFull then
Write('Inventory Full Banking');
end;
procedure TreeCutting;
begin
if (not (LoggedIn)) then
Exit;
repeat
WalkToTrees;
CutTrees;
WalkToBank;
BankIt;
until (Players[CurrentPlayer].Banked >= (Players[CurrentPlayer].Integers[0])) or (not (LoggedIn));
if (Players[CurrentPlayer].Banked >= Players[CurrentPlayer].Integers[0]) then
begin
LoadsDone := True;
Write(Players[CurrentPlayer].Name + ' has finished: ' + IntToStr(Players[CurrentPlayer].Integers[0]) + ' Loads');
end;
end;
procedure PlayerDone;
begin
if (not (LoggedIn)) then
Exit;
if (LoadsDone) then
begin
Write('All Logs have been cut Switching Players.');
Players[CurrentPlayer].Worked := Players[CurrentPlayer].Worked + TimeFromMark(Working);
//ProgressReport;
if (not (Players[CurrentPlayer].Booleans[1])) then
begin
Players[CurrentPlayer].Strings[1] := Players[CurrentPlayer].Strings[1] + 'Player not set to attempt a re-run logging out'#13#10;
Players[CurrentPlayer].Active := False;
Logout;
end else
Players[CurrentPlayer].Strings[1] := Players[CurrentPlayer].Strings[1]+'Re-Run set to true, will attempt another run'#13#10;
Write('Progress Report');
ProgressReport;
end;
end;
procedure Main;
begin
repeat
LoginPlayer;
Wait(500);
MarkTime(Working);
CheckLevels;
WriteLn('Woodcutting Level: ' + IntToStr(Players[CurrentPlayer].Integers[1]));
WriteLn('Recommended training is ' + Players[CurrentPlayer].Strings[0]);
SetupTree;
Wait(500);
SetAngle(True);
TreeCutting;
PlayerDone;
CheckLogged;
until(AllPlayersInactive)
end;
procedure Setup;
begin
SetUpSRL;
DeclarePlayers;
end;
begin
Setup;
Wait(1000);
Main;
ProgressReport;
end.