PDA

View Full Version : Uses of TPA walking



Blumblebee
08-03-2009, 03:12 PM
Now this tutorial is more about theory and thinking than it is about raw code, something to bring to your attention that is usually overlooked.

Now first thing is, we can all all understand that RadialWalk() is a form of TPA walking, but there are many other ways of tpa walking, and many uses for this.

Before reading this tutorial I would suggest having a basic knowledge of TPA's, how to make and manipulate them.

I will break this tutorial up into 3 parts,

I. Color finding
II. Area manipulation
III. Theory
IV. Examples

I. Color Finding

Now, Color finding is simple and very similiar to mainscreen finding, infact, you can make it exactly the same as mainscreen finding with different co-ords (MMx1 instead of MSx1 ;)). Keeping in mind there might be some functions you may want to include and use in your tpa finding. these being:

SortTPAFrom(tpa: TpointArray; From: Tpoint);

SortTPAFrom(tpa: Tpointarray; from: Tpoint);

sorts a given tpointarray from a certain point. Some example points are:

Point(MMcx, MMcy); {middle of the mm}
Point(MMx2, MMy2); {Bottom Right}

looks like this:

SortTPAFrom(tpa, Point(MMcx, MMcy);

simple right? This procedure is used simple to start your tpa from a given point. To express this point I'll give you an example situation:
http://i31.tinypic.com/6gbnm1.jpg

say you want to walk to this point on the minimap, now a simple findwatercolor would obtain all the water, and walking to a tpoint, you would have the possiblity to walk to any point on the lake. so before you split your tpa, or click it in general, a simple SortTPAFrom(tpa, Point(aPointInsidetheRedCircle) would make the first tpa the script moves to/clicks in that area, or the closest point to that area and make your character walk there.


Rs_OnMiniMap(x, y: Integer);


Rs_OnMiniMap(x, y: Integer);

Ok, so now you want to find a color that is a dark brown, a color that may be similiar to that of the outerlayer of the minimap. A simple fix for your mouse clicking this area is simple a RS_OnMiniMap check.

Rs_OnMiniMap is simple an easy to use, helps to keep the script accurate and keep away from silly errors and mistakes. Lets take an example:

Function ClickMMTpointArray(tpa: TpointArray; xmod, ymod: Integer): Boolean;
var i: integer;
begin
for i := 0 to High(tpa) do
begin
WriteLn('Current Point at: ('+IntToStr(Tpa[i].x)+', '+IntToStr(tpa[i].y)+');');
if not rs_OnMiniMap(tpa[i].x, tpa[i].y) then Continue;
Mouse(tpa[i].x+xmod, tpa[i].y+ymod, 5, 5, True);
Wait(150+random(200));
if FlagPresent then
begin
FFlag(5);
Result := True;
Exit;
end else
Continue;
end;
end;

this is my favorite tpa clicking function. Simple it goes through the TPA from 0 to the highest point until one is on the minimap, then it clicks it. Keeping the script accurate.



FilterPointsPie( var Points: TpointArray;
SD, ED, MinR, MaxR: Extended; Mx, My: Integer);

FilterPointsPie( var Points: TpointArray; SD, ED, MinR, MaxR: Extended; Mx, My: Integer);
This function can come off as incredibly confusing but dont worry I'll walk you through it slowly, and show some uses.

lets start with

vars Points: TpointArray ;
this is self explainitory you simply just put in your tpa there.
SD, ED: Extended;
this, is the start and end radians where it will filter from. Confused, think back to RadialWalking when you inputed the start and end radials to where you wanted the function to search in. If your still confused I would suggest a refresher on radialwalk before continuing this tutorial.
MinR, MaxR: Extended;
The Minimum and Maximum Radius (not to be confused with Radians) to which you want to filter from. Say you want to walk a long distance however the same color appears frequently, you can simple filter from 0 to 60 and then your script will only look at the tpoints between 61 to the outside of the minimap. Its also a good way to filter out the outside of the Minimap ( the ridge) that has similiar colors to some places on the map.
Mx, My: Integer
this is simply the center of the circle to which you wants points filtered from. For use of the Minimap I would Suggest MMcx, MMcy which is the center of the minimap.


RadialWalkEx(var TPA: TPointArray; cx, cy, TheColor, tol, StartRadial, EndRadial, Radius: Integer): Boolean;


Alright, so one of my favorite functions to mess around with, simply this is a more extended version of radialwalk and one that you can easily edit aswell. So first of all, you will notice the tolerance parameter, which allows you to now use static colors and search with tolerance. This is even more handy now considering autocolor.scar isn't working (and won't be fixed probably).

ex. Function RadialWalkExEx(TheColor, StartRadial, EndRadial, Radius, Xmod, Ymod: Integer): Boolean;
var TPA: TPointArray; I: Integer;
begin
if RadialWalkEx(tpa, MMCX, MMCY, TheColor, 0, StartRadial, EndRadial, Radius) then
for i := 0 to High(tpa) do
if MFNF(tpa[i].x+Xmod, tpa[i].y+Ymod, 5, 5) then
begin
FFlag(10);
Result := True;
Exit;
end;
end;


this is my modified version for a more broader approach. You can also do something like...

RadialWalkEx(TPA, MMCX, MMCY, 1234567, 15, 0, 90, 60)
if length(TPA) > 0 then
begin
// either you can manipulate the TPA like so...
ATPA := TPAtoATPAex(TPA, 5, 5);
for i := 0 to high(ATPA) do
begin
P := MiddleTPA(ATPA[i]);
// etc
end;
// or something like this
for i := 0 to High(TPA) do
begin
Mouse(TPA[i].x, TPA[i].y, 5, 5, True);
// etc
end;
end;


So keep this function handy the next time your walking and don't want to create your own autocolor, or there is a unique color on the MM. it's a good way to keep using the RadialWalk you know and love, but now expand on it and use it for a larger audience of problems. I can go into more detail if required, I don't know how much needs to be said that isn't already quite self-explainitory.

FindColorSkipBox(var x, y, Color, x1, y1, x2, y2: Integer; Skip: Tbox)


Now this is one of my new favorite functions to use. This is a much easier way of manipulating the search area. Best used with autocolors, this can help differentiate where you are by searching only a certain area and negating other spaces. An example being, in one of my scripts I use this to check if I am at my final destination. There are 4 rocks on the screen, so I filter out the 2 in a box that I dont want my character to walk to, and if it finds the other two rocks in a different area then it preforms a task.

example being:

Function WalkToAltar(): Boolean;
var i: Integer; x, y: Integer; Skip: TBox;
begin
Skip.x1 := 589; // here is where I set up my Tbox. You could alternativly make this a global variable
Skip.y1 := 135; // That would allow you only to have to declare it once at the start of the script
Skip.x2 := 665;
Skip.y2 := 167;
WriteLn('Walk to Altar initiated');
SetRunEx();
RoadColor := FindNewVarrockRoadColor;
repeat
if Random(2) = 1 then RoadColor := FindNewVarrockRoadColor;
PathWalk(0);
Inc(i);
if FindColorSkipBox(x, y, FindRockColor, MMx1, MMy1, MMx2, MMy2, Skip) then Break;
until I > 3;
Result := PathWalk(2);
end;

So pretty much my script repeats a walk until it finds the rock color in an area then breaks the loop if it finds it. Again I can expand on this if requested but in my opinion it seems pretty self explainitory again.



got more functions that you would like explaining? Let me know and I can add them.


II. Area Manipulation
This is a small section of this tutorial, and is simply for those who find that mainscreen or minimap that the mouse just keeps mousing over things.

First of all You will need to study this picture and understand the constants for area manipluation and furthermore I hope you start to gain an idea of how you can change the search area.

http://i30.tinypic.com/2iuxgn7.jpg

With this picture I hope you can deturmine bottom left bottom right, ect areas of the screen.

Now With Any findcolor procedure (findcolor, findcolors. findcolorspiral, findcolorsspiral, etc) you should not that each should give you an area for which you can search in the color. Most of the time you give the default MSx1, MSy1, MSx2, MSy2 (for mainscreen) or MM for minimap finding. However you should note that those numbers can be manipluated to look in only a certain section to find a particular color, even basic co-ords can be used to serach a section of a minimap.

keep in mind each area is a box. This box requires two main points, each corner of the box, the top left and the bottom right. Quite simple and this will allow you to make your walking very accurate with TPA walking, as accuate as a ddtm if done correctly.

III. Theory

The theory part of it is more just examples and ideas that you can impliment in your script. Now, have you ever been pissed off about using findsymbol()? When someone stands on it and the script totally screws up? well simply enough you can just use a simple TPA to walk instead of FindSymbol. This allows tolerance, and only getting a section of the symbol instead of the whole thing, allowing for even more accurate finding.

How about when there are two symbols on the screen? You can use area manipulation to only look at one, using findsymbolin() or a custom tpa.

TPA's and area manipulation have endless opportunity, its all about looking outside the box and realizing the unique colors and areas on the minimap. Theory really cant be taught, but hopefully it can be inspired.

IV. Examples

Finally, what you've been waiting for, some examples of TPA walking. Now for me I prefer having a function that gathers the TPA and a function that Clicks it, however I have deduced two different TPA walking styles. Keep in mind each person has their own styles, likes and dislikes, and that what may work for me might not work for you.

From my guildminer:

Function GetMMPoints(x, y, color, width, height, tolerance: Integer): TpointArray;
var tpa: TpointArray; atpa: T2DpointArray; l, i, p: Integer;
begin
FindColorsSpiralTolerance(x, y, tpa, color, MMx1, MMy1, MMx2, MMy2, tolerance);
Atpa := TPAtoATPAEx(Tpa, width, height);
for i := 0 to High(atpa) do
begin
if Length(atpa) > 5 then
begin
l := getarraylength(Result);
SetArrayLength(Result, l+1);
Result[l] := MiddleTpa(atpa[i]);
end;
end;
if Length(result) = 0 then Exit;
for i := 0 to High(Result) do
if rs_OnMiniMap(result[i].x, result[i].y) then Inc(p);
if p = 0 then SetArrayLength(Result, 0);
WriteLn('Found: '+IntToStr(l)+' Result(s)');
end;

this function literally gathers all the points on the mm of a similiar color, the syntax is simple and easy to understand. I do not wish to break it down for you, but if requested I eventually will. This is a very confusing way of doing it but its my way and i like it :) another, more simple way of tpa walking would be something like this:

