Welcome Guest [Log In] [Register]
Welcome to Northernskies,

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Locked Topic
How To Make Baby Variants; by Ghost
Topic Started: Aug 27 2012, 12:16 PM (2,508 Views)
Ghost
Member Avatar
Administrator

Tutorial: How To Make Baby Variantsby: Ghost

In this tutorial I’m going to show/teach you a few things regarding baby variants:

  • How to make baby variants.
  • How to make them grow up randomly.
  • How to make control to what adult the baby will grow up to.

    Please note; this is not something you can easily add in a few minutes.

    We’re going to edit the BEH and TSK files. A mistake in one of those files will probably make your animal stop moving or doing any behaviors.

    For that reason general knowledge of coding is required. You need to know how to open and edit XML, BEH and TSK files and how to make a z2f file etc. These things won't be explained in this tutorial, so if you don't know how to do that then I direct you to one of the basic coding tutorials other members have made.

    I'm using my Mustang hacks coding as base for this tutorial. You will need to change the code names and a few other things if you want to copy the coding.

    If you need any help, please ask it here.
    Contents
    Step 1; The XML files.

    • Making new young XML files for the baby variants.
    • Making new adult XML files for the growing up.
    Step 2; The TSK and BEH files.
    • Editing the XML and BEH files so the young grow up to a specific adult.
    • Editing the XML and BEH files so the young grow up randomly.
    Closing words
    Step 1; The XML files

    For the baby variants to work, we need to make new XML files for every new baby variant. In those newly made XML files, we are going to define what skin they'll have.

    Young XML

    First you need to write down how you made your baby variants. I use the same naming style as BF used for the adult variants.
    The main skin is called MustangAmerican_Young_F.dds
    The first variant is called MustangAmerican_Young_F_1.dds
    The second variant is called MustangAmerican_Young_F_2.dds
    Just keep naming all the variants you might have like that.

    After you've done that we can go and make the first XML file. We will need to make a male and female young XML file for every new variant (unless the variants are gender specific).

    This is how the complete XML looks for the first male variant. I'll go in detail on all the things that need to be changed for the following variants.
Code: HTML
 
<BFTypedBinder binderType="MustangAmerican_Young_M_1">
<types>
<entity>
<actor>
<animal>
<Mammalia>
<Perissodactyla>
<Equidae>
<MustangAmerican>
<MustangAmerican_Young>
<MustangAmerican_Young_M_1/>
</MustangAmerican_Young>
</MustangAmerican>
</Equidae>
</Perissodactyla>
</Mammalia>
</animal>
</actor>
</entity>
</types>
<instance>
<BFGEntity/>
</instance>
<shared>
<UIToggleButton template="adopt">
<on>
<event msg="ZT_SETPLACEMENTOBJECT" data="BFString" string="MustangAmerican_Young_M"/>
</on>
</UIToggleButton>
<ZTDevComponent/>
<BFAIEntityDataShared b_Male="1"/>
</shared>
<binder>
<BFNamedBinder binderName="mainObj">
<instance>
<BFPhysObj>
<BFActorComponent actorfile="entities/units/animals/MustangAmerican/MustangAmerican_Young_F.bfm" scale="0.6" />
</BFPhysObj>
</instance>
</BFNamedBinder>
<BFNamedBinder binderName="texController" required="1">
<instance>
<BFAITextureController currState="well" defaultState="well">
<attribList>
<health />
<hygiene />
</attribList>
<stateList>
<sickanddirty>
<attribData>
<health minRange="70" maxRange="101" />
<hygiene minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Young_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Young_F_1.dds" />
</textureData>
</sickanddirty>
<sick>
<attribData>
<health minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Young_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Young_F_1.dds" />
</textureData>
</sick>
<dirty>
<attribData>
<hygiene minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Young_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Young_F_1.dds" />
</textureData>
</dirty>
<well>
<textureData>
<mainObj material="MustangAmerican_Young_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Young_F_1.dds" />
</textureData>
</well>
</stateList>
</BFAITextureController>
</instance>
</BFNamedBinder>
</binder>
</BFTypedBinder>
Lets start at the top of the XML file.
Code: HTML
 
<BFTypedBinder binderType="MustangAmerican_Young_M_1">
Here we can see the binderType of the first young male variant. This line has to be changed for every young variant. You can use an F instead of the M for the females. Just use number 1 for the first variant, number 2 for the second variant etc.

Then come these lines:
Code: HTML
 
<types>
<entity>
<actor>
<animal>
<Mammalia>
<Perissodactyla>
<Equidae>
<MustangAmerican>
<MustangAmerican_Young>
<MustangAmerican_Young_M_1/>
</MustangAmerican_Young>
</MustangAmerican>
</Equidae>
</Perissodactyla>
</Mammalia>
</animal>
</actor>
</entity>
</types>
The <MustangAmerican_Young_M_1/> part has to be changed for every new variant and needs to be the same as the binderType explained earlier.

On to the next part.
Code: HTML
 
<instance>
<BFGEntity/>
</instance>
<shared>
<UIToggleButton template="adopt">
<on>
<event msg="ZT_SETPLACEMENTOBJECT" data="BFString" string="MustangAmerican_Young_M"/>
</on>
</UIToggleButton>
<ZTDevComponent/>
<BFAIEntityDataShared b_Male="1"/>
</shared>
Don't change the string="MustangAmerican_Young_M"/>. Every baby variant has the same line, don't add the _1 _2 etc. It won't work correctly if you do! Only change the M to an F if you are making the female variants. Also change the b_Male="1" to b_Male="0" when you are making the female XML.

Code: HTML
 
<binder>
<BFNamedBinder binderName="mainObj">
<instance>
<BFPhysObj>
<BFActorComponent actorfile="entities/units/animals/MustangAmerican/MustangAmerican_Young_F.bfm" scale="0.6" />
</BFPhysObj>
</instance>
</BFNamedBinder>
Not much to change here. Just make sure to change the BFM path if you use different ones for the male and female young. Also edit the scale to the required amount (you can look up the size in the _young.xml file).

Now to the last part.
Code: HTML
 
<BFNamedBinder binderName="texController" required="1">
<instance>
<BFAITextureController currState="well" defaultState="well">
<attribList>
<health />
<hygiene />
</attribList>
<stateList>
<sickanddirty>
<attribData>
<health minRange="70" maxRange="101" />
<hygiene minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Young_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Young_F_1.dds" />
</textureData>
</sickanddirty>
<sick>
<attribData>
<health minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Young_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Young_F_1.dds" />
</textureData>
</sick>
<dirty>
<attribData>
<hygiene minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Young_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Young_F_1.dds" />
</textureData>
</dirty>
<well>
<textureData>
<mainObj material="MustangAmerican_Young_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Young_F_1.dds" />
</textureData>
</well>
</stateList>
</BFAITextureController>
</instance>
</BFNamedBinder>
</binder>
</BFTypedBinder>
This part defines what skin the young will use and this makes it possible for us to define different skins to the young. Make sure to change the DDS path to the correct one.

Well there you have it, the first young variant XML. You will have to make a male and a female one for every variant you want.

Adult XML
We also have to make new XML files for the adults. Otherwise we can't let the young grow up correctly (as in keep the variant skin). It's quite similar to the young XML so I won't explain it in as much detail.

Here is a female XML file.
Code: HTML
 
<BFTypedBinder binderType="MustangAmerican_Adult_F_1">
<types>
<entity>
<actor>
<animal>
<Mammalia>
<Perissodactyla>
<Equidae>
<MustangAmerican>
<MustangAmerican_Adult>
<MustangAmerican_Adult_F>
<MustangAmerican_Adult_F_1/>
</MustangAmerican_Adult_F>
</MustangAmerican_Adult>
</MustangAmerican>
</Equidae>
</Perissodactyla>
</Mammalia>
</animal>
</actor>
</entity>
</types>
<instance>
<BFGEntity/>
</instance>
<shared>
<UIToggleButton template="adopt">
<UIAspect>
<default image="entities\units\animals\MustangAmerican\MustangAmerican_Adult_F_icon.dds" />
</UIAspect>
<UIHelpInfo ids="entityname:MustangAmerican" />
<on>
<event msg="ZT_SETPLACEMENTOBJECT" data="BFString" string="MustangAmerican_Adult_F" />
</on>
</UIToggleButton>
<ZTDevComponent/>
<BFAIEntityDataShared b_Male="0" f_adoptCount="rand(1,4)"/>
</shared>
<binder>
<BFNamedBinder binderName="mainObj">
<instance>
<BFPhysObj>
<BFActorComponent actorfile="entities/units/animals/MustangAmerican/MustangAmerican_Adult_F.bfm" scale="1.2"/>
</BFPhysObj>
</instance>
</BFNamedBinder>
<BFBinder required="1">
<instance>
<BFAIEntityDataInstance b_Pregnant="false"/>
</instance>
</BFBinder>
<BFNamedBinder binderName="texController" required="1">
<instance>
<BFAITextureController currState="well" defaultState="well">
<attribList>
<health />
<hygiene />
</attribList>
<stateList>
<sickanddirty>
<attribData>
<health minRange="70" maxRange="101" />
<hygiene minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Adult_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Adult_Sick_Dirty_1.dds" />
</textureData>
</sickanddirty>
<sick>
<attribData>
<health minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Adult_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Adult_Sick_1.dds" />
</textureData>
</sick>
<dirty>
<attribData>
<hygiene minRange="70" maxRange="101" />
</attribData>
<textureData>
<mainObj material="MustangAmerican_Adult_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Adult_Dirty_1.dds" />
</textureData>
</dirty>
<well>
<textureData>
<mainObj material="MustangAmerican_Adult_F" image="entities\units\animals\MustangAmerican\MustangAmerican_Adult_F_1.dds" />
</textureData>
</well>
</stateList>
</BFAITextureController>
</instance>
</BFNamedBinder>
</binder>
</BFTypedBinder>
The same changes have to be done as with the young XML files, but there are a few differences.

Here is the first one.
Code: HTML
 

<MustangAmerican>
<MustangAmerican_Adult>
<MustangAmerican_Adult_F>
<MustangAmerican_Adult_F_1/>
</MustangAmerican_Adult_F>
</MustangAmerican_Adult>
</MustangAmerican>
What's important to notice is that I added the <MustangAmerican_Adult_F_1/> line. If we were to change this part the same as we did with the young, a lot of gender specific behaviors wouldn't be done by the male and/or female adult variants.

Only the female XML needs the following part, you need to remove it for the male XML.
Code: HTML
 
<BFBinder required="1">
<instance>
<BFAIEntityDataInstance b_Pregnant="false"/>
</instance>
</BFBinder>
That concludes this section. You should now have 2 new young and 2 new adult XML files for every variant. In the next section I'll explain how to code the TSK file.
Step 2; The TSK and BEH files

Now on to the TSK and BEH files.

I'll start with the TSK file.

Inside the TSK we need to edit and add parts that control the growing up. There are two different things you can do. You can either directly determine to what adult the young will grow up to or make a BehSet so you can let the young grow up randomly. The latter might come in handy when the young don't really differ and you just want them able to grow up to different variants.

I will explain both of them, so you can decide what works best for you.

Firstly open up the TSK file and search for 'puberty'. A bit below that you can see the Age_F TaskTemplate.

Code: HTML
 
<BFAITaskTemplate Name="Age_F" UniqueID="MustangAmerican:Age_F">
<BFAICreateData>
<Subjects>
<MustangAmerican_Young_F/>
<Qualifiers inWater_OR_onLand="true"/>
</Subjects>
<Targets>
<self/>
</Targets>
<Objects>
<t_Age/>
</Objects>
</BFAICreateData>
<BFAIEvalData fixedScore="2000"/>
<BFBehExecTask>
<ZTBehMorph morphTargetEntityType="MustangAmerican_Adult_F" morphScale="true" morphPeriod="10" initScale="0.4"/>
</BFBehExecTask>
<BFAICompletionData/>
</BFAITaskTemplate>
This part of the coding causes the subject (MustangAmerican_Young_F) to grow up to MustangAmerican_Adult_F. We can use this coding for our newly made baby variants.

You will need both the Age_F and Age_M TaskTemplates.
What you need to do is change the Age_F and Age_M to Age_F_1 and Age_M_1 for the first baby variants. Change it to Age_F_2 and Age_M_2 for the second etc. Do the same for the UniqueID.

You will also need to change the subject to the corresponding baby variant. So for the Age_F_1 TaskTemplate you will need to change MustangAmerican_Young_F to MustangAmerican_Young_F_1 and so on.

Lastly you need to change the following
Code: HTML
 
<BFBehExecTask>
<ZTBehMorph morphTargetEntityType="MustangAmerican_Adult_F" morphScale="true" morphPeriod="10" initScale="0.4"/>
</BFBehExecTask>[/php]
to
[php] <BFBehExecTask>
<ZTBehMorph morphTargetEntityType="MustangAmerican_Adult_F_1" morphScale="true" morphPeriod="10" initScale="0.4"/>
</BFBehExecTask>
You need to do the same for the Age_M TaskTemplates.

Fully edited TaskTemplates for the first variants will look like this:

Code: HTML
 
<BFAITaskTemplate Name="Age_F_1" UniqueID="MustangAmerican:Age_F_1">
<BFAICreateData>
<Subjects>
<MustangAmerican_Young_F_1/>
<Qualifiers inWater_OR_onLand="true"/>
</Subjects>
<Targets>
<self/>
</Targets>
<Objects>
<t_Age/>
</Objects>
</BFAICreateData>
<BFAIEvalData fixedScore="2000"/>
<BFBehExecTask>
<ZTBehMorph morphTargetEntityType="MustangAmerican_Adult_F_1" morphScale="true" morphPeriod="10" initScale="0.4"/>
</BFBehExecTask>
<BFAICompletionData/>
</BFAITaskTemplate>
<BFAITaskTemplate Name="Age_M_1" UniqueID="MustangAmerican:Age_M_1">
<BFAICreateData>
<Subjects>
<MustangAmerican_Young_M_1/>
<Qualifiers inWater_OR_onLand="true"/>
</Subjects>
<Targets>
<self/>
</Targets>
<Objects>
<t_Age/>
</Objects>
</BFAICreateData>
<BFAIEvalData fixedScore="2000"/>
<BFBehExecTask>
<ZTBehMorph morphTargetEntityType="MustangAmerican_Adult_M_1" morphScale="true" morphPeriod="10" initScale="0.4"/>
</BFBehExecTask>
<BFAICompletionData/>
</BFAITaskTemplate>
Now on to the BEH file.
Open it up and search for '<Birth>'.

You should see these lines:
Code: HTML
 
<Birth>
<subjects>
<MustangAmerican_Adult_F/>
</subjects>
<behaviors>
<BFBehRandomSet>
<randomSets>
<SpawnF weight="50"/>
<SpawnM weight="50"/>
</randomSets>
</BFBehRandomSet>
</behaviors>
</Birth>

We need to add all the new baby variants. For that need to add a few lines Like I did below.
Code: HTML
 
<Birth>
<subjects>
<MustangAmerican_Adult_F/>
</subjects>
<behaviors>
<BFBehRandomSet>
<randomSets>
<SpawnF weight="25"/>
<SpawnM weight="25"/>
<SpawnF_1 weight="25"/>
<SpawnM_1 weight="25"/>
</randomSets>
</BFBehRandomSet>
</behaviors>
</Birth>
I added both the SpawnF_1 an SpawnM_1 for the first variant. The weights determine how high the chance is of getting that variant. Make sure they add up to 100. They don't need to have equal chances. So you can let some variants be less likely to occur.

After that we can go on to the next part.
Just below the <Birth> part you will see the following:
Code: HTML
 
<SpawnF>
<subjects>
<MustangAmerican_Adult_F/>
</subjects>
<behaviors>
<BFBehSpawn spawnEntity="MustangAmerican_Young_F" spawnRelation="child" subjectNode="Floor" fadeInPeriod="1" randomPosOffset="3" randomRotOffset="180" spawnInTA="true"/>
<BFBehScript context="behavior" file="scripts/justgavebirth.lua" function="justgavebirth"/>
</behaviors>
</SpawnF>
<SpawnM>
<subjects>
<MustangAmerican_Adult_F/>
</subjects>
<behaviors>
<BFBehSpawn spawnEntity="MustangAmerican_Young_M" spawnRelation="child" subjectNode="Floor" fadeInPeriod="1" randomPosOffset="3" randomRotOffset="180" spawnInTA="true"/>
<BFBehScript context="behavior" file="scripts/justgavebirth.lua" function="justgavebirth"/>
</behaviors>
</SpawnM>

You will change and add those lines for every extra variant you have. So for the first variants you need to add these lines below the ones I showed above:
Code: HTML
 
<SpawnF_1>
<subjects>
<MustangAmerican_Adult_F/>
</subjects>
<behaviors>
<BFBehSpawn spawnEntity="MustangAmerican_Young_F_1" spawnRelation="child" subjectNode="Floor" fadeInPeriod="1" randomPosOffset="3" randomRotOffset="180" spawnInTA="true"/>
<BFBehScript context="behavior" file="scripts/justgavebirth.lua" function="justgavebirth"/>
</behaviors>
</SpawnF_1>
<SpawnM_1>
<subjects>
<MustangAmerican_Adult_F/>
</subjects>
<behaviors>
<BFBehSpawn spawnEntity="MustangAmerican_Young_M_1" spawnRelation="child" subjectNode="Floor" fadeInPeriod="1" randomPosOffset="3" randomRotOffset="180" spawnInTA="true"/>
<BFBehScript context="behavior" file="scripts/justgavebirth.lua" function="justgavebirth"/>
</behaviors>
</SpawnM_1>

Note that I didn't change the subject, in this case MustangAmerican_Adult_F. I only changed the spawnEntity and the <SpawnF> / </SpawnF> parts (the corresponding male ones too of course).

After all that is added you are done with the baby variants and let them grow up to a specific adult variant. I'll explain what to change to let them grow up randomly.

Random Growing Up
For them to randomly grow up we need to open the TSK file.

Search for the following part:
Code: HTML
 
<BFBehExecTask>
<ZTBehMorph morphTargetEntityType="MustangAmerican_Adult_F" morphScale="true" morphPeriod="10" initScale="0.4"/>
</BFBehExecTask>


We change it to this:
Code: HTML
 
<BFBehExecTask>
<BFBehPlaySet behSet="YoungGrowF"/>
</BFBehExecTask>

You don't necessarily have to use the YoungGrowF name. You can use any name you want. Just make sure you remember what you used.

What we just changed makes it possible for us to add coding similar to the birth coding to the BEH file. You will need to make this change for every young variant you want to grow up randomly.

Now we need to go back to BEH file.

Under the last </SpawnM_> we need to add the following for the first female young:
Code: HTML
 
<YoungGrowF>
<subjects>
<MustangAmerican_Young_F/>
</subjects>
<behaviors>
<BFBehRandomSet>
<randomSets>
<AdultF weight="50"/>
<AdultF_1 weight="50"/>
</randomSets>
</BFBehRandomSet>
</behaviors>
</YoungGrowF>

Just add as many <AdultF_ lines as you need. Make sure to change the 'YoungGrowF' if you used a different name earlier. Below that we add the following coding:
Code: HTML
 

<AdultF>
<subjects>
<MustangAmerican_Young_F/>
</subjects>
<behaviors>
<ZTBehMorph morphTargetEntityType="MustangAmerican_Adult_F" morphScale="true" morphPeriod="10" initScale="0.4"/>
</behaviors>
</AdultF>
<AdultF_1>
<subjects>
<MustangAmerican_Young_F/>
</subjects>
<behaviors>
<ZTBehMorph morphTargetEntityType="MustangAmerican_Adult_F_1" morphScale="true" morphPeriod="10" initScale="0.4"/>
</behaviors>
</AdultF_1>

Now we have done the parts for one female young. Do the same for the male young and any additional baby variants you want to let grow up randomly.
Closing words

That's all you need to know to be able to make baby variants and control how they grow up. I hope you found the tutorial useful.

If you have any questions don't hesitate to ask them in the special thread I'll open for this tutorial.

I also need to thank Milchman and Thom. We all worked on figuring out how to do this.

~Ghost
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
ZetaBoards - Free Forum Hosting
Join the millions that use us for their forum communities. Create your own forum today.
Learn More · Register Now
« Previous Topic · Coding Tutorials · Next Topic »
Locked Topic