Page 1 of 5 123 ... LastLast
Results 1 to 25 of 115

Thread: Map Walking - The Basics to the Advanced

  1. #1
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Map Walking - The Basics to the Advanced

    Map Walking
    by ZephyrsFury
    Contents

    Since I’m leaving for the next couple of months I won’t be of much help here so I decided I would make up for it with this large tutorial. It’s about map walking (my speciality ) and is extremely detailed. It covers everything from RadialWalking to colour clicking, then onto DTMs and DDTMs. There’s also a bit of failsafes as that is the key to success when you are map walking in RS. For anyone that feels like a light read or if you can’t be bothered learning then leave now . Otherwise enjoy reading this 5646 word tutorial....

    To create a successful and flawless script in Runescape, you need several things:
    1. You must be able to script (the basics – variables, constants, procedures, etc).
    2. Must utilise SRL well.
    3. Failsafes
    4. Must know how to map walk.


    Now I know there is a lot more that I could add to my list but since this tutorial is about map walking, I’ll let you read other tuts, look at scripts and talk to experienced scripters to find out for yourself. .

    As a mentioned above, map walking in RS is essential to create a good script. Actually I wouldn’t say a power chopper requires it but if you want to include DeathWalk, banking, walking between trees, etc. then it is needed. Basically, if you haven’t figured it out already, map walking is the name given to walking in RS between places using SCAR.

    In this tutorial I will go through the basics of map walking (RadialWalk, RadialRoadWalk, symbol clicking, colour finding) as well as some other more advanced methods (DDTMs and DTMs). I’ll also be going through the most common failsafes for walking as well as some of my own. I warn you though, this tutorial is extremely long and in depth. I’ll do my best to explain everything but I’m not a teacher – only a 15 year old to whom English was a second language.

    Throughout this tutorial, I’ll be using examples from my Rune Mysteries Runner which obviously requires lots and lots of walking (Between and within 3 different cities and places). I’ve also attached a list of several good tutorials to do with the topics discussed here as well as some tool that might help you with map walking.

    Now onto the first part – RadialWalk and RadialRoadWalk.

  2. #2
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default RadialWalk and RadialRoadWalk

    RadialWalk and RadialRoadWalk

    Back to Top

    Now these functions are the most commonly used and (IMO) one of the best. Basically, it searches for a colour, outside in, towards the centre of the minimap and if it finds the colour, it clicks. Simple, ingenious and efficient I say. . Before I explain how to use it I’ll explain how it works. I know what you’re saying... “Theory...! I CBFed with theory... just get on with it... I wanna make my uber flawless dragon slayer quest runner already... ”. Well it makes sense if you want to do something practical then you need to know the theory. So here it goes...

    RadialWalk basically combines FindColor with a bit of trigonometry and geometry. It requires you to specify two angles and a radius (imagine a piece of pizza, the tip of the piece is the minimap centre and the crust is the radius). It will search between those two angles starting from the radius and move inwards towards the minimap centre searching for the colour pixel-by-pixel. If it finds the colour it clicks. Like I said, simple.

    Now there’s the theory behind RW in a nutshell. On to the practical stuff like I promised:

    SCAR Code:
    function RadialWalk(TheColor: Integer; StartRadial, EndRadial: Integer; Radius: Integer; Xmod, Ymod: Integer): Boolean;

    An explanation of the parameters:
    • TheColor: The colour you are looking for. ie the colour it will click.
    • StartRadial: The first angle where the function will start looking from. (Usually from 0 to 360). 0 is north, 90 east, 180 south, 270 west, 360 north again.
    • EndRadial: Same with StartRadial except this is the angle where it stops searching. It can be greater than or less than the start angle. If it’s larger than then it will search clockwise. If it’s less than it will search anti-clockwise (think about it logically ).
    • Radius: The distance in pixels from the minimap centre it will start searching from.
    • Xmod: The distance on the X axis the mouse will move every time the function tries to click but the flag doesn’t appear. (MouseFindNoFlag). So if it finds the colour and clicks but the flag doesn’t appear (can’t reach it), it will move the mouse Xmod units along the X axis until the flag appears. (negative is left, postive is right).
    • Ymod: Same with Xmod except along the Y axis. (negative for up, positive for down).




    Ok so now an example:

    SCAR Code:
    RadialWalk(MyRoadColour, 70, 100, 65, -1, 0);

    If you look at that example, you can see it will try and find the RoadColour (a variable with a colour stored in it) in a sector of the minimap that has a radius of 65 pixels, which starts at 70 degrees and finishes at 100 degrees (approximately east). If it can’t place the flag then it will move one pixel west (-1) and try again.

    Here’s a screenie of what the script will do when you call RadialWalk with the above parameters:



    I mentioned above that RadialWalk searches for the colour outwards in . So it will click the pixel that is furthest away from the minimap centre. So choose your radius well. I sometimes have a problem when the radius is too big because the flag appear off the minimap or close to it so when the character begins to walk, it might disappear making the script think the flag has been reach and continues on with the script.

    To get the best start and end angles and the best radius I’d recommend that you use Yakman’s Radial Walking Aid which is invaluable to me when I use RadialWalk. You used to be able to find this in then SRL folder but it seems to have disappeared so I’ve uploaded it below.

    Now that we’ve discussed RadialWalk, RadialRoadWalk should be easy. Basically it follows the same principle except RRW is designed for walking using the road colour (obviously). Basically if you call RadialRoadWalk you should use RoadColor as TheColor. This is because RRW dynamically updates the road colour as it goes along so there’s no chance of it getting stuck because the colour changed by a few tolerance numbers.

    So the same example above except with RRW:

    SCAR Code:
    RadialRoadWalk(RoadColor, 70, 100, 65, -1, 0);

    The parameters at the same. The only major difference is the TheColor is usually RoadColor;

    That’s pretty much all for RadialWalk and RadialRoadWalk. For more information see the Recommended Tutorials list at the bottom. Now onto the next section – Symbol Clicking.

  3. #3
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Symbol Clicking

    Symbol Clicking

    Back to Top

    Now many experienced scripters reading this tutorial might disagree with me using symbols as a method of walking. The position of symbols are quite dynamic and they are easily missed if there’s a couple of people standing on top of them. But despite the disadvantages, they are quite useful; not exactly for getting the place to click but as a way of telling the script when to stop clicking. “Huh?” I hear you say? Well take this example. We are walking along a road in the middle of nowhere and we have to tell the script when to stop. We could script a repeat loop and make it repeat until it finds the symbol. Before we do that I’ll talk about the function itself.

    Once again theory time. . FindSymbol is much more simple to understand than RW or RRW. Basically all it does is it searches for a preloaded bitmap of the symbol on the minimap. If it finds it then it checks to see if the accuracy returned by the bitmap finding function is greater or equal to SymbolAccuracy (see below). If it is then it return true and stores the coordinates of the bitmap.

    SCAR Code:
    function FindSymbol(var rx, ry: Integer; Name: String): Boolean;

    So a description of the parameters:

    • rx: This is the x variable in which the function stores the x coordinates of the symbol if found.
    • ry: Same as rx except it has the y coordinates of the symbol stored in it.
    • Name: The name of the symbol. There’s a list of valid symbol names in Symbol.scar. Its below if you want to save time.


    SCAR Code:
    {*******************************************************************************
    Valid Arguments are:
      - bank              - mining site, mining spot         - transportation
      - magic shop        - water source, water              - furnace
      - anvil             - rare trees, tree                 - fishing spot, fish
      - cookery, cook     - quest                            - mill
      - weave             - pottery, pot                     - spinning wheel, spin
      - guide             - shop, store                      - shield
      - altar             - arrow                            - bar
      - dungeon           - churn                            - house
      - Axe Shop          - Cookery Shop                     - Windmill
      - minigame          - fur trader                       - Archery Shop
      - staff Shop        - clothes shop                     - farming spot
      - apothecary        - Sword shop                       - platebody shop
      - scimitar shop     - gem stall                        - silk stall
      - plateskirt shop   - agility                          - training dummy
      - food shop         - fishing shop/fish store          - Jewelery
      - Crafing shop      - portal (to player owned houses)  - Makeover Mage
      - Mace Shop         - Hair Dresser                     - Mining Shop
      - silver stall      - spice stall                      - farming shop
      - slayer master     - herbalist                        - candle shop
      - Saw Mill          - Kebab shop                       - Short cut
      - hunter store      - hunter training                  - Sandpit
    *******************************************************************************}
    Now for an example of what I mean.

    SCAR Code:
    repeat
      RadialWalk(RoadColour, 70, 100, 65, -1, 0);
    until(FindSymbol(x, y, 'anvil');

    The above example will RW until it finds the anvil symbol. I know I’ll get killed by people for having no failsafes but I’ve dedicated a whole section to it below.

    Another (more common) way of using FindSymbol although not as much for map walking is shown below:

    SCAR Code:
    if (FindSymbol(x, y, 'mining site')) then
    begin
      Mouse(x, y, 5, 5, True);
      Writeln('Found the mining symbol');
    end else Writeln('Could not find mining symbol');

    But you may still ask me what if the symbol is covered and the symbol cannot be found even though it is there. Well there is an extended variable called SymbolAccuracy. As I explained above, when the bitmap finding function finds a close match to the preloaded bitmap of the symbol, its stores the accuracy into a variable. FindSymbol then checks to see if the accuracy is greater or equal to SymbolAccuracy. If it is then FindSymbol returns true (it found the symbol). Now when we SetupSRL at the begin of the script, SymbolAccuracy is set to 0.8 or 80% as I like to use for explanation purposes. If FindSymbol finds a bitmap with an accuracy of 0.7 (70%) for instance, it returns false even though it might have found the correct symbol. So by manually seting SymbolAccuracy to 0.5 (50%), it could improve the chances of finding the symbol (notice how could is bolded).
    For example:

    SCAR Code:
    SymbolAccuracy := 0.5;
    If (FindSymbol(x, y, 'anvil')) then
      Mouse(x, y, 5, 5, True);
    SymbolAccuracy := 0.8;  //Remember to change it back to 0.8 when you are done.

    A real-life example of this (not really but it’s from my RM Runner) is below:
    SCAR Code:
    repeat
        if (not(WalkBesideWall('n'))) then
        begin
          WriteDebug('Using mouse clicks to walk along wall');
          Mouse(RandomRange(MMCX - 5, MMCX + 5), RandomRange(30, 40), 1, 1, true);
          AntiBanProc;
          ZephFlag(15);
        end else
          WriteDebug('Using WalkBesideWall');
        c := c + 1;
      until(FindSymbol(Sx, Sy, 'spin')) or (c >= 20);

    Yes it might look a bit strange but if you look closely, I made the script WalkBesideWall (a function I used for walking) until it finds the spinning wheel symbol or until it’s walked 20 times.

    I’ve also attached some links below of some good symbol finding tuts. Next section... boy this is getting long. 5 pages in MS Word, almost 2000 words so far.

  4. #4
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Clicking Colours

    Clicking Colours

    Back to Top

    Now I can’t really explain much here. Basically, as the name suggests, this section is about using a colour on the minimap to click and hopefully walk somewhere. Pretty simple?... It should be. The only function(s) you would need are FindColor, FindColorTolerance and FindColorSpiralTolerance. There are more which you could use to get more accurate points but for now I’ll explain these.

    I’m not going to explain the parameters for these functions because you should already know them. You should also already know the difference between the 3 functions above. In a nutshell – FindColor finds a colour and stores the coordinates with NO tolerance. FindColorTolerance is the same as FindColor except you can specify a tolerance so the colour doesn’t have to be exact. FindColorSpiralTolerance is the same as FindColorTolerance except it searches for the colour starting from the points stored in your variables.

    By using these functions, you can get the coords of the first colour point found. (FindColor and FindColorTolerance search from left to right, up to down. FindColorSpiralTolerance searches from the points stored in your x, y variables). Now that you have the coordinates, you can just use a quick call to Mouse to make it click. Simple as that.

    Examples:
    SCAR Code:
    if (FindColor(x, y, DoorColour, MMX1, MMY1, MMX2, MMY2)) then
      Mouse(x, y, 0, 0, True);

    SCAR Code:
    if (FindColorTolerance(x, y, 2917530, MMX1, MMY1, MMX2, MMY2, 10)) then
      Mouse(x, y, 0, 0, True);

    SCAR Code:
    x := MMCX;  
    y := MMCY;
    if (FindColorSpiralTolerance(x, y, LadderColour, MMX1, MMY1, MMX2, MMY2, 5)) then
      Mouse(x, y, 0, 0, True);

    Notice in the last example I set x and y to the coords of the minimap centre. When I call FindColorSpiralTolerance, it will start searching from the coords in x and y (MMCX, MMCY) thus finding the closest ladder first. It’s very useful for finding colours close to you (on the mainscreen like trees, mining rock, etc.).

    If you look at this screenie here:



    If you use FindColorTolerance for the red drop dot colour, the one on the left would be found first. If you used FindColorSpiralTolerance however, the one to the right would be found first (provided that x and y have the minimap centre stored in them).

    Another way of using colours to map walk is similar to the way I used symbols. You could use a repeat loop that repeats until it find a colour. ie:

    SCAR Code:
    repeat
      RadialWalk(RoadColor, 70, 100, 65, -1, 0);
    until(FindColor(x, y, 255, MMX1, MMY1, MMCx, MMY2));

    This method is useful for walking to a part of the map where there are no symbols or suitable DTMs for detecting when to stop. In my RM Runner I use a method similar to this when I'm walking west towards Fally. I repeat my RadialWalk until the script find a white colour that symbolises the wall that leads up to Barbarian Village.

    Although I emphasized this section on the three functions above, I think I should mention a couple of others:

    1. FindColorsTolerance – notice the ‘s’ after Color. Basically it works in the same way as FindColorTolerance except it stores all coordinates of all points where the colour is found into a TPointArray. One use for this would be to find the average of all the x values and the y values thus effectively “clicking in the middle of the points”. Here’s a little function I quickly made (not sure if it will work):

      SCAR Code:
      function FindMiddle(var cx, cy: Integer; Colour, x1, y1, x2, y2, Tol: Integer): Boolean;
      var
        Temp: TPointArray;
        Sum: TPoint;
        i, Length: Integer;
      begin
        Sum.x := 0; Sum.y := 0;
        FindColorsTolerance(Temp, Colour, x1, y1, x2, y2, Tol);
        Length := GetArrayLength(Temp);
        for i := 0 to Length - 1 do
        begin
          Sum.x := Sum.x + Temp[i].x;
          Sum.y := Sum.y + Temp[i].y;
        end;
        cx := Round(Sum.x / Length);
        cy := Round(Sum.y / Length);
        Result := (cx > 0) and (cy > 0);
      end;

      To use it you would do something like:

      SCAR Code:
      if (FindMiddle(x, y, DoorColour, MMX1, MMY1, MMX2, MMY2, 5)) then
        Mouse(x, y, 0, 0, True);
    2. Here’s one of my personal function I’ve made for my RM Runner. It’s called GetDoorCoords and it basically stores the coords all doors on the minimap. It only stores one point per door and ignores drop dots.

      SCAR Code:
      function GetDoorCoords(var Points: TPointArray): Boolean;
      var
        i, j, k, m, Tempx, Tempy: Integer;
        DoorColours1, DoorColours2: TPointArray;
      begin
        if (DoorColour = 0) then
          DoorColour := FindDoorColour;
        if (DoorColour = 0) then Exit;
        FindColorsTolerance(DoorColours1, DoorColour, MMX1, MMY1, MMX2, MMY2, 0);
        WriteDebug('Got ' + IntToStr(GetArrayLength(DoorColours1)) + ' DoorColour pixels');
        i := 0;
        for j := 0 to GetArrayLength(DoorColours1) - 1 do
        begin
          if (FindColor(Tempx, Tempy, DoorColour, DoorColours1[j].x - 1, DoorColours1[j].y - 1,
            DoorColours1[j].x + 1, DoorColours1[j].y - 1)) or
          (FindColor(Tempx, Tempy, DoorColour, DoorColours1[j].x - 1, DoorColours1[j].y,
            DoorColours1[j].x - 1, DoorColours1[j].y)) or
          (FindColor(Tempx, Tempy, DoorColour, DoorColours1[j].x - 1, DoorColours1[j].y + 1,
            DoorColours1[j].x + 1, DoorColours1[j].y + 1)) or
          (FindColor(Tempx, Tempy, DoorColour, DoorColours1[j].x + 1, DoorColours1[j].y,
            DoorColours1[j].x + 1, DoorColours1[j].y)) then
          begin
            SetArrayLength(DoorColours2, i + 1);
            DoorColours2[i].x := DoorColours1[j].x;
            DoorColours2[i].y := DoorColours1[j].y;
            i := i + 1;
          end;
        end;
        WriteDebug('Got ' + IntToStr(GetArrayLength(DoorColours2)) + ' Door points');
        i := 0;
        m := 0;
        repeat
          for k := m to GetArrayLength(DoorColours2) - 2 do
          begin
            if (Distance(DoorColours2[k].x, DoorColours2[k].y, DoorColours2[k + 1].x,
            DoorColours2[k + 1].y) > 8) or (k + 1 = GetArrayLength(DoorColours2) - 1) then
            begin
              SetArrayLength(Points, i + 1);
              Points[i] := DoorColours2[k];
              i := i + 1;
              Break;
            end;
          end;
          m := k + 1;
        until(m >= GetArrayLength(DoorColours2) - 1);
        WriteDebug('Got ' + IntToStr(GetArrayLength(Points)) + ' Doors');
        if (GetArrayLength(Points) > 0) then
          Result := True;
      end;

      Now that you have all the doors you can make it click in the middle of them using my function above.


    That’s it for Colour Clicking. Never thought I would be able to expand FindColor into 2 and a half pages but then again I never thought I would feel like explaining so much. . So now for the more advanced sections – DDTM’s and DTM’s. .

  5. #5
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Deformable Template Models – Dynamic and Static

    Deformable Template Models – Dynamic and Static

    Back to Top

    Deformable Template Models or DTMs for short is an advanced but simple (huh?) method of walking. It can also be used for other things as well (I’ll explains these briefly later). Basically there are two types. Static DTMs are old, simple and easy to make and use. Dynamic DTMs or DDTMs are a bit harder to make and use (just a bit but are as simple as normal DTMs when you get the hang of it). I’ll explain the basics behind both types of DTMs first.

    I don’t really know how to explain DTMs properly so I might sound a bit confusing. I’ll try my best though. A DTM is a main point and a set of sub points. The sub points (and the main point if required) is given a specific colour and coordinates. When you have one or more sub points and the main point, a shape is formed. When you use a function such as FindDTM, SCAR searches a certain area for that particular “shape” with the matching colours. If it is found then it returns true and saves the coords of the main point.

    Now lets talk about static DTMs first. These are as simple as DTMs get. They are made using SCAR’s DTM Editor (Tools > DTM Editor). See YoHoJo or Fawki’s DTM tuts below for info on how to make them. Basically you just click a point, set the colours, tolerances (there’s more stuff but they aren’t really important unless you know how to use them). When you are done with the points, go to file in the DTM Editor and click DTM to Text. That should print a little bit of coding in the debug. This coding is the DTM. Well it’s a string that is converted into the DTM which is stored as an integer by SCAR.

    Here’s what the DTM Editor looks like:


    The red lines are the sub points. They all end in the middle which is the main point. The edit boxes, etc. on the right allow you to set the colours, tolerances and coordinates of each of the points.

    Example of a DTM:

    SCAR Code:
    BankDTM := DTMFromString('78DA630C666060486600032608C5F0F52B038' +    
               '311906684E170FC6A4080319A0873E2116A18709803004A110B71');

    DTMFromString converts the string of numbers and letters into a DTM which is returned as an integer (DTMs are integers). That means that from the above example, BankDTM must be declared as an integer. ie:

    SCAR Code:
    var
      BankDTM: Integer;

    Now that you have the DTM loaded, you need a way of using it. There are several functions for this. I’ll emphasize on one of them (the most most useful for walking) and another more common one. The one that is used for walking is FindDTMRotated.

    SCAR Code:
    function FindDTMRotated(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; StartAngle, EndAngle, AngleStep: Extended; var Angle: Extended): Boolean;

    Yes I know its long but most of it should be familiar. Here’s the parameters description:

    • DTM: The DTM that it is searching for. (BankDTM if you are using the above example).
    • x: The variable in which the x coordinates of the DTM are stored if found.
    • y: Similar to x, just the y variable instead.
    • x1, y1, x2, y2: The bounds of the area it searches in (Same as FindColor).
    • StartAngle: The angle in radians where it starts rotating the DTM from. Remember 0 rad = 0 degrees, Pi = 180 degrees, 2 * Pi = 360 degrees. I usually make this a negative.
    • EndAngle: The max angle that it rotates the DTM to (also in radians). This is usually a positive angle.
    • AngleStep: How much the function increments the angle by every time it searches. The smaller the number, the more times it must increment the angle in order to reach the EndAngle thus the more times it must search for the DTM therefore the more accurate but also the more lag.
    • Angle: A variable in which the angle at which the DTM was found is stored. Pretty much useless but is required for the function to work. .


    The reason this function is useful for walking is because the minimap isn’t always perfect north, that means that the DTM that you created will not always work. This function rotates the DTM and searches thus making sure your DTM is found. You might also ask why StartAngle is negative and EndAngle is postive. It’s because the minimap angle varies in both the negative (anti-clockwise) and the postive (clockwise) directions. A vertical line can look like this:



    and like this:



    so if you DTM was a line, by making the StartAngle negative, it allows for shifts in both directions. Otherwise if it was 0 for example, it would only rotate the DTM clockwise and decrease your chance of finding it.



    Another way of finding DTMs is by using FindDTM. This method is much faster (it only searches for the DTM once) but does not rotate the DTM. That means it is useful for places where the DTM does not rotate at all.... hmm... THE INVENTORY. Yes, inventory items are the best place to use DTMs. Not only do they not rotate, but the actually images do not change. Further still, all inventory items have a black line along the edges. This black line is generic for all items. To make a DTM of an inventory item you would just put all your sub points along the black outline.

    So a brief description of FindDTM:

    SCAR Code:
    function FindDTM(DTM: Integer; var x, y: Integer; x1, y1, x2, y2: Integer): Boolean;

    • DTM: The DTM that it is searching for. (BankDTM if you are using the above example).
    • x: The variable in which the x coordinates of the DTM are stored if found.
    • y: Similar to x, just the y variable instead.
    • x1, y1, x2, y2: The bounds of the area it searches in (Same as FindColor).


    Much simpler ey? Yes it is but it’s not useful for the minimap unless it’s perfect north all the time.

    Now that we’ve gone through static DTMs, it’s time for the hard stuff. Let’s go dynamic!!! . Anyway... a DDTM is the same as a normal DTM except it can be created during the runtime of a script. Now you might ask why we would bother when DTM Editor can easily create a DTM for us using random combinations of numbers and letters. Well... since DDTMs are created when a script is running, we can create it using colours, points and tolerances unique to that particular time when the script is running. An example of this would be using SRL’s FindRoadColor to get the colour of the road at that instance in time then use that colour as the colour of one or more of the sub points/main points. Another example would be to variable as the tolerance then change the tolerance variable however you like before you create the DTM. This is why it is dynamic - because you can change the information stored in the points every time the DTM is created.

    Now the code for creating the DDTM is a bit complicated. I suggest you read Fawki’s tut (link below) on how to create one. I’ll show some examples and hopefully you’ll understand:

    SCAR Code:
    procedure SetRoadDTM(Time: Integer);
    var
      RMainPoint: TDTMPointDef;   //The main point
      DTMRSubPoints: Array of TDTMPointsDef;   //The subpoints
      RTDTM: TDTM;   //The DDTM type
    begin
      if (Time = 1) then
        SetArrayLength(DTMRSubPoints, 6)
      else
        SetArrayLength(DTMRSubPoints, 5);

      RMainPoint.x      :=  57;
      RMainPoint.y      :=  66;
      RMainPoint.areasize  :=  1;
      RMainPoint.areashape  :=  0;
      RMainPoint.color  :=  RoadColour;
      RMainPoint.tolerance  :=  15;

      DTMRSubPoints[0].x      :=  58;
      DTMRSubPoints[0].y      :=  85;
      DTMRSubPoints[0].areasize  :=  1;
      DTMRSubPoints[0].areashape  :=  0;
      DTMRSubPoints[0].color  :=  RoadColour;
      DTMRSubPoints[0].tolerance  :=  15;

      DTMRSubPoints[1].x      :=  48;
      DTMRSubPoints[1].y      :=  107
      DTMRSubPoints[1].areasize  :=  1;
      DTMRSubPoints[1].areashape  :=  0;
      DTMRSubPoints[1].color  :=  RoadColour;
      DTMRSubPoints[1].tolerance  :=  15;

      DTMRSubPoints[2].x      :=  66;
      DTMRSubPoints[2].y      :=  64;
      DTMRSubPoints[2].areasize  :=  1;
      DTMRSubPoints[2].areashape  :=  0;
      DTMRSubPoints[2].color  :=  RoadColour;
      DTMRSubPoints[2].tolerance  :=  15;

      DTMRSubPoints[3].x      :=  97;
      DTMRSubPoints[3].y      :=  72;
      DTMRSubPoints[3].areasize  :=  1;
      DTMRSubPoints[3].areashape  :=  0;
      DTMRSubPoints[3].color  :=  RoadColour;
      DTMRSubPoints[3].tolerance  :=  15;

      DTMRSubPoints[4].x      :=  28;
      DTMRSubPoints[4].y      :=  55;
      DTMRSubPoints[4].areasize  :=  2;
      DTMRSubPoints[4].areashape  :=  0;
      DTMRSubPoints[4].color  :=  15461350;
      DTMRSubPoints[4].tolerance  :=  20;

      if (Time = 1) then
      begin
        DTMRSubPoints[5].x      :=  30;
        DTMRSubPoints[5].y      :=  90;
        DTMRSubPoints[5].areasize  :=  2;
        DTMRSubPoints[5].areashape  :=  0;
        DTMRSubPoints[5].color  :=  15461350;
        DTMRSubPoints[5].tolerance  :=  20;
      end;

      RTDTM.MainPoint  :=  RMainPoint;
      RTDTM.SubPoints  :=  DTMRSubPoints;
      RoadDTM  :=  AddDTM(RTDTM);
    end;

    Here’s the description of the variables in the TDTMPointDef type:
    • x: The x coordinate of the point.
    • y: The y coordinate of the point.
    • AreaSize: The size of the area around the point that the DTM includes (The bigger the area the more chance the point will be found but also the more lag). I recommend you leave it as 1 for now.
    • AreaShape: The shape of the area. I’m not sure about this one but 0 is rectangle.
    • Color: The colour of the point. It can be a just a colour or a variable with the colour stored in it.
    • Tolerance: The tolerance of the colour.


    Notice how the variables in the TDTMPointDef type are similar (in fact identical) to the stuff you see in the DTM Editor. This is because when created, DDTMs are the same as DTMs. You use them the same way; you can you the functions I talked about above to find them. Also notice this part:

    SCAR Code:
    if (Time = 1) then
      begin
        DTMRSubPoints[5].x      :=  30;
        DTMRSubPoints[5].y      :=  90;
        DTMRSubPoints[5].areasize  :=  2;
        DTMRSubPoints[5].areashape  :=  0;
        DTMRSubPoints[5].color  :=  15461350;
        DTMRSubPoints[5].tolerance  :=  20;
      end;

    This is another example by what I mean by dynamic. I can make the DTM have different number of sub points when I create it. This example was from my RM Runner. The reason I have the number of points different every time is because, depending on the direction you are walking from, one of the points might not be visible. Thus the last sub point is only incorporated into the DTM when Time = 1.

    The last “paragraph” in the example is also very important:
    SCAR Code:
    RTDTM.MainPoint  :=  RMainPoint;
      RTDTM.SubPoints  :=  DTMRSubPoints;
      RoadDTM  :=  AddDTM(RTDTM);

    This is required to make the actual DTM. The first line tells SCAR that RMainPoint is RTDTM’s main point. The second line tells SCAR that DTMRSubPoints are RTDTM’s sub points. Then the last line makes the DTM (using AddDTM) and stores it in RoadDTM (an integer like above in the BankDTM example). Now that the DTM is created, just use FindDTM or FindDTMRotated to find it just like a normal one.

    I hope I explained myself clear enough. DTMs are really hard to explain lol . Now onto the next section – Mouse and Flag.

  6. #6
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Mouse, Flag and MouseFlag

    Mouse, Flag and MouseFlag

    Back to Top

    Ok since I have a little bit of time today I'm going to take this opportunity to add a new section to this tutorial. I should have added it before but I guess it would be already familiar to intermediate level scripters.

    This section is mainly on Flag and FFlag, an SRL procedure that (when called) waits until the red flag on the minimap disappears or is within a set distance from the minimap centre. There are really several versions of Flag but I'll only explain a couple.

    procedure MouseFindNoFlag(ax, ay, xmod, ymod: Integer);I'll explain Flag first of all because it is the simplest one with no parameters needed:

    SCAR Code:
    procedure Flag;

    The way you use this is by calling Flag after you've clicked somewhere on the minimap (by using symbols, colours or DTMs). When called, Flag check will wait until the colour 255 disappears (until the flag disappears). This means your character will stop for a couple of milliseconds before moving on thus making your character seem a bit suspicious I suppose. Thats why our wonderful SRL Devs came up with FFlag:

    SCAR Code:
    procedure FFlag(Distance: Integer);

    Distance: The procedure will wait until the flag is within the distance specified. This means the script will continue before the character stops completely thus making it seem more human.

    Although FFlag does seem quite good there is a problem with it as well as Flag where the Flag doesn't appear after a click (the click was in an area that was unclickable or the flag appeared offscreen). If this occurs, FFlag or Flag can't find the flag colour and continues thus stuffing up your main loop.

    There are several ways to solve this but the most common would be to just wait a second or two before calling FFlag. This allows the Flag to appear on screen as the character starts to walk towards it:

    SCAR Code:
    if (FindColor(x, y, RoadColour, MMX1, MMY1, MMX2, MMY2)) then
    begin
      Mouse(x, y, 5, 5, True);
      Wait(2000);  //Waits 2 seconds for the flag to appear on screen
      FFlag(10);
    end;

    There is also another way to solve this problem but I'll explain that later.

    Now that I've explained Flag and the like, I think I might explain to you another method of map walking. It is the most unreliable method and the most suspisious as well. I like to call it "Walking Blind" or walking using coordinates. What do I mean by this? I mean using Mouse and clicking the same coordinate every time. The reason why this is unreliable is because the minimap shifts and changes the camera angle every time RS is played. Thus your character can get lost quite easily (unless of course you have lots of failsafes). Although I (as will many other scripters) frown upon it, I thought I might cover it a bit I do (I admit) use it from time to time.

    This method uses the procedure Mouse or something similar to that. The only thing useful about this method is several procedures in the Mouse family that are designed for map walking:

    SCAR Code:
    procedure MouseFlag(cx, cy, rx, ry: Integer);

    This procedure combines Mouse and Flag to form.. well MouseFlag. The paramters are the same as normal Mouse except it always left clicks.

    SCAR Code:
    procedure MouseFindNoFlag(ax, ay, xmod, ymod: Integer);

    This procedure is a little bit different. Remember how I said there are several methods to solve the problem with the flag appearing offscreen? Well this is one of the other solutions. It is basically the same as MouseFlag except if the flag doesn't appear it will keep trying and adding the x and y mod until it appears.

    After all this Flag business I would like you to note one small (and quite trival) problem. Remember how I said FFlag would wait until the colour 255 appears within a certain distance from the minimap centre? If you hadn't noticed the colour 255 is the top of the flag not the stick thing to where the character is walking to. That means if you're approaching the flag from the south, FFlag will think you're further away from the flag that you really are and vice versa for approaching from the north. Thats why I'll share with you my version of FFlag:

    SCAR Code:
    procedure ZephFlag(Dist: Integer);
    var
      Dx, Dy, m, T: Integer;
    begin
      MarkTime(T);
      repeat
        if (FindColor(Dx, Dy, 255, MMX1, MMY1, MMX2, MMY2)) then
        begin
          m := GetColor(317, 172);
          if (Distance(Dx, Dy + 14, MMCX, MMCY) >= Dist) then
          begin
            Wait(100);
            if (TimeFromMark(T) > 15000) then
            begin
              if (GetColor(317, 172) = m) then
              begin
                if (FindColor(Dx, Dy, 255, MMX1, MMY1, MMX2, MMY2)) then
                  Mouse(Dx, Dy + 14, 1, 1, True)
                else
                  Mouse(MMCX, MMCY, 0, 0, True);
                Break;
              end;
            end else
            if (TimeFromMark(T) > 30000) then Break;
          end else Break;
        end;
      until(not(FindColor(Dx, Dy, 255, MMX1, MMY1, MMX2, MMY2)));
    end;

    It has the same parameter "Distance" as FFlag but it measures the distance from the bottom of the flag and thus solves the problem with the colour 255 getting detected as the flag bottom.

    Now onto the final section... Failsafes....

  7. #7
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Failsafes - The Key to a Successful Script

    Failsafes – The Key to a Successful Script

    Back to Top

    What I said in the title of this section is true. Without failsafes, your scripts will suck. Period. The reason you have a failsafe is to avoid or correct something when you can’t find a colour, or when that UpText never appears, or if symbol is covered, etc. Basically they are you plan B’s and C’s and D’s and E’s, etc. If you look at every successful script in the world, you’ll notice they will use failsafes in almost everything. Examples:

    SCAR Code:
    if (not(LoggedIn)) then Exit;
    If the player isn’t logged in then it exits the procedure/function.

    SCAR Code:
    repeat
      i := i + 1;  
      if (FindColor(x, y, 2341235, MMX1, MMY1, MMX2, MMY2) then ;
      begin
        Mouse(x, y, 0, 0, True);
        Break;
      end;
    until(i = 10);
    Never create endless loops. Always break them if it’s done what it’s supposed to do or if it has tried a certain number of times. The example above breaks out of the loop if it finds the colour or if it has tried 10 times.

    SCAR Code:
    if (FindDTMRotated(RoadDTM, x, y, MMX1, MMXY1, MMX2, MMY2, - Pi / 4, Pi / 4, 0.05, Angle)) then
      Mouse(x, y, 0, 0, True)
    else
    if (FindColorTolerance(x, y, RoadColor, MMX1, MMY1, MMX2, MMY2, 10)) then
      Mouse(x, y, 0, 0, True)
    else
    begin
      Writeln('Could not find road...');
      Exit;
    end;
    Have Plan B if Plan A doesn’t work and a Plan C if Plan B doesn’t work. That way you decrease you chances of getting lost while walking or while doing anything else.

    These are just some of the more common ones. You can use any function you like as a failsafe. Other more common examples of this would be:
    • Timers – using MarkTime and TimeFromMark to repeat until a certain time is reached. For example:
      SCAR Code:
      MarkTime(Timer);
      repeat
        if FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2) then
          Mouse(x, y, 0, 0, True);
      Until(TimeFromMark(Timer > 60000); //until 60 seconds has elapsed.
    • Auto Colouring if the colour cannot be found – this is one I use the most in my script. I use it basically every time I use RadialWalk. It’s pretty simple:
      SCAR Code:
      repeat
          c := c + 1;
          if (not(RadialWalk(RoadColour, 290, 210, 55, 1, 0))) then
          begin
            RoadColour := FindRoadColor;
            c := c - 1;
          end;
        until(c >= 3);
      If it can’t do the RadialWalk then it finds the road colour and tries again.
    • Another form of timer – this might not be common but I use it occasionally so I thought I might share it with you. Basically, when a player starts a run in my script, a timer is started. During the mainloop and throughout all the loops and functions in my script, it checks to see if the time has passed a predetermined amount of time. In my RM Runner, it involves a function that returns true if it has:
      SCAR Code:
      function TimeExceeded: Boolean;
      begin
        if (TimeFromMark(TotalTime) > MaxTimePerChar * 60 * 1000) then
        begin
          Writeln('Player has taken too long. Logging...');
          Players[CurrentPlayer].Loc := 'MaxTime exceeded';
          Players[CurrentPlayer].Active := False;
          LogOut;
          Result := True;
        end;
      end;

      And in the actual script I use something similar to if(not(LoggedIn)) then Exit;:

      SCAR Code:
      repeat
        if (TimeExceeded) then Exit;
        if (not(LoggedIn)) then Exit;
      //rest of the loop here.
      until(something...);
      This type of thing is pretty much the same as Timers but I thought I’d include a real-life example.


    That’s pretty much all I can think of. Check out some of the tutorials below that are dedicated to failsafes.

  8. #8
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default Conclusion – Recommended Reads

    Conclusion – Recommended Reads

    Back to Top

    Ok now, that you’ve read your way through all 5037 words, 14 pages (Size 11 Calibri font on MS Word 2007), you should be an expert (as good as me at least) in map walking. I’ve gone through the most common methods for map walking. Many of these methods are not as good as the others but I want to give you a broad but detailed (man.... writing tuts at 12 am makes you come up with weird oxymorons) tutorial on the main methods of walking.

    In my humble opinion, I’d say RadialWalk and RadialRoadWalk are the best when you want to follow a colour that doesn’t change much (roads, paths, water, cliffs, etc.). DDTM’s are good for detecting and confirming the location of your playing and moving him/her back on track. FindColor and the family are useful if you have a good colour finding function and when there is not much of the colour in the area you are searching for. FindSymbol can also be very useful when searching for a symbol that exists in a place where not many people stand on or where there is only one symbol that can be found there. But then again none of these will work well without failsafes so yea... just experiment and see which one works best for your situation. .

    Recommended Reads – Tutorials that Taught Me to Teach You
    I think the best way to do this would be to organise the links into groups based on the sections in my tut.

    RadialWalk and RadialRoadWalk


    Symbol Finding


    Colour Clicking


    DDTMs and DTMs


    Failsafes


    If you think that your tutorial should be added PM me or post on this thread.

    So that’s the end of this extremely long wall of words . Hope it helped you understand some things and taught you something new. If you have any suggestions, compliments, flaming, etc, post here and I’ll help or consider improving it. Good luck with your scripting peoples.

    Zeph...

  9. #9
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow, just wow! Rep++ to you.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  10. #10
    Join Date
    Jun 2007
    Posts
    785
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    very nice! thanks

    [22:20] <[-jesus-]> freddy, go uninstall yourself

  11. #11
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Santa_Clause View Post
    Wow, just wow! Rep++ to you.
    Told you it would be long.

  12. #12
    Join Date
    May 2007
    Location
    NSW, Australia
    Posts
    2,823
    Mentioned
    3 Post(s)
    Quoted
    25 Post(s)

    Default

    Wow, what a masive and very helpful guide!

    Good job man.

  13. #13
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Isn't there a DDTM Editor...?
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  14. #14
    Join Date
    Apr 2007
    Posts
    379
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes by SKy Scripter... I think. But A DDTM is just A DTM writen out. ANyways great Tut Zeph!! I learned a lot about the work of DDTMs.
    Now we just need to wait until runescape starts rotating the inventory -.-

  15. #15
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Santa_Clause View Post
    Isn't there a DDTM Editor...?
    Yea SKy has one somewhere. I don't think there is much use for it though because like I said DDTMs are pretty much the same as DTM except for the dynamic part. You can just use a normal DTM editor to get your points and everything and then just copy it into the DDTM assembling procedure.

    Quote Originally Posted by Tails111 View Post
    Yes by SKy Scripter... I think. But A DDTM is just A DTM writen out. ANyways great Tut Zeph!! I learned a lot about the work of DDTMs.
    Now we just need to wait until runescape starts rotating the inventory -.-
    Lol all they need is a shift of several pixels every time and we would be screwed.

    EDIT: Oh and I was wondering if this tut here crashed SRL a couple of hours ago. Pretty much as soon as I posted everything, the server crashed.

  16. #16
    Join Date
    Mar 2007
    Location
    Netherlands->Amersfoort.
    Posts
    1,615
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  17. #17
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Yes its big... hopefully equivalent to my contribution to this community over the 2 months that I'm away.

    And scheisse... the links open in new windows/tabs...

  18. #18
    Join Date
    Apr 2007
    Location
    Australia
    Posts
    4,163
    Mentioned
    9 Post(s)
    Quoted
    19 Post(s)

    Default

    Nice!

  19. #19
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    nice work, now leave!!
    ~Hermen

  20. #20
    Join Date
    Oct 2006
    Location
    MI USA
    Posts
    3,166
    Mentioned
    6 Post(s)
    Quoted
    11 Post(s)

    Default

    WOW, Thank you very much for taking the time to make this...Cleared up a lot of things for me.

    ~RAM

    EDIT: STICKIED !


  21. #21
    Join Date
    Nov 2006
    Location
    In an Amish Paradise
    Posts
    729
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    All I got to say is AWESOME! I finally understand x and ymods... Will be coming back to learn and red more latter

    Keep up the great tuts
    ~Stupedspam

  22. #22
    Join Date
    Jun 2007
    Location
    Hell Stream
    Posts
    584
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  23. #23
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by RAM View Post
    WOW, Thank you very much for taking the time to make this...Cleared up a lot of things for me.

    ~RAM

    EDIT: STICKIED !
    Wow... didn't think it was that good. Thanks RAM.

    Edit: Read all the tut, now have some pain in head need some time to digest
    Lol just take it one section at a time... don't want to cause any migraines here.

  24. #24
    Join Date
    Mar 2007
    Location
    Netherlands->Amersfoort.
    Posts
    1,615
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    zephy gratz on tut cup

    w00t! i just finished reading!

  25. #25
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Lol I got a tut cup???? It wasn't there 30 seconds ago... lol. TY whoever gave me it

Page 1 of 5 123 ... LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. HTML Basics?
    By Khazar in forum Web Development
    Replies: 15
    Last Post: 04-18-2011, 07:00 AM
  2. back to basics!
    By fucker in forum OSR Help
    Replies: 1
    Last Post: 12-08-2007, 08:42 PM
  3. I know the basics of scripting ~Help~
    By Gwallunit in forum OSR Help
    Replies: 4
    Last Post: 03-01-2007, 04:28 PM

Posting Permissions

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