Results 1 to 10 of 10

Thread: [First Script] tWillows [would love advice, opinions, and assistance]

  1. #1
    Join Date
    Jan 2012
    Posts
    246
    Mentioned
    3 Post(s)
    Quoted
    91 Post(s)

    Post [First Script] tWillows [would love advice, opinions, and assistance]

    Hey guys, first script here. It's currently not functional, it'll walk to willows, detect the color for the tree, and click, but then it quits. I'm posting it here so hopefully I can get some good advice on how to make it functional. Maybe I don't have enough specific colors because after it clicks the first willow, it doesn't detect another one. I believe I may have fixed that by adding repeat...until in the main loop, but when it runs the next procedure (runToDepositBox(); ), it clicks on the 'HERO' menu rather than walking to the box. Do I need to change the SPS path to make it functional? I used the same points that I did to walk from the DepositBox and it'll correctly walk to the trees. It also doesn't have any angle changes or antiban. Any advice would be greatly, greatly appreciated. Big thanks to @KeepBotting for helping me out over Skype whenever I had any questions and to @The Mayor for his beginners tutorials.

    Simba Code:
    program tWillows;

    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    {$I SPS/lib/SPS-RS3.Simba}

    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := 'UN';
        password := 'PW';
        isActive := true;
        isMember := false;
      end
      currentPlayer := 0;
    end;

    procedure runToWillows();
    var
       pathToWillows: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      pathToWillows := [Point(197, 181), Point(179, 183), Point(167,163), Point(171, 138), Point(194, 134), Point(217, 125), Point(235,112), Point(254,100)];

      if SPS.walkPath(pathToWillows) then
        minimap.waitPlayerMoving()
      else
        writeLn('We failed to walk to the Willows');

    end;

    procedure clickWillowTree();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;

    begin
      if not isLoggedIn() then
        exit;

      findColorsSpiralTolerance(x, y, TPA, 1582627, mainScreen.getBounds(), 3, colorSetting(2, 0.67, 0.41));

      if (Length(TPA) < 1) then
        exit;

      ATPA := TPA.toATPA(30, 30);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);

      for i := 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['illow'], 500) then
        begin
        repeat
          fastClick(MOUSE_LEFT);
          wait(10000);
          until tabBackPack.isFull();
        end;
      end;

    end;

    procedure runToDepositBox();
    var
       pathToDepositBox: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      pathToDepositBox := [Point(254, 100), Point(235, 112), Point(217,125), Point(194, 134), Point(171, 138), Point(167, 163), Point(179,183), Point(197,181)];

      if SPS.walkPath(pathToDepositBox) then
        minimap.waitPlayerMoving()
      else
        writeLn('We failed to walk to the Deposit Box');

    end;

    procedure findDepositBox();
    var
      x, y, i: integer;
    begin
      if not isLoggedIn() then
        exit;

      repeat
        mainscreen.findObject(x, y, 4084066, 7, colorSetting(2, 0.06, 0.19), mainscreen.playerPoint, 30, 50, 50, ['eposit', 'box'], MOUSE_LEFT);
        wait(randomRange(1000, 2000));
        inc(i);
      until depositBox.isOpen() or (i >= 15);
    end;

    procedure depositWillows();
    var
      bankTimer: TTimeMarker;

    begin
      if not isLoggedIn() then
        exit;

      if depositBox.isOpen() then
      begin

        bankTimer.start();

        repeat
          if (depositBox.count > 0) then
          begin
            depositBox.quickDeposit(QUICK_DEPOSITBOX_INVENTORY);
            wait(gaussRangeInt(500, 750));
          end;
        until(depositBox.isEmpty()) or (not isLoggedIn()) or (bankTimer.getTime() > 10000);

      end;

      depositBox.close();

    end;

    {Main Loop}
    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();

       SPS.setup('SarimWillows', RUNESCAPE_OTHER);  // Setup our map

      if not isLoggedIn() then
      begin
        players[currentPlayer].login();
        exitTreasure();
        mainScreen.setAngle(MS_ANGLE_HIGH);
        minimap.setAngle(MM_DIRECTION_NORTH);
      end;

      repeat
        runToWillows();
        repeat
          clickWillowTree();
          until tabBackPack.isFull();
        runToDepositBox();
        findDepositBox();
        depositWillows();

      until false;

    end.

    An image is included at the bottom. Needs to be saved in RUNESCAPE_OTHER.

    A copy of the script is also available.
    Attached Images Attached Images

  2. #2
    Join Date
    Nov 2014
    Posts
    44
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    I am also a new scripter and here are some comments after reading your script:

    Simba Code:
    exitSquealOfFortune();
    should be replaced by
    Simba Code:
    exitTreasure();
    since Squeal of Fortune does not exist anymore.


    Simba Code:
    procedure clickWillowTree();
    var
      x, y: integer; //we need to declare these variables since findObject outputs these
    begin
      if mainscreen.findObject(x, y, 1516577, 4, ['illow'], MOUSE_RIGHT) then
      begin
        writeLn('We right clicked a tree!'); //if findObject results true, this will print
        chooseOption.select(['hop down']); // this will choose ‘Chop down’ option in chooseOptions menu
      end;
      tabBackpack.waitForShift(5000);
    end;
    I think you can refer to The Mayor's tutorial about ACA. It will be better to click on the nearest tree instead of randomly picking a tree of correct colur. (Script below is copied from the tutorial. Please change accordingly)
    Simba Code:
    procedure findColorz();
    var
      x, y: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      findColorsSpiralTolerance(x, y, TPA, 5644066, mainScreen.getBounds(), 10, colorSetting(2, 0.10, 1.02));

      if length(TPA) < 1 then
        exit;

      ATPA := TPA.toATPA(30, 30);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);

      smartImage.debugATPA(ATPA);
    end;

    for i := 0 to high(ATPA) do
    begin
      mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
      if isMouseOverText(['illow'], 1000) then
        fastClick(MOUSE_LEFT);
    end;

    Will try to run the script after I get 30 WC haha.

  3. #3
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by Theron View Post
    Hey guys, first script here. It's currently not functional, it'll walk to willows, detect the color for the tree, and click, but then it quits. I'm posting it here so hopefully I can get some good advice on how to make it functional. Maybe I don't have enough specific colors because after it clicks the first willow, it doesn't detect another one...
    Quote Originally Posted by boscolamhk View Post
    Simba Code:
    if mainscreen.findObject(x, y, 1516577, 4, ['illow'], MOUSE_RIGHT) then
    I think you can refer to The Mayor's tutorial about ACA. It will be better to click on the nearest tree instead of randomly picking a tree of correct colur. (Script below is copied from the tutorial. Please change accordingly)
    The call to findObject he used will search from the playerpoint out. You can check out the code in SIBMADIR\Includes\SRL-6\lib\interfaces\mainscreen.simba

    The script looks good. Simple, clean, organized. You should probably think of any options you might want to support over time and add calls the the SRL player form instead of filling player info in manually in the script.

    Other than that one goal would be to add failsafes everyplace it might fail. Don't check one thing, check three. And humanize it. Record a session where you do them by hand and look for things you might add to the script. Misclicks, occasional delays, whatever makes it less botty.

    Here's a willow finder I had in my code stash. I don't know if it still works. Log in near some willows and run it. Push the disable smart button and you can move around and see what it would find.

    Simba Code:
    program willow
    {$DEFINE SMART}
    {$include_once srl-6/srl.simba}

    const
       colList = [2504767,2902350,
          2574671,2769735,2901835,2703172,
          2570554,2967374,2505279,3033166,
          3231315,2502959,3032907,2439229,
          2637124,2702917,2504765,2571071,
          2437944,2372407,2504250,2438973,
          2637121,2570557,2571075,2637634,
          2571841,2703428,2571329,2504764,
          2702915,2570556,2768707,2637377,
          2572353,2572355,2373174,2636863,
          2570297,2636091,2504507,2572098,
          2570303,2571584,2504760,2571324,
          2504504,2505017];
         
    var
       cdata: T2DColorData;
       i: integer;
       tpa: TPointArray;
       atpa: T2DPointArray;
       
    begin
       smartEnableDrawing := true;
       setupSRL();
       
       setLength(cdata, length(colList));
       for i := 0 to high(cdata) do
          with cdata[i] do
          begin
             color := colList[i];
             tolerance := 0;
             settings := colorSetting(0);
          end;
       
       while (true) do
       begin
          cdata.gatherIn(tpa, mainscreen.getBounds());
          atpa := tpa.cluster(20);
          atpa.filterBetween(0, 40);
          atpa.filterBetween(400, maxint);
          smartImage.debugATPA(atpa);
          for i := 0 to high(atpa) do
             writeln('len atpa[', i, '] is ', length(atpa[i]));
          sleep(1000);
          smartImage.clear();
       end;
    end.

  4. #4
    Join Date
    Jan 2012
    Posts
    246
    Mentioned
    3 Post(s)
    Quoted
    91 Post(s)

    Default

    Quote Originally Posted by bonsai View Post
    The call to findObject he used will search from the playerpoint out. You can check out the code in SIBMADIR\Includes\SRL-6\lib\interfaces\mainscreen.simba

    The script looks good. Simple, clean, organized. You should probably think of any options you might want to support over time and add calls the the SRL player form instead of filling player info in manually in the script.

    Other than that one goal would be to add failsafes everyplace it might fail. Don't check one thing, check three. And humanize it. Record a session where you do them by hand and look for things you might add to the script. Misclicks, occasional delays, whatever makes it less botty.

    Here's a willow finder I had in my code stash. I don't know if it still works. Log in near some willows and run it. Push the disable smart button and you can move around and see what it would find.

    Simba Code:
    program willow
    {$DEFINE SMART}
    {$include_once srl-6/srl.simba}

    const
       colList = [2504767,2902350,
          2574671,2769735,2901835,2703172,
          2570554,2967374,2505279,3033166,
          3231315,2502959,3032907,2439229,
          2637124,2702917,2504765,2571071,
          2437944,2372407,2504250,2438973,
          2637121,2570557,2571075,2637634,
          2571841,2703428,2571329,2504764,
          2702915,2570556,2768707,2637377,
          2572353,2572355,2373174,2636863,
          2570297,2636091,2504507,2572098,
          2570303,2571584,2504760,2571324,
          2504504,2505017];
         
    var
       cdata: T2DColorData;
       i: integer;
       tpa: TPointArray;
       atpa: T2DPointArray;
       
    begin
       smartEnableDrawing := true;
       setupSRL();
       
       setLength(cdata, length(colList));
       for i := 0 to high(cdata) do
          with cdata[i] do
          begin
             color := colList[i];
             tolerance := 0;
             settings := colorSetting(0);
          end;
       
       while (true) do
       begin
          cdata.gatherIn(tpa, mainscreen.getBounds());
          atpa := tpa.cluster(20);
          atpa.filterBetween(0, 40);
          atpa.filterBetween(400, maxint);
          smartImage.debugATPA(atpa);
          for i := 0 to high(atpa) do
             writeln('len atpa[', i, '] is ', length(atpa[i]));
          sleep(1000);
          smartImage.clear();
       end;
    end.
    SO I should replace my clickWillows(); procedure with the code you provided and it should detect easier? Also whenever it gets a full ivnentory, and tries to walk to the depositbox, it clicks on the 'hero' menu, is that most likely caused because I have a bad points selected as the path?

  5. #5
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Theron View Post
    SO I should replace my clickWillows(); procedure with the code you provided and it should detect easier? Also whenever it gets a full ivnentory, and tries to walk to the depositbox, it clicks on the 'hero' menu, is that most likely caused because I have a bad points selected as the path?
    walkPath should never click outside the MM bounds. Most likely an interface issue? I just gave it a run, it finds willows ok, and it walks ok, but it couldn't find the deposit box as the colours were bad The most botty thing is it clicks the tree each time it gets a log. You should so something like the waiting(); procedure at the bottom of this post.

  6. #6
    Join Date
    Jan 2012
    Posts
    246
    Mentioned
    3 Post(s)
    Quoted
    91 Post(s)

    Default

    @NKN

    I'd love your opinion please.

  7. #7
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by Theron View Post
    @NKN

    I'd love your opinion please.
    I'll look at it tomorrow.

    Quote this post sometime so I don't forget.

  8. #8
    Join Date
    Jan 2012
    Posts
    246
    Mentioned
    3 Post(s)
    Quoted
    91 Post(s)

    Default

    Quote Originally Posted by NKN View Post
    I'll look at it tomorrow.

    Quote this post sometime so I don't forget.
    nkn.

  9. #9
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Alright here's what I see.


    You click the willow tree every log. You should click it once until the tree is gone, or you stop chopping for some other reason.

    And to provide a safer, more streamlined script, I'd advise making your procedures functions that return boolean.


    For instance, here
    Simba Code:
    procedure runToDepositBox();
    var
       pathToDepositBox: TPointArray;
    begin
      if not isLoggedIn() then
        exit;

      pathToDepositBox := [Point(254, 100), Point(235, 112), Point(217,125), Point(194, 134), Point(171, 138), Point(167, 163), Point(179,183), Point(197,181)];

      if SPS.walkPath(pathToDepositBox) then
        minimap.waitPlayerMoving()
      else
        writeLn('We failed to walk to the Deposit Box');

    end;


    What if that writeln was replaced with
    Simba Code:
    result := false;

    You can then do something like

    Simba Code:
    if(runToDepositBox) then
      depositWillows();

    I find that structuring things like that helps scripts flow and run much longer than a straight linear pathing.

  10. #10
    Join Date
    Jan 2012
    Posts
    246
    Mentioned
    3 Post(s)
    Quoted
    91 Post(s)

    Default

    Updated colors on deposit box and changed how it detects willows, having issues with creating a waiting procedure while cutting willows, also having issues with detecting when the inventory is full.

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
  •