SRL Archive - Help and Support

Simple TPA Question


Footy

2012-10-10 19:43:50

I'm creating a TPA function to find the bank chest in SW, but I've run into an issue. Basically, my plan is to search for the rim of the chest(a unique color), make a box around this rim, then search for the brown chest color within the rim(or click inside the box I've made). The issue I have is creating this box. I know TPABounds will give you a TBox containing all the TPoints, but what if I get one tpoint in my array that is across the screen? It would completely ruin the function. What would you recommend to ensure this box stays only around the chest?

Nebula

2012-10-10 19:46:56

Only use the method if the length of the unique color is above a certain amount?

if length( ) < # then
Do something else. (ie rotate the camera so that it will show the box that is covered up)

Footy

2012-10-10 19:50:11

The box being covered up isn't the issue, it will never be covered with camera angle at it's highest. The issue comes when I use FindColorsSpiralTolerance and it fills the TPA, what happens if it finds a color on the other side of the screen? It would make a massive box to search for the other color, which would find the boxes and crates of the same color.

NCDS

2012-10-10 19:52:57


r := TPAToATPAEx(arrayOfOutlineColor, width, height); // splits the tpa into a 2D array sepcified by width and height.
h := High(r);
for i := 0 to h do
// then count color or whatever for the chest color until you find one with adequate results
Make sense?

Footy

2012-10-10 19:54:14

Makes perfect sense! Thanks! And if thats what you were trying to get at nebula, thanks! :)

Nebula

2012-10-10 20:00:47

Oh, now I get what you're saying.

Use SplitTPA, so you have an ATPA of points that are dist away from each other. assuming the bank chest boarder is the most concentrated area, sort the atpa by size and use the first array in the atpa.

ninjad/whatever it's called. (E actually what ncds said what exactly what I first said)

or before actually clicking anything, check the area of the box you have, and make sure it is within a certain range.

Edit again: SplitTPA flood fills, so using a distance 2-3 will work even though some of the points of the boarder are 20+ pixels apart.

Footy

2012-10-10 20:05:28

NCDS beat you, but both of the functions work. I'll choose one of them when I decide to start working on this again. Repped both of you, thanks!

litoris

2012-10-11 10:02:15

Just a protip next time, TPAs are very problematic without ATPAs, you should always use them in conjunction.