SRL Archive - OSR Help

TPA Advice


Yanhua

2011-12-28 19:02:32

Hello Scripters,

I'm kind of new to using TPAs, and would like to ask for some guidance.

Well, I need to get the door. :)

So far, I've got this.



This is my procedure. Is there a way to make it filter out all the TPAs in the ATPA except for the door?


Procedure HandleDoor;
Var
Door:TPointArray;
B:TBox;
ATPA:T2DPointArray ;
Begin
If FindColorsSpiralTolerance(MSCX, MSCY, Door, 2172458, MSX1, MSY1, MSX2, MSY2, 0) Then
Begin
B := GetTPABounds(Door);
ATPA:=TPAtoATPAEx(Door, 15, 10000);
DebugATPABounds(ATPA);
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 2);
If IsUpText('pen') Then
Begin
WriteLn('The door is Closed. We are going to open it.');
MouseBox(B.X1, B.Y1, B.X2, B.Y2, 1);
end else
If IsUpText('ose') Then
Begin
WriteLn('The door is Open. We are OK to proceed.');
end;
end;
end;


RISK

2011-12-28 19:07:03

Why not 'Filter' the ATPAs from the center point (The center of the Runescape main screen)? This will make sure that you get the closest found ATPA first.

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

You could also check the distance of the ATPA and if it's over X amount of pixels away from the center of the Runescape screen, it will continue to the next ATPA.

Troll

2011-12-28 19:08:29

You could try something like
For I := High(ATPA) DownTo 0 Do
If High(ATPA[1]) > MinColourCount Then
etc
etc
That is off the top of my head but could work, sorry for not much detail but im off to bed and if no one else does might expand on this when i wake up :p

Anyway hope that helps for now

E: Ninja'd by RISK with a difrent idea :D

Yanhua

2011-12-28 19:12:06

From: RISK
Why not 'Filter' the ATPAs from the center point (The center of the Runescape main screen)? This will make sure that you get the closest found ATPA first.

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

You could also check the distance of the ATPA and if it's over X amount of pixels away from the center of the Runescape screen, it will continue to the next ATPA.


Okay, then after that how do I get the mouse to move to the TPA returned by the sorting?

RISK

2011-12-28 19:13:30

for I := 0 to High(ATPA) do
begin
MiddleTPA(ATPA[I], X, Y);
MMouse(X, Y, 5, 5);
end;

Yanhua

2011-12-28 19:18:46

From: RISK
for I := 0 to High(ATPA) do
begin
MiddleTPA(ATPA[I], X, Y);
MMouse(X, Y, 5, 5);
end;


That doesn't work :(

MiddleTPA doesn't return X, Y.

RISK

2011-12-28 19:19:43

Yeah it does. How were you using it?

Yanhua

2011-12-28 19:21:37

From: RISK
Yeah it does. How were you using it?


MiddleTPA doesn't.

MiddleTPAEx does.

RISK

2011-12-28 19:22:32

Oops, lol. You're right. My bad. Yeah, use MiddleTPAEx(ATPA, X, Y);.

Yanhua

2011-12-28 19:25:13

From: RISK
Oops, lol. You're right. My bad. Yeah, use MiddleTPAEx(ATPA, X, Y);.


Yup :)

Thanks RISK for all your help. I got my procedure working flawlessly now. :p

Going to release an good Edgeville cooker today or tomorrow.

Sabzi

2011-12-28 19:27:37

What?
MiddleTPA returns a TPoint.

Point := MiddleTPA(TPA);
Mouse(Point.x, Point.y, 5, 5, True);

Yanhua

2011-12-28 19:28:40

From: Sabzi
What?
MiddleTPA returns a TPoint.

Point := MiddleTPA(TPA);
Mouse(Point.x, Point.y, 5, 5, mouse_Left);


Yeah, I guess that'll work too.

I'm using this.

MiddleTPAEx(ATPA[I], X, Y);
MMouse(X, Y, 5, 5);

Sabzi

2011-12-28 19:31:00

Totally fine. I was just saying that MiddleTPA does exists.