PDA

View Full Version : How to use DTM's in your script.



Fearlesssss
06-16-2007, 10:31 PM
This tutorial is about DTM's. I'll start with the basics of DTM's.
I have quit SRL so I won't finish this tut. Sorry

DTM
What is it: A Deformable Template Model.
What is his use: It is useful for finding a certain point in RuneScape.(Even when colors change and when the compass changes.)
Parameters(FindDTM): DTMName, x, y, x1, y1, x2, y2

DTMName: The name of the DTM we want to search for.
x, y: Just put in x, y. No numbers. This means where it is gonna click.
x1, y1, x2, y2: This is the area we want to search in for the DTM. It
can be 1, 1, 5, 5(This area is probably too small) but if
you have included SRL you can put in for example:
MSX1, MSY1, MSX2, MSY2.(The mainscreen coords)

I'll explain the parameters x1, y1, x2 and y2 a bit more.

1____________
| |
| |
| |
| |
| |
|____________2

Number 1: A coordinate: For example (3, 4)
^ ^
x1 y1
Number 2: Also a coordinate: Lets say(555, 666)
^ ^
x2 y2


So it are just 2 points that make a box together. Just like in paint if you wanna select something: You click on a point and then you move your mouse somewhere else. I automaticly draws a box. Try it out and you'll see. (Or you alreaddy knew;))

How to use a DTM in your script

In a script a DTM Finding script can look like this:

program ThaDTMScript; //The name of the script.
var //To declare the variables.
x, y: integer; //x, y are coordinates, so they are integers.
ThaDTM: integer; //A DTM is an integer.

procedure LoadThaDTM; //The name of the procedure.
begin
ThaDTM := DTMFromString('78DA63F4606060306340016FDFDC03D38C5 03' +
'EA31790B04353F3F61E8306B29A004C35B76FDF4055130224 ACD1' +
'D55C47551389A54353454354351D0173128184157E350097A F14D' +
'9'); //I made a DTM and this is how I have putted it in my script.
//Now the DTM is loaded.
end;

procedure FindThaDTM; //The name of the procedure.
begin
if(FindDTM(ThaDTM, x, y, 3, 4, 555, 666))then //Searches for the DTM
//In a area from (3,4) to (555, 666).
begin
MoveMouseSmooth(x, y); //if found the dtm it clicks.
end else
begin
Writeln('Couldn''t find ThaDTM'); //if not found the dtm is writes it to debug
end;
end;

begin //mainloop
LoadThaDTM; //The first procedure to run
FindThaDTM; //The second procedure to run
end.


Finding objects with dtm's
Finding a object using a DTM works very well when the object has a weird shape, but if it haven't and you can make dtm's well, it's also very easy.

In scar go to: Tools>DTM editor(Do this when you can see the object in rs). A window will popup.
First you need to pick the parent point. This is the point where we will click if we found the object. So click on the object somewhere in the middle(I used a coal ore for example):
http://img526.imageshack.us/img526/2745/pic2qr7.png

After that we add other points to make the DTM unique. Just click on some random other points on the ore. If you look in the upper left corner you see a larger image of where your mouse is. Try to pick out the points that are unique, so not just a black one. You need one thats not one color, you need a unique one. So here is an example of mine after I picked the other points:
http://img526.imageshack.us/img526/2788/pic1pz1.png
After that SAVE.

Because JaGeX changes the colors everytime you log in again we need TOLERANCE. There also is AREA but you don't really need that in Object Finding. Tolerance may not be added to the parrent point!!! Otherwise it messes up. Only to the other points. Highlight all the points (except the parent) and make the Tolerance around 10. Now SAVE! Close the dtm editor and open rs. Open the dtm editor again with the object visible. Then click: test>Find DTM...
Go to the dtm which you just saved and open it. If it says found it's alright if it didn't found the dtm then open your dtm again and add more tolerance. Save and try to let the dtm-editor find it. If it findes it log out of rs and back in and try again. If it still finds it, it is a good dtm. If your dtm is done open dtm editor and open your dtm. Click file> DTM to Text
Close the dtm - editor. In the debug box in SCAR you will find your dtm in code. Highlight and press CTRL-C and then in your script press CTRL-V, it should look like this(BTW this is not the dtm we just made):

program New;
begin
DTM := DTMFromString('78DA630C656260B0614001859E12609A11C A6' +
'70C43A8E142526381AC261CA8C616BF1A0008F104BE');
end.


Omg you forgot to indentifie! You nooby:p. But after line 1 this:

var
DTM: integer;

So it will be this:

program New;
var
DTM: integer;
begin
DTM := DTMFromString('78DA630C656260B0614001859E12609A11C A6' +
'70C43A8E142526381AC261CA8C616BF1A0008F104BE');
end.
And for the dtm-finding look above in the chapter How to use DTM's in your script. So that you could try your dtm.

Esteban
06-17-2007, 04:01 AM
another guide on DTMs. Not bad, but you should include how you would use it in Runescape, like in the inventory or the Minimap.

Fearlesssss
06-18-2007, 03:21 PM
Yep I was planning to do that, but I'll add when I have time;)

Fearlesssss
06-19-2007, 07:09 PM
I added a new chapter:D pretty big though.

gamer716
06-20-2007, 12:00 AM
thanks, this guide was very helpful. simple and easy to understand. but my script doesn't find my DTM

edit: nvm its works!

Lalaji
07-21-2007, 01:49 AM
You never added "FreeDTM" ;)
Nice tut

YoHoJo
07-24-2007, 07:42 PM
Not bad, but since all the points you chose were random, they colors arent constant, so you would need to add some tolerance to each of those points.
A better thing to do is choose the outline of the ore which is a black color that NEVER changes, so it will always work and not need tolerance.
=)