//::///////////////////////////////////////////////
//:: Shimmering Lights: On Enter
//:: jx_spll_shimlightsA.nss
//:://////////////////////////////////////////////
/*
	This spell may be triggered when a creature
	casts another spell in a wild magic zone.
	It creates shimmering colors that swirl around
	the caster in a 9 meters radius.
	All creatures inside the area must succeed a
	Will Save or be blinded for the duration of
	the spell. Moreover, all creatures take a
	-40 malus to hide checks and invisibility
	effects are removed.
*/
//:://////////////////////////////////////////////
//:: Created By: jallaix
//:: Created On: Mar 24, 2007
//:://////////////////////////////////////////////

#include "nw_i0_spells"


void main()
{
	object oTarget = GetEnteringObject();

	int iCasterLevel = JXGetCasterLevel();
	int iDC = JXGetSpellSaveDC();

	// Target Blinded
    if (!MySavingThrow(SAVING_THROW_WILL, oTarget, iDC, SAVING_THROW_TYPE_NONE, GetAreaOfEffectCreator()))
    {
		effect eBlind = EffectBlindness();
		ApplyEffectToObject(DURATION_TYPE_PERMANENT, eBlind, oTarget);
    }

	// Hide skill decreased
	effect eSkill = EffectSkillDecrease(SKILL_HIDE, 40);
	ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSkill, oTarget);

	// Invisibility is removed
	effect eLoop = GetFirstEffect(oTarget);
	while (GetIsEffectValid(eLoop))
	{
		if (GetEffectType(eLoop) == EFFECT_TYPE_INVISIBILITY)
			RemoveEffect(oTarget, eLoop);
		eLoop = GetNextEffect(oTarget);
	}
}