Using and Creating DTM's for begginers ~ Mad Cow

Discussion in 'Code Snippets and Tutorials' started by Anonymous, Mar 22, 2007.

  1. Anonymous

    Anonymous Guest

    Using and Creating DTM's for begginers by Mad Cow


    What is a DTM?
    The term DTM stands for Deformable template model. A DTM is like a FindColor command only in order for the DTM to be found, SCAR will look for multiple colors with a specified tolerance in areas of your choice.

    How do I open the DTM editor?
    Easy. Open SCAR and click Tools -> DTM Editor

    Is a DTM better than a bitmap? What's the difference?

    Bitmap = Searches for a picture file
    DTM = Searches for multiple colours in various locations

    So in my opinion, DTM's generally are better than bitmaps though in some areas bitmaps are more effective. For instance, loading a big bitmap may lag your computer whilst DTM's are usually fairly small in size.

    Making a DTM

    1) Creating a DTM
    Open Runescape or whatever you are creating the DTM for then open the DTM editor. Now lets create out first point. In the DTM editor click on the item you wish give the x, y cords to when the DTM is found.

    Eg. [​IMG]

    Note that I increased the tolerance to 20? Well this is just incase we can’t find the Log; we will look for the closest colour to it. We do not need to increase the area as this is the first point.

    2) Adding points to a DTM
    Now to create some points. Click on another area such as the Inventory Bag and once again, increase the tolerance. Now increase the area by lets say 10 just to make it so if the colour moves slightly, it will look in that area box for the specified colour.

    Eg. [​IMG]

    3) Testing your DTM
    Now add some more points if you wish. Don't add any more than 5 or it may not be able to find the image. Save the DTM and now its time to test it :D.

    Click on Test -> Find DTM and if it found it. You have successfully created a DTM! If not, go back to step one and start all over.

    4) Implementing a DTM into a script
    Now we have our DTM, we have to add it into our script. Go File -> DTM to Text. You should get a random bunch of letters and numbers. Now lets create a new procedure.
    Code (Text):
    1. program DTM_Tutorial;
    2.  
    3. procedure LoadDTM;
    4. begin
    5. end;
    6.  
    7. begin
    8. end.
    Now lets copy that piece of code into our procedure and rename it to whatever you want. We also have to declare the variable.

    You should now have something like this:
    Code (Text):
    1. program DTM_Tutorial;
    2. var
    3.   TutorialDTM : Integer;
    4.  
    5. procedure LoadDTM;
    6. begin
    7.   TutorialDTM := DTMFromString('78DA63F464666038CDC8800C2202141844803' +
    8.        '448F43F10307603D52C80A8E182AAF977D60BAE06040059550957' +
    9.        '');
    10. end;
    11.  
    12. begin
    13. end.
    Now that we have done all of it. The last part is to call upon the procedure in our main begin.

    You should now have:
    Code (Text):
    1. program DTM_Tutorial;
    2. var
    3.   TutorialDTM : Integer;
    4.  
    5. procedure LoadDTM;
    6. begin
    7.   TutorialDTM := DTMFromString('78DA63F464666038CDC8800C2202141844803' +
    8.        '448F43F10307603D52C80A8E182AAF977D60BAE06040059550957' +
    9.        '');
    10. end;
    11.  
    12. begin
    13.   LoadDTM;
    14. end.
    Now lets test that there are no errors.

    Try running the script and hopefully you should get:
    Code (Text):
    1. Successfully compiled
    2. Successfully executed
    5) Finding the DTM
    Now you have all of the code lets attempt to find the DTM. Lets see what we need to do.

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

    Now let me explain.
    DTM : Integer = The name of the DTM. Eg. TutorialDTM
    x, y : Integer = Where to save the cords when/if the DTM is found.
    x1, y1, x2, y2: Integer = The area to find the DTM in.

    Now we need to declare x and y as integers. Once you've done that we will add UNDER the procedure "LoadDTMâ" a simple
    Code (Text):
    1. if(FindDTM(TutorialDTM, x, y, 545, 10, 746, 223)) then
    2.   WriteLn('The DTM was found');
    Essentially, we would replace the ‘WriteLn('The DTM was found');’ with something like "ClickMouse(x, y, true);" or a Mouse procedure from an include.

    Now your final code should be something like this:
    Code (Text):
    1.  program DTM_Tutorial;
    2. var
    3.   TutorialDTM, x, y : Integer;
    4.  
    5. procedure LoadDTM;
    6. begin
    7.   TutorialDTM := DTMFromString('78DA63F464666038CDC8800C2202141844803' +
    8.        '448F43F10307603D52C80A8E182AAF977D60BAE06040059550957' +
    9.        '');
    10. end;
    11.  
    12. begin
    13.   LoadDTM;
    14.   if(FindDTM(TutorialDTM, x, y, 545, 10, 746, 223)) then
    15.     WriteLn('The DTM was found');
    16. end.
    Congratulations! You have successfully created a DTM!

    If you enjoyed this tutorial please post good or bad feedback.
     
  2. chelsea1

    chelsea1 Level IV

    Joined:
    Nov 26, 2006
    Messages:
    2,538
    Likes Received:
    31
    Location:
    London
    this looks great
    i have had a little experiance with these before but not much
    i think for my next version of t/u i will use these instead as it is a bit slow in searching for all of the cards
     
  3. zav75

    zav75 Level I

    Joined:
    Feb 28, 2007
    Messages:
    76
    Likes Received:
    6
    Location:
    Canada, Province of Québec
    DTM are nice, when you know when use it.