Results 1 to 11 of 11

Thread: How to check if a ATPA has a certain number of points?

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default How to check if a ATPA has a certain number of points?

    I am trying to search for an object inside of a ATPA and i want to filter the ATPA so only ones with a certain number of points inside of them.

    Simba Code:
    if (Length(ATPA[i]) > 2) then Continue;

    I tried using this but I'm pretty sure that's checking for the number of ATPA's, not the number of points, how do i check the number of points?

  2. #2
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Kevin View Post
    Simba Code:
    if (Length(ATPAToTPA(ATPA)) > 2) then Continue;

    How about that?
    Ok thanks ill check if that works

  4. #4
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    ATPA[i] is a TPA so you are checking for the amount of points.

    In SRL-6 i did add this though, should solve your needs.
    https://github.com/SRL/SRL-6/blob/ma...tmp.simba#L241

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Ollybest View Post
    ATPA[i] is a TPA so you are checking for the amount of points.

    In SRL-6 i did add this though, should solve your needs.
    https://github.com/SRL/SRL-6/blob/ma...tmp.simba#L241
    I get a type mismach on :

    Simba Code:
    insert(atpa[i], c);

  6. #6
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    That isn't in ps (at least in 992)

    Simba Code:
    procedure filterTPAsBetween(var atpa: T2DPointArray; len1, len2: integer);
    var
      h, l, i: integer;
      c: T2DPointArray;
    begin
      h := high(atpa);

      for i := 0 to h do
      begin
        l := length(atpa[i]);

        if (not (inRange(l, len1, len2))) then
        begin
          setLength(c, length(c) + 1); // could be done way more efficiency but meh.
          c[high(c)] := atpa[i];
        end;
      end;

      atpa := c;
    end;

  7. #7
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Ollybest View Post
    That isn't in ps (at least in 992)

    Simba Code:
    procedure filterTPAsBetween(var atpa: T2DPointArray; len1, len2: integer);
    var
      h, l, i: integer;
      c: T2DPointArray;
    begin
      h := high(atpa);

      for i := 0 to h do
      begin
        l := length(atpa[i]);

        if (not (inRange(l, len1, len2))) then
        begin
          setLength(c, length(c) + 1); // could be done way more efficiency but meh.
          c[high(c)] := atpa[i];
        end;
      end;

      atpa := c;
    end;
    I figured it would be in lape, but there is a problem now, it cannot find the object within the box, but I know the object exists because I have a high tolerance.
    Simba Code:
    {$I SRL-OSR/SRL.Simba}
    {$I SRL/SRL/Misc/Debug.simba}

    Var
      cage: TBox;
      ATPA: T2DPointArray;
    procedure filterTPAsBetween(var atpa: T2DPointArray; len1, len2: integer);
    var
      h, l, i: integer;
      c: T2DPointArray;
    begin
      h := high(atpa);

      for i := 0 to h do
      begin
        l := length(atpa[i]);

        if (not (inRange(l, len1, len2))) then
        begin
         setLength(c, length(c) + 1);
         c[high(c)] := atpa[i];
        end;
      end;

      atpa := c;
    end;
    Function FindCage: Boolean;
    var
      TPA,TPA2: TPointArray;
      i,CTS,X,Y: Integer;
    begin
      Result := False;

      CTS := GetColorToleranceSpeed;

      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, 594520, 0, 0, 514, 338, 8);
      SetColorSpeed2Modifiers(0.02, 0.02);
      ColorToleranceSpeed(CTS);

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

      ATPA := TPAToATPAEx(TPA, 120, 120);
      SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));

      for i := 0 to High(ATPA) do
      begin

        filterTPAsBetween(ATPA, 1, 8)

        debugATPABounds(ATPA);
        cage := GetTPABounds(ATPA[i]);
        result := true;

      end;
    end;
    Function FindDemon: Boolean;
    var
      cage: TBox;
      TPA: TPointArray;
      i,CTS,X,Y: Integer;
      NPC_ATPA: T2DPointArray;
      h:TPoint;

    begin
      Result := False;

      CTS := GetColorToleranceSpeed;

      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.15, 1.94);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, 662873, cage.x1, cage.y1, cage.x2, cage.y2, 11);
      SetColorSpeed2Modifiers(0.02, 0.02);
      ColorToleranceSpeed(CTS);
      if (Length(TPA) < 1) then Exit;

      NPC_ATPA := TPAToATPAEx(TPA, 40, 40);

      SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));

      debugATPABounds(NPC_ATPA);

      for i := 0 to High(NPC_ATPA) do
      begin

        filterTPAsBetween(NPC_ATPA, 1, 5)
        debugATPABounds(NPC_ATPA);
        if WaitUpTextMulti(['', ''], 600) then

        begin
          MiddleTPAEx(NPC_ATPA[i], X, Y);
          Result := true;
        end;
      end;
    end;


    begin
     SetupSRL;
     FindCage;
     FindDemon;
    end.

    I have not added for it to move the mouse to the object yet, just trying to see if it will find it.

  8. #8
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    take filterTPAsBetween(ATPA, 1, 8) out the loop, put it under tpaToATPAEx

    and you forgot to set SetColorSpeed2Modifiers(0.00, 0.00);.

  9. #9
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Ollybest View Post
    take filterTPAsBetween(ATPA, 1, 8) out the loop, put it under tpaToATPAEx

    and you forgot to set SetColorSpeed2Modifiers(0.00, 0.00);.
    Ok did all that, it was setting it back to what it orginally was, so I did all that.

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

    Var
      cage: TBox;
      ATPA: T2DPointArray;
    procedure filterTPAsBetween(var atpa: T2DPointArray; len1, len2: integer);
    var
      h, l, i: integer;
      c: T2DPointArray;
    begin
      h := high(atpa);

      for i := 0 to h do
      begin
        l := length(atpa[i]);

        if (not (inRange(l, len1, len2))) then
        begin
         setLength(c, length(c) + 1);
         c[high(c)] := atpa[i];
        end;
      end;

      atpa := c;
    end;
    Function FindCage: Boolean;
    var
      TPA,TPA2: TPointArray;
      i,X,Y: Integer;
    begin
      Result := False;

      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.00, 0.00);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, 594520, 0, 0, 514, 338, 2);
      SetColorSpeed2Modifiers(0.00, 0.00);

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

      ATPA := TPAToATPAEx(TPA, 120, 120);

      filterTPAsBetween(ATPA, 1, 120)
      SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));

      for i := 0 to High(ATPA) do
      begin


        debugATPABounds(ATPA);
        cage := GetTPABounds(ATPA[i]);
        result := true;

      end;
    end;
    Function FindDemon: Boolean;
    var
      cage: TBox;
      TPA: TPointArray;
      i,CTS,X,Y: Integer;
      NPC_ATPA: T2DPointArray;
      h:TPoint;

    begin
      Result := False;

      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.07, 1.82);
      FindColorsSpiralTolerance(MSCX, MSCY, TPA, 1451877, cage.x1, cage.y1, cage.x2, cage.y2, 10);
      SetColorSpeed2Modifiers(0.00, 0.00);
      if (Length(TPA) < 1) then Exit;

      NPC_ATPA := TPAToATPAEx(TPA, 40, 40);

      filterTPAsBetween(NPC_ATPA, 1, 5)

      SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));


      debugATPABounds(NPC_ATPA);


      for i := 0 to High(NPC_ATPA) do
      begin

        debugATPABounds(NPC_ATPA);
        if WaitUpTextMulti(['ank', 'eposite'], 600) then

        begin
          MiddleTPAEx(NPC_ATPA[i], X, Y);

          mmouse(x,y,1,1);
          Result := true;
        end;
      end;
    end;


    begin
     SetupSRL;
     FindCage;
     FindDemon;
    end.

    It's not moving the mouse I guess it's not finding it somehow

  10. #10
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    do writeln(length(atpa)) after filterTPAsBetween(ATPA, 1, 120) to see if you actually have any atpa's to search in.

  11. #11
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Ollybest View Post
    do writeln(length(atpa)) after filterTPAsBetween(ATPA, 1, 120) to see if you actually have any atpa's to search in.
    Ok I did a little debugging and it does find it, as seen here:

    Code:
    271,81|392,225
    But I also did a writeln in the findDemon procedure to get the coords again and the result was:

    Code:
    0,0|0,0
    So somehow they are all resetting back to 0 even though cage is global?

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
  •