How would someone write a spell scriot that would remove multiple effects such as (poison, disease, curse, paralysis and negative levels) from all allies within a meduim sphere around the caster? I have written several scripts but none actually seem to work while in gameplay. ![]()
remove effect from all in an area
#1
Posté 27 avril 2015 - 06:20
#2
Posté 27 avril 2015 - 07:37
//it's a loop within a loop
#include "nw_i0_spells"
int kL_GetIsEffectBad(effect eEffect);
void main()
{
object oCaster;// = ; defn
location lCaster = GetLocation(oCaster);
effect eEffect;
object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lCaster); // 10' circle
while (GetIsObjectValid(oTarget))
{
if (spellsIsTarget(oTarget, SPELL_TARGET_ALLALLIES, oCaster))
{
eEffect = GetFirstEffect(oTarget);
while (GetIsEffectValid(eEffect))
{
if (kL_GetIsEffectBad(eEffect))
{
RemoveEffect(oTarget, eEffect);
eEffect = GetFirstEffect(oTarget); // remove linked effects safely.
}
else
eEffect = GetNextEffect(oTarget);
}
}
oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_MEDIUM, lCaster);
}
}
// Returns TRUE if an effect is bad.
int kL_GetIsEffectBad(effect eEffect)
{
int iType = GetEffectType(eEffect);
if (iType == EFFECT_TYPE_ABILITY_DECREASE
|| iType == EFFECT_TYPE_AC_DECREASE
|| iType == EFFECT_TYPE_ARCANE_SPELL_FAILURE
|| iType == EFFECT_TYPE_AMORPENALTYINC
|| iType == EFFECT_TYPE_ATTACK_DECREASE
|| iType == EFFECT_TYPE_BLINDNESS
|| iType == EFFECT_TYPE_CHARMED
|| iType == EFFECT_TYPE_CONCEALMENT_NEGATED
|| iType == EFFECT_TYPE_CONFUSED
|| iType == EFFECT_TYPE_CURSE
|| iType == EFFECT_TYPE_CUTSCENE_PARALYZE
|| iType == EFFECT_TYPE_CUTSCENEGHOST
|| iType == EFFECT_TYPE_CUTSCENEIMMOBILIZE
|| iType == EFFECT_TYPE_DAMAGE_DECREASE
|| iType == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE
|| iType == EFFECT_TYPE_DAMAGE_REDUCTION_NEGATED
|| iType == EFFECT_TYPE_DARKNESS
|| iType == EFFECT_TYPE_DAZED
|| iType == EFFECT_TYPE_DEAF
|| iType == EFFECT_TYPE_DISEASE
|| iType == EFFECT_TYPE_DOMINATED
|| iType == EFFECT_TYPE_ENEMY_ATTACK_BONUS
|| iType == EFFECT_TYPE_ENTANGLE
|| iType == EFFECT_TYPE_FRIGHTENED
|| iType == EFFECT_TYPE_INSANE
|| iType == EFFECT_TYPE_JARRING
|| iType == EFFECT_TYPE_MESMERIZE
|| iType == EFFECT_TYPE_MISS_CHANCE
|| iType == EFFECT_TYPE_MOVEMENT_SPEED_DECREASE
|| iType == EFFECT_TYPE_NEGATIVELEVEL
|| iType == EFFECT_TYPE_PARALYZE
|| iType == EFFECT_TYPE_PETRIFY
|| iType == EFFECT_TYPE_POISON
|| iType == EFFECT_TYPE_POLYMORPH
|| iType == EFFECT_TYPE_SAVING_THROW_DECREASE
|| iType == EFFECT_TYPE_SILENCE
|| iType == EFFECT_TYPE_SKILL_DECREASE
|| iType == EFFECT_TYPE_SLEEP
|| iType == EFFECT_TYPE_SLOW
|| iType == EFFECT_TYPE_SPELL_FAILURE
|| iType == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE
|| iType == EFFECT_TYPE_STUNNED
|| iType == EFFECT_TYPE_SWARM
|| iType == EFFECT_TYPE_TURNED
|| iType == EFFECT_TYPE_WOUNDING)
{
return TRUE;
}
return FALSE;
}
- GCoyote aime ceci
#3
Posté 27 avril 2015 - 07:41
you'd need to jot in the spellhook, signalEvent, OBJECT_SELF, etc.
#4
Posté 27 avril 2015 - 01:05
Thanks, I am sure I can handle the rest. I just never wrote a remove effect script that involved every ally in an area.
#5
Posté 28 avril 2015 - 03:59
I made it into a spell script:
#6
Posté 28 avril 2015 - 05:23
I adapted the following function from one of the restoration spells. I call it from a loop through the entire party (within an overland map OnExit script), but it should work from within any loop of creatures (like a spell shape):
void Restore(object oCreature)
{
effect eBad = GetFirstEffect(oCreature);
//Search for negative effects
while(GetIsEffectValid(eBad))
{
if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
GetEffectType(eBad) == EFFECT_TYPE_CURSE ||
GetEffectType(eBad) == EFFECT_TYPE_DISEASE ||
GetEffectType(eBad) == EFFECT_TYPE_POISON ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_CHARMED ||
GetEffectType(eBad) == EFFECT_TYPE_DOMINATED ||
GetEffectType(eBad) == EFFECT_TYPE_DAZED ||
GetEffectType(eBad) == EFFECT_TYPE_CONFUSED ||
GetEffectType(eBad) == EFFECT_TYPE_FRIGHTENED ||
GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL ||
GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
GetEffectType(eBad) == EFFECT_TYPE_SLOW ||
GetEffectType(eBad) == EFFECT_TYPE_STUNNED )
{
if (
GetEffectSpellId(eBad) != SPELL_ENLARGE_PERSON &&
GetEffectSpellId(eBad) != SPELL_RIGHTEOUS_MIGHT &&
GetEffectSpellId(eBad) != SPELL_STONE_BODY &&
GetEffectSpellId(eBad) != SPELL_IRON_BODY &&
GetEffectSpellId(eBad) != 803)
{
//Remove effect if it is negative.
RemoveEffect(oCreature, eBad);
eBad = GetFirstEffect(oCreature);
}
}
else
eBad = GetNextEffect(oCreature);
}//end while
}
#7
Posté 28 avril 2015 - 05:54
But it still does not seem to be working in the actual game. What am I missing? I made the sphere one size bigger and added a healing effect but I not see where they would interfere with the regualr spell script.
object oCaster = OBJECT_SELF;
#8
Posté 28 avril 2015 - 05:58
object oCaster = OBJECT_SELF;
Thanks
#9
Posté 28 avril 2015 - 06:07
ApplyEffectToObject()
outside the effect loop. Try putting it (just once) above
eEffect = GetFirstEffect(oTarget);
(Because if it's inside the effect loop, target may get healed multiple times on each single cast - once per effect that he/she has. That's also where i'd put SignalEvent(), although it's usually not important for non-hostile spells)
#10
Posté 28 avril 2015 - 06:13
#11
Posté 28 avril 2015 - 01:22
i just woke up but, it looks like you should move
ApplyEffectToObject()
outside the effect loop. Try putting it (just once) above
eEffect = GetFirstEffect(oTarget);
(Because if it's inside the effect loop, target may get healed multiple times on each single cast - once per effect that he/she has. That's also where i'd put SignalEvent(), although it's usually not important for non-hostile spells)
Yea, I ran into that but I corrected it. Thanks the spell is working now and I now have everything I need to finish my newest custom class.
#12
Posté 28 avril 2015 - 03:59





Retour en haut






