PDA

View Full Version : Yohojo's DTM Tut 2 DDTMs



YoHoJo
06-27-2007, 08:39 PM
Note: I HIGHLY recommend reading my normal DTM Tutorial before attempting to create a DDTM.
Link:http://www.villavu.com/forum/showthread.php?t=564


Thanks to Fakawi on Making the first DDTM Tutorial.
I'v learned a lot from it.


Part 1: Creating a DDTM!
Hello, and welcome to Yohojo's DDTM tutorial.
Well, you should already know about DTMs and how they work well for constant things like items and other things off of the runescape mainscreen.

The one problem with DTMs is that they were static, meaning that they couldn't be easily edited or changed. They had a set tolerance,area,color ect. Making it hard for them to be very tolerable for some things.

This is why DDTMs were created.
Instead of un-understandable code like in normal DTMS:
KnifeDTM:= DTMFromString('78DA63DCCBC0C0E0C580023212E219FE036 94' +
'620FE0F048CBB31D54064612490DE0E240208A8D90224C209 A8D9' +
'0A24A209A8D90724FC09A83908243CF1AB010061060D7C');

DDTMs display their information and values in a more human friendly dialect :p.

Creating a DDTM is very similar to creating a normal one.
We still have the same instances to look for such as :

X coordinate
Y coordinate
Area Size
Area Shape
Color
Tolerance

Each of these values are shown on the DTM Editor:
http://i15.photobucket.com/albums/a399/yohojo88/DDTM%20Tutorial/DTMPanel-1.jpg

When creating a DDTM, the DTM editor is not needed.
All coding can be done by hand to create it.

I will show you how i made my DTM for my auto road colorer.

First we must define some variables:

var RoadMP: TDTMPointDef;
var RoadSP: array[0..3] of TDTMPointDef;
var RoadDTMSkel: TDTM;

I will call the Main Point of my DDTM: RoadMP
I will call the Sub Points of my DDTM: RoadSP
And the 'Skeleton' of the DDTM: RoadDTMSkel

Notice that the Subpoints are an array as we will be using many of them.

Now we must fill out the 'skeleton' of the DTM.
We must fist declare a main point:

RoadMP.x:=;
RoadMP.y:=;
RoadMP.areasize:=;
RoadMP.areashape:=;
RoadMP.color:=;
RoadMP.tolerance:=;

This is what must be inputed and filled out on scar in order to declare your main DTM point.
To do this, first get the color picker, and click were you would like your main point to be.
In the debug you will get something similar to:

Color Picked: 7041653at (660, 40)
You must now choose an areasize, shape, and tolerance.
REMEMBER: A main point can not have an area size larger than 1

After you finish you should have something like this:

Procedure Load;
Begin
RoadMP.x:=660;
RoadMP.y:=40;
RoadMP.areasize:=1;
RoadMP.areashape:=0;
RoadMP.color:=7041653;
RoadMP.tolerance:=RDTMTol;

This is now your parent point of your DDTM.

Next, you must choose a few sub-points.

For my sub points of the road, i choose 4 points in a box around the main one like so:
http://i15.photobucket.com/albums/a399/yohojo88/DDTM%20Tutorial/MainSUb-1.jpg

These four points were also filled in, using RoadSP Variable, and the same outline as my main point

RoadSP[0].x:=663;
RoadSP[0].y:=43;
RoadSP[0].areasize:=1;
RoadSP[0].areashape:=0;
RoadSP[0].color:=7041653;
RoadSP[0].tolerance:=30;

RoadSP[1].x:=657;
RoadSP[1].y:=37;
RoadSP[1].areasize:=1;
RoadSP[1].areashape:=0;
RoadSP[1].color:=7041653;
RoadSP[1].tolerance:=30;

RoadSP[2].x:=657;
RoadSP[2].y:=43;
RoadSP[2].areasize:=1;
RoadSP[2].areashape:=0;
RoadSP[2].color:=7041653;
RoadSP[2].tolerance:=30;

RoadSP[3].x:=663;
RoadSP[3].y:=37;
RoadSP[3].areasize:=1;
RoadSP[3].areashape:=0;
RoadSP[3].color:=7041653;
RoadSP[3].tolerance:=30;

TIDBIT: Knowing that the road was all the same color, i entered the same color automatically, also. Instead of picking 4 more points, i subtracted/added 3 coordinates from each x and y to create a box around my main point.
This saves time and color picking =).

RoadSP[0].x:=663;
RoadSP[0].y:=43;

RoadSP[1].x:=657;
RoadSP[1].y:=37;

RoadSP[2].x:=657;
RoadSP[2].y:=43;

RoadSP[3].x:=663;
RoadSP[3].y:=37;

After you have your main and sub-points. You must now tell scar to 'make' your DTM.

