Alangara_PRC8/_removed/NW_S0_LGHTNBOLT.nss
Jaysyn904 86feb9ca6f Initial commit
Initial commit.
2024-06-05 21:21:06 -04:00

131 lines
5.1 KiB
Plaintext

//::///////////////////////////////////////////////
//:: Lightning Bolt
//:: NW_S0_LightnBolt
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Does 1d6 per level in a 5ft tube for 30m
*/
//:://////////////////////////////////////////////
//:: Created By: Noel Borstad
//:: Created On: March 8, 2001
//:://////////////////////////////////////////////
//:: Last Updated By: Preston Watamaniuk, On: May 2, 2001
#include "ke_spell_factor"
#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
int nCasterLevel = GetCasterLevel(OBJECT_SELF);
//Limit caster level
if (nCasterLevel > 40)
{
nCasterLevel = 40;
}
int nDamage;
int nMetaMagic = GetMetaMagicFeat();
//Set the lightning stream to start at the caster's hands
effect eLightning = EffectBeam(VFX_BEAM_LIGHTNING, OBJECT_SELF, BODY_NODE_HAND);
effect eVis = EffectVisualEffect(VFX_IMP_LIGHTNING_S);
effect eDamage;
object oTarget = GetSpellTargetObject();
location lTarget = GetLocation(oTarget);
object oNextTarget, oTarget2;
float fDelay;
int nCnt = 1;
oTarget2 = GetNearestObject(OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, OBJECT_SELF, nCnt);
while(GetIsObjectValid(oTarget2) && GetDistanceToObject(oTarget2) <= 30.0)
{
//Get first target in the lightning area by passing in the location of first target and the casters vector (position)
oTarget = GetFirstObjectInShape(SHAPE_SPELLCYLINDER, 30.0, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, GetPosition(OBJECT_SELF));
while (GetIsObjectValid(oTarget))
{
//Exclude the caster from the damage effects
if (oTarget != OBJECT_SELF && oTarget2 == oTarget)
{
if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, OBJECT_SELF))
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_LIGHTNING_BOLT));
//Make an SR check
if (!MyResistSpell(OBJECT_SELF, oTarget))
{
//Roll damage
nDamage = ((d6(nCasterLevel)+30)*12)/10;
//Enter Metamagic conditions
if (nMetaMagic == METAMAGIC_MAXIMIZE)
{
nDamage = ((6*(nCasterLevel)+30)*12)/10;//Damage is at max
}
if (nMetaMagic == METAMAGIC_EMPOWER)
{
nDamage = nDamage + (nDamage/2); //Damage/Healing is +50%
}
//Adjust damage based on Reflex Save, Evasion and Improved Evasion
nDamage = GetReflexAdjustedDamage(nDamage, oTarget, GetSpellSaveDC(),SAVING_THROW_TYPE_ELECTRICITY);
//Set damage effect
//starting the grand circus of importing and converting back and forth //
float fDamage = IntToFloat(nDamage);
// multiplaying damage with fFactor //
float fFactor = CalculateFactor();
fDamage = fDamage * fFactor;
// converting the float damage back to INT damage so we can use it again //
int nDamage2 = FloatToInt(fDamage);
// Done and remember to change nDamage with nDamage2 below :) //
eDamage = EffectDamage(nDamage2, DAMAGE_TYPE_ELECTRICAL);
if(nDamage > 0)
{
fDelay = GetSpellEffectDelay(GetLocation(oTarget), oTarget);
//Apply VFX impcat, damage effect and lightning effect
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT,eDamage,oTarget));
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT,eVis,oTarget));
}
}
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eLightning,oTarget,1.0);
//Set the currect target as the holder of the lightning effect
oNextTarget = oTarget;
eLightning = EffectBeam(VFX_BEAM_LIGHTNING, oNextTarget, BODY_NODE_CHEST);
}
}
//Get the next object in the lightning cylinder
oTarget = GetNextObjectInShape(SHAPE_SPELLCYLINDER, 30.0, lTarget, TRUE, OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, GetPosition(OBJECT_SELF));
}
nCnt++;
oTarget2 = GetNearestObject(OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE, OBJECT_SELF, nCnt);
}
}