Log in

View Full Version : Help with TPA and ATPA?



laakerules
03-02-2012, 02:27 AM
How would i make a ATPA function go about checking all the ATPA on the screen would i do a for 1 to I do

And then have junk here. And also have I sort the ATPA from hgh priority to low? and if so can i get an example by chance?


Here is my current function for finding the loot. I took 2 TPA and added them together to be able to get a better result. but that result is pointless unless i get help with having them go over all of the points.

Flight
03-02-2012, 02:37 AM
Oh glorious T2DPointArrays, where would we be without you??

The thing about all arrays is they start at 0. 0 Is the first variable in the array. So if you sort the ATPA from, let's say the middle of the screen (Point(MSCX, MSCY);) then ATPA[0] will be the closest to the center (your player). I'm gonna use my 'FindRocks' function from GranitePro to give an example; it's very simple and I'll explain it out how it works. Give me just a second and I'll edit this post.


Function FindRock(Var X,Y: Integer): Boolean;
var
B: TBox;
TPA,TPA2: TPointArray;
Hmod,Smod: Extended;
i,Tol,CTS,Col: Integer;
ATPA: T2DPointArray;
begin
Result := False;
CTS := GetColorToleranceSpeed;

ColorToleranceSpeed(3);
{Search the mainscreen area for a color starting at the center, TPA will be the found points}
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 9095162, MSX1, MSY1, MSX2, MSY2, 3);

{No colors found so let's reset our CTS and exit this function (result := False)}
if (Length(TPA) < 1) then
begin
ColorToleranceSpeed(CTS);
Exit;
end;

{Of our HUGE TPA let's split each section into 30x30 boxes}
ATPA := TPAToATPAEx(TPA, 30, 30);

{Now, let's sort those boxes from the middle of the main screen}
SortATPAFromFirstpoint(ATPA, Point(MSCX, MSCY));

{'i' will represent which box we're observing, so start from 0 to the max # of boxes}
for i := 0 to High(ATPA) do
begin

B := GetTPABounds(ATPA[i]); //This isn't really needed, but it's my own style...

with B do //Within this specific box do whatever
begin
ColorToleranceSpeed(2);
ReturnValues(RockCols, Hmod, Smod, Col, Tol);

SetColorSpeed2Modifiers(Hmod, SMod);
FindColorsSpiralTolerance(MSCX, MSCY, TPA2, Col, B.X1, B.Y1, B.X2, B.Y2, Tol)
ColorToleranceSpeed(CTS);

if (Length(TPA2) > 0) then
begin
MiddleTPAEx(ATPA[i], X, Y); //The middle of this TPA (box)
Result := True;
HumanMMouse(X, Y, 5, 5);
if WaitUpTextMulti(['Mine','Rocks'], 555) then
begin
Result := True;
GetMousePos(X, Y);
Exit;
end else
Result := False;
end;

end;

end;

end;


I used comments throughout the function, I hope it makes sense. Anyways if something is unclear about it just ask a question and I'll explain exactly how it works and why I used it.

laakerules
03-02-2012, 02:52 AM
Okay made sense and worked! :) thanks.

I have it currently painting pretty colors on the ATPA, but only does the one it has selected at the time, im using SMART_DrawDotsMulti(true, ATPA);


Edit: Sorry for double post, forgot to edit instead of posting! :duh:

Flight
03-02-2012, 02:55 AM
There's actually functions for debugging ATAPs.

procedure DebugATPABounds(aPoints: array Of TPointArray);


It's REALLY helpful when developing scripts and you'd like to see what Simba is seeing. It's truly a must for scripters. I do believe you'll have to include debug.simba for it though ({$i SRL/SRL/misc/debug.simba}).

Edit:
Here is an absolutely wonderful guide on TPAs/ATPAs: http://villavu.com/forum/showthread.php?t=49067.

I know at first it might seem a little overwhelming but I guarantee you it will step up your scripting ability far past the next level. I couldn't recommend this guide enough. :p

laakerules
03-02-2012, 02:58 AM
Whoa sick that brought up like a viewer box! :O


Coolio, anyway to make it like Put an Ellipse around the ATPA? By chance?


Edit: And what would you say is the best ATPA size? 30,30?

Flight
03-02-2012, 03:07 AM
Whoa sick that brought up like a viewer box! :O


Coolio, anyway to make it like Put an Ellipse around the ATPA? By chance?


Edit: And what would you say is the best ATPA size? 30,30?

I'm not quite sure, but I believe paintsmart.simba recently had similar functions made. I think it was Mormonman who made them, I'm sure you could use any of those. ATPA size depends on what you're looking for. Take a look at the second section of that Wizzup Plugin guide (usage in Runescape) and you'll see how you can determine the height/width boundaries. In the example I think it was cowhides being used, they're basically 20x20 or so:

http://i140.photobucket.com/albums/r37/naumanakhlaq/pic3-1.jpg

But should you look for something like, let's say a willow tree, and you're looking for the tree trunk color, it's much taller than it is wide, so we'd use something like 20 or 30 width with like a 60 height or whatever. You get the idea.

laakerules
03-02-2012, 03:09 AM
Ya i get the idea, thanks flight big help bro! :)