//::///////////////////////////////////////////////
//:: Glyph of Warding
//:: x2_s0_glphwarda.nss
//:: Copyright (c) 2006 Obsidian Entertainment Inc.
//:://////////////////////////////////////////////
/*
    The caster creates a trapped area which detects
    the entrance of enemy creatures into 3 m area
    around the spell location.  When tripped it
    causes an explosion that does 1d8 per
    two caster levels up to a max of 5d8 damage.
	Damage type is dependent on caster alignment.
*/
//:://////////////////////////////////////////////
//:: Created By: Patrick Mills
//:: Created On: August 01, 2006
//:://////////////////////////////////////////////

#include "jx_inc_magic"
#include "x2_inc_spellhook" 

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

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

    //Define the AOE and then place it at the location permanently (until triggered)
    location lTarget = JXGetSpellTargetLocation();
    JXApplyAreaEffectAtLocation(AOE_PER_GLYPH_OF_WARDING, lTarget );

	JXPostSpellCastCode();
}











/*
//This is the old script from NWN1
//::///////////////////////////////////////////////
//:: Glyph of Warding
//:: X2_S0_GlphWard
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////

    The caster creates a trapped area which detects
    the entrance of enemy creatures into 3 m area
    around the spell location.  When tripped it
    causes a sonic explosion that does 1d8 per
    two caster levels up to a max of 5d8 damage.

//:://////////////////////////////////////////////
//:: Created By: Andrew Nobbs
//:: Created On: Dec 04, 2002
//:://////////////////////////////////////////////

#include "jx_inc_magic"
#include "x2_inc_spellhook"

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

   object oGlyph = CreateObject(OBJECT_TYPE_PLACEABLE,"x2_plc_glyph",JXGetSpellTargetLocation());
   object  oTest = GetNearestObjectByTag("X2_PLC_GLYPH",oGlyph);

    if (GetIsObjectValid(oTest) && GetDistanceBetween(oGlyph, oTest) <5.0f)
    {
        FloatingTextStrRefOnCreature(84612,OBJECT_SELF);
        DestroyObject(oGlyph);
        { JXPostSpellCastCode(); return; }
    }


   // Store the caster
   SetLocalObject(oGlyph,"X2_PLC_GLYPH_CASTER",OBJECT_SELF);

   // Store the caster level
   SetLocalInt  (oGlyph,"X2_PLC_GLYPH_CASTER_LEVEL",JXGetCasterLevel(OBJECT_SELF));

   // Store Meta Magic
   SetLocalInt (oGlyph,"X2_PLC_GLYPH_CASTER_METAMAGIC",JXGetMetaMagicFeat());

   // This spell (default = line 768 in spells.2da) will run when someone enters the glyph
   SetLocalInt(oGlyph,"X2_PLC_GLYPH_SPELL",764);

   // Tell the system that this glyph was player and not toolset created
   SetLocalInt (oGlyph,"X2_PLC_GLYPH_PLAYERCREATED",TRUE);

   // Tell the game the glyph is not a permanent one
   DeleteLocalInt(oGlyph,"X2_PLC_GLYPH_PERMANENT");

   // Force first hb
   ExecuteScript("x2_o0_glyphhb",oGlyph);


	JXPostSpellCastCode();
}
*/
