//::///////////////////////////////////////////////
//:: Body of the Sun
//:: nw_s0_bodysun.nss
//:: Copyright (c) 2006 Obsidian Entertainment
//:://////////////////////////////////////////////
/*
	By drawing on the power of the sun, you cause your body to emanate fire.
	Fire extends 5 feet in all directions from your body, illuminating the 
	area and dealing 1d4 points of fire damage per two caster levels (maximum 5d4)
	to adjacent enemies every round.
*/
//:://////////////////////////////////////////////
//:: Created By: Patrick Mills
//:: Created On: Oct 18, 2006
//:://////////////////////////////////////////////


#include "nw_i0_spells"
#include "jx_inc_magic"
#include "x2_inc_spellhook" 
#include "nwn2_inc_metmag"

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

void mainSpell()
{
    /*
      Spellcast Hook Code
      Added 2003-07-07 by Georg Zoeller
      If you want to make changes to all spells,
      check x2_inc_spellhook.nss to find out more

    */

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

// End of Spell Cast Hook

//Declare major variables
//Also prevent stacking

	object	oCaster		=	OBJECT_SELF;
	string	sSelf		=	ObjectToString(oCaster) + IntToString(JXGetSpellId());
	object	oSelf		=	GetNearestObjectByTag(sSelf);
	effect 	eVis		=	EffectVisualEffect(924);
	float	fDuration	=	RoundsToSeconds(JXGetCasterLevel(oCaster));

	
//Destroy the object if it already exists before creating a new one

	if (GetIsObjectValid(oSelf))
	{
		DestroyObject(oSelf);
	}
	
//Determine duration
			fDuration	=	ApplyMetamagicDurationMods(fDuration);

//Generate the object
	JXApplyAreaEffectToObject(60, oCaster, fDuration, "", "", "", sSelf);
	JXApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oCaster, fDuration);

	JXPostSpellCastCode();
}
