Author Topic: Removing specific *visual* effects  (Read 423 times)

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Removing specific *visual* effects
« on: November 29, 2011, 09:36:29 pm »


                <looking appalled at the ragged edge...>

There is no way to determine *which* visual effects are on an object?

From the Lexicon on RemoveEffect:
you must loop through effects on the creature, and remove the effect(s) of the correct type, and possibly the correct creator and subtype. View the codesample below for information on how to do this. 

and 

It was previously mentioned that visual effects have no effecttype. This is incorrect, this function will return EFFECT_TYPE_VISUALEFFECT for visual effects. 


So my only choice in removing the visual effects are to remove *all* visual effects?


effect eLoop=GetFirstEffect(oPC);

while (GetIsEffectValid(eLoop))
{
   if (GetEffectType(eLoop)==EFFECT_TYPE_VISUALEFFECT)
      RemoveEffect(oPC, eLoop);

   eLoop=GetNextEffect(oPC);
}

<... of an incomplete incantation scroll of enormous power>
               
               

               


                     Modifié par Rolo Kipp, 29 novembre 2011 - 09:37 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Removing specific *visual* effects
« Reply #1 on: November 29, 2011, 09:45:44 pm »


               Yep, unfortunately the nwn functions are missing GetEffectInteger that would allowed it.

Possibilities are:
1) NWNX has this function (think its nwnx_effect for unix or nwnx_funcs for win)
2) if its spell, check GetEffectSpellId();
3) if its not spell, you have to assign the creation of the effect to some plot object in your module with unique tag beforehand ( AssignCommand(GetObjectByTag("EC_MYVFX"), ApplyEffect...); ) and then check in your script fot the tag of GetEffectCreator();
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Removing specific *visual* effects
« Reply #2 on: November 29, 2011, 10:01:28 pm »


               <punches...>

Ahh. Number three is the ticket, I think. Just have the Torc create the effect and check for effects created by the Torc.

Thank you ShadoOow. :-)

<...a T ticket>
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Removing specific *visual* effects
« Reply #3 on: November 29, 2011, 10:04:44 pm »


               Oh, I forgot to make clearer example for the effect application:

AssignCommand(GetObjectByTag("EC_MYVFX"), ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(nVFX), oPC, 60.));

point is that you must not declare the effect into variable beforehand otherwise the creator will be OBJECT_SELF!
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Removing specific *visual* effects
« Reply #4 on: November 29, 2011, 10:49:18 pm »


               <grins...>

Well, that explains why it didn't work :-P

Trying again.

Edit: WooHOO! Worked like a charm =)

Except... ;-P
1) Can't link effects... but that's ok.
2) The little bubbles continue for about 6 seconds after everything is removed... wierd :-)

<...with happiness>
               
               

               


                     Modifié par Rolo Kipp, 29 novembre 2011 - 10:56 .
                     
                  


            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Removing specific *visual* effects
« Reply #5 on: November 29, 2011, 11:13:24 pm »


               1) you can you just have to do it in one line like EffectLinkEffect(Effect1,Effect2)
2) yes I also noticed this, its a model issue I guess
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Removing specific *visual* effects
« Reply #6 on: November 29, 2011, 11:20:27 pm »


               Sure you can link the effects.   Just assing it is the object to create and link the effects.




effect eEffectsLinked ()
{
  effect Effect1 = EffectVisualEffect(nVFX);
  effect Effect2 = EffectVisualEffect(nVFX2);
  return EffectLinkEffects( Effect1,Effect2);
}

void main()
{
  AssignCommand(GetObjectByTag("EC_MYVFX"), ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffectsLinked ()
, oPC, 60.));
}

Or a little cleaner


void  eEffectsApplyed to ( object oTarget)
{
      effect Effect1 = EffectVisualEffect(nVFX);
      effect Effect2 = EffectVisualEffect(nVFX2);
      effect eEffect =  EffectLinkEffects( Effect1,Effect2);
     ApplyEffectToObject(DURATION_TYPE_TEMPORARY,  eEffect, oTarget, 60.)     
}

void main()
{
  object oPC = GetEnteringObject();
 AssingCommand(GetObjectByTag("EC_MYVFX"),eEffectsApplyed to(oPC));
}
               
               

               


                     Modifié par Lightfoot8, 29 novembre 2011 - 11:32 .