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