I'm having a bit of issues getting an area of effect custom spell to fire... Though I suppose it isn't a 'spell' in a typical sense. What I am trying to do is after checking a variable in another item on the player's inventory, if it is high enough then the player will be able to cast the spell via the item's "Cast Spell: Unique Power Self" property. However, I am typically only getting one of two results. The first result is that is just does the visual effect and nothing else. The second result involves it choosing one enemy and targetting them so many times that my in game chat log can't scroll back enough to see all of the reflex saves the creature made, followed by the game lagging for a few seconds as it tries to do all of the damage and visual effects on the creature at the same time. It never moves past that first target to a second one though, and I am unsure what I have done wrong really... I did butcher out pieces of the firestorm spell script for this, as will be evident in the script, so again, I am unsure why it wouldn't work right. Thank you in advance for any help, advice, and explinations offered.
And the script. . . .
#include "nw_i0_spells"
#include "x0_i0_spells"
void main()
{
object oPC = GetItemActivator();
object oMana = GetItemPossessedBy(oPC, "mana");
string MP;
int cMP = GetLocalInt(oMana, MP);
if (GetLocalInt(oMana, MP) < 5)
{
SendMessageToPC(oPC, "Not enough MP");
}
else if (GetLocalInt(oMana, MP) > 4)
{
int iDex = GetAbilityModifier(ABILITY_DEXTERITY , oPC);
int iLevel = GetHitDice(oPC);
int iDamage;
int iBonus;
float fTim = IntToFloat(iLevel) + iDex;
int iDC = iLevel + iDex + 10;
effect eVis = EffectVisualEffect(VFX_IMP_FLAME_M);
effect eDin = EffectVisualEffect(VFX_FNF_FIRESTORM);
float fDelay;
fDelay = GetRandomDelay(1.5, 2.5);
//Apply Fire and Forget Visual in the area;
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eDin, GetLocation(oPC));
//Declare the spell shape, size and the location. Capture the first target object in the shape.
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetLocation(oPC), OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
//Cycle through the targets within the spell shape until an invalid object is captured.
if (spellsIsTarget(oTarget, SPELL_TARGET_SELECTIVEHOSTILE, oPC) && oTarget != oPC)
{
while(GetIsObjectValid(oTarget))
{
iBonus = iDex*3;
iDamage = d10(iLevel) + iBonus;
iDamage = GetReflexAdjustedDamage(iDamage/2, oTarget, iDC, SAVING_THROW_TYPE_FIRE);
if(iDamage > 0)
{
// Apply effects to the currently selected target. For this spell we have used
//both Divine and Fire damage.
effect eFire = EffectDamage(iDamage, DAMAGE_TYPE_FIRE);
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eFire, oTarget));
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget));
}
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_COLOSSAL, GetLocation(OBJECT_SELF), OBJECT_TYPE_CREATURE | OBJECT_TYPE_DOOR | OBJECT_TYPE_PLACEABLE);
}
}
// SetLocalInt(oMana, MP, cMP - 5);
}