Function Water_Walk(Wx, Wy: Integer): Boolean;
var TPA: TPointArray; ATPA: T2DPointArray; P: TPoint; H: Integer;
begin
if not LoggedIn then Exit;
FindColorsSpiralTolerance(Wx, Wy, TPA, FindWaterColor, MMX1, MMY1, MMX2, MMY2, 1);
if Length(TPA) = 0 then
begin
Result := False;
Exit;
end;
ATPA := SplitTPAEx(TPA, 3, 3);
SortATPASize(ATPA, True);
for H := 0 to High(ATPA) do
begin
P := MiddleTPA(ATPA[H]);
MMouse(P.x + 25, P.y + 25, 5, 5);
Wait(RandomRange(125, 550));
GetmousePos(P.x, p.y);
Mouse(P.x, p.y, 5, 5, True);
Wait(200+random(100));
if not FlagPresent then Continue;
FFlag(15);
Result := True;
if Result then Break;
end;
end;

a simple tpa that walking via a boolean and clicks/sorts by a certain x and y co-ordinate set by the user.

V. Final Notes

I updated this slightly, and I would like to continue doing so, so please if there is a function you think deserves to be added or should/could be explained then let me know.

tls
08-03-2009, 03:36 PM
Welcome Back?

Blumblebee
08-03-2009, 03:40 PM
I leave in 2 days from now again, thought I'd do something in the couple days I was around again for a bit :)

