Results 1 to 15 of 15

Thread: Is there a way to make ATPA boxes forced to be larger than a predefined variable?

  1. #1
    Join Date
    Dec 2016
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Question Is there a way to make ATPA boxes forced to be larger than a predefined variable?

    Say I want to outline an ore node. Can I force every box my script creates to be 30px by 30px wide? This would help with randomization when I click the ores. I just can't seem to figure it out. I've messed with color tolerances and tried randomizing the sizes in this line of code shown below. It throws an error so there must be another way.

    Code:
    findColorsSpiralTolerance(x, y, 5, 5, TPA, 2176376, mainscreen.getBounds(), 4, colorSetting(2,0.05,0.35));

  2. #2
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Simba Code:
    TPAtoATPAEx(TPA, Width, Height);

    That will break a TPA up into an Array of TPAs (known as an ATPA or T2DPointArray). Now you can cycle through the ATPA in a loop and access your desired 30x30 boxes.

  3. #3
    Join Date
    Dec 2016
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Here is my script so far. I do have the atpa set to (30, 30) already, but I get small boxes that just show as an x. When the script goes to click on them there's no randomization because it can only click the x. I've looked at other scripts and they seem to be setup just like mine. I guess I could try increasing the atpa size or maybe the color tolerance.

    Code:
    program RimmingtonMiner;
    
    {$DEFINE SMART}              // Always have this to load smart
    {$I SRL-6/SRL.simba}         // To load the SRL include files
    {$I SPS/lib/SPS-RS3.Simba}   // To load the SPS include files
    
    //const
      //IronOreCol := '1979247';
      //IronOreTol := '9';
      //IronOreHue := '0.04';
      //IronOreSat := '1.98';
    
    var
      LoadsDone, Ironint, IronOre, scriptPaintBMP : integer;
    
    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := '';
        password := '';
        isActive := true;
        isMember := false;
      end;
      currentPlayer := 0;
    end;
    
    procedure ProgressReport();
    var
      IronOreMined, profit, profitPerHour, ExpMade, ExpPerHour: integer;
    
    begin
      ExpMade := LoadsDone * 980;
      ExpPerHour := Round(((LoadsDone * 980) * 3600) / (GetTimeRunning / 1000));
      IronOreMined := LoadsDone * 28;
      profit := (IronOreMined * Ironint);
      profitPerHour := round((profit * 60) / (getTimeRunning() / 60000));
    
      begin
        smartImage.clear;
        smartImage.drawBitmap(scriptPaintBMP, Point(3, 461));
        smartImage.drawText(ToStr(TimeRunning), Point(102, 474), 'smallChars', true, clWhite);
        smartImage.drawText(ToStr(IronOreMined), Point(149, 500), 'smallChars', true, clWhite);
        smartImage.drawText(ToStr(LoadsDone), Point(113, 530), 'smallChars', true, clWhite);
        smartImage.drawText(ToStr(ExpMade) + 'exp earned', Point(412, 540), 'smallChars', true, clWhite);
        smartImage.drawText(ToStr(ExpPerHour) + 'exp/hr', Point(412, 555), 'smallChars', true, clWhite);
        smartImage.drawText(ToStr(profit) + 'gp earned', Point(412, 522), 'smallChars', true, clLime);
        smartImage.drawText(ToStr(profitPerHour) + 'gp/hr', Point(412, 507), 'smallChars', true, clLime);
      end;
    end;
    
    procedure travelToMines();
    begin
      // NOT FINISHED
    end;
    
    procedure mineRocks();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA:T2DPointArray;
    
    begin
      findColorsSpiralTolerance(x, y, TPA, 2176376, mainscreen.getBounds(), 4, colorSetting(2,0.05,0.35));
    
      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(ATPA[i].getBounds().getRandomPoint());
        if isMouseOverText(['Mine Iron ore'], randomRange(350,550)) then
        begin
          fastClick(MOUSE_LEFT);
          writeLn('We left clicked iron ore!');
          tabBackPack.waitForShift(randomRange(5724, 6241));
          wait(randomRange(259, 436));
          smartImage.clear();
          break;
        end;
      end;
    
    end;
    
    procedure dropOres();
    begin
      KeyDown(49);
      wait(randomRange(5000, 5250));
      KeyUp(49);
    end;
    
    procedure lilAntiBan();
    begin
      if random(9) = 0  then                      //Approximately 10% of the time this procedure is run an antiban feature will engage.
      case random(100) of
        0..10 : begin
            writeLn('Hovering Over Skill...');
            hoverSkill(SKILL_MINING);        //Feel free to change this skill to suit your needs.
            wait(randomRange(750, 1400));
            end;
        11..20 : begin
            writeLn('Picking Up Mouse...');
            pickUpMouse;
            end;
        21..30 : begin
            writeLn('Looking at Random Game Tab...');
            randomGameTab(true);
            end;
        31..45 : begin
            writeLn('Acting Like a Bored Human...');
            boredHuman(true);
            end;
        46..50 : begin
            writeLn('Moving Mouse a Small Amount...');
            smallRandomMouse();
            end;
        51..90 : begin
            writeLn('Moving Outside the Client + Shortbreaking...');
            mouseOffClient(OFF_CLIENT_RANDOM, randomRange(6012, 40302));    //Yes I do like strange numbers ;)
            end;
        91..100 : begin
            writeLn('Sleeping and Moving Mouse...');
            sleepAndMoveMouse(1250 + random(2347));
            end;
    
        end;
    end;
    
    // main loop
    begin
      clearDebug();               // Clear the debug box
      smartEnableDrawing := true; // So we can draw on SMART
      setupSRL();                   // Load the SRL include files
      declarePlayers();             // Set up your username/pass
      SPS.setup('RIMM_MINE', RUNESCAPE_OTHER);
      exitTreasure();            // Exit treasure hunter
      minimap.setAngle(MM_DIRECTION_EAST);  // Make compass north and angle high
      mainScreen.setAngle(MS_ANGLE_HIGH);
    
    repeat
      if not isLoggedIn() then             // If player isn't logged in then
      begin
        players[currentPlayer].login();   // Log them in
        exitTreasure();            // Exit treasure hunter
        minimap.setAngle(MM_DIRECTION_EAST);  // Make compass east and angle high
        mainScreen.setAngle(MS_ANGLE_HIGH);
      end;
    
      repeat
      //ProgressReport();
      //travelToMines();
        mineRocks();
      until tabBackpack.isFull();
      dropOres();
      lilAntiBan();
      until false;
    
    end.

  4. #4
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Debug your ATPA (into simba debug). See how many points each index has.

  5. #5
    Join Date
    Dec 2016
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    How would I go about debuging an atpa? I know how to do it with a tpa. This is the results.

    When I try to debug an atpa I just get this.

    You can see that the boxes don't look like (30,30) though.

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

    Default

    ATPA[index].getBounds() -> returns a tbox, increase the bounds of said tbox

  7. #7
    Join Date
    Dec 2016
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Okay, I switched that line to
    mouse(ATPA[i].getBounds(30,30).getRandomPoint());
    and I get this error. Error: Too many parameters found at line 67, column 29 at line 67
    Compiling failed.

    It seems like that should work. I've read the docs to see what arguments .getBounds() accepts and I haven't been able to make sense of it.

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

    Default

    Quote Originally Posted by guitarafro View Post
    Okay, I switched that line to
    mouse(ATPA[i].getBounds(30,30).getRandomPoint());
    and I get this error. Error: Too many parameters found at line 67, column 29 at line 67
    Compiling failed.

    It seems like that should work. I've read the docs to see what arguments .getBounds() accepts and I haven't been able to make sense of it.
    it takes no paramaters, you sent it two integers

    e;
    Simba Code:
    newBox := IntToBox(ATPA[I].getBounds().X1 - 10, ATPA[I].getBounds().Y1 - 10, ATPA[I].getBounds().X2 + 10, ATPA[I].getBounds().Y2 + 10);
    mouse(newBox.getRandomPoint()); //<- not sure if this will work, not familiar with srl-6
    Last edited by jstemper; 01-17-2017 at 07:01 PM. Reason: toBox -> IntToBox

  9. #9
    Join Date
    Dec 2016
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Okay, I'm outside of my knowledge range for this stuff now. I've taken your example above and added it like this. Just taking a stab in the dark. Ended up with this.

    Code:
    mouse(ATPA[I].getBounds().X1 - 10, ATPA[I].getBounds().Y1 - 10, ATPA[I].getBounds().X2 + 10, ATPA[I].getBounds().Y2 + 10).getRandomPoint();
    Now I get an error saying Error: Unknown declaration "getRandomPoint" at line 67. Is there a tutorial for this on the forums? I think it would be easier if I can examine how someone else has done this and incorporate it into my own script.
    Last edited by guitarafro; 01-17-2017 at 07:16 PM.

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

    Default

    Quote Originally Posted by guitarafro View Post
    Okay, I'm outside of my knowledge range for this stuff now. I've taken your example above and added it like this. Just taking a stab in the dark. Ended up with this.

    Code:
    mouse(ATPA[I].getBounds().X1 - 10, ATPA[I].getBounds().Y1 - 10, ATPA[I].getBounds().X2 + 10, ATPA[I].getBounds().Y2 + 10).getRandomPoint();
    Now I get an error saying Error: Unknown declaration "getRandomPoint" at line 67. Is there a tutorial for this on the forums? I think it would be easier if I can examine how someone else has done this and incorporate it into my own script.
    look at the example, you can only use .getRandomPoint() on tboxs (I think, never used srl-6 on rs3)
    You are also missing end parenthesis

    Simba Code:
    mouse(IntToBox(ATPA[I].getBounds().X1 - 10, ATPA[I].getBounds().Y1 - 10, ATPA[I].getBounds().X2 + 10, ATPA[I].getBounds().Y2 + 10).getRandomPoint());

    just keep in mind that increasing the size of the box will probably cause you to click outside the rock sometimes... there are definitely better ways to do it than this

  11. #11
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Well, firstly you should improve the color data as there is visible ore veins not being detected, therefore not stretching your ATPA's as best as possible. I took your image and worked on the rock to the right.



    As you can see, a nice ATPA size and the red circles simulate 10 getRandomPoint clicks. A healthy spread of different points.

    Debug your ATPAs and ATPABounds with:

    Simba Code:
    Writeln(ATPA); //debugs every TPoint in each element (TPA)
    for i := 0 to High(ATPA) do
      Writeln(ATPA[i].GetBounds);  //Debugs the box produced for the Points in the TPA. This determines the click point
    Attached Images Attached Images

  12. #12
    Join Date
    Dec 2016
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    What does FilterTPASBetween do? I added it to my script and it seems to have fixed the small boxes/single points. I got it from Fady AIO's Portable script. My mineRock procedure now looks like this.

    Code:
    procedure mineRocks();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA:T2DPointArray;
    
    begin
      findColorsSpiralTolerance(x, y, TPA, IronOreCol, mainscreen.getBounds(), IronOreTol, colorSetting(CTS,IronOreHue,IronOreSat));
    
      if length(TPA) < 1 then
        exit;
    
        ATPA := TPA.toATPA(40,40);
        FilterTPAsBetween(ATPA,1,20);
        ATPA.sortFromMidPoint(mainscreen.playerPoint);
        smartImage.debugATPA(ATPA);
    
      for i := 0 to high(ATPA) do
      begin
        mouse(ATPA[i].getBounds().getRandomPoint());
        if isMouseOverText(['Mine Iron ore'], randomRange(350,550)) then
        begin
          fastClick(MOUSE_LEFT);
          writeLn('We left clicked iron ore!');
          tabBackPack.waitForShift(randomRange(5724, 6241));
          wait(randomRange(259, 436));
          smartImage.clear();
          break;
        end;
      end;
    
    end;

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

    Default

    Quote Originally Posted by guitarafro View Post
    What does FilterTPASBetween do? I added it to my script and it seems to have fixed the small boxes/single points. I got it from Fady AIO's Portable script. My mineRock procedure now looks like this.

    Code:
    procedure mineRocks();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA:T2DPointArray;
    
    begin
      findColorsSpiralTolerance(x, y, TPA, IronOreCol, mainscreen.getBounds(), IronOreTol, colorSetting(CTS,IronOreHue,IronOreSat));
    
      if length(TPA) < 1 then
        exit;
    
        ATPA := TPA.toATPA(40,40);
        FilterTPAsBetween(ATPA,1,20);
        ATPA.sortFromMidPoint(mainscreen.playerPoint);
        smartImage.debugATPA(ATPA);
    
      for i := 0 to high(ATPA) do
      begin
        mouse(ATPA[i].getBounds().getRandomPoint());
        if isMouseOverText(['Mine Iron ore'], randomRange(350,550)) then
        begin
          fastClick(MOUSE_LEFT);
          writeLn('We left clicked iron ore!');
          tabBackPack.waitForShift(randomRange(5724, 6241));
          wait(randomRange(259, 436));
          smartImage.clear();
          break;
        end;
      end;
    
    end;
    it removes the tpoints between min and max length (in your case 1-20)

    have a read through this http://docs.villavu.com/simba/scriptref/tpa.html

    this will also become your best friend https://villavu.com/forum/showthread.php?t=49067

  14. #14
    Join Date
    Dec 2016
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Okay, I should have enough information to solve this now. Thank you two for your help!

  15. #15
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    What does FilterTPASBetween do? I added it to my script and it seems to have fixed the small boxes/single points. I got it from Fady AIO's Portable script. My mineRock procedure now looks like this.
    Yep, this is why I wanted you to debug your points. You'd have seen indexes in there with really low amount of TPoints in them.


    Make sure you improve your color data, because your script will be ignoring rocks right next to you from time to time when they fall below your 20 TPoints threshold.

    Also you generally want to filter by a certain minimum amount for most uses of object finding. Never know when someone will run by wearing a small amount matching color.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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