Author Topic: Removing visual effect from placeable  (Read 592 times)

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Removing visual effect from placeable
« on: July 17, 2011, 07:50:26 pm »


               Is this impossible to do? Or is there something wrong with this function (which is called from another placeable)...

void clearfx(object target)
{   effect fx = GetFirstEffect(target);
    while(GetIsEffectValid(fx))
    {   RemoveEffect(target, fx);
        fx = GetNextEffect(target);
    }

               
               

               


                     Modifié par _six, 17 juillet 2011 - 06:51 .
                     
                  


            

Legacy_Alex Warren

  • Sr. Member
  • ****
  • Posts: 326
  • Karma: +0/-0
Removing visual effect from placeable
« Reply #1 on: July 17, 2011, 07:58:34 pm »


               The function is OK. Are you sure you're passing the right target?

Was the effect you try to remove added by another script?
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Removing visual effect from placeable
« Reply #2 on: July 17, 2011, 08:00:53 pm »


               What Event are you calling from?
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Removing visual effect from placeable
« Reply #3 on: July 17, 2011, 08:01:47 pm »


               I remember having difficulty with this, but only vaguely. Do they appear as properly stripped if you exit the area and reenter? If so, then it's a client rendering problem, which I know can happen in some cases with nwn - this is an issue with changing placeable appearances, for example.

If so, cutscene invis will not remedy it - polymorph will, to re-render creatures, though I don't think it will work on places. You may be stuck deleting and recreating it to 'strip' vfx.

Funky
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Removing visual effect from placeable
« Reply #4 on: July 17, 2011, 08:04:08 pm »


               I do not think there is anything wrong with the function. And my memory is not as good as it once was.

I think the problem you may be running into is a bug in the bioware system. If memory serves, there are cases where if two effects are added to an object of the same type, the engine loses track of the one that is written over.

A possiable solution would be to make sure you remove effects of the type you are tring to add before adding the new one.

There is also an isue with visual effects not getting updated in the client untill the object is redrawn. The efects have been removed but the client is still showing them. If this is the case if the PC leaves the visual range(three tiles away) for the item and returns it will show the update.

My memory is fuzzy.
Hope that helps.
               
               

               


                     Modifié par Lightfoot8, 17 juillet 2011 - 07:04 .
                     
                  


            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Removing visual effect from placeable
« Reply #5 on: July 17, 2011, 08:04:52 pm »


               Hm. That's possible. Actually it's part of a puzzle where I delete and recreate the placeables a few times anyway, so that wouldn't be too much of a stretch to do every time. Though I'd rather not have to.

This is fired from a placeable's OnUsed. Here is the whole script. Incidentally, the other visual effects are displayed perfectly correctly and on the correct placeables only. However, the placeables where no new effect is provided retain transparency instead of it being cleared.

void main()
{
    int i = StringToInt(GetSubString(GetTag(OBJECT_SELF), 5, 2)), m;

    // Find starting point of row
    i -= (i%4>0) ? (i%4)-1 : 3;

    for(m=i+4; i<m; i++)
    {    object plc = GetObjectByTag("Array"+IntToString(i));
         clearfx(plc);

        if(GetLocalInt(plc, "act"))
        {   ApplyEffectToObject(0, EffectVisualEffect(VFX_IMP_PDK_RALLYING_CRY), plc);
            ApplyEffectToObject(2, EffectVisualEffect(VFX_DUR_GHOST_TRANSPARENT), plc);
            SetLocalInt(plc, "act", FALSE);
        }
        else
        {    SetLocalInt(plc, "act", TRUE);
        }
    }
}
               
               

               


                     Modifié par _six, 17 juillet 2011 - 07:07 .
                     
                  


            

Legacy_Alex Warren

  • Sr. Member
  • ****
  • Posts: 326
  • Karma: +0/-0
Removing visual effect from placeable
« Reply #6 on: July 17, 2011, 08:07:44 pm »


               That's because VFX_DUR_GHOST_TRANSPARENT is bugged. I've tired to use this effect for fog cloud spell but it made my PC permanently transparent. I had to use other effect instead.

Edit: checked my script. I used VFX_DUR_GLOW_GREY instead '<img'>
               
               

               


                     Modifié par Alex Warren, 17 juillet 2011 - 07:09 .
                     
                  


            

Legacy__six

  • Hero Member
  • *****
  • Posts: 1436
  • Karma: +0/-0
Removing visual effect from placeable
« Reply #7 on: July 17, 2011, 08:08:23 pm »


               

Alex Warren wrote...

That's because VFX_DUR_GHOST_TRANSPARENT is bugged. I've tired to use this effect for fog cloud spell but it made my PC permanently transparent. I had to use other effect instead.


Hm. In that case, are there any others that have the same effect?

If not, deletion-recreation it is.

Edit: Actually, just tried it out, and the grey glow actually looks really good. Will use that instead. Cheers!
               
               

               


                     Modifié par _six, 17 juillet 2011 - 07:15 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Removing visual effect from placeable
« Reply #8 on: July 17, 2011, 08:12:31 pm »


               

_six wrote...

If not, deletion-recreation it is.


If it comes to that,  You may want to Recreate/delete   instead of the delete/create.