Log in

View Full Version : Delete Not In Box or Specific Size..



Brandon
03-03-2012, 07:04 PM
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:

{$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

bg5
03-03-2012, 08:47 PM
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?
http://puu.sh/jjjw

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:p

Way 1:
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:
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.

Brandon
03-03-2012, 09:05 PM
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..

bg5
03-03-2012, 09:48 PM
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.

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.