Aller au contenu

Photo

remove effect from all in an area


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

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. :huh:



#2
kevL

kevL
  • Members
  • 4 056 messages
//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
kevL

kevL
  • Members
  • 4 056 messages
err, i didn't make that a spellscript per se.

you'd need to jot in the spellhook, signalEvent, OBJECT_SELF, etc.

#4
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

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
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

I made it into a spell script:

 

#include "nw_i0_spells" 
#include "nwn2_inc_spells"
#include "x2_inc_spellhook"
const int SPIRIT_ANCIENT = 1612;
 
int kL_GetIsEffectBad(effect eEffect);
 
 
 
void main()
{
    if (!X2PreSpellCastCode())
    {
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }
 
    object oCaster;// = ; defn
    location lCaster = GetLocation(oCaster);
    effect eEffect;
effect eHeal;
effect eHeal2;
int nHeal;
int nCasterLvl = GetLevelByClass(64, OBJECT_SELF);
effect eVis = EffectVisualEffect( VFX_IMP_HEALING_M );
nHeal = (d8(nCasterLvl/4))+(nCasterLvl*2);
eHeal2 = EffectLinkEffects( eHeal, eVis );
 
    object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, 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);
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eHeal2, oTarget);
                    eEffect = GetFirstEffect(oTarget); // remove linked effects safely.
                }
                else
   ApplyEffectToObject(DURATION_TYPE_PERMANENT, eHeal2, oTarget);
                    eEffect = GetNextEffect(oTarget);
            }
        }
 
        oTarget = GetNextObjectInShape(SHAPE_SPHERE, RADIUS_SIZE_LARGE, 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;
}
 
 
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.


#6
Dann-J

Dann-J
  • Members
  • 3 161 messages

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
kevL

kevL
  • Members
  • 4 056 messages

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
Laugh out loud

Laugh out loud
  • Members
  • 109 messages
    object oCaster = OBJECT_SELF;

Thanks



#9
kevL

kevL
  • Members
  • 4 056 messages
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)

#10
kevL

kevL
  • Members
  • 4 056 messages
ps. Note that in Dann's Restore() function, it avoids removing generally positive spells that have a bad effect linked in

#11
Laugh out loud

Laugh out loud
  • Members
  • 109 messages

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
kevL

kevL
  • Members
  • 4 056 messages
k, good stuff