#include "x0_I0_SPELLS"
#include "x2_inc_spellhook"
void main()
{
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 nDamStrike;
int nNumAffected = 0;
int nMetaMagic = GetMetaMagicFeat(); //Declare lightning effect connected the casters hands
effect eLightning = EffectBeam(VFX_BEAM_LIGHTNING, OBJECT_SELF, BODY_NODE_HAND);;
effect eVis = EffectVisualEffect(VFX_IMP_LIGHTNING_S);
effect eDamage;
object oFirstTarget = OBJECT_SELF;
object oHolder;
object oTarget;
location lSpellLocation;
//------------------------------------------------------------------------------------------------------
SignalEvent(oFirstTarget, EventSpellCastAt(OBJECT_SELF, SPELL_CHAIN_LIGHTNING));
ApplyEffectToObject(DURATION_TYPE_INSTANT,eDamage,oFirstTarget); ApplyEffectToObject(DURATION_TYPE_INSTANT,eVis,oFirstTarget);
if (oTarget == GetObjectByTag("BomblingHeart"))
{
ExecuteScript("dropactivate", oFirstTarget);
}
//Apply the lightning stream effect to the first target, connecting it with the caster ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eLightning,oFirstTarget,0.5);
//Reinitialize the lightning effect so that it travels from the first target to the next target
eLightning = EffectBeam(VFX_BEAM_LIGHTNING, oFirstTarget, BODY_NODE_CHEST);
float fDelay = 0.2; int nCnt = 0;
// *
// * Secondary Targets
// *
//Get the first target in the spell shape
oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetLocation(oFirstTarget), TRUE, OBJECT_TYPE_PLACEABLE);
while (GetIsObjectValid(oTarget))
{
//Connect the new lightning stream to the older target and the new target
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eLightning,oTarget,0.5));
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, SPELL_CHAIN_LIGHTNING));
//Do an SR check
if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
{
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT,eVis,oTarget)); oHolder = oTarget;
if (oTarget == GetObjectByTag("BomblingHeart"))
{
DelayCommand(fDelay, ExecuteScript("dropactivate", oTarget));
}
//change the currect holder of the lightning stream to the current target
if (GetObjectType(oTarget) == OBJECT_TYPE_PLACEABLE)
{
eLightning = EffectBeam(VFX_BEAM_LIGHTNING, oHolder, BODY_NODE_CHEST);
}
else
{
// * April 2003 trying to make sure beams originate correctly
effect eNewLightning = EffectBeam(VFX_BEAM_LIGHTNING, oHolder, BODY_NODE_CHEST); if(GetIsEffectValid(eNewLightning))
{
eLightning = eNewLightning;
}
}
fDelay = fDelay + 0.1f;
}
//Count the number of targets that have been hit.
if(GetObjectType(oTarget) == OBJECT_TYPE_PLACEABLE)
{
nCnt++;
}
//Get the next target in the shape.
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetLocation(oFirstTarget), TRUE, OBJECT_TYPE_PLACEABLE);
if (oTarget == GetObjectByTag("BomblingHeart"))
{
DelayCommand(fDelay, ExecuteScript("dropactivate", oTarget));
}
}
}
BomblingHeart script is just the activation of whatever I decide to do once the chain reaches a placeable.
Modifié par MrPencilpusher, 29 octobre 2011 - 09:12 .