//::///////////////////////////////////////////////
//:: Wild Mage Spell - Stabilize Heartbeat
//::///////////////////////////////////////////////
/*
Description modified from AD&D 2nd Edition - "Tome of Magic"

Stabilize

Caster Level(s): Wizard / Sorcerer 9
Innate Level: 9
School: Abjuration
Descriptor(s): Wild Magic
Component(s): Verbal, Somatic
Range: 0
Area of Effect / Target: 30' diameter circle
Duration: ld4 + 1 turns
Casting Time: 4 rounds
Save: None
Spell Resistance: None

     This spell requires immense magical effort to cast,
relegating it to the highest spell level. Stabilize 
negates the effects of wild magic regions, allowing the 
caster and all creatures in a 30-foot radius to cast spells 
and use magical items normally. The spell is centered on the 
caster and follows his movements. 
     The caster’s own spells never cause wild surges when 
cast within the duration of a stabilize spell, nor do the 
effects of wild surges extend into the protected area. 
Furthermore, the wild mage’s spells function at his true 
level. A random roll is not used to determine level 
variation. The spell affects wildstrike and wildzone.

2d2f_sp_stabilize_heart.nss
*/
//::///////////////////////////////////////////////
//:: Created By: 2DruNk2Frag
//:: Created On: 03-08-2008
//:: Last Update: 03-24-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 oPC = GetFirstPC();
		object oCaster = JXGetAOERealCreator();
		float fDur = 6.0; // 1 round
		float nRadius = RADIUS_SIZE_LARGE;//30 ft
		int nSpellId = SPELL_STABILIZE;
		//object oTarget1 = GetFirstObjectInShape(SHAPE_CUBE, nRadius, GetLocation(oCaster), FALSE);
		object oTarget = GetFirstInPersistentObject();
		effect eVis = EffectVisualEffect(VFX_DUR_STABILIZE);
		eVis = SetEffectSpellId(eVis,nSpellId);
	
		//SendMessageToPC(oPC, "stabilize heart script fired");
	
		if(GetIsDead(oPC) || !GetIsObjectValid(OBJECT_SELF))
    	{
        DestroyObject(OBJECT_SELF, 0.0);
    	}	
			
		/*while(GetIsObjectValid(oTarget))
    	{
			SignalEvent(oTarget, EventSpellCastAt(oPC, nSpellId, FALSE));
			
           	JXApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oTarget,fDur);
		
		oTarget = GetNextInPersistentObject();		
		}*/
}