//::///////////////////////////////////////////////
//:: Electric Jolt
//:: [x0_s0_ElecJolt.nss]
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
1d3 points of electrical damage to one target.
*/
//:://////////////////////////////////////////////
//:: Created By: Brent
//:: Created On: July 17 2002
//:://////////////////////////////////////////////

#include "70_inc_spells"
#include "x0_i0_spells"
#include "x2_inc_spellhook"

void main()
{

/*
  Spellcast Hook Code
  Added 2003-06-20 by Georg
  If you want to make changes to all spells,
  check x2_inc_spellhook.nss to find out more

*/

    if (!X2PreSpellCastCode())
    {
    // If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

// End of Spell Cast Hook

   //Declare major variables
   spellsDeclareMajorVariables();

    effect eVis = EffectVisualEffect(VFX_IMP_LIGHTNING_S);
    if(spellsIsTarget(spell.Target, SPELL_TARGET_SINGLETARGET, spell.Caster))
    {
        //Fire cast spell at event for the specified target
        SignalEvent(spell.Target, EventSpellCastAt(spell.Caster, spell.Id));
        //Make SR Check
        if(!MyResistSpell(spell.Caster, spell.Target))
        {
            //Set damage effect

            //1d3 of additional damage roughly for every 3 caster levels, but no more than 10d3.
            int cMultiplier = GetCasterLevel(OBJECT_SELF) / 3;
            if (cMultiplier <= 1) cMultiplier = 1;
            if (cMultiplier >= 7) cMultiplier = 7;
            int nDamage =  MaximizeOrEmpower(3, cMultiplier, spell.Meta);
            effect eBad = EffectDamage(nDamage, DAMAGE_TYPE_ELECTRICAL);
            //Apply the VFX impact and damage effect
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, spell.Target);
            ApplyEffectToObject(DURATION_TYPE_INSTANT, eBad, spell.Target);
        }
    }
}