Simba Code:
{Thanks to Coh3n for his guides (mainly [url]http://villavu.com/forum/showthread.php?t=58935[/url])
Also Thanks to everyone else who helped on IRC.
Thanks to Bart for the findlevel function!
Big thanks to the creators of everything I've used
}
program TreeChopper;
{$DEFINE SMART8}
{$i srl/srl.simba}
const
EmptyInventory = 'Bonfire'; //'Burn' or 'Bonfire' are accepted
Loads = 50; //Fill in how many loads
HoldingHatchet = True; //True if hatchet is in your inventory
Reporting = True; // True if you want a regular report (make sure to set up xp bars correctly), false if not
var
inv1, inv2, Loadsdone, i, LogsCut, LogsBurnt, hat, invspace :Integer;
InvFS1, InvFS2, TimeFS1, TimeFS2 :Integer;
WCexpbar, FMexpbar, WCexpstart, FMexpstart, WCexpbar2, FMexpbar2 : Integer;
Burning : Boolean;
TextAR1, TextAR2 : TStringArray;
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
end;
function GetLevelArray(): TIntegerArray; //Thanks to Bart for this function
var
Level: Integer;
RRArray: Array of Extended;
begin
SetLength(RRArray, 120);
SetLength(Result, 120);
RRArray[0] := 0;
for Level := 2 to 120 do
begin
RRArray[Level - 1] := RRArray[level - 2] + Floor((Level - 1) + (300 * Pow(2, ((Level - 1) / 7.0)) ));
Result[Level - 1] := Floor(RRArray[Level - 1] / 4);
end;
end;
function GetLevel(xp: Integer): Integer; //Thanks to Bart for this function
var
levels: TIntegerArray;
begin
levels := GetLevelArray;
for Result := 1 to High(levels) do
if (levels[Result] > xp) then
Exit;
end;
procedure Antiban;
var
Red: String;
begin
if (not(LoggedIn))then Exit;
RunEnergy(80);
if (GetMMLevels('run',Red) < 20) then RestUntil(95);
CloseAdWindow();
FindSpinTicket();
ExitSquealOfFortune();
FindDwarvenPopup();
case Random(600) of
0:HoverSkill('woodcutting',false);
2:RandomRClick;
4:begin
PickUpMouse;
Wait(Random(500));
PickUpMouse;
end;
6:RandomMovement;
8:BoredHuman;
9:HoverSkill('firemaking',false);
end;
end;
procedure Setup;
begin
if HoldingHatchet = True then
begin
hat:=1
invspace:= 27
end else
begin
hat:=0
invspace:= 28
end;
CloseAdWindow();
FindSpinTicket();
ExitSquealOfFortune();
FindDwarvenPopup();
TimeFS1 := 0;
TimeFS2 := 0;
inv2:=InvCount;
inv1:=InvCount;
Loadsdone := 0;
LogsCut := 0;
LogsBurnt := 0;
If (not ISXPBarOpenEx(1)) then
begin
ToggleXPBar(True);
end;
ResetXPTotal;
WCexpbar := GetXPBar(1);
FMexpbar := GetXPBar(2);
WCexpstart:=GetXp('Woodcutting')
FMexpstart:=GetXp('Firemaking')
Writeln('Current Woodcutting experience on bar : ' + IntToStr(WCexpbar));
Writeln('Current Firemaking experience on bar : ' + IntToStr(FMexpbar));
Writeln('Set all vars.');
end;
procedure Report;
begin
if (reporting=true) then
begin
ClearDebug;
WCexpbar2 := GetXPBar(1);
FMexpbar2 := GetXPBar(2);
writeln(' Been running For : ' + TimeRunning)
writeln('Logs Cut : ' + Inttostr(LogsCut)
+ ' ¦ Logs Burnt : ' + Inttostr(LogsBurnt))
Writeln('Woodcutting experience gained : ' + IntToStr(WCexpbar2 - WCexpbar)
+ ' ¦ Firemaking experience gained : ' + IntToStr(FMexpbar2 - FMexpbar));
Writeln('Woodcutting levels gained : ' + IntToStr((GetLevel((WCexpbar2-WCexpbar)+WCexpstart))-(GetLevel(WCexpstart)))
+ ' ¦ Firemaking levels gained : ' + IntToStr((GetLevel((FMexpbar2-FMexpbar)+FMexpstart))-(GetLevel(FMexpstart))));
Writeln('Current Woodcutting Level : ' + IntToStr(GetLevel((WCexpbar2-WCexpbar)+WCexpstart))
+ ' ¦ Current Firemaking Level : ' + IntToStr(GetLevel((FMexpbar2-FMexpbar)+FMexpstart)));
if (Loadsdone = 0) then writeln(' ' + Inttostr(Loadsdone) + ' Full Loads Done')
else writeln(' ' + Inttostr(Loadsdone-1) + ' Full Loads Done');
end;
end;
procedure ChangeScreen(Chance:Integer);
var
screen:Integer;
begin
screen:= (Random(Chance))
if (screen<2) then
begin
KeyDown((screen * 2) + 38);
Sleep(100 + Random(300));
KeyUp((screen * 2) + 38);
Wait(100 + Random(100));
MakeCompass(Random(360));
end;
end;
procedure Failsafe;
begin
if(not(LoggedIn))then Exit;
InvFS2 := InvCount;
FindNormalRandoms;
if (TimeFS1 = 0) or (InvFS2<>InvFS1) then
begin
MarkTime(TimeFS1);
InvFS1 := Invcount;
end;
TimeFS2 := (TimeFromMark(TimeFS1)/1000);
if (TimeFS2 > 90) and (InvFS2 = InvFS1) then
begin
TimeFS1 := 0;
Writeln('Been idle for 90 seconds, going to Draynor.')
If OpenLodestoneScreen then
begin
Lodestoneteleport('Draynor Village');
wait(RandomRange(12000,15000));
end;
end;
end;
procedure ChopTree;
var
x, y, Time1, Time2 : Integer;
begin
if(not(LoggedIn))then Exit;
Failsafe
Antiban;
FindNormalRandoms;
ChangeScreen(5);
ColorToleranceSpeed(2)
SetColorSpeed2Modifiers(1.2, 1.25);
if FindObj(x,y,'ree',1582373 ,2)then //1582373
begin
MMouse(x, y, 5, 5);
if WaitUpText('ree', 500) then
begin
Writeln('Found Tree');
Mouse(x,y,0,0,True);
inv1 := InvCount;
MarkTime(Time1);
repeat
if(not(LoggedIn))then Exit;
inv2 := InvCount;
FindNormalRandoms;
Antiban;
wait(random(500));
Time2 := (TimeFromMark(Time1)/1000);
until (inv2>inv1) or (Time2 > (RandomRange(15,20)));
end else
begin
Writeln('Found the colour but no tree');
ChangeScreen(2);
end;
end else
begin
Writeln('Couldn''t find the colour');
ChangeScreen(5);
end;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(1);
if (inv2>inv1) then
begin
LogsCut:= (((LoadsDone-1)*invspace) + (Invcount-hat))
Report;
end;
inv1:=InvCount;
end;
procedure CheckBurning;
var
textline, Timer1, Timer2:Integer;
begin
if(not(LoggedIn))then Exit;
Burning := false;
MarkTime(Timer1)
repeat
Timer2 := (TimeFromMark(Timer1)/1000);
FindNormalRandoms;
TextAR2 := ChatBoxTextArray(clBlack);
textline:=8
if (TextAR2[textline] = '') then
repeat
textline:=textline-1
until (TextAR2[textline]<>'');
if (pos('The fire', TextAR2[8]) <>0) or (pos('level', TextAR2[8]) <>0) AND (TextAR2 <> TextAR1) then
begin
writeln('Fire Lit');
Wait(RandomRange(200,500));
Burning := true;
end else
begin
writeln('Still Lighting');
Wait(RandomRange(200,500));
Burning := false;
Antiban;
end;
until (Burning = true) or (Timer2 > (RandomRange(15,20)));
end;
procedure Burn( Tpe :String);
var
text : TStringArray;
FSMoverep,textline: Integer;
FSDone : Boolean;
begin
if(not(LoggedIn))then Exit;
Mouse(80,491,20,10,true);
writeln('Emptying Inv');
wait(random(1000));
i:= InvCount;
ClickNorth(0)
while i > hat do
begin
Failsafe
FindNormalRandoms;
Burning := false;
i:= InvCount;
if (not ExistsItem(i)) then
begin
i:=29
repeat
i:= i-1;
if (i = hat) then i:=28;
until (ExistsItem(i));
end;
TextAR1 := ChatBoxTextArray(clBlack);
MMouseItem(i);
MouseItem(i, 0);
if WaitOption('ight', 500) then
begin
wait(RandomRange(1000,1500));
textline:=8
text:= ChatBoxTextArray(clBlack);
if (text[textline] = '') then
repeat
textline:=textline-1
until (text[textline]<>'');
if (pos('You can', text[textline]) <>0) then
begin
FSMoverep := 1;
FSDone := false;
repeat
writeln('Can''t Light Fire here');
Mouse((MSCX+30),(MSCY + (30*FSMoverep)),10,5,true);
If(IsMoving) then FSDone := true;
repeat
FindNormalRandoms;
Wait(RandomRange(500,1000));
until (not FlagPresent);
Inc(FSMoverep);
until (FSDone = true) or (FSMoverep >=10);
end;
if (i>Invcount) then
begin
CheckBurning;
Inc(LogsBurnt);
if Tpe = 'Bonfire' then i:= (hat);
Report;
end;
end else
begin
MouseItem(i, 0);
WaitOption('rop', 500);
wait(RandomRange(500,1000));
end;
if Tpe = 'Burn' then i:= InvCount;
end;
end;
procedure EmptyInv;
var
Timer1, Timer2 : Integer;
begin
case EmptyInventory of
'Burn': Burn('Burn');
'Bonfire':
repeat
begin
Burn('Bonfire');
i:= InvCount;
if (not ExistsItem(i)) then
begin
i:=29
repeat
i:= i-1;
if (i = hat) then i:=28;
until (ExistsItem(i));
end;
MMouseItem(i);
Wait(RandomRange(200,300));
if IsUpTextEx('Craft') then
begin
MouseItem(i, 1);
Wait(RandomRange(500,800));
MouseBox(334, 150, 389, 200,1);
repeat
Marktime(Timer1);
inv1:=Invcount;
repeat
if(not(LoggedIn))then Exit;
inv2 := InvCount;
FindNormalRandoms;
Antiban;
wait(random(500));
Timer2 := (TimeFromMark(Timer1)/1000);
until (inv2<inv1) or (Timer2 > (RandomRange(7,10))) or (Invcount = hat);
if inv2<inv1 then Inc(LogsBurnt);
Report;
until (Timer2 > (RandomRange(7,10))) or (Invcount = hat);
end else Writeln('Couldn''t find Craft');
end;
until(Invcount = hat);
end;
if (InvCount = Hat) then
begin
Inc(Loadsdone);
Report;
end;
end;
begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
Setup;
EmptyInv;
if (not (InvFull)) then
begin
Repeat
if(not(LoggedIn))then Exit;
FindNormalRandoms;
Antiban;
ChopTree;
wait(random(2000));
inv2:=InvCount;
inv1:=InvCount;
if (InvFull) then EmptyInv;
until ((Loadsdone-1) >= Loads)
end;
end.