Skip to content

Handling Events

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

EventWhen it fires
EVENT_HITNormal hit
EVENT_HIT_COMBOHit during a multi-hit attack (e.g. Power Bounce)
EVENT_BURN_HITHit by fire
EVENT_BURN_DEATHKilled by fire
EVENT_SHOCK_HITElectrocuted (e.g. from touching Zap Tap)
EVENT_SHOCK_DEATHKilled by shock
EVENT_SPIN_SMASH_HITHit by spin smash
EVENT_SPIN_SMASH_DEATHKilled by spin smash
EVENT_DEATHKilled by normal damage
EVENT_ZERO_DAMAGEHit but took 0 damage
EVENT_IMMUNEImmune to the attack
EVENT_RECOVER_STATUSRecovering from a status effect
EVENT_SCARE_AWAYScared away by Bow's ability
EVENT_BLOW_AWAYBlown away by a wind attack
EVENT_SPIKE_TAUNTPlayer 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)
EndCaseGroup

Available helpers:

HelperPurpose
EVS_Enemy_HitStandard hit reaction
EVS_Enemy_BurnHitBurn hit (needs LVar2 for burn-still animation)
EVS_Enemy_ShockHitElectrocution reaction
EVS_Enemy_SpinSmashHitSpin smash knockback
EVS_Enemy_DeathDeath sequence and removal
EVS_Enemy_NoDamageHitFlinch with no damage
EVS_Enemy_RecoverStatus recovery
EVS_Enemy_ScareAwayScare away (needs LVar2 for hurt animation)
EVS_Enemy_AirLiftAir lift attempt
EVS_Enemy_BlowAwayBlown away
EVS_Enemy_KnockbackGeneric knockback

For a complete event handler covering all event types, see src/battle/actor/gloomba.c.