//::///////////////////////////////////////////////
//:: Analyze Dweomer
//:: jx_sp_anadweomer.nss
//:://////////////////////////////////////////////
/*
	The caster analyzes 1 item or creature per
	round. If the object analyzed is a magical
	item, it is identified. If it's a creature,
	all active spells are revealed except if the
	target creature succeeds a Will check.
*/
//:://////////////////////////////////////////////
//:: Created By: jallaix
//:: Created On: Aug 17, 2007
//:://////////////////////////////////////////////


#include "x2_inc_spellhook" 


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

void mainSpell()
{
    if (!X2PreSpellCastCode())
    {
        JXPostSpellCastCode();
		return;
    }

	// Get the caster level
    object oCaster = OBJECT_SELF;
	int iCasterLevel = JXGetCasterLevel();
	if (iCasterLevel == 0) iCasterLevel = 1;

	// Compute the spell's duration
	float fDuration = RoundsToSeconds(iCasterLevel);
	if (JXGetMetaMagicFeat() & METAMAGIC_EXTEND)
		fDuration = fDuration * 2;

	// VFX effect
	JXApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_DUR_SPELL_IDENTIFY), oCaster);

	// An area of effect is used just to be able to dispel the spell
	JXApplyAreaEffectToObject(AOE_MOB_FEAR, oCaster, fDuration + 1.0, "jx_sp_anadweomera", "", "");

	JXPostSpellCastCode();
}