Time for action – Using ignores
This will be a simple experiment; we're just going to have AwesomeEnemy
not take any damage while it's fleeing.
At the top of
AwesomeEnemy
'sFleeing
state, add the following line:ignores TakeDamage;
This one's pretty hard to test, but adding this line will make
AwesomeEnemy
ignore calls toTakeDamage
while it is in theFleeing
state.
What just happened?
If we had more than one function that we wanted to ignore, then we would separate them with commas. For example, if we wanted it to ignore the EndAttack
function as well, we would write it like this:
ignores TakeDamage, EndAttack;
Labels and latent functions
States can have special functions that can only be executed from within that state, code that can't be called from normal functions. These are called latent functions. In addition, states can use labels to control the flow of state code. Let's take a look.