Results 1 to 11 of 11

Thread: Draynor Willows Attempt #1

  1. #1
    Join Date
    Nov 2012
    Posts
    161
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default Draynor Willows Attempt #1

    Hi Everyone,

    Thank you in advance for any advice.

    Want to thank @TheMayor for literally 99.99% of the code herein.

    What I'm having trouble with:
    1) Can't get mainscreen.findObject function to recognize the colors I have picked using the aca remake cts2 setting.
    see below for aca screen:
    pic1.PNG

    2) Because of that I decided to use the minimap fishpoint to get to the cutting spot from the bank and then use simple tboxes on each of the 4 trees. Right now, the script will walk to fish spot, move the mouse to the first tree and cut. But I want it to recognize when a log hasn't been cut for 5 seconds and use an if statement to move to the next tree (tboxB), if it finds a tree there w mouseovertext I would like it to cut that tree then move to the next until full then head back to the bank.

    My questions are:
    A) Why aren't my colors working? getting the error that no colors matching were found. How can the colors not match?

    B)I need help with nesting if statements in the final loop.

    C) Can I also use a DTM for the trees and order them from 1st to last? (i.e. 5 dtms, 1 per tree)or would the collection of colors not differentiate one tree from another?

    D) Do you think SPS walking is necessary? Is there anyway to randomize even more the minimap clicks from minimap.findsymbol function?


    I'm doing this script to learn so I don't release some horrible code and everyone who tries it on the public forum gets banned

    Below is the code so far, feel free to take a look:

    Code:
    program new;
    //{$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    {$I SPS/lib/SPS-RS3.Simba}
    {$I srl-6/lib/misc/srlplayerform.simba}
    
    {const     //copied from Evergreens script
    
      TREE_COL = 2438970;
      TREE_TOL = 3;
      TREE_HUE = 0.32;
      TREE_SAT = 0.57;}
    
    
    var
      fishPoint: Tpoint;
    
    
    procedure getToFishSpot();
    begin
      minimap.findSymbol(fishPoint, MM_SYMBOL_FISHING, minimap.getBounds());
      mouse(fishPoint, MOUSE_LEFT);
      wait(randomRange(10000,15000));
    end;
    
    {procedure cutWillow();
    var
      x, y: integer;
      begin
      if mainscreen.findObject(x,y, 2966076, 8, ['illow'], MOUSE_RIGHT) then
      begin
      writeLn('Clicked Tree');
      chooseOption.select(['hop down']);
     end
    end;}
    
    procedure lookBoxA();
    var
    boxA: Tbox;
    begin
      boxA := intToBox(187,20, 206,42);
      mouseBox(boxA, MOUSE_MOVE);
    end;
    
    procedure findWillows;
    var
      x, y: integer;
    begin
      if
      isMouseOverText(['hop down']) then
      fastClick(MOUSE_LEFT);
      //tabBackPack.waitForShift(5000);
      end;
    
    procedure lookBoxB();
    var
    boxB: Tbox;
    begin
      boxB := intToBox(258,100,272,108);
      mouseBox(boxB, MOUSE_MOVE);
    end;
    
    
    begin
      clearDebug();
      getToFishSpot();
      lookBoxA();
      findWillows();
      lookBoxB();
      findWillows();
    
      repeat
        findWillows();
        until tabBackPack.waitForShift(5000);
    
    end.

  2. #2
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    Simba Code:
    {const     //copied from Evergreens script

      TREE_COL = 2438970;
      TREE_TOL = 3;
      TREE_HUE = 0.32;
      TREE_SAT = 0.57;}

    I don't think you need this because
    A - you don't have anything using a const
    B - you don't have a TPA which is what i'm pretty sure these variables are for

    I would advise using TPAs because from what it looks like you have some basic object finding functions. When using ACA you find variables used for TPAs. If you want to find values to use for findobj I would suggest getting them from the DTM function in Simba.
    You have permission to steal anything I've ever made...

  3. #3
    Join Date
    Nov 2012
    Posts
    161
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    Quote Originally Posted by Wu-Tang Clan View Post
    Simba Code:
    {const     //copied from Evergreens script

      TREE_COL = 2438970;
      TREE_TOL = 3;
      TREE_HUE = 0.32;
      TREE_SAT = 0.57;}

    I don't think you need this because
    A - you don't have anything using a const
    B - you don't have a TPA which is what i'm pretty sure these variables are for

    I would advise using TPAs because from what it looks like you have some basic object finding functions. When using ACA you find variables used for TPAs. If you want to find values to use for findobj I would suggest getting them from the DTM function in Simba.
    Thanks! I will try to implement some TPA's in the morning. For now, I have fixed it so it runs from bank to willows, cuts using color. But I'm using the function tabBackPack.waitForShift(10000); but it doesn't seem to be waiting 10 seconds between running my chopping wood procedure. It also runs till inventory full. Any advice on fixing the timing of how it waits between looking for another tree? is the tabbackpack time random? Need to write another procedure to run back to bank and bank. Here's the new code:
    Code:
    program new;
    //{$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    {$I SPS/lib/SPS-RS3.Simba}
    {$I srl-6/lib/misc/srlplayerform.simba}
    
    
    var
      fishPoint: Tpoint;
    
    
    procedure getToFishSpot();
    begin
      minimap.findSymbol(fishPoint, MM_SYMBOL_FISHING, minimap.getBounds());
      mouse(fishPoint, MOUSE_LEFT);
      wait(randomRange(5000,12000));
    end;
    
    procedure cutWillow();
    var
      x, y: integer;
    begin
    
        if mainscreen.findObject(x,y, 2768196,3,['illow'], MOUSE_RIGHT) then
        begin
        writeLn('Clicked Tree');
        chooseOption.select(['hop down']);
        tabBackPack.waitForShift(10000);
    
       end;
    end;
    
    
    
    begin
      clearDebug();
      setupSRL();
      getToFishSpot();
      cutWillow();
    
      repeat
        cutWillow();
        until tabBackPack.isFull();
    
    
    end.

  4. #4
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Quote Originally Posted by nkd2009 View Post
    Thanks! I will try to implement some TPA's in the morning. For now, I have fixed it so it runs from bank to willows, cuts using color. But I'm using the function tabBackPack.waitForShift(10000); but it doesn't seem to be waiting 10 seconds between running my chopping wood procedure. It also runs till inventory full. Any advice on fixing the timing of how it waits between looking for another tree? is the tabbackpack time random? Need to write another procedure to run back to bank and bank. Here's the new code:
    Code:
    program new;
    //{$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    {$I SPS/lib/SPS-RS3.Simba}
    {$I srl-6/lib/misc/srlplayerform.simba}
    
    
    var
      fishPoint: Tpoint;
    
    
    procedure getToFishSpot();
    begin
      minimap.findSymbol(fishPoint, MM_SYMBOL_FISHING, minimap.getBounds());
      mouse(fishPoint, MOUSE_LEFT);
      wait(randomRange(5000,12000));
    end;
    
    procedure cutWillow();
    var
      x, y: integer;
    begin
    
        if mainscreen.findObject(x,y, 2768196,3,['illow'], MOUSE_RIGHT) then
        begin
        writeLn('Clicked Tree');
        chooseOption.select(['hop down']);
        tabBackPack.waitForShift(10000);
    
       end;
    end;
    
    
    
    begin
      clearDebug();
      setupSRL();
      getToFishSpot();
      cutWillow();
    
      repeat
        cutWillow();
        until tabBackPack.isFull();
    
    
    end.
    it isn't waiting the whole 10 seconds because your backpack changes within those 10 seconds (you cut down a log)
    Simba Code:
    (*
    waitForShift
    ------------

    .. code-block:: pascal

        function TRSTabBackPack.waitForShift(waitTime: integer): boolean;

    Returns true if the backpack count changes within **waitTime**

    .. note::

        - by Olly
        - Last Updated: 29 July 2013 by Olly

    Example:

    .. code-block:: pascal

       if tabBackpack.waitForShift(5000) then
         writeln('Backpack count has changed!');

    *)


    function TRSTabBackpack.waitForShift(waitTime: integer): boolean;
    var
      c: integer;
      timeOut : LongWord;
    begin
      result := false;
      c := self.count();
      timeOut := getSystemTime() + waitTime;

      while (timeOut >= getSystemTime()) do
        if (c <> self.count()) then
          exit(true)
        else
          wait(20 + random(50));
    end;

    Looks like it breaks out if backpack item count changes

  5. #5
    Join Date
    Nov 2012
    Posts
    161
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    Quote Originally Posted by jstemper View Post
    it isn't waiting the whole 10 seconds because your backpack changes within those 10 seconds (you cut down a log)
    Simba Code:
    (*
    waitForShift
    ------------

    .. code-block:: pascal

        function TRSTabBackPack.waitForShift(waitTime: integer): boolean;

    Returns true if the backpack count changes within **waitTime**

    .. note::

        - by Olly
        - Last Updated: 29 July 2013 by Olly

    Example:

    .. code-block:: pascal

       if tabBackpack.waitForShift(5000) then
         writeln('Backpack count has changed!');

    *)


    function TRSTabBackpack.waitForShift(waitTime: integer): boolean;
    var
      c: integer;
      timeOut : LongWord;
    begin
      result := false;
      c := self.count();
      timeOut := getSystemTime() + waitTime;

      while (timeOut >= getSystemTime()) do
        if (c <> self.count()) then
          exit(true)
        else
          wait(20 + random(50));
    end;

    Looks like it breaks out if backpack item count changes
    Good call, thank you.
    Ok so within this procedure:
    Code:
    procedure cutWillow();  //cuts willows
    var
      x, y: integer;
    begin
        if mainscreen.findObject(x,y, 2768196,3,['illow'], MOUSE_RIGHT) then
        begin
        writeLn('Clicked Tree');
        chooseOption.select(['hop down']);
        //tabBackPack.waitForShift(10000);
        wait(randomRange(300,400));
        end;
          begin;
            if (mainScreen.isPlayerAnimating(200)) then
            wait(randomRange(12000,15000));
          end;
        end;
    1) I am using the .isplayeranimating (see above snippet) with a threshold of 200 which seems to be working however I would like to adjust it to not wait a random range after it checks if the player is animating but say if player is NOT animating, then .tabbackpack full check, and then repeat chopping procedure. It seems like the function isplayeranimating when used in a procedure only returns a true result and I'm not sure how to negate it to do the opposite. do I need to change the procedure to a function and use a Boolean true/false to get that?

    2) I am also having trouble with my loop. it can start in bank or willows, clicks minimap willows, chops, runs to bank, deposits and then just doesn't know what to do. Why doesn't it repeat the main loop and go back to willows after finddepositbox procedure is complete?

    3) how can I randomize this function (using it in procedure gettofishspot() so it doesn't click nearly the same exact spot. can I just add a var x y and then adjust the end of the function? sorry, don't really know how to describe this.

    minimap.findSymbol(fishPoint, MM_SYMBOL_FISHING, minimap.getBounds());

    full code below:
    Code:
    program new;
    //{$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    {$I SPS/lib/SPS-RS3.Simba}
    {$I srl-6/lib/misc/srlplayerform.simba}
    
    
    var
      fishPoint: Tpoint;    //Tpoint var to get to trees using mm symbol
      bankPoint: Tpoint;    //Tpoint var to get to bank using mm symbol
    
    
    procedure getToFishSpot();     //runs to trees, waits max of 12 seconds to get there
    begin
      minimap.findSymbol(fishPoint, MM_SYMBOL_FISHING, minimap.getBounds());
      mouse(fishPoint, MOUSE_LEFT);
      wait(randomRange(8000,12000));
    end;
    
    procedure cutWillow();  //cuts willows
    var
      x, y: integer;
    begin
        if mainscreen.findObject(x,y, 2768196,3,['illow'], MOUSE_RIGHT) then
        begin
        writeLn('Clicked Tree');
        chooseOption.select(['hop down']);
        //tabBackPack.waitForShift(10000);
        wait(randomRange(300,400));
        end;
          begin;
            if (mainScreen.isPlayerAnimating(200)) then
            wait(randomRange(12000,15000));
          end;
        end;
    
    procedure runToBank();   //runs to bank
    begin
    wait(randomRange(2000,3000));
    minimap.findSymbol(bankPoint, MM_SYMBOL_BANK, minimap.getBounds());
    mouse(bankPoint, MOUSE_LEFT);
    //wait(randomRange(12000, 14000));
    if minimap.waitPlayerMoving() then
      writeLn('We are no longer moving');
    end;
    
    
    procedure findDepositBox();   //uses deposit box
    var
      x, y, i: integer;
    begin
      if not isLoggedIn() then
        exit;
    
      repeat
      if minimap.waitPlayerMoving() then
      writeLn('We are no longer moving');
      wait(randomRange(1000, 2000));
        mainscreen.findObject(x, y, 9593499, 27, colorSetting(2, 0.88, 0.10), mainscreen.playerPoint, 30, 50, 50, ['eposit', 'box'], MOUSE_LEFT);
        wait(randomRange(1000, 2000));
        inc(i);
      until depositBox.isOpen() or (i >= 15);
      depositBox.quickDeposit(QUICK_DEPOSITBOX_INVENTORY);
      depositBox.close();
    end;
    
    
    
    begin             //main loop
      clearDebug();
      setupSRL();
      getToFishSpot();
      cutWillow();
    
    repeat
    
      repeat
        cutWillow();
        until tabBackPack.isFull();
        runToBank();
        findDepositBox();
     until false;
    
    
    end.

  6. #6
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Quote Originally Posted by nkd2009 View Post

    1) I am using the .isplayeranimating (see above snippet) with a threshold of 200 which seems to be working however I would like to adjust it to not wait a random range after it checks if the player is animating but say if player is NOT animating, then .tabbackpack full check, and then repeat chopping procedure. It seems like the function isplayeranimating when used in a procedure only returns a true result and I'm not sure how to negate it to do the opposite. do I need to change the procedure to a function and use a Boolean true/false to get that?
    Simba Code:
    if (Mainscreen.isPlayerAnimating(200)) then
      //this will happen if statement is true
    else
      //this will happen if statement is false

    Quote Originally Posted by nkd2009 View Post
    2) I am also having trouble with my loop. it can start in bank or willows, clicks minimap willows, chops, runs to bank, deposits and then just doesn't know what to do. Why doesn't it repeat the main loop and go back to willows after finddepositbox procedure is complete?
    this is the code that gets executed. notice getToFishSpot() is not in any repeat blocks

    Simba Code:
    begin
      clearDebug();
      setupSRL();
      getToFishSpot();
      cutWillow();
      repeat
        repeat
          cutWillow();
        until (tabBackPack.isFull());
        runToBank();
        findDepositBox();
      until (false);
    end.

    Quote Originally Posted by nkd2009 View Post
    3) how can I randomize this function (using it in procedure gettofishspot() so it doesn't click nearly the same exact spot. can I just add a var x y and then adjust the end of the function? sorry, don't really know how to describe this.
    You should be able to randomize it like this or something similar
    Simba Code:
    mouse(Point(fishPoint.x + RandomRange( - 5, 5), fishPoint.y + RandomRange( - 5, 5)), MOUSE_LEFT);

  7. #7
    Join Date
    Nov 2012
    Posts
    161
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    Awesome, loop is fixed. thank you!!

    [QUOTE=jstemper;1382396]
    Simba Code:
    if (Mainscreen.isPlayerAnimating(200)) then
      //this will happen if statement is true ***want this to be "do nothing until not animating, else chop"***
    else
      //this will happen if statement is false

    That helps but I still cannot think of how to say, if the player is animating THEN do nothing UNTIL player not animating, then cut willows again. This is an issue because trees can either last 1 log or 10 logs depending on world just length of time the tree lasts randomly. How do you say do nothing, no action until the animating stops? if I keep it the way it is, after the animating process stops, it will continue to wait? correct? maybe I'm misunderstanding how the function works and what my wait time actually does? seems like I need an inverse of the function..

  8. #8
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    Quote Originally Posted by nkd2009 View Post
    How do you say do nothing
    wait()

    wait(100); //this would wait for 100 ms (0.1 seconds)

  9. #9
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    [QUOTE=nkd2009;1382400]Awesome, loop is fixed. thank you!!

    Quote Originally Posted by jstemper View Post
    Simba Code:
    if (Mainscreen.isPlayerAnimating(200)) then
      //this will happen if statement is true ***want this to be "do nothing until not animating, else chop"***
    else
      //this will happen if statement is false

    That helps but I still cannot think of how to say, if the player is animating THEN do nothing UNTIL player not animating, then cut willows again. This is an issue because trees can either last 1 log or 10 logs depending on world just length of time the tree lasts randomly. How do you say do nothing, no action until the animating stops? if I keep it the way it is, after the animating process stops, it will continue to wait? correct? maybe I'm misunderstanding how the function works and what my wait time actually does? seems like I need an inverse of the function..
    I think something like this would work
    Simba Code:
    procedure waitWhileAnimating(Threshold, waitTime, timeOut: Integer);
    var
      I : Integer;
    begin
      I := (GetSystemTime + timeOut);
      while ((GetSystemTime < I) and (Mainscreen.isPlayerAnimating(Threshold))) do
        Wait(waitTime);
    end;

  10. #10
    Join Date
    Nov 2012
    Posts
    161
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    Quote Originally Posted by acow View Post
    wait()

    wait(100); //this would wait for 100 ms (0.1 seconds)
    Acow, I see what you are getting at. How I phrased the question was not great. However, I already have a simple random wait function being used. The problem arises because of the randomness of the trees and not being one action per loop. I.e. in mining, you mine a rock, after that rock is mined, you move on. However when cutting a tree, the tree could be cut before I even click in a populated world or take 30 seconds so I can't just put a long or short wait function for the duration of the cutting. it could be less than 1 second or more than 30. my if isplayeranimating function correctly sees if i'm chopping, but I need a constant loop to see if animating then check again in 1 second if animating, if still animating, check again, and then when it sees not animating, immediately look for trees again. Does that help?

    procedure in script below:
    Code:
    procedure cutWillow();  //cuts willows
    var
      x, y: integer;
    begin
        if mainscreen.findObject(x,y, 2768196,3,['illow'], MOUSE_RIGHT) then
        begin
        writeLn('Clicked Tree');
        chooseOption.select(['hop down']);
        wait(randomRange(300,400));
        end;
          begin;
            if (mainScreen.isPlayerAnimating(200)) then
            wait(randomRange(12000,15000)); //***right now it waits 10 to 12 seconds so it doesn't spam clicks this is the problem***
          end;
        end;
    ideally I would add a check to see if isplayeranimating then check after 1-2 seconds again if player animating then rerun the mainscreen.findobject function above
    is there a way to add a repeat loop within the procedure to perform those checks?

    [QUOTE=jstemper;1382404]
    Quote Originally Posted by nkd2009 View Post
    thank you!!

    I think something like this would work
    Simba Code:
    procedure waitAnimating(Threshold, waitTime, timeOut: Integer);
    var
      I : Integer;
    begin
      I := (GetSystemTime + timeOut);
      while ((GetSystemTime < I) and (Mainscreen.isPlayerAnimating(Threshold))) do
        Wait(waitTime);
    end;
    ok so basically add a procedure that checks if animating separately and then put it in within the main loop repeat? or is there a way to use two procedures within a procedure? i.e.
    isplayeranimating();
    checkplayeranimating(); <--- if this is true then
    wait 1 second then repeat this until
    isplayeranimating(); returns false??

    as for your procedure, is the getsystemtime using the computer time? do you set a value for it?
    can you give some more instruction on which pieces are inputs by me and how it would be added to the loop? as far as the wait time would that need a value as well?

    Thanks

  11. #11
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    Quote Originally Posted by nkd2009 View Post
    Acow, I see what you are getting at. How I phrased the question was not great. However, I already have a simple random wait function being used. The problem arises because of the randomness of the trees and not being one action per loop. I.e. in mining, you mine a rock, after that rock is mined, you move on. However when cutting a tree, the tree could be cut before I even click in a populated world or take 30 seconds so I can't just put a long or short wait function for the duration of the cutting. it could be less than 1 second or more than 30. my if isplayeranimating function correctly sees if i'm chopping, but I need a constant loop to see if animating then check again in 1 second if animating, if still animating, check again, and then when it sees not animating, immediately look for trees again. Does that help?
    I was hoping that was all you're missing since your psuedocode sounded perfect.

    Have you gone through this beginner guide https://villavu.com/forum/showthread.php?t=58935 before?

    I'd highly recommend reading these parts http://i.imgur.com/7taolhD.png especially http://i.imgur.com/Dfl1HoE.png

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
  •