Visual Effects

Creating visual effects through scripting works much the same way in NWN2 as it did in NWN1. Use EffectVisualEffect() to create an effect, then ApplyEffectToObject() or ApplyEffectAtLocation() to place that effect in the game.

From the official NWN2 Documentation:

"Visual effects are composed of effect files, which are individual components of an effect (a particle system, a trail, a billboard, etc.), and SEF files, which point to the effect files and organize them into a more complex visual effect."

Effect constants start with "VFX_".

  • Apply VFX_IMP_ constants instantly, to a target.
  • Apply VFX_DUR_ constants for a duration, either permanent or temporary, to a target.
  • Apply VFX_FNF_ constants instantly, and only at a location.

Non-functional Visual Effects

Jassper asked a question in the official forums about certain VFX constants not working. Cracking open the visualeffects.2da, it was discovered that a lot of the effects listed don't have .sef files associated with them.

From loudent2 :

It turns out a lot of the effects have been deprecated. It isn't immedietely apparant which ones (I had a similar problem using the tornado effect). Not sure if this is the problem in your case.

And from Ravine_HU:

I've read somewhere about this... coz the VFXs totally changed in nwn2 - everything is in the sef-files. U can check the visualeffects.2da for the list - find the row, and if there is no xy.sef references in it...unlucky.

I personally miss some nice effect from nwn1, like this raise dead for example. I can't even find that kind of effect which is only visible to the PC whom attached to (for example, no effect for blindness...).

However, the visual effect editor is cool.

Oh yeah, and check the "broken functions list" topic too, there are some issues with applying visualeffects.

More from Jassper

After looking in the 2da file for spells, NWN2 uses visual sp_conjuration_conjure.sef for raise dead. I copied that to the visualeffects.2da under the heading VFX_IMP_RAISE_DEAD and vola! I have an effect - altough it is not the NWN1 style raise dead.

So that indeed seems to be the issue - these effects simply wern't included, or haven't been replaced yet.

BTW, quesion about saveing changes in the 2da's. Will the new 2da be local to that mod only, or is it now a global change for all modules?

And finally, from mykael22000

Saved .2das get written out to your override directory - meaning they'll affect all of your games, but aren't stored inside the module you edited so if you send it to someone else, they won't have a copy...

Get the nwnhak utility from NWN1, create a new hak and move the .2da into it. Then park it in your Hak directory and tell the module to use it. It still won't be sent to anyone with the module, but at least it'll complain and tell them that they are missing it. it also won't stuff up all of your other games.

NWN Lexicon: visual effects samples

The following samples for creating visual effects through scripting are from the NWN1 Lexicon. (Currently the lexicon is at http://nwn1.nwn2lexicon.com/, but I'm unsure what's in store for that site.)

// Sample code for applying a VFX_IMP_ visual, a AC-bonus
// (Mage armor) visual, to a target.
void main()
{
    // This is the Object to apply the effect to.
    object oTarget = OBJECT_SELF;

    // Create the visual portion of the effect.
    effect eVis = EffectVisualEffect(VFX_IMP_AC_BONUS);

    // Apply the visual effect to the target.
    // - We apply VFX_IMP_ constants instantly, to a target.
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
}

// Sample code for applying a VFX_DUR_ visual, a 
// stoneskin visual, to a target.
void main()
{
    // This is the Object to apply the effect to.
    object oTarget = OBJECT_SELF;

    // Create the visual portion of the effect
    effect eDur = EffectVisualEffect(VFX_DUR_PROT_STONESKIN);

    // Apply the visual effect to the target.
    // - We apply VFX_DUR_ constants for a duration, here 
    //    it is permanent (could be temporary), to a target.
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDur, oTarget);
}

// Sample code for applying a VFX_FNF_ visual, a fireball, 
// to a location.
void main()
{
    // This is the Target to apply the effect at.
    location lTarget = GetLocation(OBJECT_SELF);

    // Create the visual portion of the effect
    effect eAOE = EffectVisualEffect(VFX_FNF_FIREBALL);

    // Apply the visual effect to the target.
    // - We apply VFX_FNF_ constants instantly, and only
    //   at a location.
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eAOE, lTarget);
}