SRL Archive - OSR Help

TPA Question


Footy

2012-09-22 10:49:06

I am trying to use TPA's to find the oven in nardah, but I'm not sure what functions to use. I'm trying to make a box around an area that has a lot of color returned. I looked at RAaSTPAEx but I have no idea how to use it. Can someone suggest what I should use? Thanks.

This is where I'll be standing, and the oven fully autocolored.


CephaXz

2012-09-22 10:57:11

Sort it in size so it finds the TPA with highest value first.

Footy

2012-09-22 10:58:36

To do that, I split it into an ATPA then sort the ATPA by size?

Brandon

2012-09-22 10:59:50

I'm trying to make a box around an area that has a lot of color returned.


Box := GetTPABounds(TPA);

MouseTBox(Box, MOUSE_LEFT);

I cannot remember if the above code is right but I know GetTPABounds will give you the box around a TPA.

Footy

2012-09-22 11:01:12

From: Brandon
Box := GetTPABounds(TPA);

MouseTBox(Box, MOUSE_LEFT);

I cannot remember if the above code is right but I know GetTPABounds will give you the box around a TPA.


Trying now, one second.

E: Works perfectly, Thanks! And thanks for that mouseTbox function, I've always been using Mouse(randomrange(box.x1, box.x2), randomrange(box.y1, box.y2), 0 0); :p

CephaXz

2012-09-22 11:04:54

From: Footy
To do that, I split it into an ATPA then sort the ATPA by size?


Yes… Something like this.


ATPA := TPAtoATPAEx(TPA, 40, 40); //width and height of your box
SortATPASize(ATPA, true);

Footy

2012-09-22 11:11:00

From: CephaXz
Yes… Something like this.


ATPA := TPAtoATPAEx(TPA, 40, 40); //width and height of your box
SortATPASize(ATPA, true);


The only reason brandon's method is more preferable is that I dont know the size of my box. It might be really big, or really small depending on which bank booth I'm at. I might use this for detecting the bank though. :D

litoris

2012-09-22 11:19:10

Just to let you know, RAaSTPAEx divides the tpa into boxes of your choice and creates a new TPA with the middle points of those boxes. Cuts down on processing time.

Footy

2012-09-22 11:21:28

You guys are making it so hard to decide which to use! Thanks for that info litoris, I'll be sure to use that function when I can.

P1ng

2012-09-22 22:58:45

I would recommend splitting the TPA into an ATPA.
Let's say you find a small amount of the colour on the opposite side of the mainscreen. Your TPA bounds are now roughly the entire mainscreen and the middle of that box would be your player.
This would not necessarily be an effective way to go.

CephaXz's method does not mean it will only click 'big' TPAs, but it will sort the TPAs in an order from biggest to smallest. This would likely make your oven the first TPA in the list

Nebula

2012-09-22 23:01:40

FindObj(); should do the trick

Ashaman88

2012-09-23 00:32:58

SplitTPAEx is my personal favorite :)

Footy

2012-09-23 09:57:37

I'm trying to use this SplitTPAex, but I cant figure out a few things:
How do I use the ATPA that it outputs?
Can I sort the TPA's from highest to lowest and lowest to highest on the screen?

Thanks!
~Footy

E: Think I figured out question one.


BankATPA := SplitTPAex(BankTPA, 10, 10);

riwu

2012-09-23 10:04:45

Yeah tons of ATPA/TPA sorting functions, just search through the function list. You may want to use wrapper functions.

Footy

2012-09-23 10:06:35

From: riwu
Yeah tons of ATPA/TPA sorting functions, just search through the function list. You may want to use wrapper functions.


I'm looking through them atm. Wrapper assigns the returned ATPA to x variable? I dont see any other difference between it and the other one.

E: I found SortATPAFrom and SortTPAFrom. This is how I believe you use it, could someone let me know if I'm doing it right, or if theres a better way to do it?

Function BankfromBank:boolean;
var
BankTPA:TPointArray;
BankATPA:T2DPointArray;
i:integer;
begin
if FindcolorsTolerance(BankTPA, color, MSX1, MXY1, MSX2, MSY2, tol) then
writeln('We found possible colors!') else
begin
writeln('We didnt find any colors for the BankTPA!');
Exit;
end;
BankATPA := SplitTPAex(BankTPA, 10, 10);
SortATPAFrom(BankATPA, point(0, 700));
L := High(BankATPA);
for i := 0 to L do
begin
mmouse(BankATPA[0][i].x, BankATPA[0][i].y, 5, 5);
if waituptext('Bank Uptext', 500) then
begin
writeln('We found the bank! Lets click on it!');
clickmouse(2);
break;
end;
end;
end;

Footy

2012-09-23 10:49:35

Appologies for double post, but I've updated the above post with some code, could someone tell me if I did it right? :)

Nebula

2012-09-23 10:54:16

No you did it wrong.

Should be: BankATPA := SplitTPAex(BankTPA, 10, 10);

Footy

2012-09-23 10:58:51

Whoops, thanks for that! Anything else need fixing up, or is in good now?

Nebula

2012-09-23 11:01:12

L := Length(BankATPA);

should be

L := High(BankATPA);

Footy

2012-09-23 11:03:19

Thanks! One other part i'm not sure about is this
mmouse(BankATPA[0][i].x, BankATPA[0][i].y, 5, 5);
I'm not sure if thats the right way to do it.

Nebula

2012-09-23 11:07:08

From: Footy
Thanks! One other part i'm not sure about is this
mmouse(BankATPA[0][i].x, BankATPA[0][i].y, 5, 5);
I'm not sure if thats the right way to do it.


Nope,


for i := 0 to High(Wutever) do
begin
MiddleTPAEx(Wutever[i], x, y);
MMouse(x, y, 5, 5);
if not isuptextcustommultiwhatever then
continue;
end;

Footy

2012-09-23 11:10:58

Alright, Great! Thanks for the help, rep+!

E: Nvm, I need to spread some rep before I give it to you.

litoris

2012-09-23 11:26:20

From: Footy

E: Nvm, I need to spread some rep before I give it to you.


There are quite a few people you could rep in this thread, :garfield:

Nebula

2012-09-23 11:43:10

From: litoris
There are quite a few people you could rep in this thread, :garfield:


Yeah P1ng and CephaXz looking quite deserving of some rep :cartman:

Ashaman88

2012-09-23 13:17:08

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

That guide explains a lot of the functions and uses for them. I highly recommend a look see. Also looking through other peoples scripts to see how they use it will help too - Flight's are especially clever.

Footy

2012-09-23 13:27:27

Thats the one I used to find SortATPAFrom, :D Thanks for the help everyone, I think I repped everyone who deserved it.
E: Still can't give it to Nebula… :p