Results 1 to 8 of 8

Thread: TPA walking

  1. #1
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default TPA walking

    In this tutorial, I will attempt to show you the uses of TPAs as well as the basics of what they are.

    How do I walk with TPAs?
    Woah sport, calm down. Before we get to the big leagues, let’s learn the basics.

    Like what?
    Before you can walk with a TPA, you need to know what it means. Let’s start with a TP (TPoint) which is a single point. Since I don't have the creativity to make a knowledgable definition of a TPoint, I will allow google to do it for me.

    a geometric element that has position but no extension
    the precise location of something
    So there you have it. A TPoint could be either of those definitions, although I find the second one easier to follow. A TPoint is the exact position of something.

    You may recognize this code:
    SCAR Code:
    program New;
    {.include srl/srl.scar}
    var
    x,y : integer;
    begin
    findcolor(x,y, {col}, MMX1, MMY1, MMX2, MMY2);
    Mouse(x,y,1,1,True);
    end.

    The simple function of this finds a color on the minimap, and returns the coordinates of the color at (x,y). Now, (x,y) is a point, and we can eliminate those variables in place of a TPoint, and it will do exactly the same thing.

    SCAR Code:
    program New;
    {.include srl/srl.scar}
    var
    CPoint : TPoint;
    begin
    findcolor(CPoint.x,CPoint.y, {col}, MMX1, MMY1, MMX2, MMY2);
    Mouse(CPoint.x,CPoint.y,1,1,True);
    end.

    This isn't exactly the best use of a TPoint, but you can understand the basic concepts of what a TPoint is with this example.

    Okay, so this TPA deal, whats up with that?
    A TPA is a simple thing once you know what a TPoint is. A TPA simply stands for TPointArray. Or in other words, and Array of TPoints, or in other words, More than one TPoint put together to make life easier. Any of those definitions.

    Here is how you define a TPA in your script, to make it ready for use.

    SCAR Code:
    var
    CPointArray : TPointArray;

    So that was easy enough, right? Ready to get down to the real fun? I know you're not. Lets have a simple example of how to create a tpa.

    SCAR Code:
    program New;
    {.include srl/srl.scar}
    var
    CPointArray : TPointArray;
    begin
    CPointArray := [Point(1,1), Point(2,2)];
    end.

    So there is is. Remember that the function Point(x,y) returns a TPoint. Also remember that square brackets [this kind] mean an array.
    If we were to move our mouse to both of these points, it would be just as easy as creating the whole stupid tpa, right? But imagine a road in runescape, there are quite a few pixles with the same colour there. Hundreds of them. It would be a pain to find each one and then move the mouse to each one. Imagine finding a tree when in a forest, and typing out hundreds of lines to move to each colour. This is where a TPA comes in handy.

    Ready for a more complex example?

    SCAR Code:
    program New;
    {.include srl/srl.scar}
    var
    CPointArray : TPointArray;
    I: Integer;
    begin
    FindColorsTolerance(CPointArray, {Col}, MMX1, MMY1, MMX2, MMY2, 5);
    for I := 0 to High(CPointArray) do
      MMouse(CPointArray[I].x, CPointArray[I].y, 1, 1);
    end.

    Let's break down this bad boy.

    FindColorsTolerance (Note the 'S' as in multiple colours) will find all of the colours that match whatever colour you choose as "Col" with a tolerance of 5. It stores every single coordinate to these colours in the Tpointarray.
    For to do - This loop starts at the value of 0, all the way up to the very last point of the array, and do whatever is one line after it. If you want more than one action performed with the colours, remember to use a begin/end
    MMouse - Self explainitory. Moves the mouse to every single found colour.

    So now we know how to find colours, make a loop, and look through them all, what now?
    Now, my friend, we get into the fun stuff.
    Here is a basic walking function using TPAs

    SCAR Code:
    program New;
    {.include srl/srl.scar}
    var
    TPA : TPointArray;
    H, I: Integer;
    begin
    FindColorsSpiralTolerance(MMCX, MMCY, TPA, {Colour}, MMX1, MMY1, MMX2, MMY2, 7);
      If Length(TPA) = 0 Then
        FindColorsSpiralTolerance(MMCX, MMCY, TPA, {Colour2}, MMX1, MMY1, MMX2, MMY2, 7);
      H := High(TDPA);
      For i := 0 To H Do
      Begin
        If rs_OnMinimap(TPA[i].x,TPA[i].y) Then
        Begin
          MouseFlag(TPA[i].x,TPA[i].y, 1, 1, 0);
          Wait(200 + Random(80));
          Exit;
        End;
      End;
    end.

    Now, let's not crap our pants. We can get through this together.

    SCAR Code:
    FindColorsSpiralTolerance(MMCX, MMCY, TPA, {colour}, MMX1, MMY1, MMX2, MMY2, 7);

    This works exactly like FindColorsTolerance, except it spirals outwards from the point (In this example, the minimap center) instead of working from left to right.

    Why is there two? Because if the first one doesn't return any values, it will look for a different colour which will hopefully return a point to walk to.

    SCAR Code:
    H := High(TPA);
      For i := 0 To H Do

    This is simply a more efficient way of calling "For I:= 0 to High(TPA)" because it doesn't have to call the function High over and over again, which will make your script more efficient.

    SCAR Code:
    If rs_OnMinimap(TPA[i].x,TPA[i].y) Then

    This is a SCAR function that makes sure that the point is on the minimap, not the little ring around it, and will prevent your script from messing up its clicks.

    The rest simply involves clicking that point, then exiting the loop.

    This is what I would consider bare bones walking. You want more complex walking? Sure thing. Here is the function I use in my smelting script:

    SCAR Code:
    Function WalkTPA(C1, C2, XM, YM, XR, YR : Integer; SortPoint : TPoint) : Boolean;
    Var
      TPA: TPointArray;
      TDPA: T2DPointArray;
      I, CTS, H, X, Y: Integer;
    Begin
      If Not LoggedIn Then Exit;
      cts := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.10, 25);
      FindColorsSpiralTolerance(MMCX, MMCY, TPA, C1, MMX1, MMY1, MMX2, MMY2, 7);
      If Length(TPA) = 0 Then
        FindColorsSpiralTolerance(MMCX, MMCY, TPA, C2, MMX1, MMY1, MMX2, MMY2, 7);
      TDPA := TPAtoATPAEx(TPA, 20, 20);
      SortATPAFromFirstPoint(TDPA, SortPoint);
      H := High(TDPA);
      For i := 0 To H Do
      Begin
        MiddleTPAEx(TDPA[i], x, y);
        If rs_OnMinimap(x,y) Then
        Begin
          MouseFlag(x + XM, y + YM, XR, YR, 0);
          Result := True;
          Inc(TPAWalks);
          Wait(200 + Random(80));
          ColorToleranceSpeed(cts);
          Exit;
        End;
      End;
      Result := False;
      ColorToleranceSpeed(cts);
    End;

    Now. Before you even have a chance of getting your head around this, you need to understand a few things about TPAs. If an Array of Tpoints isn't enough for you, how about an Array of TPAs? This is called an ATPA, and is defined in a script as a T2DPointArray. I really can't find the words to explain an ATPA properly. Let me give it a shot anyway.

    An ATPA allows you to sort your TPAs based on the locations of them. Grouping a bunch of TPAs together means that less points will be around that area, and less misclicks.

    How do you make an ATPA? There are a few ways. In my example, I used TPAtoATPAEx(TPA, 20, 20); which will take any tpas that are within 20 pixel range of eachother and make them into a square group, which is now counted as a single area.

    Another way is TPAtoATPA(TPA, 5) where 5 is the radius of a circle. It does the same as TPAtoATPAEx except it makes a circle instead of a rectangle.

    SplitTPA will create the same circles as TPAtoATPA, but if there are any circles that are in contact with one another, it will group the two of them together in a single ATPA instead of two.

    SplitTPAEx will do the same as SplitTPA, but in a rectangle.

    So now that we have all of these things circling in our head, which one do we use? Well it depends on the situation. MainScreen things can most often be circles, but a minimap needs more accuracy, like in a box.

    So we know the basics of how the function is defined. Let's look at my function again.

    SCAR Code:
    cts := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorspeed2Modifiers(0.10, 25);

    This is simply a group of things that makes it easier for the script to find the colours, if I have been taught right. Make sure to grab the current colortolerancespeed and store it, so you can set it back at the end of the function.

    SCAR Code:
    FindColorsSpiralTolerance(MMCX, MMCY, TPA, C1, MMX1, MMY1, MMX2, MMY2, 7);
      If Length(TPA) = 0 Then
        FindColorsSpiralTolerance(MMCX, MMCY, TPA, C2, MMX1, MMY1, MMX2, MMY2, 7);

    This part simply looks for the colours, i'm sure we understand it.

    SCAR Code:
    TDPA := TPAtoATPAEx(TPA, 20, 20);
      SortATPAFromFirstPoint(TDPA, SortPoint);
      H := High(TDPA);
      For i := 0 To H Do

    Here I am making my ATPA. The Function SortATPAFromFirstPoint(ATPA, Point) sorts the ATPA by distance from the point, so if you know the general direction of where you are walking, you can help your script become more accurate.

    SCAR Code:
    MiddleTPAEx(TDPA[i], x, y);
        If rs_OnMinimap(x,y) Then

    MiddleTPAEx takes the big group of TPA's that you have in a rectangle (or circle) and returns where the center of the group is, to make your click more accurate. On minimap checks to see if the center is on the minimap.

    The rest of the function simply goes through and clicks, then increases a variable used for my proggy, and resets the colortolerancespeed.

    I hope that this may have made TPA's easier to understand for you. I think they are very good for walking short distances, when included with an autocolor, and even as I was writing this, I was changing my TPA functions around to make them better, and more accurate.

    In closing, I will hand out some links to other great TPA tutorials that I have learned from in the past, and may help you out.

    Detailed TPA and ATPA tutorial - By Cazax
    The Almighty TPA Tutorial - By N3ss3s
    Uses of TPA walking - By BlumbleBee

    I will include anything else that people might want to know, so request away if you feel the need for more knowledge.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  2. #2
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Reserved in case I decide to add anything

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  3. #3
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well done, nice tutorial, learned quite a bit. inc(rep);

  4. #4
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Heh. Thanks. I put quite a bit of work into it

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  5. #5
    Join Date
    Nov 2008
    Location
    Norway, Alesund
    Posts
    924
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Bookmarked , also REP++

  6. #6
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Nothing wrong or confusing? I'll add anything you guys think is needed.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  7. #7
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Maybe add RadialWalkEx, since its considered TPA?

    Edit: Best for road walking ofc,.

  8. #8
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by Smarter Child View Post
    Maybe add RadialWalkEx, since its considered TPA?

    Edit: Best for road walking ofc,.
    I'd have to learn it first, but sure

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •