//::///////////////////////////////////////////////
//:: Sun Shards
//:: meb_sunshards
//:: 2010 MrZork
//::
//:: Bioware's Firebrand and DoMissileStorm (from x0_i0_spells.nss) are
//:: the templates for this spell.
//:://////////////////////////////////////////////
/*
Description:
Caster Level(s): Wizard / Sorcerer 7
Innate Level: 7
School: Evocation
Component(s): Verbal, Somatic
Range: Medium
Area of Effect / Target: Colossal
Duration: Instant
Save: Reflex 1/2
Spell Resistance: Yes
Bolts of magical energy (one per four caster levels, rounded down) burst
forth from the caster and target random enemies in the area. If there
are more enemies than bolts, only the nearest are targeted. If there are
more bolts than enemies in range, the excess bolts disappear. Each bolt
impacts for 5d8 of magical damage plus 1d8 per two caster levels, to a
maximum of 25d8 total at caster level 40. Those targets who make a
reflex save suffer half damage.
*/
#include "X0_I0_SPELLS"
#include "x2_inc_spellhook"
void DoMagicMissileStorm(int nD8Dice, int nMissiles, int nSpell, int nMIRV = VFX_IMP_MIRV, int nVIS = VFX_IMP_MAGBLUE, int nCASTERFX = FALSE, int nDAMAGETYPE = DAMAGE_TYPE_MAGICAL, int nReflexSave = FALSE);
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
int nDamage = 5 + GetCasterLevel(OBJECT_SELF)/2;
if (nDamage > 25)
nDamage = 25;
int nMissiles = GetCasterLevel(OBJECT_SELF)/4;
// 840 is the spells.2da line of the Sun Shards spell
// may want to use VFX_IMP_SUNSTRIKE instead of VFX_IMP_MIRV
// ditto for VFX_IMP_PULSE_FIRE or VFX_IMP_FLAME_M or VFX_IMP_FLAME_S instead of VFX_IMP_MAGBLUE
DoMagicMissileStorm(nDamage, nMissiles, 840, VFX_IMP_MIRV, VFX_IMP_FLAME_M, VFX_IMP_PULSE_FIRE, DAMAGE_TYPE_MAGICAL, TRUE);
}
//::///////////////////////////////////////////////
//:: DoMissileStorm
//:: Copyright (c) 2002 Bioware Corp.
//:://////////////////////////////////////////////
/*
Fires a volley of missiles around the area
of the object selected. Only one missile can hit each
target, Firebrand-style rather than Isaac's * Storm-style.
Each missiles (nD8Dice)d6 damage.
There are casterlevel missiles (to a cap as specified)
*/
//:://////////////////////////////////////////////
//:: Created By: Brent
//:: Created On: July 31, 2002
//:://////////////////////////////////////////////
//:: Modified March 14 2003: Removed the option to hurt chests/doors
//:: was potentially causing bugs when no creature targets available.
//:: Modified Aug 2010 for use with Sun Shards. Added nCASTERFX (default
//:: is FALSE for none) for the effect that plays on the caster)
void DoMagicMissileStorm(int nD8Dice, int nMissiles, int nSpell, int nMIRV = VFX_IMP_MIRV, int nVIS = VFX_IMP_MAGBLUE, int nCASTERFX = FALSE, int nDAMAGETYPE = DAMAGE_TYPE_MAGICAL, int nReflexSave = FALSE)
{
object oTarget = OBJECT_INVALID;
int nCasterLvl = GetCasterLevel(OBJECT_SELF);
int nMetaMagic = GetMetaMagicFeat();
int nCnt = 1;
effect eMissile = EffectVisualEffect(nMIRV);
effect eVis = EffectVisualEffect(nVIS);
float fDist = 0.0;
float fDelay = 0.0;
float fDelay2, fTime;
location lTarget = GetSpellTargetLocation(); // missile spread centered around target
if (nCASTERFX)
{
effect eCaster = EffectVisualEffect(nCASTERFX);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eCaster, oTarget);
}
oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lTarget, TRUE, OBJECT_TYPE_CREATURE);
//PrintString("DoMagicMissileStorm: first target=" + ObjectToString(oTarget) + " (" + GetName(oTarget) + ")");
//Cycle through the targets within the spell shape until an invalid object is captured.
while ( (GetIsObjectValid(oTarget)) && (nCnt <= nMissiles) )
{
// * caster cannot be harmed by this spell
if (spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE, OBJECT_SELF) &&
(oTarget != OBJECT_SELF) &&
(GetObjectSeen(oTarget,OBJECT_SELF))
)
{
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, nSpell));
// * recalculate appropriate distances
fDist = GetDistanceBetween(OBJECT_SELF, oTarget);
fDelay = fDist/(3.0 * log(fDist) + 2.0);
if (!MyResistSpell(OBJECT_SELF, oTarget, fDelay))
{
//Roll damage
int nDam = d8(nD8Dice);
//PrintString("DoMagicMissileStorm: target=" + ObjectToString(oTarget) + " (" + GetName(oTarget) + ") not resisted, base nDam=" + IntToString(nDam));
//Enter Metamagic conditions
if (nMetaMagic & METAMAGIC_MAXIMIZE) // can't happen with level 7 spell
{
nDam = nD8Dice*8;//Damage is at max
}
if (nMetaMagic & METAMAGIC_EMPOWER)
{
nDam = nDam + nDam/2; //Damage/Healing is +50%
//PrintString("DoMagicMissileStorm: (empowered) target=" + ObjectToString(oTarget) + " (" + GetName(oTarget) + ") nDam=" + IntToString(nDam));
}
// Jan. 29, 2004 - Jonathan Epp
// Reflex save was not being calculated for Firebrand
if(nReflexSave)
{
if ( nDAMAGETYPE == DAMAGE_TYPE_ELECTRICAL )
{
nDam = GetReflexAdjustedDamage(nDam, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_ELECTRICITY);
}
else if ( nDAMAGETYPE == DAMAGE_TYPE_FIRE )
{
nDam = GetReflexAdjustedDamage(nDam, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_FIRE);
}
else if ( nDAMAGETYPE == DAMAGE_TYPE_MAGICAL )
{
nDam = GetReflexAdjustedDamage(nDam, oTarget, GetSpellSaveDC(), SAVING_THROW_TYPE_SPELL);
}
}
fTime = fDelay;
fDelay2 += 0.1;
fTime += fDelay2;
//Set damage effect
effect eDam = EffectDamage(nDam, nDAMAGETYPE);
//Apply the MIRV and damage effect
DelayCommand(fTime, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
DelayCommand(fDelay2, ApplyEffectToObject(DURATION_TYPE_INSTANT, eMissile, oTarget));
DelayCommand(fTime, ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget));
} // if spell not resisted
else
{ // * spell resisted, apply a dummy visual effect
ApplyEffectToObject(DURATION_TYPE_INSTANT, eMissile, oTarget);
}
nCnt++;// * increment count of missiles fired
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, lTarget, TRUE, OBJECT_TYPE_CREATURE);
//PrintString("DoMagicMissileStorm: new target=" + ObjectToString(oTarget) + " (" + GetName(oTarget) + ")");
}
}