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
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