Raskolnikov
03-05-2008, 04:37 AM
DDTMS
Their Uses
DDTMs can be used for map walking (walkpath, or finddtmrotated)
They can also be used for finding objects that change colors often.
How to Use them
Now, how do you use them? First off, a ddtm is basically a dtm that can be changed during runtime. So, how to make them? I personally use the method of taking a color point. Here's an example (my script):
function LoadShrimp: integer;
var
fishMP: TDTMPointDef;
fishSP: array of TDTMPointDef;
fishDDTM: TDTM;
begin
SetArrayLength(fishSP, 3);
fishMP.x := 557;
fishMP.y := 301;
fishMP.areasize := 1;
fishMP.areashape := 0;
fishMP.color := 6982976;
fishMP.tolerance := 9;
fishSP[0].x := 606;
fishSP[0].y := 296;
fishSP[0].areasize := 1;
fishSP[0].areashape := 0;
fishSP[0].color := 65536;
fishSP[0].tolerance := 0;
fishSP[1].x := 619;
fishSP[1].y := 313;
fishSP[1].areasize := 1;
fishSP[1].areashape := 0;
fishSP[1].color := 65536;
fishSP[1].tolerance := 0;
fishSP[2].x := 632;
fishSP[2].y := 293;
fishSP[2].areasize := 1;
fishSP[2].areashape := 0;
fishSP[2].color := 65536;
fishSP[2].tolerance := 0;
fishDDTM.MainPoint := fishMP;
fishDDTM.SubPoints := fishSP;
result := AddDTM(fishDDTM);
end;
Okay, let me walk you through this.
SetArrayLength(fishSP, 3);
is used to set the array length of how many sub points your DDTM will have.
fishMP.x := 557;
fishMP.y := 301;
These are the coordinates for your main point.
fishMP.areasize := 1;
fishMP.areashape := 0;
These two lines aren't to be worried about, not even on the subpoints.
fishMP.color := 6982976;
This is the color of your main point
fishMP.tolerance := 9;
This is the tolerance of your main point.
Now onto the subpoints. Many of the concepts are the same when declaring the subpoints, but some are still different.
fishSP[0].x := 606;
fishSP[0].y := 296;
These are the coordinates of your subpoint.
fishSP[0].color := 65536;
This is the color of your sub point. It is usually this when you are dealing with items, but it is different when map walking.
fishSP[0].tolerance := 0;
This is usually the tolerance for items, if your using the black line, but if you are map walking, use this to suit you.
Now, onto how to make it into something usable!
fishDDTM.MainPoint := fishMP;
fishDDTM.SubPoints := fishSP;
result := AddDTM(fishDDTM);
Okay, the first line is declaring the DDTM's main point.
The second is declaring the sub points.
The final one turns the ddtm into an integer where you can use it!
Now you can use your DDTM like this:
if FindDTM(LoadShrimp, blah blah) then
DoSomething;
Edit:
You might ask, what if I want the same shape, but different colors? Do I have to make a whole new ddtm for each type of object?
Answer: No, you can make a case statement:
case BarType of
'iron': TheColor := 2107921
'steel' //ect...
Then, in your ddtm main point color put this:
BarThing.color := TheColor;
Thanks for reading my tutorial, and I hope you learned how to use DDTMs!
Cut em2 it
Their Uses
DDTMs can be used for map walking (walkpath, or finddtmrotated)
They can also be used for finding objects that change colors often.
How to Use them
Now, how do you use them? First off, a ddtm is basically a dtm that can be changed during runtime. So, how to make them? I personally use the method of taking a color point. Here's an example (my script):
function LoadShrimp: integer;
var
fishMP: TDTMPointDef;
fishSP: array of TDTMPointDef;
fishDDTM: TDTM;
begin
SetArrayLength(fishSP, 3);
fishMP.x := 557;
fishMP.y := 301;
fishMP.areasize := 1;
fishMP.areashape := 0;
fishMP.color := 6982976;
fishMP.tolerance := 9;
fishSP[0].x := 606;
fishSP[0].y := 296;
fishSP[0].areasize := 1;
fishSP[0].areashape := 0;
fishSP[0].color := 65536;
fishSP[0].tolerance := 0;
fishSP[1].x := 619;
fishSP[1].y := 313;
fishSP[1].areasize := 1;
fishSP[1].areashape := 0;
fishSP[1].color := 65536;
fishSP[1].tolerance := 0;
fishSP[2].x := 632;
fishSP[2].y := 293;
fishSP[2].areasize := 1;
fishSP[2].areashape := 0;
fishSP[2].color := 65536;
fishSP[2].tolerance := 0;
fishDDTM.MainPoint := fishMP;
fishDDTM.SubPoints := fishSP;
result := AddDTM(fishDDTM);
end;
Okay, let me walk you through this.
SetArrayLength(fishSP, 3);
is used to set the array length of how many sub points your DDTM will have.
fishMP.x := 557;
fishMP.y := 301;
These are the coordinates for your main point.
fishMP.areasize := 1;
fishMP.areashape := 0;
These two lines aren't to be worried about, not even on the subpoints.
fishMP.color := 6982976;
This is the color of your main point
fishMP.tolerance := 9;
This is the tolerance of your main point.
Now onto the subpoints. Many of the concepts are the same when declaring the subpoints, but some are still different.
fishSP[0].x := 606;
fishSP[0].y := 296;
These are the coordinates of your subpoint.
fishSP[0].color := 65536;
This is the color of your sub point. It is usually this when you are dealing with items, but it is different when map walking.
fishSP[0].tolerance := 0;
This is usually the tolerance for items, if your using the black line, but if you are map walking, use this to suit you.
Now, onto how to make it into something usable!
fishDDTM.MainPoint := fishMP;
fishDDTM.SubPoints := fishSP;
result := AddDTM(fishDDTM);
Okay, the first line is declaring the DDTM's main point.
The second is declaring the sub points.
The final one turns the ddtm into an integer where you can use it!
Now you can use your DDTM like this:
if FindDTM(LoadShrimp, blah blah) then
DoSomething;
Edit:
You might ask, what if I want the same shape, but different colors? Do I have to make a whole new ddtm for each type of object?
Answer: No, you can make a case statement:
case BarType of
'iron': TheColor := 2107921
'steel' //ect...
Then, in your ddtm main point color put this:
BarThing.color := TheColor;
Thanks for reading my tutorial, and I hope you learned how to use DDTMs!
Cut em2 it