Results 1 to 5 of 5

Thread: [SRL] Hardwood Grove - Teak / Mahogany - Chop & Drop

  1. #1
    Join Date
    Feb 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [SRL] Hardwood Grove - Teak / Mahogany - Chop & Drop

    I don't post very often. Thought I should share something back.

    Information

    - SRL/RSWalker only. Use 1.2+ and latest version of SRL
    - Chops Teak or Mahogany Trees
    - Default to the 3 North Teak Trees
    - Tested in Hardwood Grove, but should work anywhere if you change the tree locations inside DefineTrees. Use SPSToolbox to find new points.
    - Will randomly use special attack if available
    - Drops when inventory is full, or nearly full - uses multiple different patterns, randomly each time and a few custom drop patterns defined.
    - Very AFK, will loose focus regularly, imitates behaviour of someone who watches television
    - Antiban will check Woodcutting exp, take breaks and perform random human behaviour - check SetupAntiban for the full details

    Credit
    Finding Objects Accurately With RSWalker
    Slacky for his public scripts - great examples to work against

    Script

    Simba Code:
    program Chopper;

    {$I SRL/osr.simba}
    {$I SRL/osr/rsclient.simba}
    {$I RSWalker/Walker.simba}

    {==============================================================================]
    | Hardwood Grove Teak's
    |
    | Steps to use:
    |   1. Define the login details if you want to run the script for extended periods
    |   2. Start the script at the 3 north Teak tree's inside of Hardwood Grove
    |   3. Brightness 100% & Medium Zoom; enough to see all trees with space
    |
    [==============================================================================}


    const
      LOGIN_NAME = '';
      LOGIN_PASS = '';
      RS_WORLD = -1; // preferred world, -1 = random world
      MAXRUNTIME = 8; // How long (in hours) to run

    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // BOT

    type
      TWoodcutter = record
        Trees: TPointArray;
        Antiban: TAntiban;
        ShutdownTime: Integer;
        Shutdown: Boolean;
        StatsDebugTick: Int64;
        Action: String;
      end;

    var
      Bot: TWoodcutter;
      Walker: TRSWalker;

    procedure TWoodcutter.DefineTrees()
    begin
    // Define the X/Y locations of the trees you want to focus, by default this
    // focuses on the 3 north teak trees. Change this if you want to chop different
    // trees.
       Self.Trees := [ Point(3118, 4096), Point(3110, 4100), Point(3102, 4096) ];
    end

    const
      TREE_UP_TEXT = 'Chop down Teak';
      DROP_PATTERN_TWO_ROW   = [0,4,1,5,2,6,3,7,8,12,9,13,10,14,11,15,16,20,17,21,18,22,19,23,20,24,25,26,27,28];
      DROP_PATTERN_TWO_ROW_R = [0,4,1,5,2,6,3,7,11,15,10,14,9,13,8,12,16,20,17,21,18,22,19,23,20,24,28,27,26,25];

    var
      LogDTM := DTMFromString('mWAAAAHicY2FgYHBlYmCwAWJPIHYE4udAsWdAfB+I3wDxzjmZDLNbwhm2zExj2L8oh4EYAABiWwtk');

    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // OVERRIDES AND METHODS FOR FATIGUE

    procedure WaitFatigue(t: Double; Exp: Double=0.2);
    begin
      System.Wait(Trunc(2*t * (1-Power(System.Max(0.0001, Bot.Antiban.EnergyLevel()/100),Exp))));
    end;

    procedure Wait(min, max:Double; weight:EWaitDir=wdMean); override;
    var t: Double;
    begin
      t := PerformanceTimer();
      inherited(min, max, weight);
      WaitFatigue(PerformanceTimer()-t);
    end;

    procedure WaitEx(mean, dev:Double); override;
    var t: Double;
    begin
      t := PerformanceTimer();
      inherited(mean, dev);
      WaitFatigue(PerformanceTimer()-t);
    end;

    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // WOODCUTTER

    procedure TWoodcutter.DeclarePlayers();
    begin
      with Players.New()^ do
      begin
        LoginName  := LOGIN_NAME;
        Password   := LOGIN_PASS;
        IsActive   := True;
        IsMember   := True;
        World      := RS_WORLD;
      end;
      Players.SetCurrent(0);
    end;

    procedure TWoodcutter.SpecialAttack(max: Integer = 30);
    begin
      if Minimap.GetSpecialAttack() = 100 then
          if Random(0, max) < 5 then
             Combat.UseSpecialAttack()
    end

    procedure TWoodcutter.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(Self.Antiban.TimeSinceBreak(), Time_Short));
        WriteLn('|- Energy Level      : ', Round(Self.Antiban.EnergyLevel,2));
        WriteLn('|- Action            : ', Action);
        WriteLn('+----------------------------------------------------');
        Self.StatsDebugTick := GetTickCount();
      end;
      SRL.DismissRandom();
      if DoAntiban and Self.Antiban.DoAntiban() then
        Players.GetCurrent()^.Login();
      Self.SpecialAttack(10000);
    end;

    function TWoodcutter.Find(Color: TCTS2Color; Location: TPointArray; MinCount: Int32=100; SplitDist: Int32=8; DoSort: Boolean=True; Expand:Int32=0): TRectArray;
    var
      L, me: TPoint;
      Rect: TRectangle;
      locations, TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      me := Walker.GetMyPos();
      locations := Copy(Location);
      if DoSort then Locations.Sorted(me);

      for L in Locations do
      begin
        Rect := Walker.GetTileMsEx(me, L, Random(5, 10)).Expand(Expand);
        if MainScreen.GetBounds.Contains(Rect.Bounds) then
        begin
          if (SRL.FindColors(TPA, Color, Rect.Bounds) < MinCount) then
            Continue;

          if (SplitDist > 0) then
          begin
            TPA  := Rect.Filter(TPA);
            ATPA := TPA.Cluster(SplitDist);
            SortATPAFromSize(ATPA, 0, False);
            if Length(ATPA) > 0 then
              Result += ATPA[0].MinAreaRect;
          end else
            Result += Rect;
        end;
      end;
    end;

    function TWoodcutter.FindTree(): TRectArray;
    var
      RandomTrees: TPointArray;
    begin
      RandomTrees := [Self.Trees[Random(0,Length(Self.Trees)-1)], Self.Trees[Random(0,Length(Self.Trees)-1)], Self.Trees[Random(0,Length(Self.Trees)-1)]];
      RandomTrees.Sort(Walker.GetMyPos);
      Result := Find(CTS2(3827067, 28, 0.03, 0.41), RandomTrees, 100, 30, True, 10);
    end;

    function TWoodcutter.IsChopping(): Boolean;
    begin
      Result := SRL.IsAnimating(MainScreen.GetPlayerBox, 300, 350)
    end;

    function TWoodcutter.Chop()  : Boolean;
    var
      TreeRectangles: array of TRectangle;
      Tree: TRectangle;
    begin

      TreeRectangles := Self.FindTree();

      Action := "Searching for Tree";

      for Tree in TreeRectangles do
      begin
        Mouse.Move(Tree);
        if not MainScreen.IsUpText(TREE_UP_TEXT) then
          Continue;

        Self.Action := "Found tree";
        Self.ProcessWhileWaiting(False);

        if Mouse.Click(ctRed) then
        begin

          Wait(700,1000);
          Minimap.WaitPlayerMoving();
          Wait(1400,1700);

          while Self.IsChopping() do
          begin
            Self.Action := "Chopping";
            Self.ProcessWhileWaiting();
            Chatbox.HandleLevelUp();
            WaitEx(100,10);
          end;

           WaitEx(5000, 2000);

          Exit(True);
        end else
        begin

          Self.Action := "Missed tree, will try again";
          Self.ProcessWhileWaiting(False);

          Wait(700,1200);
          Minimap.WaitPlayerMoving();
          Wait(700,1200);
          Exit(False);
        end;
      end;

    end;

    procedure TWoodcutter.DropItems()
    var
      Pattern, DTMS, Slots: TIntArray;
      Index, DTM: Int32;
    begin

      SRL.SetFocus();

      Action := "Dropping Logs";
      Self.ProcessWhileWaiting(False);

      DTMS := [ LogDTM ];

      for DTM in DTMS do
        Slots += Inventory.FindDTM(DTM);

      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)));

    end

    procedure TAntiban.RandomMouse();
    begin
      DebugNote('[RND] Random Mouse');
      Mouse.Move(SRL.RandomPoint(Mainscreen.GetBounds));
      WaitEx(7000, 2000);
    end;

    procedure TWoodcutter.SetupAntiban();
    begin
      Self.Antiban.Init(SKILL_WOODCUTTING, 4);

      Self.Antiban.AddTask([@Antiban.LoseFocus,         ONE_MINUTE*3]);
      Self.Antiban.AddTask([@Antiban.HoverPlayers,      ONE_MINUTE*9]);
      Self.Antiban.AddTask([@Antiban.CheckSkill,        ONE_MINUTE*9]);
      Self.Antiban.AddTask([@Antiban.OpenRandomTab,     ONE_MINUTE*33]);
      Self.Antiban.AddTask([@Antiban.RandomCompass,     ONE_MINUTE*19]);
      Self.Antiban.AddTask([@Antiban.CheckStats,        ONE_MINUTE*12]);
      Self.Antiban.AddTask([@Antiban.VeryShortBreak,    ONE_MINUTE*25]);
      Self.Antiban.AddTask([@Antiban.DoMiscStuff,       ONE_MINUTE*24]);

      Self.Antiban.AddBreak([50 * ONE_MINUTE, 05 * ONE_MINUTE, 0.05]);
      Self.Antiban.AddBreak([02 * ONE_HOUR,   15 * ONE_MINUTE, 0.15]);
      Self.Antiban.AddBreak([04 * ONE_HOUR,   50 * ONE_MINUTE, 0.85]);
      Self.Antiban.AddBreak([16 * ONE_HOUR,   09 * ONE_HOUR,   0.99]);

    end;

    procedure Free()
    begin
       FreeDTMs([LogDTM]);
    end

    function Inventory.IsFullOrNearlyFull(): Boolean;
    begin
       Result := Self.IsFull() or (Self.Count < Random(20, 28));
    end

    procedure TWoodcutter.Run();
    begin

      Repeat

        if Inventory.IsFull() then
          Self.DropItems()
        else
          Self.Chop()

        if (getTimeRunning() > Self.ShutdownTime) then
        begin
          Self.Shutdown := True;
        end;

        Players.GetCurrent()^.Login();

        Self.ProcessWhileWaiting(False);

      Until(Self.Shutdown);

    end

    procedure TWoodcutter.Init();
    begin

      Inventory.ShiftDrop := True;

      Walker.Init("world.png");
      Self.DefineTrees();
      Action := "Initialising";

      Self.SetupAntiban();
      Self.DeclarePlayers();
      Players.LoginCurrent();

      Self.Shutdown := False;
      Self.ShutdownTime := (MAXRUNTIME*3600000)-(MAXRUNTIME*360000);

    end

    begin

      AddOnTerminate(@Free);
      AddOnTerminate(@Walker.Free);

      {$ifdecl RSClient}
      RSClient.SetFocus();
      {$endif}

      Bot.Init();
      Bot.Run();

    end.

    WARNING: Use at your own risk.
    Last edited by ollie; 04-13-2019 at 05:39 PM. Reason: Breaks

  2. #2
    Join Date
    Feb 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Recent Run

    +---| STATS |----------------------------------------
    |- Script Runtime : 07h 12m 05s
    |- Time Since Break : 14m
    |- Energy Level : 77.82
    |- Action : Chopping
    +----------------------------------------------------

  3. #3
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,180
    Mentioned
    112 Post(s)
    Quoted
    1849 Post(s)

    Default

    Congrats on the release
    GitLab projects | Simba for Linux | Find me on IRC or Discord | OSRS scripts | Come play ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

  4. #4
    Join Date
    Feb 2012
    Posts
    172
    Mentioned
    2 Post(s)
    Quoted
    82 Post(s)

    Default

    Thanks for sharing this with us, ran it for 30 minutes and it worked great!

  5. #5
    Join Date
    Jul 2018
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks dude! I'll use it soon! Do you give me the permission to modify it to my needs?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •