Results 1 to 4 of 4

Thread: Delete Not In Box or Specific Size..

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

    Default Delete Not In Box or Specific Size..

    I'll get straight to the point:

    I got an atpa made with:

    TPAToATPAEx(70, 70);

    I want to delete anything that is smaller than 30 but larger than 70 but still be able to use the ATPA.. How can I do this?

    I was thinking:
    Simba Code:
    {$I SRL/SRL.Simba}

    var
      MyBox, MidBox: TBox;
      Width, Height, X, Y: Integer;
    begin
      MyBox:= GetTPABounds(ATPA[0]);
      MidBox:= MiddleBox(MyBox);
      MiddleTPAEx(ATPA[0], X, Y);
      Width:= iAbs(MyBox.X2 - MyBox.X1);
      Height:= iAbs(MyBox.Y2 - MyBox.Y1);

      if ((Width >= 30) AND (Width <= 70)  And (Height >= 30) AND (Height <= 70)) then
        For I:= 0 To High(ATPA[0]) do
        if (Not PointInBox(Point(X, Y), MyBox)) then
          DeleteValueInTPA(ATPA[0], I);
      else
        //The Box is larger than 70.. so shrink it to BxB.. and delete points not in the 70x70 box..    Where 30 <= B <= 70
        //AND if the box is smaller than 30.. then delete all the points in the ATPA at that position :S
    end.
    But I just can't figure it out :S
    I am Ggzz..
    Hackintosher

  2. #2
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    If I understand it right you want something like this? Where red color is boundary of TPA and green square is zone of points ,which you want delete from TPA? Where red is basic TPA ,and you want to delete everything ,which is not in green zone?


    If yes I have code already made ,I will paste ,when clean it up.

    is smaller than 30 OR larger than 70
    sorry I'm logic freak

    Way 1:
    Simba Code:
    program new;

      MyBox ,KeepBox: TBox ;
      ATPA : T2dPointArray;
      I :integer;

    begin

      ATPA := TPAToATPAEx(ATPA[0],70,70);     // Your ATPA
      MyBox:= GetTPABounds(ATPA[0]);
      if (MyBox.x2 >= 70)and(MyBox.y2 >= 70) then  // Make sure your ATPA has right dimension or it might fail
      begin
        KeepBox := InttoBox(Mybox.x1+30,Mybox.y1+30,MyBox.x1+70,MyBox.y1+70);
        For I:= 0 To High(ATPA[0]) do
          if not(PointInBox(ATPA[0][i], KeepBox)) then
            DeleteValueInTPA(ATPA[0], I);
      end;
    end.

    Way 2:
    Simba Code:
    program new;

      MyBox : TBox ;
      ATPA : T2dPointArray;
      I :integer;

    begin

      ATPA := TPAToATPAEx(ATPA[0],70,70);     // Your ATPA
      MyBox:= GetTPABounds(ATPA[0]);
      if (MyBox.x2 >= 70)and(MyBox.y2 >= 70) then  // Make sure your ATPA has right dimension or it might fail
      begin
        For I:= 0 To High(ATPA[0]) do
          if (ATPA[0][i].x < (MyBox.x1+30)) or (ATPA[0][i].x >(MyBox.x1+ 70)) or (ATPA[0][i].x < (MyBox.y1+30)) or (ATPA[0][i].x >(MyBox.y1+ 70)) then
            DeleteValueInTPA(ATPA[0], I);
      end;
    end.
    Last edited by bg5; 03-03-2012 at 09:06 PM.

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

    Default

    Exactly! Except that if it's less than 30 then I don't want it at all.. Basically lets say your fighting a spash monster like in soulwars.. the pyre fiends can splash when u hit them so they flames spread outwards.. and sometimes when other players are attacking them, the flames splash and my bot keeps thinking that it's a free NPC cuz it has no HP bar on the splashes.. So basically I'm trying to limit it to only find the solid parts alone and remove the stupid splashes.

    I got the logic.. just dunno how to program it I think :S I was thinking of combining it with count colour..

    Basically what you have.. so if that green box is too small or colour count is too low then delete the TPA (both red and green) from the ATPA and repeat..
    I only need to click it if the NPC on screen is a between a certain size..
    I am Ggzz..
    Hackintosher

  4. #4
    Join Date
    Oct 2011
    Posts
    805
    Mentioned
    21 Post(s)
    Quoted
    152 Post(s)

    Default

    I've played SW maybe 2 times ,so I don't know how it's looks ,but I hope this code is what you want.

    Simba Code:
    program new;
      var
      MyBox ,KeepBox: TBox ;
      ATPA : T2dPointArray;
      I,h,a, margX ,margY :integer;


    begin
      ATPA := TPAToATPAEx(ATPA[0],70,70);     // Your ATPA
      h := high(ATPA);
      for a := 0 to h do
      begin
        MyBox:= GetTPABounds(ATPA[a]);
        if (MyBox.x2 <= 30)and(MyBox.y2 <= 30) then    // Delete too small TPA
            DeleteTPAfromATPA(ATPA,ATPA[a])
        else
        begin
          if (MyBox.x2 >= 70) then            // if it's too long trim to proper size
            margX := (MyBox.x1 + 70)
          else
            margX := MyBox.x2;               // if it's shorter then 70 keep it's size ( will be somewhere between 30 and 70)

          if (MyBox.y2 >= 70) then
            margY := MyBox.y1 + 70;
          else
            margY := MyBox.y2;

          KeepBox := InttoBox(Mybox.x1+30,Mybox.y1+30,MargX,MargY);
          For I:= 0 To High(ATPA[a]) do
            if not(PointInBox(ATPA[a][i], KeepBox)) then
              DeleteValueInTPA(ATPA[a], I);
        end;
      end;
    end.
    Last edited by bg5; 03-03-2012 at 09:51 PM.

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
  •