SRL Archive - Help and Support

TPA, help


Laimonas171

2012-10-25 07:07:29

browsing the forum, I have noticed that TPA is quite big thing here, but I didn't find any easy understandable tutorials, maybe someone can explain me with an example how it works, I want to create procedure which mines Ore fast, and regular findObjEx doesn't work very fast + in some cases hovers some ppl, and from the side it looks very botty. If I get it right with TPA you can find obj more acurate, and faster as well.

masterBB

2012-10-25 07:19:42

We got tons of tutorials about TPAs. If you don't understand a specific part I could help you out with that. The most important thing is to realize that a TPA is nothing but a list of points. So you will search the screen for a certain color, and store the points where that color was found. Then you will sort it with one of the many TPA functions and tada! Done.

riwu

2012-10-25 07:21:39

Yeah i actually read at least 5 TPA last time before i finally master it, but it's well worth the effort ;) Take it slowly and really, read up all the TPA tutorials there are (in both the intermediate and advanced section), you will eventually understand it. I rmb there are a few that explains quite well and much easier to understand, cant rmb which though.

For a start, i'll give you some basic concepts:
When you use an ordinary color finding function (eg. FindColor), it will find the color from the screen and once it found the color, it returns the point to the var param (x,y) and breaks. But what if there are more points on the screen that has the color? TPA functions (FindColorsTolerance etc) solves the problem by storing all the TPoint where the colors are found to an array.

And now with an array of Tpoint you can manipulate it in several ways using plugin functions from Simba (check out the WizzyPlugin tutorial), such as sorting it from a point, or size etc, and most commonly, grouping those close to each other through SplitTPA/TPAtoATPA, and looping through them then using MiddleTPA to find the median of these points.
Ok i probably sound confusing, but just be patient and keep reading all the different tutorials and re-reading them until you understand.

Also the source code: https://github.com/MerlijnWajer/Simba/blob/master/Units/MMLCore/tpa.pas
is probably the most useful information, and i learnt how most TPA functions work, as well as how to handle arrays in general from there. You may need to be very familiar with for loops and arrays to understand them though. (and you can experiment with the functions using make-up static TPAs to get an idea)

Laimonas171

2012-10-25 07:23:51

From: masterBB
We got tons of tutorials about TPAs. If you don't understand a specific part I could help you out with that. The most important thing is to realize that a TPA is nothing but a list of points. So you will search the screen for a certain color, and store the points where that color was found. Then you will sort it with one of the many TPA functions and tada! Done.


Doesnt findOBjEX, search for multi colours?

or with tpa, before we start to search for sth, it "read" the screen area, for exact color, after that check all founded spots?

Can you make quick example of finding color let's say 1234568 ? some comments would be nice

edit: Riwu I see. Going to read documantation (i guess) Link you put here. I know for cycle, but on php, vb so probably get the idea, we will see though… :D

litoris

2012-10-25 07:34:19

From: Laimonas171
Doesnt findOBjEX, search for multi colours?

or with tpa, before we start to search for sth, it "read" the screen area, for exact color, after that check all founded spots?

Can you make quick example of finding color let's say 1234568 ? some comments would be nice

edit: Riwu I see. Going to read documantation (i guess) Link you put here. I know for cycle, but on php, vb so probably get the idea, we will see though… :D


Example: When you use the findcolor function, it gives you one x coordinate and one y coordinate, which form a point together. When you use findcolors, it gives you as many points as it can that contain the color you tried to find.
You can have tolerances in both version, so it doesn't have to be the "exact" color.

riwu

2012-10-25 07:34:52

From: Laimonas171
Doesnt findOBjEX, search for multi colours?

or with tpa, before we start to search for sth, it "read" the screen area, for exact color, after that check all founded spots?

Can you make quick example of finding color let's say 1234568 ? some comments would be nice

Searching for multiple colors != searching for multiple points with a color. Let's say you have a whole screen of blue. FindColor returns a single (x,y) point but that doesn't make sense since we should have more points with that color right?

So basically TPA functions searches the whole screen for the color and stores ALL the points to the array.
FindColorsTolerance(TPA, 1234568, MSX1,MSY1….)
will return an array of TPoint that has the color 1234568 (or similar if you set tolerance). So let's say on the screen there is 2 points (25,100), (90,200) with that color, the TPA returned will be [Point(25,100), Point(90,200)]. So let's say you want to choose the point that is nearer to your character you simply do SortTPAFrom(TPA, Point(MSCX, 177/MSCY)), and now TPA[0] (the first point in the array) will be the one. But that's just the most basic form of TPA. Grouping the TPA to ATPA is much more useful.

Also you can Combine the TPAs retrieved from different colors (like i did on my Waterfiend script, where i combine the points from the blue color of the water rune and the white color of the rune, then splitting them and checking the length. And you can see how fast i can detect when a fight ends, done with TPA as well ;)).

Footy

2012-10-25 07:46:37

I have a tut, NKN also has a good tut, there are a bunch in the intermediate section.

P1ng

2012-10-25 08:24:13

To begin with, I assume you are familiar with for to do loops, general arrays and functions.

If not, I or someone else will surely explain them to you.

function FindMyTPA: Boolean;
var
i, H: Integer;
M: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if FindColorsTolerance(TPA, 123456, MSx1, MSy1, MSx2, MSy2, 10) then //searches for colour on RS mainscreen
begin
ATPA := TPAtoATPAEx(TPA, 25, 25); //splits the each tpa into another array grouped into 25x25 pixel areas
SortATPAFrom(ATPA, Point(MSCx, MSCy)); //sets the array in order of closest to furthest from the centre of the mainscreen
H := High(ATPA); //sets the integer H as the number of ATPAs there are

for i := 0 to H do //cycles from the first to last ATPA
begin
M := MiddleTPA(ATPA[i]); //makes M a TPoint that is the middle of the ATPA it is up to
MMouse(M.x, M.y, RandomRange(-2, 2), RandomRange(-2, 2)); //moves the mouse to that TPoint with some randomness

Result := WaitUpText('uptext', 200); //checks for the uptext

if Result then //if appropriate uptext is found do this, otherwise keep searching
begin
ClickMouse2(mouse_Left); //click
Break; //stop searching
end;
end;
end else
WriteLn('None of colour: 123456 available in mainscreen');
end;

Laimonas171

2012-10-25 13:31:46

Thank you guys. Kinda get it, but not able to do it from scratch, watched YoHoJo's tutorial easiest way to get it work, and ACA tool is FTW. Though still someday have to learn how to do that by my self. :redface:

Edit:
Some rep
  • P1ng, for good example + explanation.
  • Footy for tutorial
  • Riwu sorry. you cannot accept more rep's :DD