Help With OnDamaged Script

I think this code is correct for spawning in critters when OBJECT_SELF is damaged. But nothing happens?


        int nMax = GetMaxHitPoints(OBJECT_SELF);
        int nHP = GetCurrentHitPoints(OBJECT_SELF);
        int nRatio = (100* nHP)/nMax;
        if (nRatio <= 25)
            AssignCommand(OBJECT_SELF, ActionPlayAnimation(ANIMATION_FIREFORGET_TAUNT));

            DelayCommand(1.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect
            ( VFX_IMP_DEATH_L ), GetLocation(GetWaypointByTag("SKELE_SUMMON_01"))));

                DelayCommand(1.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "skeleton003", GetLocation(GetWaypointByTag("SKELE_SUMMON_01"))));

            DelayCommand(2.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect
            ( VFX_IMP_DEATH_L ), GetLocation(GetWaypointByTag("SKELE_SUMMON_2"))));

                DelayCommand(2.5, CreateObjectVoid(OBJECT_TYPE_CREATURE, "skeleton003", GetLocation(GetWaypointByTag("SKELE_SUMMON_2"))));

            // Attack the PC.
            DelayCommand(3.0, AdjustReputation(oPC, GetNearestObjectByTag("SKELE_WAR_001"), -100));
            DelayCommand(3.0, SetIsTemporaryEnemy(oPC, GetNearestObjectByTag("SKELE_WAR_001")));
            DelayCommand(3.0, AssignCommand(GetNearestObjectByTag("SKELE_WAR_001"), DetermineCombatRound(oPC)));

Everything works as long as I remove the math problem. So I would have to say the code is incorrect. What say you experts?
Edit: It’s working now. Think I might of had a bracket out of place…

Damn. Didn’t see that until I had done a little work on it. Ah well…

Observations -

  • Both GetMaxHitPoints() and GetCurrentHitPoints() have a default parameter which just happens to be OBJECT_SELF, so no need to give them that parameter.
  • Being a belt & braces guy I would have staggered the timings in your DelayCommand() calls. Maybe not necessary but just to be on the safe side… E.g. 1.5, 1.51, 2.5, 2.51, etc.