//::///////////////////////////////////////////////
//:: Divine Trickery
//:: NW_S2_DivTrick.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Grants the user a bonus to Search, Disable Traps,
    Move Silently, Open Lock , Pick Pockets
    Set Trap for 5 Turns + Chr Mod
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: November 9, 2001
//:://////////////////////////////////////////////

#include "jx_inc_magic"
#include "x2_inc_spellhook"

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

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


    object oTarget = JXGetSpellTargetObject();
    int nDuration = 5 + GetAbilityModifier(ABILITY_CHARISMA);
    int nLevel = GetLevelByClass(CLASS_TYPE_CLERIC);
    nLevel = 1 + nLevel/2;

    //Declare major variables
    effect eSearch = EffectSkillIncrease(SKILL_SEARCH, nLevel);
    effect eDisable = EffectSkillIncrease(SKILL_DISABLE_TRAP, nLevel);
    effect eMove = EffectSkillIncrease(SKILL_MOVE_SILENTLY, nLevel);
    effect eOpen = EffectSkillIncrease(SKILL_OPEN_LOCK, nLevel);
    effect ePick = EffectSkillIncrease(SKILL_SLEIGHT_OF_HAND, nLevel);
    effect eHide = EffectSkillIncrease(SKILL_HIDE, nLevel);
    effect ePers = EffectSkillIncrease(SKILL_DIPLOMACY, nLevel);
    effect eDur = EffectVisualEffect(VFX_DUR_CESSATE_POSITIVE);
    
    //Link Effects
    effect eLink = EffectLinkEffects(eSearch, eDisable);
    eLink = EffectLinkEffects(eLink, eMove);
    eLink = EffectLinkEffects(eLink, eOpen);
    eLink = EffectLinkEffects(eLink, ePick);
    eLink = EffectLinkEffects(eLink, eHide);
    eLink = EffectLinkEffects(eLink, ePers);
    eLink = EffectLinkEffects(eLink, eDur);

    effect eVis = EffectVisualEffect( VFX_IMP_IMPROVE_ABILITY_SCORE );
    //Fire cast spell at event for the specified target
    SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELLABILITY_DIVINE_TRICKERY, FALSE));

    //Apply the VFX impact and effects
    JXApplyEffectToObject(DURATION_TYPE_TEMPORARY, eLink, oTarget, TurnsToSeconds(nDuration));
    JXApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);

	JXPostSpellCastCode();
}
