NWN2Wiki
Advertisement
///////////////////////////////////////////////////////////////////////////////
// EffectHealOnZeroHP
///////////////////////////////////////////////////////////////////////////////
// Created By:	Brock Heinz
// Created On:	09/02/2005
// Description: Creates a deferred heal effect that is applied to the target
//				when it reaches or falls below zero hit points
// Argument: oTarget - the target to add disintegrate effects to
// Argument: nDamageToHeal - the amount of damage to heal on the target
// Returns: effect - the newly created effect
///////////////////////////////////////////////////////////////////////////////
effect EffectHealOnZeroHP( object oTarget, int nDmgToHeal );

When using this effect in a module with a system of death and dying similar to that found in Storm of Zehir, it is important to note that this effect is very literal. If you set nDmgToHeal to 1, exactly one hit point will be healed which will not bring oTarget back to life if its hit points are at negative one or lower.

Another use of this function is to create a poor man's OnDeath event. Because this effect automatically ends when oTarget reaches zero hit points, it is possible to mimic the OnDeath module event without actually using or editing it. To do this you would start by assigning a unique spell ID with SetEffectSpellId to the effect, and then write a script which checks for an effect with that ID as often as you would like. I would recommend a recursive script as it is easier to adjust the timing of the check (see bard songs for examples of recursive scripts). When the check script does not find your effect, it can be then routed to fire another series of scripts (or the event you want to fire when oTarget reaches zero hp) and end the checks. The script which checks for the effect's ID must be called after the effect is placed on oTarget, otherwise it will fire prematurely.

Advertisement