Results 1 to 7 of 7

Thread: Help with TPA and ATPA?

  1. #1
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Help with TPA and ATPA?

    How would i make a ATPA function go about checking all the ATPA on the screen would i do a for 1 to I do

    And then have junk here. And also have I sort the ATPA from hgh priority to low? and if so can i get an example by chance?


    Here is my current function for finding the loot. I took 2 TPA and added them together to be able to get a better result. but that result is pointless unless i get help with having them go over all of the points.
    Last edited by laakerules; 03-02-2012 at 02:41 AM.

  2. #2
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Oh glorious T2DPointArrays, where would we be without you??

    The thing about all arrays is they start at 0. 0 Is the first variable in the array. So if you sort the ATPA from, let's say the middle of the screen (Point(MSCX, MSCY) then ATPA[0] will be the closest to the center (your player). I'm gonna use my 'FindRocks' function from GranitePro to give an example; it's very simple and I'll explain it out how it works. Give me just a second and I'll edit this post.

    Simba Code:
    Function FindRock(Var X,Y: Integer): Boolean;
      var
        B: TBox;
        TPA,TPA2: TPointArray;
        Hmod,Smod: Extended;
        i,Tol,CTS,Col: Integer;
        ATPA: T2DPointArray;
      begin
        Result := False;
        CTS := GetColorToleranceSpeed;

        ColorToleranceSpeed(3);
      {Search the mainscreen area for a color starting at the center, TPA will be the found points}
        FindColorsSpiralTolerance(MSCX, MSCY, TPA, 9095162, MSX1, MSY1, MSX2, MSY2, 3);

      {No colors found so let's reset our CTS and exit this function (result := False)}
        if (Length(TPA) < 1) then
        begin
          ColorToleranceSpeed(CTS);
          Exit;
        end;

      {Of our HUGE TPA let's split each section into 30x30 boxes}
        ATPA := TPAToATPAEx(TPA, 30, 30);

      {Now, let's sort those boxes from the middle of the main screen}
        SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));

      {'i' will represent which box we're observing, so start from 0 to the max # of boxes}
        for i := 0 to High(ATPA) do
        begin

          B := GetTPABounds(ATPA[i]);  //This isn't really needed, but it's my own style...

          with B do  //Within this specific box do whatever
          begin
            ColorToleranceSpeed(2);
            ReturnValues(RockCols, Hmod, Smod, Col, Tol);

            SetColorSpeed2Modifiers(Hmod, SMod);
            FindColorsSpiralTolerance(MSCX, MSCY, TPA2, Col, B.X1, B.Y1, B.X2, B.Y2, Tol)
            ColorToleranceSpeed(CTS);

            if (Length(TPA2) > 0) then
            begin
              MiddleTPAEx(ATPA[i], X, Y);   //The middle of this TPA (box)
              Result := True;
              HumanMMouse(X, Y, 5, 5);
              if WaitUpTextMulti(['Mine','Rocks'], 555) then
              begin
                Result := True;
                GetMousePos(X, Y);
                Exit;
              end else
                Result := False;
            end;

          end;

        end;

      end;

    I used comments throughout the function, I hope it makes sense. Anyways if something is unclear about it just ask a question and I'll explain exactly how it works and why I used it.
    Last edited by Flight; 03-02-2012 at 02:43 AM.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  3. #3
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay made sense and worked! thanks.

    I have it currently painting pretty colors on the ATPA, but only does the one it has selected at the time, im using SMART_DrawDotsMulti(true, ATPA);


    Edit: Sorry for double post, forgot to edit instead of posting!

  4. #4
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    There's actually functions for debugging ATAPs.
    Simba Code:
    procedure DebugATPABounds(aPoints: array Of TPointArray);

    It's REALLY helpful when developing scripts and you'd like to see what Simba is seeing. It's truly a must for scripters. I do believe you'll have to include debug.simba for it though ({$i SRL/SRL/misc/debug.simba}).

    Edit:
    Here is an absolutely wonderful guide on TPAs/ATPAs: http://villavu.com/forum/showthread.php?t=49067.

    I know at first it might seem a little overwhelming but I guarantee you it will step up your scripting ability far past the next level. I couldn't recommend this guide enough.
    Last edited by Flight; 03-02-2012 at 02:59 AM.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  5. #5
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Whoa sick that brought up like a viewer box! :O


    Coolio, anyway to make it like Put an Ellipse around the ATPA? By chance?


    Edit: And what would you say is the best ATPA size? 30,30?

  6. #6
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by laakerules View Post
    Whoa sick that brought up like a viewer box! :O


    Coolio, anyway to make it like Put an Ellipse around the ATPA? By chance?


    Edit: And what would you say is the best ATPA size? 30,30?
    I'm not quite sure, but I believe paintsmart.simba recently had similar functions made. I think it was Mormonman who made them, I'm sure you could use any of those. ATPA size depends on what you're looking for. Take a look at the second section of that Wizzup Plugin guide (usage in Runescape) and you'll see how you can determine the height/width boundaries. In the example I think it was cowhides being used, they're basically 20x20 or so:



    But should you look for something like, let's say a willow tree, and you're looking for the tree trunk color, it's much taller than it is wide, so we'd use something like 20 or 30 width with like a 60 height or whatever. You get the idea.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  7. #7
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ya i get the idea, thanks flight big help bro!

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
  •