Page 1 of 2 12 LastLast
Results 1 to 25 of 29

Thread: How to make Dynamic DTM's with DIVI.

  1. #1
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default How to make Dynamic DTM's with DIVI.

    As most of you will know, DIVI supports dynamic DTM's. DTM's can now be modified during runtime. You could even create your own DTM's using DIVI's powerfull DTM AddDTM; function while the script is running!
    For this tut, I assume you have (basic) knowledge of DTM 's: knowing what they are, how to make 'm and how to use them.

    TDTMPointdef

    DTM 's are made of a number of Dynamic Deformable Template Model Point Definitions: TDTMPointdef. These TDTMPointdef records have the following members:
    • TDTMPointdef.x
    • TDTMPointdef.y
    • TDTMPointdef.areasize
    • TDTMPointdef.areashape
    • TDTMPointdef.tolerance
    • TDTMPointdef.color


    If you have ever made a DTM, these variables must look familiair, exactly the same can be seen in the DTM-Editor:




    There are two kind of TDTMPointdef's: one MainPoint and an arbitrary number of SubPoints. The MainPoint is the DTM's HotSpot, it's the coordinate that is returned by FindDTM. The SubPoints are the DTM's Reference Points grouped together in an array.

    So, there can only be one MainPoint but many SubPoints. These indiviual TDTMPointdef are grouped together into the TDTM type.The TDTM consists of:
    • TDTM.MainPoint
    • TDTM.SubPoints

    of type TDTMPointdef.

    An example

    SCAR Code:
    var SubPoints: array[0..2] of TDTMPointDef;
    var MainPoint : TDTMPointDef;
    var MasterTDTM: TDTM;
    var TheDTM:Integer;

    procedure AssembleDTM;
    begin
      MainPoint .x:=625;            
      MainPoint .y:=34;
      MainPoint .areasize:=1
      MainPoint .areashape:=0;
      MainPoint .color:=6843241;
      MainPoint .tolerance:=10;    

      SubPoints[0].x:=630;
      SubPoints[0].y:=31;
      SubPoints[0].areasize:=1;
      SubPoints[0].areashape:=0;
      SubPoints[0].color:=6843241;
      SubPoints[0].tolerance:=10;

      SubPoints[1].x:=623;
      SubPoints[1].y:=30;
      SubPoints[1].areasize:=1;
      SubPoints[1].areashape:=0;
      SubPoints[1].color:=6843241;
      SubPoints[1].tolerance:=10;

      MasterTDTM.MainPoint := MainPoint;
      MasterTDTM.SubPoints := SubPoints;
      TheDTM:= AddDTM(MasterTDTM);
    end;
    We have succesfully made a DTM named TheDTM consisting of one MainPoint and two AnchorPoints. The last lines are most important:
    SCAR Code:
    MasterTDTM.MainPoint := MainPoint;
    MasterTDTM.SubPoints := SubPoints;
    TheDTM:= AddDTM(MasterTDTM);
    We assign the individual TDTMPointDef's to the MasterTDTM and convert the MasterTDTM to TheDTM using function AddDTM(DTM: TDTM): Integer;


    Advantages


    The advantages are numereous. Whilst DTM's where pretty static objects in SCAR 2.03, now you can remodel to your hearts content. Some of the more obvious advantages:
    • Assign variables to any Member of the TDTMPointDef.
    • Assign your own Colors to any Point inside a DTM.
    • Create or Modify Point Coordinates.
    • Adjust the size, shape and tolerance of any given Point.
    • Alter the length of the SubPoint-Array.


    You could even write a DTM-maker tool, that scans for common colors and decides upon the best main and subpoints.


    Making Dynamic DTM's

    Alas, making Dynamic DTM's is still a troublesome process. You first need to make a normal DTM using the DTM-editor, and then you will need to manually fill in each variabe inside your TDTMPointDef's. Too bad SCAR "hangs" with the DTM-Editor open, so you will need a second SCAR open to type in the values into the TDTMPointDef's.



    -------------------------------------------------------


    Full Working RS-Example


    Here is a full working Dynamic DTM example as posted before on the inside DIVI... forum.




    Stand below Falador above Rimmington Mine. Fill in the RoadColor. The script will find centrepoint (tol 255 thus any color (!)) at almost any angle and move the mouse to the centre of the bifurcation.


    SCAR Code:
    program BifurcationFinder;
    var CGPT: array[0..2] of TDTMPointDef;
    var CGMainPT: TDTMPointDef;
    var CG: TDTM;
    var CGx, CGy: Integer;
    var CGDTM: Integer;
    var WhichAngle: Extended;

    const RoadColor = 5921377;   // ColorPick RoadColor.
    const Tolerance = 1;
    const AreaSize  = 1;
    const AreaShape  = 0;

    procedure SetCGDTM;
    begin

      CGMainPT.x:=648;            // Centre Of Minimap
      CGMainPT.y:=83;
      CGMainPT.areasize:=1;
      CGMainPT.areashape:=0;
      CGMainPT.color:=0;
      CGMainPT.tolerance:=255;    // Any Color

      CGPT[0].x:=615;
      CGPT[0].y:=59;
      CGPT[0].areasize:=AreaSize;
      CGPT[0].areashape:=AreaShape;
      CGPT[0].color:=RoadColor ;
      CGPT[0].tolerance:=Tolerance;

      CGPT[1].x:=672;
      CGPT[1].y:=75;
      CGPT[1].areasize:=AreaSize;
      CGPT[1].areashape:=AreaShape;
      CGPT[1].color:=RoadColor ;
      CGPT[1].tolerance:=Tolerance;

      CGPT[2].x:=632;
      CGPT[2].y:=105;
      CGPT[2].areasize:=AreaSize;
      CGPT[2].areashape:=AreaShape;
      CGPT[2].color:=RoadColor ;
      CGPT[2].tolerance:=Tolerance;
      CG.MainPoint := CGMainPT;
      CG.SubPoints := CGPT;
    end;

    begin
      SetCGDTM;
      CGDTM:=AddDTM(CG);
      Repeat
      Wait(1000);
      if FindDtmRotated(CGDTM, CGx, CGy, MMX1, MMY1, MMX2, MMY2, -PI*2, PI*2, 0.2,
            WhichAngle) then
      begin
        Writeln(IntToStr(CGx)+' '+IntToStr(CGy) + ' at '+FLoatToStr(WhichAngle));
        MoveMouse(CGx, CGy);
        writeln('DTMRotated Found');
      end else writeln('Not Found');
      Wait(1000);
      until False
    end.











    Another Example






    This DTM is made of three RockColorpixels (= a constant), plus a "any" color MainPoint (color 0 and tol 255)
    Provided you know this RockColor, you can callibrate in any direction! I use it in my priv. GoblinTrainer to keep my Players inside the GoblinHouse. Try and see for yourself. Position your Player at the GoblinHouse, Set RoadColor in line 9 and walk a little around the house, you can even walk upwards to the chickenchurn, DIVI checks if our MoveMouse is in Bounds with the MiniMap using the new function rs_OnMinimap. If it discovers the coords are out of bounds, it will move the mouse to the centre of the DTM. It will work from - Pi/2 til Pi/2, a halve circle.


    SCAR Code:
    program GoblinRock;
    var DTMSubPoints: array[0..2] of TDTMPointDef;
    var CGMainPoint: TDTMPointDef;
    var RockTDTM: TDTM;
    var CGx, CGy: Integer;
    var RockDTM: Integer;
    var WhichAngle: Extended;

    const RoadColor = 6843241;   // ColorPick RoadColor.
    const Tolerance = 1;
    const AreaSize  = 1;
    const AreaShape  = 0;

    procedure SetRockDTM;
    begin

      CGMainPoint.x:=625;            
      CGMainPoint.y:=34;
      CGMainPoint.areasize:=1;
      CGMainPoint.areashape:=0;
      CGMainPoint.color:=0;
      CGMainPoint.tolerance:=255;    // Any Color

      DTMSubPoints[0].x:=630;
      DTMSubPoints[0].y:=31;
      DTMSubPoints[0].areasize:=AreaSize;
      DTMSubPoints[0].areashape:=AreaShape;
      DTMSubPoints[0].color:=RoadColor;
      DTMSubPoints[0].tolerance:=Tolerance;

      DTMSubPoints[1].x:=623;
      DTMSubPoints[1].y:=30;
      DTMSubPoints[1].areasize:=AreaSize;
      DTMSubPoints[1].areashape:=AreaShape;
      DTMSubPoints[1].color:=RoadColor;
      DTMSubPoints[1].tolerance:=Tolerance;

      DTMSubPoints[2].x:=628;
      DTMSubPoints[2].y:=37;
      DTMSubPoints[2].areasize:=AreaSize;
      DTMSubPoints[2].areashape:=AreaShape;
      DTMSubPoints[2].color:=RoadColor;
      DTMSubPoints[2].tolerance:=Tolerance;

      RockTDTM.MainPoint := CGMainPoint;
      RockTDTM.SubPoints := DTMSubPoints;
      RockDTM            := AddDTM(RockTDTM);
    end;


    begin
      SetRockDTM;
      Repeat
      Wait(1000);
     if FindDtmRotated(RockDTM, CGx, CGy, MMX1, MMY1, MMX2, MMY2, - Pi/2, Pi/2, 0.1,
            WhichAngle) then
      begin
        if rs_OnMinimap(CGx + 10, CGy + 50) then
          MoveMouse(CGx + 10, CGy + 50)
        else
          MoveMouse(CGx, CGy)
         writeln('DTMRotated Found');
      end
      else
      writeln('not found');
      Wait(1000);
      until False
    end.
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  2. #2
    Join Date
    Mar 2006
    Posts
    13,241
    Mentioned
    228 Post(s)
    Quoted
    267 Post(s)

    Default

    Wow nice. Very helpful tut thanks.

    Edit: First post too
    STOP PM'ING ME

  3. #3
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    6,136
    Mentioned
    28 Post(s)
    Quoted
    17 Post(s)

    Default

    Added another example.
    SRL is a Library of routines made by the SRL community written for the Program Simba.
    We produce Scripts for the game Runescape.

  4. #4
    Join Date
    Jun 2006
    Location
    USA
    Posts
    428
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ah, thank you so much for this Fawki Will help tons.

  5. #5
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Awesome!

    I'm gonna have to spend some time learning these...
    Interested in C# and Electrical Engineering? This might interest you.

  6. #6
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    very nice fakawi, its very well explainined
    Join the Official SRL IRC channel. Learn how to Here.

  7. #7
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    I think this is one of the most powerful new tools available in Divi. I haven't jumped in and tried making use of it yet, but I am excited about the possibilities!

  8. #8
    Join Date
    Mar 2007
    Posts
    3,681
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    ohh nice examples Fakawi they are clear to understand

  9. #9
    Join Date
    May 2007
    Location
    Finland
    Posts
    41
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice tutorial Im still not 100% sure how this works but this helped me enough that I have some idea.

  10. #10
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Great tutorial, quite easy if you already know DTMs, i just learned by looking at the code =). But i bet the words also help .
    Im going to try to use these also for my mapwalking experiments w/ DTMs.
    ++rep haha

  11. #11
    Join Date
    Jun 2006
    Location
    USA
    Posts
    1,828
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for making this tutorial!
    This explained me pretty good how to use DDTMs.

    ...Time to do some tests with them.

  12. #12
    Join Date
    May 2007
    Location
    Canada
    Posts
    261
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hmm, dosn't sound to hard. Very interesting

  13. #13
    Join Date
    Mar 2007
    Posts
    3,681
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    I'm still a little confused between DDTMs and DTMs i mean whats the difference? (sorry about stupid question )

  14. #14
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    wow, i actually understand now! i read it before, and didnt, but now i do! So, i can walk with these things too right?

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  15. #15
    Join Date
    Oct 2006
    Posts
    2,297
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Wt-Fakawi, i beg you writing a tut in dutch cause i really want to learn, but i just don't get it plz i'm begging you (aub ik smeek u).
    [QUOTE=Santa_Clause;277761]I love you too TSN :p[/QUOTE]
    [CENTER][URL="http://www.stats.srl-forums.com/sigs"][IMG]http://www.stats.srl-forums.com/sigs/1324.png[/IMG][/URL][/CENTER]

  16. #16
    Join Date
    Aug 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I understand the whole dtm part and how to make one and to get it to click there but i dont understand the inside bounds part and i could realy use it for a chicken killer im making if anyone is willing to explain the plz talk to me on msn mine is crazyirishman84@hotmail.com

  17. #17
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    i have
    SCAR Code:
    procedure AssembleDTM;
    begin
      MainPoint .x:=821;
      MainPoint .y:=242;
      MainPoint .areasize:=0;
      MainPoint .areashape:=0;
      MainPoint .color:=DirtRoadColor;
      MainPoint .tolerance:=0;

      SubPoints[0].x:=823;
      SubPoints[0].y:=256;
      SubPoints[0].areasize:=1;
      SubPoints[0].areashape:=0;
      SubPoints[0].color:=WaterColor;
      SubPoints[0].tolerance:=0;

      SubPoints[1].x:=823;
      SubPoints[1].y:=230;
      SubPoints[1].areasize:=1;
      SubPoints[1].areashape:=0;
      SubPoints[1].color:=WaterColor;
      SubPoints[1].tolerance:=0;

      SubPoints[2].x:=801;
      SubPoints[2].y:=239;
      SubPoints[2].areasize:=1;
      SubPoints[2].areashape:=0;
      SubPoints[2].color:=DirtRoadColor;
      SubPoints[2].tolerance:=0;

      SubPoints[3].x:=843;
      SubPoints[3].y:=241;
      SubPoints[3].areasize:=1;
      SubPoints[3].areashape:=0;
      SubPoints[3].color:=DirtRoadColor;
      SubPoints[3].tolerance:=0;

      MasterTDTM.MainPoint := MainPoint;
      MasterTDTM.SubPoints := SubPoints;
      TheDTM:= AddDTM(MasterTDTM);
    end;
    SCAR Code:
    if FindDtmRotated(CGDTM, CGx, CGy, MMX1, MMY1, MMX2, MMY2, -PI*2, PI*2, 0.2,WhichAngle) then
                   Mouse(x,y,2,2,true);
    ...but it keeps clicking above the birdge(by the way this is the bridge between barb village and varrok
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  18. #18
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    lol dan i doubt anyone is going to test that for you.
    Just make sure you choose more unique points and that its unique.

    Quote Originally Posted by hugolord View Post
    I'm still a little confused between DDTMs and DTMs i mean whats the difference? (sorry about stupid question )
    You make DTMs in the DTM editor and they spit out stuff like:
    SCAR Code:
    KnifeOutline := DTMFromString('78DA63F464626078C8800232E2E318FE03694' +
           '620FE0F048C6E986A80C2609A11CA67B407AA7947408D0F50CD13' +
           'FC6A001C5C13D6');
    Set tolerance, set points, set area, set color.

    Now, DDTMs are the same thing, but in human understandable code, allowing us to edit them more easily and adding tolerance and are while the script runs!
    Amazing! =)

  19. #19
    Join Date
    Jul 2006
    Location
    NY
    Posts
    371
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Awesome tutorial. Never understood this but now its pretty easy to understand. Good job!

  20. #20
    Join Date
    Jan 2007
    Location
    Qld, Australia
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Awesome tut Fawki, It made sense
    The second time I read through it xP
    I bookmarked it cause, I'll forget it >_<

    Anyway, I never realised how useful DTMs could be :O

    I'm use this for my Air Crafter

    (To anyone who thinks "OMG ITS A LEECHER" because I probly have big longevity and low activity and 4 posts now(I think) its because I took a break from scripting okay..)

  21. #21
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by dan cardin View Post
    i have
    SCAR Code:
    procedure AssembleDTM;
    begin
      MainPoint .x:=821;
      MainPoint .y:=242;
      MainPoint .areasize:=0;
      MainPoint .areashape:=0;
      MainPoint .color:=DirtRoadColor;
      MainPoint .tolerance:=0;

      SubPoints[0].x:=823;
      SubPoints[0].y:=256;
      SubPoints[0].areasize:=1;
      SubPoints[0].areashape:=0;
      SubPoints[0].color:=WaterColor;
      SubPoints[0].tolerance:=0;

      SubPoints[1].x:=823;
      SubPoints[1].y:=230;
      SubPoints[1].areasize:=1;
      SubPoints[1].areashape:=0;
      SubPoints[1].color:=WaterColor;
      SubPoints[1].tolerance:=0;

      SubPoints[2].x:=801;
      SubPoints[2].y:=239;
      SubPoints[2].areasize:=1;
      SubPoints[2].areashape:=0;
      SubPoints[2].color:=DirtRoadColor;
      SubPoints[2].tolerance:=0;

      SubPoints[3].x:=843;
      SubPoints[3].y:=241;
      SubPoints[3].areasize:=1;
      SubPoints[3].areashape:=0;
      SubPoints[3].color:=DirtRoadColor;
      SubPoints[3].tolerance:=0;

      MasterTDTM.MainPoint := MainPoint;
      MasterTDTM.SubPoints := SubPoints;
      TheDTM:= AddDTM(MasterTDTM);
    end;
    SCAR Code:
    if FindDtmRotated(CGDTM, CGx, CGy, MMX1, MMY1, MMX2, MMY2, -PI*2, PI*2, 0.2,WhichAngle) then
                   Mouse(x,y,2,2,true);
    ...but it keeps clicking above the birdge(by the way this is the bridge between barb village and varrok
    You've called the DDTM 'TheDTM' while putting 'CGDTM' in the function. If that doesn't solve it, make sure you specify the dirt and water colours just before you run 'AssembleDTM'.

  22. #22
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    @Dan

    The name of your dtm is
    'TheDTM'
    as you said here
    TheDTM:= AddDTM(MasterTDTM);

    So yo gota do If FindDTM(TheDTM) Then

  23. #23
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    one question: Do I have to make DDTM to find rotated DTMs or do I justed use the FindDTMRotated thingy?
    Because if I can just use normal DTMs I wasted some time, but actually it wasnt waste, still learned sumting

    btw fawki you have endless loop in your script with no break and MOVEMOUSE!

    What did you do to the real fawki and where is he!?

  24. #24
    Join Date
    Dec 2006
    Location
    UK
    Posts
    118
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow. Very clear and concise tut. (Still had to read it twice). This tut will help with mapwalking and find things on the minimap that don't have constant colours or icons.

    But is there an easier way to create DDTMS without have to enter all the varables in manualy?

  25. #25
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by n3ss3s View Post
    one question: Do I have to make DDTM to find rotated DTMs or do I justed use the FindDTMRotated thingy?
    Because if I can just use normal DTMs I wasted some time, but actually it wasnt waste, still learned sumting
    The point of a DDTM is that you can create one during a script, ie. you can create one with up-to-date colours such as the road colour at the exactly time and not having to go through the trouble with getting the right colours and tolerances while making a DTM. Of course you can use FindDTMRotated to find normal DTM's. I think its what it was designed for. DDTM's are relatively new.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 09-21-2007, 07:49 PM
  2. Dynamic DTM's Roadcolor
    By rkroxpunk in forum OSR Help
    Replies: 11
    Last Post: 06-01-2007, 06:57 PM
  3. dtm vid tut teaches how to make and use dtm's
    By -fedexer- in forum Outdated Tutorials
    Replies: 22
    Last Post: 05-31-2007, 05:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •