The How To's of Gift Making
by MarineManiac
This tutorial teaches how to use only cart based animals, but can be applied to shops.
- Zoo Tycoon 2
- Objects & Scenery
- Scripting
- Reading time
- 6 min
- Comments
- 0
by Zooasaurus
For advanced coders.
This is a tutorial designed for those that already have the basic coding down, and wish to know more.
In this tutorial, you will find out how to add and subtract behaviors from animals. It will include everything from pack hunting behaviors to swimming underwater.
Now, behaviors are controlled through the .beh and .tsk files under ai.
There are two basic types of behaviors.
entities/units/animals/ai.I’ll first teach you how to code the type 1 behaviors.
This is an example of a behavior. This particular one is taken from the Bengal Tiger.
It’s from the .beh file.
<Sleep>
<subjects>
<TigerBengal/>
</subjects>
<behaviors>
<BFBehRandomSet>
<randomSets>
<SleepSide weight="50"/>
<SleepPaws weight="50"/>
</randomSets>
</BFBehRandomSet>
</behaviors>
</Sleep>
It has the starting code <Sleep> and closing code </Sleep>, the behaviors name.
It’s type 1 because there is no animation reference.
The following behavior is type 2.
<SleepSide>
<subjects>
<TigerBengal/>
</subjects>
<behaviors>
<BFBehAnimate targetAnim="Sleep_Idle" playTime="20"/>
</behaviors>
</SleepSide>
It has an animation, “Sleep_Idle” which is in the bfm.
Codes in the .tsk files are abit different though. The code for sleep is:
<BFAITaskTemplate Name="Sleep" UniqueID="TigerBengal:Sleep">
<BFAICreateData>
<Subjects>
<TigerBengal/>
<Qualifiers_AND onLand="true" isSwimming="false"/>
</Subjects>
<Targets>
<self/>
</Targets>
<Objects/>
</BFAICreateData>
<BFAIEvalData>
<BFAIAttributeFloatMap rest="-35"/>
</BFAIEvalData>
<BFBehExecTask>
<ZTBehViewEvent viewKey="Pos_1"/>
<ZTBehFeedback>
<ZTFeedbackData>
<ZTActionInfo locID="animalactions:Sleeping"/>
</ZTFeedbackData>
</ZTBehFeedback>
<BFBehPlaySet behSet="Sleep"/>
</BFBehExecTask>
<BFAICompletionData>
<BFAIAttributeFloatMap rest="-100"/>
<BFAITokenList>
<BFAIToken Name="t_Stretch" GiveTo="subject" Timeout="5"/>
</BFAITokenList>
<BFBehExecTask>
<ZTBehFeedback>
<ZTFeedbackData>
<ZTEmoticonInfo emoticonName="EmoteAnimalRestVeryGood"/>
</ZTFeedbackData>
</ZTBehFeedback>
</BFBehExecTask>
</BFAICompletionData>
</BFAITaskTemplate>
Everyone of these codes starts with <BFAITaskTemplate> and ends with </BFAITaskTemplate>.
From what I know, where it says UniqueID= the resulting code is a reference to a beahvior in the .beh.
To add one of these behaviors, simply add the code in the right place. it dosen’t matter where in the file you add it, but the codes have to match. And you need to add the corresponding code in the .tsk file for it to work.
Note
Not all .beh codes have a .tsk code, so don’t worry if you can’t find one.
Type 2 codes are more difficult, as you’ll require multiple files and an understanding of what animations are used.
These are the codes required for the Deinosuchus to swim underwater:
<Surface_Submerge>
<subjects>
<Deinosuchus/>
</subjects>
<behaviors>
<BFBehLocoSwitchSet switch="false">
<behaviorTable>
<water behSet="Submerge"/>
<underwater behSet="Surface"/>
</behaviorTable>
</BFBehLocoSwitchSet>
</behaviors>
</Surface_Submerge>
<Submerge>
<subjects>
<Deinosuchus/>
</subjects>
<behaviors>
<ZTBehFeedback>
<ZTFeedbackData>
<ZTActionInfo locID="animalactions:Submerging"/>
</ZTFeedbackData>
</ZTBehFeedback>
<BFBehWander minPlayTime="7" maxPlayTime="15" avoidLand="true" minDepth="2" maxDepth="10" avoidEntityRadius="8">
<avoidEntityTypes>
<TrainingArea/>
</avoidEntityTypes>
</BFBehWander>
</behaviors>
</Submerge>
<Surface>
<subjects>
<Deinosuchus/>
</subjects>
<behaviors>
<ZTBehFeedback>
<ZTFeedbackData>
<ZTActionInfo locID="animalactions:Surfacing"/>
</ZTFeedbackData>
</ZTBehFeedback>
<BFBehWander minPlayTime="7" maxPlayTime="15" avoidLand="true" minDepth="0" maxDepth="0" avoidEntityRadius="8">
<avoidEntityTypes>
<TrainingArea/>
</avoidEntityTypes>
</BFBehWander>
</behaviors>
</Surface>
<BFAITaskTemplate Name="Surface_Submerge" TaskDelayMin="30" TaskDelayMax="60" distanceInfluenced="false" UniqueID="Deinosuchus:Surface_Submerge">
<BFAICreateData>
<Subjects>
<Deinosuchus/>
<Qualifiers isSwimming="true"/>
</Subjects>
<Targets>
<water/>
</Targets>
<Objects/>
</BFAICreateData>
<BFAIEvalData fixedScore=".002"/>
<BFBehExecTask>
<BFBehPlaySet behSet="Surface_Submerge"/>
</BFBehExecTask>
<BFAICompletionData/>
<BFAIFailureData>
<BFBehExecTask>
<BFBehPlaySet behSet="FailureSet"/>
</BFBehExecTask>
</BFAIFailureData>
</BFAITaskTemplate>
Although an animation is not referenced, many are used to make this work. There is also a section in the main Deinosuchus main ai .xml file required for the behavior.
Important
You’ll have to add this to your animal in order for the animation to work.
This is the code:
<BFNamedBinder binderName="underwater" required="1">
<instance>
<BFLocoAnimate version="1">
<stop name="TreadWaterSub" />
<slow name="SwimSub" >
<anim name="Swim_2SwimSub" yaw="1.0" />
<anim name="SwimSub_Ahead" yaw="1.0" pitch="0.5" />
</slow>
<medium name="SwimSub" >
<anim name="Swim_2SwimSub" yaw="1.0" />
<anim name="SwimSub_Ahead" yaw="1.0" pitch="0.5" />
</medium>
<fast name="SwimSub" >
<anim name="Swim_2SwimSub" yaw="1.0" />
<anim name="SwimSub_Ahead" yaw="1.0" pitch="0.5" />
</fast>
<stalk name="SwimSub" >
<anim name="Swim_2SwimSub" yaw="1.0" />
<anim name="SwimSub_Ahead" yaw="1.0" pitch="0.5" />
</stalk>
<evade name="SwimSub" >
<anim name="Swim_2SwimSub" yaw="1.0" />
<anim name="SwimSub_Ahead" yaw="1.0" pitch="0.5" />
</evade>
<glide name="SwimSub" minAnimSpeed="0.5" maxAnimSpeed="1.5" >
<anim name="Swim_2SwimSub" yaw="1.0" pitch="0.5" acceleration="-0.1" />
<anim name="SwimSub_Ahead" yaw="1.0" pitch="0.5" />
</glide>
<attack name="SwimSub" >
<anim name="Swim_2SwimSub" yaw="1.0" />
<anim name="SwimSub_Bite" yaw="1.0" pitch="0.5" />
</attack>
</BFLocoAnimate>
</instance>
</BFNamedBinder>
</binder>
</BFBinder>
It’s connected to other codes, but this is the only neccessary part.
Note
All major locomotion behaviors require similar codes.
The final step to making this work is add the actions from the animal your taking the behaviors from bfm and adding them your animal’s bfm.
Important
If the animal your using isn’t similar. You’ll have to replace the animation used with one your animal uses.
If you have any questions, feel free to pm me at Zt2 Desigining Center, Zoo Tycoon Volcano, ZooMania, or any other site you know I’m on.
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.