Results 1 to 11 of 11

Thread: ATPA question

  1. #1
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Question ATPA question

    So I'm making a simple script that collects redberries from a bush. I think I'm almost done but I can't figure out how to solve something. This is what I have so far (major thanks to The Mayor for his AIO guide):

    Simba Code:
    procedure getRedberries();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
      redberriesTimer: TTimeMarker;

    begin
      if not isLoggedIn() then
        exit;

      redberriesTimer.start();

      repeat

      findColorsSpiralTolerance(x, y, TPA, 1473055, mainScreen.getBounds(), 10, colorSetting(2, 0.14, 1.53));

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

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

      for i:= 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['Redberry bush'], 2000) then
        begin
          fastClick(MOUSE_LEFT);
          //smartImage.clear;
          break;
        end;
      end;
      tabBackpack.waitForShift(2000);

      until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
    end;

    So it clicks the redberry bush and collects redberries. But the problem is there are only 2 redberries every bush, so I have to make it stop clicking after there aren't any left and continue to the next bush. I really don't know how to do that, it just keep clicking the bush while there aren't any redberries anymore. Maybe this could help you visualizing my problem:


    And if I would finally make it work and it reaches the other bush and gets 2 redberries, do I have to use minimap.setAngle() to turn the camera so it could go to the other bush again or is there another/better way to do? Thanks in advance!
    Last edited by Spaceblow; 08-16-2014 at 12:33 PM.

  2. #2
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Tweak your for..to..do loop a bit.

    Simba Code:
    for i:= 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['Redberry bush'], 2000) then
        begin
          fastClick(MOUSE_LEFT);
          wait(randomRange(1000, 2000)); //however long it takes you to pick a berry
          //may want to move the mouse a few random pixels here
          fastClick(MOUSE_LEFT);
          //smartImage.clear;
          break;
        end;
      end;

    In regards to your second question, I'd say just zoom all the way out and have the script keep your camera angle at wherever you can always see both bushes.

    If that's not possible, you'd have to devise a function that checks which bush you're at, and turns a specific angle based on the result.

    You could even even just bruteforce it by turning a random angle (or a specific angle that you know will always move the second bush into view) if no points are found.
    Last edited by KeepBotting; 08-09-2014 at 01:33 AM.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

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

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

    Default

    You've picked the bush colour and put it into a TPA. Now you can look inside those TPA bounds for the red berry colour (yes they are small, but simba will see them). Just declare another TPA variable and then go something like:


    Simba Code:
    for i:= 0 to high(ATPA) do
      if findColorsSpiralTolerance(x, y, berryTPA, 1977796, ATPA[i].getBounds(), 2, colorSetting(2, 0.10, 0.95)) then
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['Redberry bush'], 2000) then
        begin
          fastClick(MOUSE_LEFT);
          smartImage.clear;
          break;
        end;
      end;

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

    Default

    Quote Originally Posted by The Mayor View Post
    You've picked the bush colour and put it into a TPA. Now you can look inside those TPA bounds for the red berry colour (yes they are small, but simba will see them). Just declare another TPA variable and then go something like:


    Simba Code:
    for i:= 0 to high(ATPA) do
      if findColorsSpiralTolerance(x, y, berryTPA, 1977796, ATPA[i].getBounds(), 2, colorSetting(2, 0.10, 0.95)) then
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['Redberry bush'], 2000) then
        begin
          fastClick(MOUSE_LEFT);
          smartImage.clear;
          break;
        end;
      end;
    He knows how to click them,

    he wants to click them twice is the problem.

    This is good advice too, though.
    Adding in a second color check will help improve accuracy.

    For example: what if the script happens to move the mouse inside your ATPA box, but not directly on top of the redberry bush?
    Then you'll get no mouseovertext and it'll think there's no bush there.
    Last edited by KeepBotting; 08-09-2014 at 01:37 AM.
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

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

  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 KeepBotting View Post
    nono

    he knows how to click them

    he wants to click them twice is the problem
    I think you will find my code picks red berries like a pro

  6. #6
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    I think you will find my code picks red berries like a pro
    oh ofc

    read my edit XD
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

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

  7. #7
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Default

    Guys, I'm really sorry for the late reply. I'm pretty busy in real life and I hope you didn't think it was rude of me.

    Quote Originally Posted by KeepBotting View Post
    Tweak your for..to..do loop a bit.

    Simba Code:
    for i:= 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['Redberry bush'], 2000) then
        begin
          fastClick(MOUSE_LEFT);
          wait(randomRange(1000, 2000)); //however long it takes you to pick a berry
          //may want to move the mouse a few random pixels here
          fastClick(MOUSE_LEFT);
          //smartImage.clear;
          break;
        end;
      end;

    In regards to your second question, I'd say just zoom all the way out and have the script keep your camera angle at wherever you can always see both bushes.

    If that's not possible, you'd have to devise a function that checks which bush you're at, and turns a specific angle based on the result.

    You could even even just bruteforce it by turning a random angle (or a specific angle that you know will always move the second bush into view) if no points are found.
    Thank you very much for your advice, I did what you suggested (turning a specific angle so both bushes would be on the mainScreen. But you probably interpreted my question wrongly. I was asking about the thing The Mayor answered. But instead you gave me a great tip about including wait(). Thanks!

    Quote Originally Posted by The Mayor View Post
    You've picked the bush colour and put it into a TPA. Now you can look inside those TPA bounds for the red berry colour (yes they are small, but simba will see them). Just declare another TPA variable and then go something like:


    Simba Code:
    for i:= 0 to high(ATPA) do
      if findColorsSpiralTolerance(x, y, berryTPA, 1977796, ATPA[i].getBounds(), 2, colorSetting(2, 0.10, 0.95)) then
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['Redberry bush'], 2000) then
        begin
          fastClick(MOUSE_LEFT);
          smartImage.clear;
          break;
        end;
      end;
    That's the answer to my main question, I really appreciate the quick replies on this forum. Thanks!

    This is what I have for this procedure. It's very basic stuff, no antibans yet:

    Simba Code:
    procedure getRedberries();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
      redberriesTimer: TTimeMarker;

    begin
      if not isLoggedIn() then
        exit;

      redberriesTimer.start();
      minimap.setAngle(320);
      mainscreen.setZoom(true);
      minimap.toggleRun(true);

      repeat

        findColorsSpiralTolerance(x, y, TPA, 1714858, mainScreen.getBounds(), 5, colorSetting(2, 0.11, 0.31));
        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(['Redberry bush'], 2000) then

              repeat

                fastClick(MOUSE_LEFT);
                wait(randomRange(650, 950));

              until tabBackpack.waitForShift(5000);

              smartImage.clear;
              break;
          end;
      until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
    end;

    So, what do you think?

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

  9. #9
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    You didn't do what I said?
    Wow I feel stupid now. I thought you meant I had to replace the bush colours with those from the redberries, so when you get the redberries and they disappear from the bush, the script goes for the other bush because there are redberries left. I probably was a little bit distracted when I was reading your message.

    I edited it and now I have this:
    Simba Code:
    procedure getRedberries();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
      berryTPA: TPointArray;
      redberriesTimer: TTimeMarker;


    begin
      if not isLoggedIn() then
        exit;

      redberriesTimer.start();
      minimap.setAngle(320);
      mainscreen.setZoom(true);
      minimap.toggleRun(true);

      repeat

      findColorsSpiralTolerance(x, y, TPA, 1473055, mainScreen.getBounds(), 10, colorSetting(2, 0.14, 1.53)); //bush colour
        ATPA:= TPA.toATPA(30, 30);
        ATPA.sortFromMidPoint(mainscreen.playerPoint);
        smartImage.debugATPA(ATPA);

          for i:= 0 to high(ATPA) do
            if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour
            begin
              mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
              if isMouseOverText(['Redberry bush'], 2000) then

              repeat

                fastClick(MOUSE_LEFT);
                wait(randomRange(650, 950));

              until tabBackpack.waitForShift(5000);

              smartImage.clear;
              break;
          end;
      until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
    end;

    I changed this line (yours):
    Simba Code:
    if findColorsSpiralTolerance(x, y, berryTPA(i), 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour

    Into this:
    Simba Code:
    if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour

    Because when I tried to use your line it said:
    Code:
    Exception in Script: Don't know which overloaded method to call with params (Int32, Int32, *unknown*, Int32, record [0]Int32; [4]Int32; [8]Int32; [12]Int32; end, Int32, record [0]Int32; [4]record [0]Extended; [10]Extended; [20]Extended; end; end) at line 144, column 12
    Why is this happening?


    I'm wondering about something though. When I test the procedure it goes to the first TPA, clicks to get the first redberries. Then it clicks to get the second redberries, now the bush is out of redberries and it's time to go to the other bush. But why does it just keeps clicking the same bush? Maybe the answer to that question is pretty obvious, but not to me.

  10. #10
    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 Spaceblow View Post


    I changed this line (yours):
    Simba Code:
    if findColorsSpiralTolerance(x, y, berryTPA(i), 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour

    Into this:
    Simba Code:
    if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA.getBounds(), 5, colorSetting(2, 0.11, 0.31)) then //redberry colour
    That wasn't my line (you must have added the (i) to the end of berryTPA, and deleted it from ATPA[i].getBounds).

    Quote Originally Posted by Spaceblow View Post
    I'm wondering about something though. When I test the procedure it goes to the first TPA, clicks to get the first redberries. Then it clicks to get the second redberries, now the bush is out of redberries and it's time to go to the other bush. But why does it just keeps clicking the same bush? Maybe the answer to that question is pretty obvious, but not to me.
    Yes, because you tell it to Since you removed the ATPA[i] in the above line, it's not going to look at the individual bushes. Basically ATPA[0] is the first bush and ATPA[1] is the second bush. Also you added in another repeat loop which is a bad idea. What happens if there was no berries left you would keep clicking it for 6 sec waiting for the backpack count to change. Use the code exactly like I posted above.

    Simba Code:
    procedure getRedberries();
    var
      x, y, i: integer;
      bushTPA, berryTPA: TPointArray;
      ATPA: T2DPointArray;
      redberriesTimer: TTimeMarker;
    begin
      if not isLoggedIn() then
        exit;

      redberriesTimer.start();
      minimap.setAngle(320);
      mainscreen.setZoom(true);
      minimap.toggleRun(true);

      repeat

        findColorsSpiralTolerance(x, y, bushTPA, 1473055, mainScreen.getBounds(), 10, colorSetting(2, 0.14, 1.53));
        ATPA:= TPA.toATPA(30, 30);
        ATPA.sortFromMidPoint(mainscreen.playerPoint);
        smartImage.debugATPA(ATPA);

        for i:= 0 to high(ATPA) do
          if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA[i].getBounds(), 5, colorSetting(2, 0.11, 0.31)) then
          begin
            mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
            if isMouseOverText(['Redberry bush'], 2000) then
            begin
              fastClick(MOUSE_LEFT);
              smartImage.clear;
              break;
            end;
          end;

      until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);

    end;

  11. #11
    Join Date
    Jul 2014
    Location
    Europe
    Posts
    182
    Mentioned
    7 Post(s)
    Quoted
    103 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    That wasn't my line (you must have added the (i) to the end of berryTPA, and deleted it from ATPA[i].getBounds).
    Wow haha, now I feel even more dumb.

    Quote Originally Posted by The Mayor View Post
    Yes, because you tell it to Since you removed the ATPA[i] in the above line, it's not going to look at the individual bushes. Basically ATPA[0] is the first bush and ATPA[1] is the second bush. Also you added in another repeat loop which is a bad idea. What happens if there was no berries left you would keep clicking it for 6 sec waiting for the backpack count to change. Use the code exactly like I posted above.
    Alright, I did and now it's working pretty good. So the following procedure is what I have now. Is it a good idea to activate an antibot if it doesn't find the mouseovertext or not?

    Simba Code:
    procedure getRedberries();
    var
      x, y, i: integer;
      bushTPA: TPointArray;
      berryTPA: TPointArray;
      ATPA: T2DPointArray;
      redberriesTimer: TTimeMarker;

    begin
      if not isLoggedIn() then
        exit;

      redberriesTimer.start();
      minimap.setAngle(320);
      mainScreen.setAngle(MS_ANGLE_HIGH);

      repeat

        findColorsSpiralTolerance(x, y, bushTPA, 1714858, mainScreen.getBounds(), 5, colorSetting(2, 0.11, 0.31));
        ATPA:= bushTPA.toATPA(30, 30);
        ATPA.sortFromMidPoint(mainscreen.playerPoint);
        smartImage.debugATPA(ATPA);

        for i:= 0 to high(ATPA) do
          if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA[i].getBounds(), 5, colorSetting(2, 0.11, 0.31)) then
          begin
            mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
            if isMouseOverText(['Redberry bush'], 2000) then
            begin
              fastClick(MOUSE_LEFT);
              tabBackpack.waitForShift(1500 + random(1000));
              writeLn('Succesfully got some redberries');
              wait(randomRange(1250, 1500)); //waiting to refresh smartImage
              smartImage.clear;
              break;
            end;
            //end else 'ANTIBAN' (this is in case there's another player with the same colours, so it doesn't keep following it with the mouse and keep returning 'isMouseOverText(): False' (I experienced this while testing))
          end;

      until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
    end;
    Last edited by Spaceblow; 08-12-2014 at 02:16 PM. Reason: updated the procedure

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
  •