#include "NW_I0_GENERIC"
#include "prc_inc_spells"

void ExplodeAtLocation(location lTarget, int nDamage, int nSaveDC = 15, float fRadius = 3.)
{

ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_FIREBALL), lTarget);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_SUMMON_UNDEAD), lTarget);

object oObject = GetFirstObjectInShape(SHAPE_SPHERE, fRadius, lTarget);
do {
int nDamageAfterSave = PRCGetReflexAdjustedDamage(nDamage, oObject, nSaveDC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nDamageAfterSave, DAMAGE_TYPE_FIRE), oObject);
} while ((oObject = GetNextObjectInShape(SHAPE_SPHERE, fRadius, lTarget)) != OBJECT_INVALID); }

void main()
{
location lSource = GetLocation(OBJECT_SELF);
DelayCommand(0.5, ExplodeAtLocation(lSource, d6(6)));


   if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
    {
        SignalEvent(OBJECT_SELF, EventUserDefined(1007));
    }

    //ExecuteScript("sf_xp", OBJECT_SELF);
    ExecuteScript("prc_npc_death", OBJECT_SELF);
    ExecuteScript("prc_pwondeath", OBJECT_SELF);
}