//::///////////////////////////////////////////////
//:: Aura of Courage
//:: NW_S2_CourageA.nss
//:: Copyright (c) 2006 Obsidian Entertainment, Inc.
//:://////////////////////////////////////////////
/*
    Paladin ability.  Grants +4 morale bonus on saves
	vs. fear effects to all allies within 10'.  The
	paladin herself gains an immunity to fear that's
	implemented in the code.
*/
//:://////////////////////////////////////////////
//:: Created By: Andrew Woo (AFW-OEI)
//:: Created On: 05/30/2006
//:://////////////////////////////////////////////
#include "nw_i0_spells"
#include "jx_inc_magic"
#include "x2_inc_spellhook"

void mainSpell();
void main()
{
	AssignCommand(JXGetCaster(), mainSpell());
}

void mainSpell()
{
    if (!X2PreSpellCastCode())
    {
	// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        { JXPostSpellCastCode(); return; }
    }

    object oTarget = JXGetSpellTargetObject();

	// Strip any Protective Auras first
	//RemoveSpellEffects(SPELLABILITY_AURA_OF_COURAGE, OBJECT_SELF, oTarget);
	
	// AFW-OEI 08/30/2006: Only apply effects if you don't already have them.
	//	The RemoveSpellEffects brute-force call was causing problems with effect icons.
	if (!GetHasSpellEffect(SPELLABILITY_AURA_OF_COURAGE, OBJECT_SELF))
	{
		//Create an instance of the AOE Object using the Apply Effect function
		SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELLABILITY_AURA_OF_COURAGE, FALSE));
	    JXApplyAreaEffectToObject(AOE_PER_AURA_OF_COURAGE, oTarget);
	}

	JXPostSpellCastCode();
}
