Results 1 to 15 of 15

Thread: GetInnerTPABound

  1. #1
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default GetInnerTPABound


    I'm trying to figure out how to get the red box in the image. One way would be to get the TPA of the black pixels and try to find the 'inner bound', and another way would be to get the pixels of the white outline and clear those excess ones at the top.
    I have no idea how to get the 'inner bound' of the black TPA, but for clearing i'm thinking of using (after sorting by size) ATPA[1]'s nearest point to center to remove the upper points (taking compass into consideration), but that may not work for some parts of the area in Ghorrock though.

    Any better ideas? Or how to find the TPA innerbound?

  2. #2
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    RAaSTPAEx(TPA, W, H);

    Depending on the angle of the compass, made the width frequent, and the height less frequent, you could try RAaSTPAEx(TPA, 3, 7) or something along those lines. then split the TPA left, SplitTPAEx(TPA, 4, 6); it might not be perfect but in theory it should work?

    just keep trying different scenarios, and different numbers

  3. #3
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Kasi View Post
    RAaSTPAEx(TPA, W, H);

    Depending on the angle of the compass, made the width frequent, and the height less frequent, you could try RAaSTPAEx(TPA, 3, 7) or something along those lines. then split the TPA left, SplitTPAEx(TPA, 4, 6); it might not be perfect but in theory it should work?

    just keep trying different scenarios, and different numbers
    Isn't RAaSTPAEx something like TPAtoATPAEx + MiddleTPA? So i'll end up with a few points on random positions? How would that work?

  4. #4
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Isn't RAaSTPAEx something like TPAtoATPAEx + MiddleTPA? So i'll end up with a few points on random positions? How would that work?
    because instead of finding all the grey color, it'll find the grey color and remove points too close together, Split TPA works in boxes. if you place the points too far apart from each other they will be split into different boxes, i can attempt to make that thing for you later today if you still dont understand

  5. #5
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    http://villavu.com/forum/showthread.php?t=76467

    I wouldn't recommend you use that directly, but the logic should work for you.

  6. #6
    Join Date
    Dec 2007
    Posts
    2,112
    Mentioned
    71 Post(s)
    Quoted
    580 Post(s)

    Default

    Quote Originally Posted by slushpuppy View Post
    http://villavu.com/forum/showthread.php?t=76467

    I wouldn't recommend you use that directly, but the logic should work for you.
    That seems quite nice also

  7. #7
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Kasi View Post
    because instead of finding all the grey color, it'll find the grey color and remove points too close together, Split TPA works in boxes. if you place the points too far apart from each other they will be split into different boxes, i can attempt to make that thing for you later today if you still dont understand
    So i'll find the grey ground colors, then RAaSTPAEx, and i would end up with something like 1 point in the red box, and another 2 or more points in the narrow path? Still don't get it :S

    Quote Originally Posted by slushpuppy View Post
    http://villavu.com/forum/showthread.php?t=76467

    I wouldn't recommend you use that directly, but the logic should work for you.
    Thanks.
    What does
    Simba Code:
    ArcTan2(o.y - pt.y, o.x - pt.x) * 180 / Pi;
    do?


    ArcTan2 will return inverse of angle alpha, given the opposite and adjacent length? And then you check whether it is within an empty array degArray? I'm confused what it does

  8. #8
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    What? It returns the actual angle not the inverse :S

    Then it converts it to radians.
    I am Ggzz..
    Hackintosher

  9. #9
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Change the coords and colours and it should work. Perhaps even use a different CTS. I did this based off that picture on the OP.

    Simba Code:
    {$I SRL/SRL.Simba}
    {$I SRL/SRL/Misc/Debug.Simba}

    Function GetBoxMinimap: TBox;
    var
      TPA: TPointArray;
      ATPA: T2DPointArray;
    Begin
      FindColorsTolerance(TPA, 7433839, MMBox.X1, MMBox.Y1, MMBox.X2, MMBox.Y2, 25);
      If (Length(TPA) < 1) Then Exit;

      ATPA := FloodFilLTPA(TPA);
      If (Length(ATPA) < 1) Then Exit;
      SortATPAFromFirstPoint(ATPA, Point(300, 300)); //Middle Of MM.
      Result := GetTPABounds(ATPA[0]);
    End;

    var
      F: TBox;
    begin
      SetupSRL;
      F := GetBoxMinimap;
      MMouse(F.X1, F.Y1, 0, 0);
      Wait(1500);
      MMouse(F.X2, F.Y2, 0, 0);
    end.
    I am Ggzz..
    Hackintosher

  10. #10
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    What? It returns the actual angle not the inverse :S

    Then it converts it to radians.
    Ugg yeah, dunno what i was talking.
    But the degArray is an empty array of length 1 when 'foundIndex := inArray(tmp,degArray)' is called?

    Quote Originally Posted by Brandon View Post
    Change the coords and colours and it should work. Perhaps even use a different CTS. I did this based off that picture on the OP.

    Simba Code:
    {$I SRL/SRL.Simba}
    {$I SRL/SRL/Misc/Debug.Simba}

    Function GetBoxMinimap: TBox;
    var
      TPA: TPointArray;
      ATPA: T2DPointArray;
    Begin
      FindColorsTolerance(TPA, 7433839, MMBox.X1, MMBox.Y1, MMBox.X2, MMBox.Y2, 25);
      If (Length(TPA) < 1) Then Exit;

      ATPA := FloodFilLTPA(TPA);
      If (Length(ATPA) < 1) Then Exit;
      SortATPAFromFirstPoint(ATPA, Point(300, 300)); //Middle Of MM.
      Result := GetTPABounds(ATPA[0]);
    End;

    var
      F: TBox;
    begin
      SetupSRL;
      F := GetBoxMinimap;
      MMouse(F.X1, F.Y1, 0, 0);
      Wait(1500);
      MMouse(F.X2, F.Y2, 0, 0);
    end.
    What does FloodFillTPA do? Difference between it and SplitTPA/TPAtoATPA?
    No time to ponder through those 100 lines of code now so would you mind giving me a brief description?

    Anyway i tried the code, the result is almost there:

    May be able to fix it if i understand FloodFillTPA.


    I kept thinking about the black pixel and white outline earlier on, totally forget about the grey ground.
    Just tried using SplitTPA to get the larger path first, then
    Simba Code:
    SortTPAByX(ATPA[0], true);
    TPAtoATPAExWrap(ATPA[0], 40, 50, ATPA);
    Came up with what i wanted, but will be another hour of work to make it compass compatible and work with different areas..


    Thanks for the help, repped

  11. #11
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Nice work guys, love the teamwork What are you working on..?

  12. #12
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Nice work guys, love the teamwork What are you working on..?
    My Waterfiend script. I'm trying to keep the player to 1 area because if it wander too far to other parts of the map the Wf will turn aggressive again.

    Any idea what FloodFillTPA/FindGapsTPA does and the difference between it and SplitTpa/TPAtoATPA?

  13. #13
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    https://docs.villavu.com/simba/scriptref/tpa.html

    CTRL + F "FloodFill" or "FindGaps"

  14. #14
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    https://docs.villavu.com/simba/scriptref/tpa.html

    CTRL + F "FloodFill" or "FindGaps"
    Yeah i've searched that and searched on forum/google as well. Doesn't describe much at all. (mostly just give the function name and parameters..)

    Guess my best bet would be https://github.com/MerlijnWajer/Simb...MLCore/tpa.pas. Need to find another time to slowly read through the code...

  15. #15
    Join Date
    Oct 2011
    Posts
    422
    Mentioned
    15 Post(s)
    Quoted
    116 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    Ugg yeah, dunno what i was talking.
    But the degArray is an empty array of length 1 when 'foundIndex := inArray(tmp,degArray)' is called?
    Essentially my snippet searches for white borders in a 360 degree arc. then consolidates the result to return an area as small as possible

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
  •