I have a spell-like feat that is supposed to target all applicable opponents (as selected by race) within range but it only seems to be targeting a few if they are of different applicable races. For example if you are being attacked by an undead, a dwarf and a spider at the same time it will be able to strike all three as they are all different races however, if you are attacked by 8 dogs it is only attacking 1-4 of them because they are all of the same race. Can someone take a look and see why it is not attacking all applicable opponents within range?
#include "nwn2_inc_spells"
#include "X0_I0_SPELLS"
#include "x2_inc_spellhook"
const int SPELL_SPIRIT_LASH = 1647;
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
object oCaster = OBJECT_SELF;
int nCasterLvl = GetLevelByClass(64, oCaster);
int nDamage;
float fDelay;
//Get the spell target location as opposed to the spell target.
location lTarget = GetSpellTargetLocation();
//Apply the ice storm VFX at the location captured above.
//Declare the spell shape, size and the location. Capture the first target object in the shape.
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_VAST, lTarget, TRUE, OBJECT_TYPE_CREATURE);
effect eEffect;
eEffect = EffectKnockdown();
eEffect = SupernaturalEffect(eEffect);
effect eDam;
effect eVis = EffectVisualEffect(VFX_HIT_TURN_UNDEAD);
effect eEff = EffectLinkEffects(eVis, eEffect);
effect eLink;
if (GetHasFeat(2818, oCaster))
{
nDamage = (d8(4) + (2 * nCasterLvl));
SendMessageToPC(GetFirstPC(), "Improved spirit lash!");
}
else
{
nDamage = (d4(4) + (2 * nCasterLvl));
}
while (GetIsObjectValid(oTarget))
{
if (spellsIsTarget(oTarget, SPELL_TARGET_STANDARDHOSTILE, oCaster))
{
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, 1647));
if ((GetRacialType(oTarget) == RACIAL_TYPE_UNDEAD || GetSubRace(oTarget) == RACIAL_SUBTYPE_INCORPOREAL)
|| (GetHasFeat(2825, oCaster, TRUE)
&& (GetRacialType(oTarget) == RACIAL_TYPE_ELEMENTAL
|| GetSubRace(oTarget) == RACIAL_SUBTYPE_PLANT))
|| (GetHasFeat(2826, oCaster, TRUE)
&& (GetRacialType(oTarget) == RACIAL_TYPE_ANIMAL
|| GetRacialType(oTarget) == RACIAL_TYPE_BEAST
|| GetRacialType(oTarget) == RACIAL_TYPE_MAGICAL_BEAST
|| GetRacialType(oTarget) == RACIAL_TYPE_VERMIN))
|| (GetHasFeat(2827, oCaster, TRUE)
&& (GetRacialType(oTarget) == RACIAL_TYPE_HUMAN
|| GetRacialType(oTarget) == RACIAL_TYPE_DWARF
|| GetRacialType(oTarget) == RACIAL_TYPE_ELF
|| GetRacialType(oTarget) == RACIAL_TYPE_GNOME
|| GetRacialType(oTarget) == RACIAL_TYPE_HALFLING
|| GetRacialType(oTarget) == RACIAL_TYPE_HALFELF
|| GetRacialType(oTarget) == RACIAL_TYPE_HALFORC)))
{
eDam = EffectDamage(nDamage, DAMAGE_TYPE_DIVINE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eDam, oTarget);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oTarget, 6.0f);
}
else
{
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_VAST, lTarget, TRUE, OBJECT_TYPE_CREATURE);
}
}
}
PS: I already got help withone once in the past and it was working but I had a system crash and lost a lot of data that I was working on. I have tried rewriting the same script again but it is not working as well as it did before the data loss. Something must not be quite right.