Cazax
08-04-2009, 05:58 AM
Nice tutorial :) Though you could add RadialWalkEx since they return the TPA, but you explained FilterPointsPie.

NCDS
08-04-2009, 06:32 AM
Looks good man

Rep+

I actually started scripting a bit like you after that hide tanner :p ..as far as the TPA walking goes anyways.

Macro_FTW
08-04-2009, 06:38 AM
Rep+. I was thinking about how to do this about 2 or 3 days ago. Good tutorial. ^^

anonymity
08-04-2009, 08:08 AM
rep + I also thought it was a great tutorial. Thanks always.

3Garrett3
08-04-2009, 08:09 AM
I was just being confused about this today. This is a great tut. I learned a thing or two.. or three. :o

Blumblebee
08-04-2009, 08:19 AM
Looks good man

Rep+

I actually started scripting a bit like you after that hide tanner :p ..as far as the TPA walking goes anyways.


Rep+. I was thinking about how to do this about 2 or 3 days ago. Good tutorial. ^^


rep + I also thought it was a great tutorial. Thanks always.


I was just being confused about this today. This is a great tut. I learned a thing or two.. or three. :o

thanks, I'm glad this has helped so many people :)

3Garrett3
08-04-2009, 08:29 AM
Thanks for writing the tut.

ps, did you just get a new cup? I thought you only had two just a second ago

Narcle
08-04-2009, 09:07 AM
Ya I love using TPA walking. :D I used it in my smelter.

Blumblebee
08-04-2009, 02:22 PM
Thanks for writing the tut.

ps, did you just get a new cup? I thought you only had two just a second ago

no ive had 3 for a while... :p haha

Ya I love using TPA walking. :D I used it in my smelter.

I loves it too, its really underrated so I figured I'd draw some attention to it :)

ShowerThoughts
08-04-2009, 05:43 PM
I love it, REP++.

Sapo
08-04-2009, 09:04 PM
It looks difficult but when you are used to it you will find it CRAZY
Nice TUT

MylesMadness
08-04-2009, 10:35 PM
I was thinking about this a couple days ago. I was thinking of a different way though.

Blumblebee
08-04-2009, 10:55 PM
I was thinking about this a couple days ago. I was thinking of a different way though.

this was more or less just my style. Can I ask how you do yours?

Smarter Child
08-05-2009, 03:02 AM
Great Tut. <3/ Rep := Rep + 1;

MylesMadness
08-07-2009, 11:17 PM
this was more or less just my style. Can I ask how you do yours?I was thinking about getting the thickness of the road, and click the on the one that is x pixels wide. Not very accurate though because the roads can have same width, so I decided to pick the road that starts x pixels over to the left. Again, could not be accurate. I just have brain storming sessions at 2 in morning.

Sir R. M8gic1an
08-10-2009, 07:17 PM
Moved to advanced. Rep+

~RM

Blumblebee
11-18-2009, 05:43 AM
out of absolute boredom I updated this slightly, added a couple more functions, and will try to add more in the next few days.

Yush Dragon
08-13-2010, 12:10 AM
hmm gotta check the tutorial out tomorow it's like 2:00 over here, gona sleep after some mins, anyway, THANKS and GOODNIGHT ;D

+rep