Code:
program TeakCutter;
{$I SRL/OSR.simba}
{$I SRL/utils/rsclient.simba}
{$I RSWalker/Walker.simba}
{$I WaspLib/WaspLib.simba}
{$H-}
{$R+}
{$X+}
const
// Account Information
USER = '';
PASS = '';
PIN = '';
MEMBER = TRUE;
// Script Settings
RUN_TIME = (8 * ONE_HOUR) + (32 * ONE_MINUTE);
TRAINING_SKILL = SKILL_WOODCUTTING;
type
TState = (DROPPING, CUT_TREE, SPEC, WAIT_CUTTING, EQUIP_LUMBERJACK);
TWoodcutter = record
State: TState;
StatsDebugTick: Int64;
Action: String;
end;
var
Woodcutter: TWoodcutter;
RSW: TRSWalker;
LumberjackHatDTM := DTMFromString('mggAAAHicY2NgYGhmYmAoB+IeIK6F4k4gfgSUe8oAoV8D8T0gfgbEYWEBQJIRjkNCfBnU1BQYyAMA85kK1A==');
LumberjackTopDTM := DTMFromString('mwQAAAHic42RgYGhlYmBoBuIqIG4H4h4oXQPEFUBcAsSGjBBsDsSWQGzMiBAzgNJ7Z0kwtGooAU1kZEiQlWCoVpNlKFeRZejQUmIoBtIgcaoDAHYODEQ=');
LumberjackLegsDTM := DTMFromString('mwQAAAHic42RgYGhkYmCoBeJqKA3iNwNxGxC3AnE7EEcwMjCEAXEcECcDcSoUJwFxJBCHAzEDAyNDYKAXmPbz8wDTTk62YNrU1ABMUx0AADBNCyw=');
LumberjackBootsDTM := DTMFromString('mwQAAAHic42RgYGhkYmBoBeI2IG4C4iogLgXiLiDuA+JaIG5kZGBoAOIOIO4C4lYouxOIW4C4DYh1NJQY1EQZGEwNtBi8nK3AmIGBEY5B4lQHAA1DDMo=');
TeakLogDTM := DTMFromString('mbQAAAHicY2VgYHBiYmCwBGIfIDYBYjcgfg4Ufw3ED4H4FRC/A+I1ExMZLm4qB7IYGS5vqQHTJAEAJcELeQ==');
TeakTreeColor := CTS2(3699829, 27, 0.26, 0.30);
TeakTreeTiles := [Point(3110, 4100), Point(3102, 4096), Point(3118, 4096)];
procedure Woodcutter.DeclarePlayers();
begin
Players.Add([USER, PASS, PIN, MEMBER, True]);
Players.SetCurrent(0);
end;
function Woodcutter.IsCutting(): Boolean;
var
i: Int32
begin
for i := 0 to 10 do
begin
if SRL.GetPixelShift(MainScreen.GetPlayerBox(), 50) > 400 then
Exit(True);
end
Result := False;
end;
function Woodcutter.DropLogs(): Boolean;
var
Pattern, Slots: TIntArray;
Index: Int32;
begin
Slots := Inventory.FindDTM(TeakLogDTM);
for Index in [DROP_PATTERN_TWO_ROW, DROP_PATTERN_TWO_ROW_R, DROP_PATTERN_SNAKE, DROP_PATTERN_SNAKE_R, DROP_PATTERN_TOPDOWN, DROP_PATTERN_TOPDOWN_R, DROP_PATTERN_REGULAR, DROP_PATTERN_TWO_ROW, DROP_PATTERN_TWO_ROW_R][Random(0, 8)] do
begin
if Slots.Find(Index) <> -1 then
Pattern += Index;
end
Inventory.DropItems(Inventory.ErrorPattern(Pattern, Random(4, 10)));
Result := not Inventory.Contains(TeakLogDTM);
end;
function Woodcutter.ClickTree(): Boolean;
begin
Result := Obj.Click(RSW, TeakTreeTiles, TeakTreeColor, ['Chop', 'Blister', 'wood', 'Tree'], False, 2, False);
if Result then
Wait(3000, 3500);
end;
function Woodcutter.LumberjackUnequipped(): Boolean;
begin
Result := Inventory.Contains(LumberjackHatDTM) or Inventory.Contains(LumberjackTopDTM)
or Inventory.Contains(LumberjackLegsDTM) or Inventory.Contains(LumberjackBootsDTM);
end;
procedure Woodcutter.LumberjackEquip();
var
LumberjackOutfit: TIntArray;
i: Int32;
begin
LumberjackOutfit := [LumberjackHatDTM, LumberjackTopDTM, LumberjackLegsDTM, LumberjackBootsDTM];
For i := 0 to High(LumberjackOutfit) do
begin
if Inventory.Contains(LumberjackOutfit[i]) then
Inventory.MouseSlot(Inventory.FindDTM(LumberjackOutfit[i])[0], Mouse_Left);
end;
Wait(300, 600);
end;
function Woodcutter.GetState(): TState;
begin
if Self.LumberjackUnequipped() then
begin
Action := 'We are not wearing lumberjack outfit. Going to wear it.';
Exit(EQUIP_LUMBERJACK);
end
else if Minimap.WeaponHasSpecialAttack() and (Minimap.GetSpecialAttack() = 100) then
begin
Action := 'Spec bar is full. Going to activate it.';
Exit(SPEC);
end
else if Inventory.IsFull() and Inventory.Contains(TeakLogDTM) then
begin
Action := 'Going to drop logs';
Exit(DROPPING);
end
else if Self.IsCutting() then
begin
Action := 'We are cutting the tree. Waiting';
Exit(WAIT_CUTTING);
end
else if not Inventory.IsFull() then
begin
Action := 'Going to cut the tree';
Exit(CUT_TREE);
end;
end;
procedure Woodcutter.ProcessWhileWaiting(DoAntiBan: Boolean = True);
begin
if GetTickCount() - Self.StatsDebugTick > 1000 then
begin
ClearDebug();
ClearDebug();
WriteLn('+---| STATS |----------------------------------------');
WriteLn('|- Script Runtime : ', SRL.MsToTime(GetTimeRunning, Time_Short));
WriteLn('|- Time Since Break : ', SRL.MsToTime(Wasp.Antiban.TimeSinceBreak(), Time_Short));
WriteLn('|- Action : ', Action);
WriteLn('+----------------------------------------------------');
Self.StatsDebugTick := GetTickCount();
end;
SRL.DismissRandom();
if (DoAntiban and Wasp.Antiban.DoAntiban()) then
Players.GetCurrent()^.Login();
end;
procedure Woodcutter.Init();
begin
{$ifdecl RSClient}
srl.SetupForClient([]);
RSClient.SetFocus();
{$else}
srl.Setup([]);
{$endif}
RSW.InitEx('world', [[5, 3], [5, 4]]);
Self.DeclarePlayers();
Wasp.SetupAntiban(TRAINING_SKILL, RUN_TIME);
Players.LoginCurrent();
Inventory.ShiftDrop := True;
end;
procedure Woodcutter.Run();
begin
MainScreen.SetAngle(True);
while Wasp.Antiban.TimeRunning < (RUN_TIME) do
begin
State := Self.GetState();
Self.ProcessWhileWaiting(True)
case State of
DROPPING: Self.DropLogs();
CUT_TREE: Self.ClickTree();
SPEC: Minimap.ToggleSpecialAttack(True);
WAIT_CUTTING: Wait(2000, 2500);
EQUIP_LUMBERJACK: Self.LumberjackEquip();
end;
if not srl.IsLoggedIn then
Break;
end;
end;
procedure Woodcutter.Free();
begin
RSW.Free();
FreeDTMs([LumberjackHatDTM, LumberjackTopDTM, LumberjackLegsDTM, LumberjackBootsDTM, TeakLogDTM]);
end;
begin
ClearDebug();
Woodcutter.Init();
AddOnTerminate(@Woodcutter.Free);
Woodcutter.Run();
end.