//::///////////////////////////////////////////////
//:: Wild Mage Spell - Wild Storm Exit Script
//::///////////////////////////////////////////////
/*
Wild Storm

2d2f_sp_wild_storm_exit.nss
*/
//::///////////////////////////////////////////////
//:: Created By: 2DruNk2Frag
//:: Created On: 04-25-2008
//:: Last Update: 04-26-2008
//::///////////////////////////////////////////////

#include "2d2f_includes"
#include "jx_inc_magic"
#include "x2_inc_spellhook" 
#include "jx_inc_magic_info"
#include "nwn2_inc_spells"
#include "nw_i0_spells"
#include "X0_I0_SPELLS"
#include "x0_i0_spells"

void main()
{
	object oTarget = GetExitingObject();
    int bValid = FALSE;
    effect eAOE;
    if(GetHasSpellEffect(SPELL_WILD_STORM, oTarget))
    {
		//Search through the valid effects on the target.
        eAOE = GetFirstEffect(oTarget);
        while (GetIsEffectValid(eAOE))
        {
            if (GetEffectCreator(eAOE) == GetAreaOfEffectCreator())
            {
                //If the effect was created by the AOE then remove it
                if(GetEffectSpellId(eAOE) == SPELL_WILD_STORM)
                {
                    RemoveEffect(oTarget, eAOE);
					object oPC = GetFirstPC();
					//SendMessageToPC(oPC, "Removing wildzone from " + GetName(oTarget));
                }
            }
            //Get next effect on the target
            eAOE = GetNextEffect(oTarget);
        }
    }
    


}