//::///////////////////////////////////////////////
//:: Detect Magic
//:: jx_sp_detectmagic.nss
//:://////////////////////////////////////////////
/*
	The caster tries to detect magic in the area in front
	of him. It takes three rounds. If he performs another
	action instead of concentrating, he starts again.
	Round 1 : Detect the presence or absence of a magic.
			  Locate Dead Magic zones.
	Round 2 : Detect the number of magical aura and the
			  strength of the most powerful.
			  Detect the presence of Wild Magic zones.
	Round 3 : Detect the strength of each aura. A
			  successful Spellcraft craft permits to
			  discover the spell school of auras that are
			  in line of sight, and even to identify
			  magical items.
			  Locate Wild Magic zones.
*/
//:://////////////////////////////////////////////
//:: Created By: jallaix
//:: Created On: Aug 12, 2006
//:://////////////////////////////////////////////


#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 = TurnsToSeconds(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, "jx_sp_detectmagica", "", "");

	JXPostSpellCastCode();
}