This is done using the variable i called: RDTMSkele
After the sub-points add these lines using your own variable names.

RoadDTMSkel.MainPoint:=RoadMP;
RoadDTMSkel.SubPoints:=RoadSP;
YRoadDTM:=AddDTM(RoadDTMSkel);

RoadDTMSkel.MainPoint:=RoadMP
Tells scar the the MainPoint of 'RDTMSkele' is RoadMP
RoadDTMSkel.SubPoints:=RoadSP;
Tells scar the the Sub-Pointsof 'RDTMSkele' are RoadSP
And YRoadDTM:=AddDTM(RoadDTMSkel)
Tells scar the 'YRoadDTM' (The name of the actual DTM) is to be made from RoadDTMSkele.

The variable 'YRoadDTM' is the one you will be using when calling upon the
FindDTM function.

Now you can use this like a normal DTM!

Program DDDTMTutorial;

var YRoadDTM:Integer;
var RoadMP: TDTMPointDef;
var RoadSP: array[0..3] of TDTMPointDef;
var RoadDTMSkel: TDTM;
{.include SRLSRL.scar}

Procedure Load;
Begin
RoadMP.x:=660;
RoadMP.y:=40;
RoadMP.areasize:=1;
RoadMP.areashape:=0;
RoadMP.color:=7041653;
RoadMP.tolerance:=30;

RoadSP[0].x:=663;
RoadSP[0].y:=43;
RoadSP[0].areasize:=1;
RoadSP[0].areashape:=0;
RoadSP[0].color:=7041653;
RoadSP[0].tolerance:=30;

RoadSP[1].x:=657;
RoadSP[1].y:=37;
RoadSP[1].areasize:=1;
RoadSP[1].areashape:=0;
RoadSP[1].color:=7041653;
RoadSP[1].tolerance:=30;

RoadSP[2].x:=657;
RoadSP[2].y:=43;
RoadSP[2].areasize:=1;
RoadSP[2].areashape:=0;
RoadSP[2].color:=7041653;
RoadSP[2].tolerance:=30;

RoadSP[3].x:=663;
RoadSP[3].y:=37;
RoadSP[3].areasize:=1;
RoadSP[3].areashape:=0;
RoadSP[3].color:=7041653;
RoadSP[3].tolerance:=30;

RoadDTMSkel.MainPoint:=RoadMP;
RoadDTMSkel.SubPoints:=RoadSP;
YRoadDTM:=AddDTM(RoadDTMSkel);
End;

Procedure FindIt;
Begin
if (FindDTM(YRoadDTM,x, y, MMX1, MMY1,MMX2, MMY2)) Then
Writeln('w0ot');
End;

Begin
SetupSRL;
Load;
FindIt;
End.

Congratulations! You have just created your first DDTM!

Part 2: Using the 'Dynamic' part of your DDTM!

Well, its nice that you have created a DDTM, but from the example script it acts no differently than a normal DTM?

So, whats the point you ask?!
Editable variables i say!

In this 2nd part of the tutorial, i will show you the true beauty of DDTMs, the Dynamic Part!

Now, in my road color finder, i add tolerance and area to my DTM to make the search very extensive.
To do this, we must first setup a common variable for Tolerance and Area for your Main and Sub Points.

Iv called mine:
RDTMTol:=40;
RDTMArea:=1;

Now you must change all the tolerance and area values to these variables like so:

RoadMP.x:=660;
RoadMP.y:=40;
RoadMP.areasize:=1;
RoadMP.areashape:=0;
RoadMP.color:=7041653;
RoadMP.tolerance:=RDTMTol;

RoadSP[0].x:=663;
RoadSP[0].y:=43;
RoadSP[0].areasize:=RDTMArea;
RoadSP[0].areashape:=0;
RoadSP[0].color:=7041653;
RoadSP[0].tolerance:=RDTMTol;

NOTICE:Keep the main points area size at 1, it can not have an area size larger than 1.


Now i made it so tolerance and area is added every loop.
This code searches for the DTM 5 times, adding an area of 1 and tolerance of 5 each time:

Procedure FindIt;
Begin
For Z:=1 To 5 Do
Begin
RDTMTol:=RDTMTol+5; // Adds 5 Tolerance
RDTMArea:=RDTMArea+1 // Adds 1 Area
if (FindDTM(YRoadDTM,x, y,MMX1,MMY1,MMX2,MMY2)) Then
begin
Writeln('Found DTM at a tolerance of '+IntToStr(RDTMTol)+
'and an area of '+IntToStr(RDTMArea))
Exit;
End
End
Writeln('DTM Not Found')
End;

Now this is the entire script.
Notice how i declare
RDTMTol and RDTMArea in the loading procedure in order to preserve their values. Each time the DTM is loaded again, the Area and Tol will be reset to their original values. If this was not here, the loop would keep adding area and tolerance creating a mess! :p

Also notice how i load before each loop, so the RDTMTol and RDTMArea are once again reset to their original values.

Program DDDTMTutorial;

var YRoadDTM,Z,RDTMTol,RDTMArea:Integer;
var RoadMP: TDTMPointDef;
var RoadSP: array[0..3] of TDTMPointDef;
var RoadDTMSkel: TDTM;
{.include SRLSRL.scar}

Procedure Load;
Begin
RDTMTol:=30
RDTMArea:=1

RoadMP.x:=660;
RoadMP.y:=40;
RoadMP.areasize:=1;
RoadMP.areashape:=0;
RoadMP.color:=7041653;
RoadMP.tolerance:=RDTMTol;

RoadSP[0].x:=663;
RoadSP[0].y:=43;
RoadSP[0].areasize:=RDTMArea;
RoadSP[0].areashape:=0;
RoadSP[0].color:=7041653;
RoadSP[0].tolerance:=RDTMTol;

RoadSP[1].x:=657;
RoadSP[1].y:=37;
RoadSP[1].areasize:=RDTMArea;
RoadSP[1].areashape:=0;
RoadSP[1].color:=7041653;
RoadSP[1].tolerance:=RDTMTol;

RoadSP[2].x:=657;
RoadSP[2].y:=43;
RoadSP[2].areasize:=RDTMArea;
RoadSP[2].areashape:=0;
RoadSP[2].color:=7041653;
RoadSP[2].tolerance:=RDTMTol;

RoadSP[3].x:=663;
RoadSP[3].y:=37;
RoadSP[3].areasize:=RDTMArea;
RoadSP[3].areashape:=0;
RoadSP[3].color:=7041653;
RoadSP[3].tolerance:=RDTMTol;

RoadDTMSkel.MainPoint:=RoadMP;
RoadDTMSkel.SubPoints:=RoadSP;
YRoadDTM:=AddDTM(RoadDTMSkel);
End;

Procedure FindIt;
Begin
For Z:=1 To 5 Do
Begin
RDTMTol:=RDTMTol+5;
RDTMArea:=RDTMArea+1
if (FindDTM(YRoadDTM,x, y,MMX1,MMY1,MMX2,MMY2)) Then
begin
Writeln('Found DTM at a tolerance of '+IntToStr(RDTMTol)+
'and an area of '+IntToStr(RDTMArea))
Exit;
End
End
Writeln('DTM Not Found')
End;

Begin
SetupSRL;
Load;
FindIt;
End.

Thank you for reading this tutorial, i hope you have learned a lot.
If you have any questions/comments/criticism/changes you would like to see/ask/hear feel free to post.
Iv made this tutorial pretty fast, so please tell me if anything is unclear to you.
Also, if you are an SRL member, check out my RoadcolorFinder using many techniques displayed in this tutorial.
http://www.villavu.com/forum/showthread.php?t=11076

Except Updates and Tidy-Ups :p

tim46
06-27-2007, 08:46 PM
Oh sweet, this is nice and detailed. Good job :) Even though I understood DDTMs before, you made them a lot clearer...thanks.

NewToAutoing
06-27-2007, 08:47 PM
Great tut, should help many people. Never thought of that adding tol and area thing. Maybe make a small explanation on the uses of making the color non-static too, and how you can use FindRoadColor and stuff like that in those places. Or set a variable to FindRoadColor, and so on..

Offtopic: What ever happened to making a tutorial on minimap DTMs? :p Though i suppose it may not be needed since you made a tutorial on DDTMs.

YoHoJo
06-27-2007, 08:49 PM
Ill make that tutorial someday.
I think ill just make a DDTM tutorial on how to make MM DTMs later.
Im busy with stuffs and things right now but ill make that eventauly.
Glad i could help you all.

And yea, the tol/area is a pretty neat idea :p i love it it works so nicely.

The Claw
06-28-2007, 08:17 AM
great tutorial, has helped me a lot. :)

Killerdou
06-28-2007, 08:33 AM
mh... what about instead of a color use RoadColor(FindRoadColor)

rkroxpunk
06-28-2007, 10:17 AM
mh... what about instead of a color use RoadColor(FindRoadColor)

not everything is autocolored....

anywayz even though i already knew DDTM's this would have saved me a lot of experimenting >.< nice Tutorial you explained very well.

YoHoJo
06-28-2007, 02:21 PM
mh... what about instead of a color use RoadColor(FindRoadColor)

I was going to add a part about custom color adding later thanks though.
Im glad i could help yall =).
And claw, ill try to help you with that west mine DTM sometime sounds like a fun challenge :p.

Rikje
06-29-2007, 03:06 PM
Great tut! lets try to make my owne ddtms :D

ow btw:
''This code searches for the DTM 5 times, adding an area of 1 and tolerance of 10 each time:''
but in the scar part under that:
''//add 5 tol each time''
wich one is the right? i tough 5 but.. (in procedure FindIt)

YoHoJo
06-29-2007, 07:37 PM
Thanks, like i said i made the tutorial very fast.
There should but lots of little mistakes, thanks for finding that =).

TravisV10
06-30-2007, 02:41 AM
Nice detail.

10/10

Santa_Clause
07-04-2007, 11:04 AM
Wow! First tutorial that I understood from the beginning.

n3ss3s
07-06-2007, 09:57 AM
Wanna sum rep++?

Rikje
07-06-2007, 08:07 PM
i have a small qeustion about dtm and ddtm. where is areashape for? :o

n3ss3s
07-06-2007, 08:23 PM
dunno, and its not gonna make any difference if its 0

YoHoJo
07-06-2007, 09:24 PM
Area shape is a different area than a square to search in.
We got like
Crosses and Xs and + signs.
They are kinda stupid, but useful in some cases i guess.

Rikje
07-07-2007, 06:23 AM
oke thanks! :D
iam going to have a little play with that.

HISTORY
08-07-2007, 11:34 AM
pretty cool! Though i don't remember any mention of them last year, SCAR Divi feature?

Rikje
08-07-2007, 01:31 PM
yep :D

Macho Man67
08-07-2007, 05:44 PM
Nice tutorial! This really helped me understand what a DDTM was and how to make them. 11/10 lol :D!

Off topic: Whats better to walk with, Radial Walking or DDTM's? (ex. for a death walk back...)

YoHoJo
08-09-2007, 01:35 AM
I use mainly RRW and a few DDTMs for things like crossroads or landmarks.
Its all up to you though. I like a mix of both.

Fizzi
08-22-2007, 05:14 AM
Well... Up til now I've been using DDTM's by loading them everytime I went to walk. I tried to change my script so I only have to load the DDTM's once, but something is wrong.

I change MMRoadCol inside my walking loop constantly, and I know it works because RadialWalk uses that color. I set the colors of the subpoints/mainpoint of my DDTM to MMRoadCol as well, but ever since I've been loading the DDTM at the begining of the script, it fails to recognize the DDTM. I'm 100% sure that even though I am changing MMRoadCol, the colors of the subpoints/mainpoint are not changing.

the scar noob
09-01-2007, 07:20 PM
Tried 5 mins ago making a DDTM for the first time, i made one for the Fountain (small one near E Bank) and i tested it multiple times and it works!!

Thanks YoHoYo!!!

ShowerThoughts
09-02-2007, 12:31 PM
10/10 thanks man i really needed it but if this uses colors(yes it does!) you can set mutiple color so you can use it as and autocolor procedure?
because i cant autocolor...

YoHoJo
09-02-2007, 10:42 PM
Glad everyones liking this.
@Pie, as for auto color DDTMs will work fine. But try using Neilse's ACA (auto color aid) that thing is beautiful.

The Claw
09-28-2007, 09:21 AM
bit of a bump but hey who cares lol. just wondering, should we free DDTMs after we are done with them and if so, how do we?

cheers

ZephyrsFury
09-28-2007, 09:33 AM
DDTMs are the same as DTM once you assemble them. So to prevent memory leaks, etc. you can free the same way you free normal DTMs - using the FreeDTM procedure.

YoHoJo
10-06-2007, 02:31 AM
bit of a bump but hey who cares lol. just wondering, should we free DDTMs after we are done with them and if so, how do we?

cheers

After you declare the line:
YRoadDTM:=AddDTM(RoadDTMSkel);
YRoadDTM works just like any other DTM.
Its freed with FreeDTM
FreeDTM(YRoadDTM);
I normally only free DTMs which i don't use much, some people say it takes less memory to just keep a DTM which you use often loaded, instead of unloading and unloading it too often.

As as for 'bumping' i never mind if anyone bumbps a tutorial, they are timeless =) (unless SRL gets updated and kills everything)

faster789
04-08-2008, 05:42 AM
bump......luv this evn tho not shur if its up-todate!

King of the Nites
04-11-2008, 12:11 AM
If you have a dtm and a ddtm in your script, should i load those in 2 different procedures or can i just do it in one??

kor
05-07-2008, 08:25 PM
i hope its up to date, cause i understood allot of it! really well explained! i hope to make my very own script soon ;)

This isnt gravedigging, is it?

Press Play
05-25-2008, 04:38 AM
nice tut...this is the first one where i could actually grasp the consept of ddtms..thanx=]

Claymore
07-05-2008, 01:47 AM
I was able to do this on a Willow Log, but now i am wondering what the hell im suppose to do next? how do i work it in a script?.