• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Custom doodad variations

Level 26
Joined
Aug 18, 2009
Messages
4,097

Introduction

This is a short tutorial that should allow to apply own variation sets to doodads. The here displayed method requires the nowadays widely spread Jass NewGen Pack.

Exposition

Variation sets in object editor are defined by having the field Art - Variations (dvar) set to >1. Additional coloration fields will spawn but you can only state one model. If you take a look at other doodads with variations, you will recognize that a click on Art - Model (dfil) does not display anything in the preview window. That's because there really is no model placed on this path but when searching for single variations, it attachs number suffixes. Assumed that the specified path is Folder\FileName, then the first variation is on Folder\FileName0, second on Folder\FileName1, third one on Folder\FileName2 and so forth.

Now, what is the problem? If you imported your models to Plant0.mdx, Plant1.mdx and Plant2.mdx, according to above logic, you would enter Plant as model in doodad editor. The editor disapproves of this though! Everytime you want to edit that field, it adds .mdl to the end since the editor likes to have this format. As a consequence, it won't find the variations anymore, it probably searches for Plant.mdl0 or similar, which does not work either.

Solution

Since the editor does not permit it, the following method will adjust the attribute of the doodad otherwise. JNGP possesses an external tool named ObjectMerger. It has the ability to unite different object editor data, if you want to transfer stuff from one map to another for example without overwriting the existing objects there. Additionally, you can create objects directly via input lines or modify them. The used language is lua. Do not fear. I will show the needed mini script here and explain what to do. The in JNGP integrated vJass language (trigger editor) is able to call external tools like the ObjectMerger automatically. So we go to the trigger editor (F4), create a new page (CTRL+T) and convert it to jass format (>>Edit >Convert to custom text). You may delete the already present content of the lower window. Instead, we write:

JASS:
//! textmacro SetDoodadModel takes id, path
    //! externalblock extension=lua ObjectMerger $FILENAME$
        //! i setobjecttype("doodads")

        //! i modifyobject("$id$")

        //! i makechange(current, "dfil", "$path$")
    //! endexternalblock
//! endtextmacro

//! runtextmacro SetDoodadModel("D000", "Plant")

What to do now? I should first mention that the script does not need to be run more than once actually. But maybe you want to change it later on or you would like to add more variation sets, so I would leave it. That is why I have wrapped it in a textmacro. The script gets run when the map is being saved and you won't see the changes in editor until you reload the map. Afterwards, you can comment out the runtextmacro line (simply add one more / in front) to avoid lengthened saving times.

As you should see, the textmacro parameters are between quotation marks. At the place where Plant is currently written, the model path needs to be - like I said above without .mdl/.mdx and without variation number. Folders are specified by double backslash (\\).

The first parameter D000 represents the id of the doodad. You can inspect it by changing to raw data display in object editor (CTRL+D), search for your desired doodad in the left list then and select the first four letters (pay attention to case sensitivity!). For custom objects it's something like D000:OOal; the colon is only a delimiter and the four letters after that indicate the original object yours was based on, not important. So only take the first four letters, D000 in that case.

Addition for destructables

Destructables may also have variations. The script for them is a bit altered though:

JASS:
//! textmacro SetDestructableModel takes id, path
    //! externalblock extension=lua ObjectMerger $FILENAME$
        //! i setobjecttype("destructables")

        //! i modifyobject("$id$")

        //! i makechange(current, "bfil", "$path$")
    //! endexternalblock
//! endtextmacro

//! runtextmacro SetDestructableModel("B000", "Plant")

Concluding word

That's all. I divagated a bit to ensure that every novice gets it right since the variation stuff does not have anything more in common with the remains and you do not need more in that direction. Those are basics however one will stumple upon sooner or later.

An example map is attached. Open the map in JNGP, activate the runtextmacro line inside the single page in trigger editor (remove one of the slashes), save, reload the map and comment the line out again in this order.
 

Attachments

  • DoodadVariationExample.w3x
    46 KB · Views: 400
Level 6
Joined
Sep 7, 2017
Messages
207
I did this but it corrupted my map and all it gives is just a crash. How could it be?
 
Last edited:
Level 12
Joined
Jun 17, 2023
Messages
36
While this is appreciated it is not necessary. By naming each doodad variation .mdl0.mdx, .mdl1.mdx, .mdl2.mdx, and so on we can trick the editor into using doodad variations. To avoid confusion it is recommended to use a descriptive subfolder name for each Doodad.

