Behavior Editing Tutorial
by Zooasaurus
In this tutorial, you will find out how to add and subtract behaviors from animals.
- Zoo Tycoon 2
- Animals
- Scripting
- Reading time
- 5 min
- Comments
- 0
Coding variant skins for your foliage.
by ShenTirag
Ok I shall explain this, it’s a bit complicated but once you get the hang of it it is easier! 😉
The coding for plant variants is based upon the coding for MM plants, such as the sea fan.
Tip
If you get stuck, try to look at how BF coded the sea fan for a bit of help!
Additionally, if you’re canny you can use this method to make variants for other things as well. The ways of doing thisare different depending on whether you are using NIFs or BFBs. I shall explain both in turn:
All NIFs are split into sections for where each texture covers. If you open up a NIF in Nifskope, you can find the name for the “section” you want to make have variant skins.
Open your NIF in Nifskope, and look at the NiMaterialProperties, they have little pallets next to them, and the texture they are linked to is the NiSourceTexture underneath that.
The word that is next to the NiMaterialProperties is the “name” of the selected area, so say for the Date Palm to make the leaves have variants you are looking for the NiMaterialProperties called leaves. Sometimes like this, they are obvious, other times they are very strange indeed! Write this down somewhere so you remember it.
Note
For NIF files, the names of the NiMaterialProperties will always stay the same for every item made from that base object.
Now you should make all your variants skins that you want, for plants and other objects you can have as many variants as you like, you just have to remember to code them all!
So again, using the Date Palm as an example, make your leaf variants (DatePalm_Desert_Fronds.DDS) and give them useful names (eg: DatePalm_Desert_Fronds1.DDS, and so on).
Now you have made your variant skins, and know the name of the model part you want to use them, so lets get coding!
Open up the AI XML file for your plant, found in entities/units/objects/foliage/ai. You will need to place in some coding into this XML.
This coding should be placed between the <BFNamedBinder binderName="mainObj"> </BFNamedBinder> tags, and after any <instance> tags.
Here is the coding that you need, and for the Date Palm, or any plant made from it and uses a NIF, it would look like this:
<shared>
<BFSharedRandomTextureInfo>
<replacementSet>
<group weight="1">
<item material="leaves" image="entities/objects/foliage/codename/codename_1.dds" layer="base" />
</group>
</shared>
Important
You must always use the NiMaterialProperties name that you found in the NIF where the <item material="material name" is. This will vary obviously from item to item depending on what base object you are using.
For more than one skin (which you’ll obviously want ;)), you must repeat everything between the group tags for every variant you want. So for example, for a plant from the DatePalm with three leaf variants it would be:
<shared>
<BFSharedRandomTextureInfo>
<replacementSet>
<group weight="1">
<item material="leaves" image="entities/objects/foliage/codename/codename_1.dds" layer="base" />
</group>
<group weight="1">
<item material="leaves" image="entities/objects/foliage/codename/codename_2.dds" layer="base" />
</group>
<group weight="1">
<item material="leaves" image="entities/objects/foliage/codename/codename_3.dds" layer="base" />
</group>
</shared>
Note
The <group weight="1"> defines how likely the variant is to show up, and if all numbers are equal, all variants have an equal chance of showing.
Save your XML file, make sure all the variant skins are in codename folder, and you should be set to go! 😉
This process is slightly different, as you can define the name of the Materials Property yourself, as long as you know what Materials file controls what texture.
Using this time the BurOak as an example (it is an ES plant and therefore has BFB files), we can open up the DDS files to find the name of the DDS file that has the skin for the leaves in it. This skin is BurOak_Grassland_C.DDS.
Therefore, to make this plant have variant leaves, we have to find the Materials file that makes this DDS file show. So open up all the Materials files and look for:
<param name="Texture0" type="texture">BurOak_Grassland_C</param>
Or the equivalent, and this is the Materials file you will need to edit to achieve variant skins.
Note
Sometimes there may be more than one Materials file using the same texture (because the model is split into smaller chunks, as in the case of the BurOak), so we will need to make all of them use the same variant at the same time.
So, now you need to choose a name for the part you want to variate, so choose something simple like “leaves”.
If you have multiple Materials files using the same texture, you will need to have multiple names, so make them simple like “leaves1” and “leaves2” if you have two Materials files for that texture. Now we must edit the Materials files.
Open the Materials files that contain the skin you want to have variants of. The first line will be something like:
<material fx="Base">
You need to insert the name you chose earlier, so it looks like this:
<material fx="Base" name="leaves1">
For each Materials file using that skin, you will need to edit that first line to include the name="name you chose.
Important
If there are two or three Materials files and you have used more than one name, make sure that each Materials file has a different one.
Now we can code the AI XML file to make variants pretty much the same way as you would with a NIF, so read the section above on coding the AI file. 😉
The only slight differences are that the
<item material="material name"
is the same as the name you put in the name="material name" section in your Materials files! 😉
If you have multiple Materials files for the same texture, your coding should look something more like this, remembering to make a new <group> for each variant skin as you would above:
<shared>
<BFSharedRandomTextureInfo>
<replacementSet>
<group weight="1">
<item material="leaves1" image="entities\objects\foliage\acodename/codename_1.dds" layer="base" />
<item material="leaves2" image="entities\objects\foliage\codename/codename_1.dds" layer="base" />
<item material="leaves3" image="entities\objects\foliage\codename/codename_1.dds" layer="base" />
</group>
</shared>
See how all the Materials files that need to have variants all will have the same variant skin at the same time? 😉
And that’s how you make foliage (or any other object) variants! Any questions and I will try and help as best as I can!
by Zooasaurus
In this tutorial, you will find out how to add and subtract behaviors from animals.
by MarineManiac
This tutorial teaches how to use only cart based animals, but can be applied to shops.
Comments 0
Log in to join the conversation.
No comments yet.