The EVS_HandleEvent script runs whenever something happens to your actor — taking a hit, being burned, dying, or recovering from a status effect. It uses a switch on the last event to dispatch the appropriate response.
Basic structure
EvtScript EVS_HandleEvent = {
Call(UseIdleAnimation,actorID ACTOR_SELF,useIdle false)
Call(EnableIdleScript,actorID ACTOR_SELF,mode IDLE_SCRIPT_DISABLE)
Call(GetLastEvent,actorID ACTOR_SELF,outEvent LVar0)
Switch(LVar0)
// handle each event type...
CaseDefault
EndSwitch
Call(EnableIdleScript,actorID ACTOR_SELF,mode IDLE_SCRIPT_ENABLE)
Call(UseIdleAnimation,actorID ACTOR_SELF,useIdle true)
Return
End
};Every event handler should disable the idle animation at the start and re-enable it at the end. Events that remove the actor from battle (death, blow away, scare away) should Return early before the re-enable.
Common events
| Event | When it fires |
|---|---|
EVENT_HIT | Normal hit |
EVENT_HIT_COMBO | Hit during a multi-hit attack (e.g. Power Bounce) |
EVENT_BURN_HIT | Hit by fire |
EVENT_BURN_DEATH | Killed by fire |
EVENT_SHOCK_HIT | Electrocuted (e.g. from touching Zap Tap) |
EVENT_SHOCK_DEATH | Killed by shock |
EVENT_SPIN_SMASH_HIT | Hit by spin smash |
EVENT_SPIN_SMASH_DEATH | Killed by spin smash |
EVENT_DEATH | Killed by normal damage |
EVENT_ZERO_DAMAGE | Hit but took 0 damage |
EVENT_IMMUNE | Immune to the attack |
EVENT_RECOVER_STATUS | Recovering from a status effect |
EVENT_SCARE_AWAY | Scared away by Bow's ability |
EVENT_BLOW_AWAY | Blown away by a wind attack |
EVENT_SPIKE_TAUNT | Player attacked and was hurt by spikes |
Helper scripts
The battle system provides helper scripts for common event responses. You set LVar0 to the part ID and LVar1/LVar2 to the appropriate animations before calling them:
CaseOrEq(EVENT_HIT_COMBO)
CaseOrEq(EVENT_HIT)
SetConst(LVar0, PRT_MAIN)
SetConst(LVar1, ANIM_Goomba_Hurt)
ExecWait(EVS_Enemy_Hit)
EndCaseGroupAvailable helpers:
| Helper | Purpose |
|---|---|
EVS_Enemy_Hit | Standard hit reaction |
EVS_Enemy_BurnHit | Burn hit (needs LVar2 for burn-still animation) |
EVS_Enemy_ShockHit | Electrocution reaction |
EVS_Enemy_SpinSmashHit | Spin smash knockback |
EVS_Enemy_Death | Death sequence and removal |
EVS_Enemy_NoDamageHit | Flinch with no damage |
EVS_Enemy_Recover | Status recovery |
EVS_Enemy_ScareAway | Scare away (needs LVar2 for hurt animation) |
EVS_Enemy_AirLift | Air lift attempt |
EVS_Enemy_BlowAway | Blown away |
EVS_Enemy_Knockback | Generic knockback |
For a complete event handler covering all event types, see src/battle/actor/gloomba.c.