void main()
{
    int nUser = GetUserDefinedEventNumber();

    if(nUser == 1001) //HEARTBEAT
    {

    }
    else if(nUser == 1002) // PERCEIVE
    {

    }
    else if(nUser == 1003) // END OF COMBAT
    {

    }
    else if(nUser == 1004) // ON DIALOGUE
    {

    }
    else if(nUser == 1005) // ATTACKED
    {

    }
    else if(nUser == 1006) // DAMAGED
    {
        if (GetCurrentHitPoints() < GetMaxHitPoints() / 3)
            SetPlotFlag(OBJECT_SELF, TRUE);
    }
    else if(nUser == 1007) // DEATH
    {
        int nMaxHP = GetMaxHitPoints(OBJECT_SELF);
        // : REMINDER: The delay is here   for a reason
        //DelayCommand(0.1, RemoveEffects(OBJECT_SELF));
        DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), OBJECT_SELF));
        if (nMaxHP != 1)
            DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(nMaxHP - (nMaxHP - 1)), OBJECT_SELF));
        else
            DelayCommand(0.3, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(nMaxHP), OBJECT_SELF));
        DelayCommand(5.1, SetIsDestroyable(FALSE, TRUE, FALSE));
        SetPlotFlag(OBJECT_SELF, TRUE);
    }
    else if(nUser == 1008) // DISTURBED
    {

    }
    else if(nUser == 2000) // Heal caller
    {
        object oTarget = GetLocalObject(OBJECT_SELF, "oHealTarget");
        ClearAllActions();
        ActionCastFakeSpellAtObject(SPELL_CURE_LIGHT_WOUNDS, oTarget);

        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(8), oTarget);

    }
    else if(nUser == 2001) // Resurrect caller
    {
        object oTarget = GetLocalObject(OBJECT_SELF, "oHealTarget");
        ClearAllActions();
        ActionCastFakeSpellAtObject(SPELL_CURE_LIGHT_WOUNDS, oTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(2), oTarget);
        SetPlotFlag(oTarget, TRUE);

    }
    else if(nUser == 2010) // Warn about goblin invasion
    {
        object oPerceived =  GetEnteringObject();
        if (GetLocalInt(GetModule(), "nZendrilWarned") != 1)
        {
            ActionMoveToObject(oPerceived, TRUE);
            SpeakString("Goblins are attacking to the north! Lend your aid if you will--quickly!", TALKVOLUME_SHOUT);
            DelayCommand(0.1, SetLocalInt(GetModule(), "nZendrilWarned", 1));
            DelayCommand(60.0, ActionMoveToObject(GetObjectByTag("JHR_WP_ZENDRILBATTLE"), TRUE));
        }
    }
}


