Buckets are one form of control flow for Behaviors, the next are states and transitions.
You can see a list of all available Transitions here.
Let's take another example:
<State id="Attacking">
<State id="Bullet1">
<Behavior numShots="3" projectileId="0"cooldown="0.6">Shoot</Behavior>
<Transition afterTime="1.2">Wait1</Transition>
</State>
<State id="Wait1">
<Transition afterTime="1">Bullet2</Transition>
</State>
<State id="Bullet2">
<Behavior projectileId="1" cooldown="10.0">Shoot</Behavior>
<Transition afterTime="1.0">Bullet1</Transition>
</State>
<Behavior bucket="movement">Follow</Behavior>
<Behavior bucket="movement">Wander</Behavior>
<Transition hitpointsLessThan="0.5">Flash</Transition>
</State>
<State id="Flash">
<Behavior type="Flash" color="FF0000">ShowEffect</Behavior>
<Transition afterTime="1.0">Explode</Transition>
</State>
<State id="Explode">
<Behavior range="0.0" projectileId="0">Explode</Behavior>
</State>
<Behavior>Taunt</Behavior>
<Behavior numShots="3" projectileId="0"
cooldown="0.6">Shoot</Behavior>
<Behavior bucket="movement">Follow</Behavior>
<Behavior bucket="movement">Wander</Behavior>
<Behavior>Taunt</Behavior>
Shoot comes from Bullet1 and Follow and Wander come from Attacking and since Taunt is outside of all states, it is always executed.
1 - The Test Chicken will shoot 3 times a barrage of 3 bullets.
<State id="Attacking">
<State id="Bullet1">
<Behavior numShots="3" projectileId="0"cooldown="0.6">Shoot</Behavior>
<Transition afterTime="1.2">Wait1</Transition>
</State>
2 - Then wait a second.
<State id="Wait1">
<Transition afterTime="1">Bullet2</Transition>
</State>
3 - Then shoot a different type of bullet, wait one second and start over.
<State id="Bullet2">
<Behavior projectileId="1" cooldown="10.0">Shoot</Behavior>
<Transition afterTime="1.0">Bullet1</Transition>
</State>
It will do this while following around any players or, if none are found, wandering aimlessly.
The state <State id="Attacking">
is the main "behavior" for the test chicken. It will execute this loop until the conditions are met to transition to another state. This condition is defined at the end of the <State id="Attacking">
:
<Transition hitpointsLessThan="0.5">Flash</Transition>
So, if the Test Chickens hitpoints are reduced below 50%, it will:
4 - Stop shooting, and flash for 1.0 second
<State id="Flash">
<Behavior type="Flash" color="FF0000">ShowEffect</Behavior>
<Transition afterTime="1.0">Explode</Transition>
</State>
5 - It will then explode.
During all of this, it will “Taunt” the player.
<Behavior>Taunt</Behavior>
Is something described here not clear or do you have ideas on how to improve the documentation? Let us know!