//::///////////////////////////////////////////////
//:: Actions for the Spell Shape Conversation
//::///////////////////////////////////////////////
//:: 2d2f: 03-01-08 - Finished

#include "jx_inc_magic"
#include "jx_inc_magic_info"
#include "2d2f_includes"
#include "nwn2_inc_spells"

void main(int nSpellId)
{
	object oCaster = GetPCSpeaker();
	int nSpellShapeSwitch = GetLocalInt(oCaster,"nSpellShapeSwitch");
	if(nSpellShapeSwitch == 1)
	{
		int nLvl = JXGetCasterLevel(oCaster);
		object oTarget = GetLocalObject(oCaster,"oSpellShapeTarget");
		int nSpellShapeLvl = GetLocalInt(oCaster, "nSpellShapeLevel");
		int nDC = 10 +  nSpellShapeLvl + GetAbilityModifier(ABILITY_INTELLIGENCE, oCaster);
		JXCastSpellFromObjectAtObject(oCaster,
										oTarget,
										nSpellId,
										METAMAGIC_NONE,
										nLvl,
										nDC,
										TRUE);
	
	}
	else
	{
	FloatingTextStringOnCreature("The power stored in Spell Shape has slipped away", oCaster);
	}	
	
	// 2d2f: Remove spell effects and reset vars
	RemoveSpellEffects( SPELL_SPELL_SHAPE , oCaster,  oCaster);
	SetLocalObject(oCaster, "oSpellShapeTarget", OBJECT_INVALID);
	SetLocalInt(oCaster, "nSpellShapeLevel", 0);
	
}