For example a working path in the Art - Model File field would look like the following. However if you type this in the trick will not work.
war3mapImported\FolderWithDoodadVariationModels\.mdl

When typing the path in use the following format. The editor will automatically add .mdl to the path but it will understand to use the models you previously renamed to .mdl0.mdx, .mdl1.mdx, .mdl2.mdx, and so on.
war3mapImported\FolderwithDoodadVariationModels\
 
Last edited:
Level 11
Joined
Apr 27, 2009
Messages
202
While this is appreciated it is not necessary. By naming each doodad variation .mdl0.mdx, .mdl1.mdx, .mdl2.mdx, and so on we can trick the editor into using doodad variations. To avoid confusion it is recommended to use a descriptive subfolder name for each Doodad.

For example a working path in the Art - Model File field would look like the following. However if you type this in the trick will not work.


When typing the path in use the following format. The editor will automatically add .mdl to the path but it will understand to use the models you previously renamed to .mdl0.mdx, .mdl1.mdx, .mdl2.mdx, and so on.
Could not find an answer for variation problem for some time. Thanks man!
 
Last edited:
While this is appreciated it is not necessary. By naming each doodad variation .mdl0.mdx, .mdl1.mdx, .mdl2.mdx, and so on we can trick the editor into using doodad variations. To avoid confusion it is recommended to use a descriptive subfolder name for each Doodad.

For example a working path in the Art - Model File field would look like the following. However if you type this in the trick will not work.


When typing the path in use the following format. The editor will automatically add .mdl to the path but it will understand to use the models you previously renamed to .mdl0.mdx, .mdl1.mdx, .mdl2.mdx, and so on.
So if it was a group of models called "tree1" "tree2" etc in a folder called "trees", you would import those models and then change their path to:

War3mapimported\trees\tree1
War3mapimported\trees\tree2
War3mapimported\trees\tree3

etc without the .mdx?
 
Level 11
Joined
Apr 27, 2009
Messages
202
Hey Footman16 the above you wrote did not work for me. But this below did.

war3mapImported\FolderwithDoodadVariationModels\.mdl0.mdx (Yes . is first in the name of the file in import manager, weird right, but it works)
war3mapImported\FolderwithDoodadVariationModels\.mdl1.mdx
war3mapImported\FolderwithDoodadVariationModels\.mdl2.mdx

Then put the path to the model exactly like this war3mapImported\FolderWithDoodadVariationModels\
Then hit enter then Object Editor will do it's magic and give you variations.

Screenshot_8.png
Screenshot_7.png
 
Last edited:
Level 12
Joined
Jun 17, 2023
Messages
36
Thank you for providing the illustrative screenshots to better communicate this process to people attempting it. To provide more clarification the folder names containing the models can be named anything. It's just important to have different folders for each Doodad you want variations of due to the inevitable duplicate file names using this trick.

So if it was a group of models called "tree1" "tree2" etc in a folder called "trees", you would import those models and then change their path to:

War3mapimported\trees\tree1
War3mapimported\trees\tree2
War3mapimported\trees\tree3

etc without the .mdx?

No the files are literally named .mdl0.mdx, .mdl1.mdx, .mdl2.mdx hence the need for descriptive folders for each Doodad you're variating. I discovered this trick when seeing if I didn't enter anything in the folder path for a model the Warcraft 3 Editor automatically added .mdl to the path. Using the knowledge of existing destructible variation file path behavior I could logically conclude it's going to add 0, 1, 2, etc. to the path and I named the files accordingly.
 
Last edited:
Level 11
Joined
Apr 27, 2009
Messages
202
Thank you for providing the illustrative screenshots to better communicate this process to people attempting it. To provide more clarification the folder names containing the models can be named anything. It's just important to have different folders for each Doodad you want variations of due to the inevitable duplicate file names using this trick.



No the files are literally named .mdl0.mdx, .mdl1.mdx, .mdl2.mdx hence the need for descriptive folders for each Doodad you're variating. I discovered this trick when seeing if I didn't enter anything in the folder path for a model the Warcraft 3 Editor automatically added .mdl to the path. Using the knowledge of existing destructible variation file path behavior I could logically conclude it's going to add 0, 1, 2, etc. to the path and I named the files accordingly.
People should know this. I barely found the answer. Someone should write a small tutorial, use the pictures above because people need this info. Write something simple so people find it on google and name it 'Using custom Doodad variations tutorial' or something like that.

Thank you again for it. Very useful, this is the only place I found this answer.
 
Top