//::///////////////////////////////////////////////
//:: Cloudkill
//:: NW_S0_CloudKill.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    All creatures with 3 or less HD die, those with
    4 to 6 HD must make a save Fortitude Save or die.
    Those with more than 6 HD take 1d10 Poison damage
    every round.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: May 17, 2001
//:://////////////////////////////////////////////

#include "jx_inc_magic"
#include "x2_inc_spellhook" 

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

void mainSpell()
{

/* 
  Spellcast Hook Code 
  Added 2003-06-23 by GeorgZ
  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
    location lTarget = JXGetSpellTargetLocation();
    int nDuration = JXGetCasterLevel(OBJECT_SELF) / 2;
    //effect eImpact = EffectVisualEffect(258);	// no longer using NWN1 VFX
    //JXApplyEffectAtLocation(DURATION_TYPE_INSTANT, eImpact, lTarget);	// no longer using NWN1 VFX
    if(nDuration < 1)
    {
        nDuration = 1;
    }
    int nMetaMagic = JXGetMetaMagicFeat();
        //Metamagic checks for entend
		if (nMetaMagic & METAMAGIC_EXTEND)
		{
			nDuration = nDuration *2;	//Duration is +100%
		}
    //Apply the AOE object to the specified location
    JXApplyAreaEffectAtLocation(AOE_PER_FOGKILL, lTarget, RoundsToSeconds(nDuration));

	JXPostSpellCastCode();
}
