The GetFirstEffect() and GetNextEffect() NWScript commands iterate through all effects on the specified object. This can be useful both for determining if a creature is under the effect of a particular type of effect and for locating an effect that should be removed. As with the other GetFirst*() and GetNext*() pairs of commands, GetFirstEffect() is used to initialize the iterator while GetNextEffect() moves the iterator to the next item.
Definition
effect GetFirstEffect (object oCreature)
effect GetNextEffect (object oCreature)
object oCreature- The object (not necessarily a creature) whose effects will be examined.
When there are no remaining effects to be returned, an invalid effect will be returned. This commonly leads to scripts that look similar to the following.
effect eSearch = GetFirstEffect(oTarget);
while ( GetIsEffectValid(eSearch) )
{
// Do something, often testing the effect first.
// Update the loop.
eSearch = GetNextEffect(oTarget);
}
See also
GetIsEffectValid()— for determining if the iterator has exhausted all effects on the object- For determining if the desired effect has been found:
GetEffectCreator()GetEffectDurationType()GetEffectSpellId()()GetEffectSubType()GetEffectType()
- For when the effects themselves are not as important as how they got there:
GetHasFeatEffect()GetHasSpellEffect()