Aller au contenu

Photo

Remove EffectNWN2SpecialEffectFile


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

#1
Hilltop2012

Hilltop2012
  • Members
  • 66 messages
I've been trying to figure this out all night. I added an effect to an object.
This part works.
void main()
{

       object oNPC = GetObjectByTag("NPC_TAG"); effect eEffect = EffectNWN2SpecialEffectFile("fx_succubus_eyes", oNPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eEffect, oNPC);
}

Now I can't get rid of it. I've tried looping through the effects the standard way. 
--------
effect eEffect = GetFirstEffect(oNPC);

while (  GetEffectVaild(eEffect) )
{
RemoveEffect(oNPC,eEffect)
eEffect = GetNextEffect(oNPC)
}

This gets rid of regular effects but not the one I'm trying to get rid of.

I've also tried 

RemoveSEFFromObject 

That didn't work.

Do you have to do something special to remove EffectNWN2SpecialEffectFile?

Thanks

#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
try changing this:

while ( GetEffectVaild(eEffect) )
{
RemoveEffect(oNPC,eEffect)
eEffect = GetNextEffect(oNPC)
}


to this

while ( GetEffectVaild(eEffect) )
{
RemoveEffect(oNPC,eEffect)
eEffect = GetFirstEffect(oNPC)
}



About 18 months ago, when I was making TWA1, I had a similar problem.  Of course I can't remember how I solved it now. I seem to remember that somehow the effect was getting added more than once to the PC, but the loop should take care of that. 

Modifié par M. Rieder, 09 novembre 2011 - 06:17 .


#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Also, you can try giving yourself some feedback to see what is going on in the script.

There is a function that returns the integer of an effect. Turn that integer into a string and have it pop up over the PC's head when the script runs to let you see what effects the script is seeing when it looks for effects to remove.

You can also write another quick script (i've done this) that just goes through all the effects and displays their integers to let you know what you are working with. When debugging, I find that the more information I can give myself from within the script, the quicker I find the problem.

#4
mogromon

mogromon
  • Members
  • 41 messages
Im not sure if it applies, but i remember applying a visual effect (that lasts over time) as an Instant effect causes it not being able to be removed later. You should try applying it whit temporary or permanent duration and then check if it can be removed.

#5
Hilltop2012

Hilltop2012
  • Members
  • 66 messages
M Rieder,

So you have to go back to the first effect in the loop? I found a thread about that last night. I'll try it. The debugging is a good idea also, Thanks

mogroman,

Thats also a good thing to try out. I'll try temporary first. Thanks.

#6
MasterChanger

MasterChanger
  • Members
  • 686 messages

mogromon wrote...

Im not sure if it applies, but i remember applying a visual effect (that lasts over time) as an Instant effect causes it not being able to be removed later. You should try applying it whit temporary or permanent duration and then check if it can be removed.


That's absolutely true. I didn't catch that the OP used DURATION_TYPE_INSTANT when I looked at it the first time (been away from coding for a while).

If you use DURATION_TYPE_INSTANT for an effect, that effect applies and is then gone. This is fine for effects that don't have a duration, like damage or one-shot VFX/SEFs. Any effect that doesn't have a duration can't be removed later because it instantly removes itself.

#7
Lance Botelle

Lance Botelle
  • Members
  • 1 480 messages

MasterChanger wrote...

mogromon wrote...

Im not sure if it applies, but i remember applying a visual effect (that lasts over time) as an Instant effect causes it not being able to be removed later. You should try applying it whit temporary or permanent duration and then check if it can be removed.


That's absolutely true. I didn't catch that the OP used DURATION_TYPE_INSTANT when I looked at it the first time (been away from coding for a while).

If you use DURATION_TYPE_INSTANT for an effect, that effect applies and is then gone. This is fine for effects that don't have a duration, like damage or one-shot VFX/SEFs. Any effect that doesn't have a duration can't be removed later because it instantly removes itself.



I concur ... I was nearly caught out doing the same thing.

RemoveSEFFromObject works fine if you ensure the original SEF is applied as a DURATION_TYPE_PERMANENT.

Lance.