EffectVisualEffect(int, int, float, vector, vector)

From NWN Lexicon
Jump to: navigation, search

Creates a new visual effect object.

effect EffectVisualEffect(
    int nVisualEffectId,
    int nMissEffect = FALSE,
    float fScale=1.0f,
    vector vTranslate=[0.0,0.0,0.0],
    vector vRotate=[0.0,0.0,0.0]
);

Parameters

nVisualEffectId
The visual effect to be applied
nMissEffect
if this is TRUE, a random vector near or past the target will be generated, on which to play the effect (Default: FALSE)
fScale
The scaling factor visual transform to apply to the visual effect. NWNEE only. Default: 1.0f
vTranslate
The translation vector visual transform to apply to the visual effect. NWNEE only. Default: [0.0,0.0,0.0]
vRotate
The rotation vector visual transform to apply to the visual effect. NWNEE only. Default: [0.0,0.0,0.0]

Description

This function creates a new Visual Effect.

Visual effects are all in the file visualeffects.2da and there are normally several which do not have effect constants (under VFX_ in the constants list).

If nMissEffect is TRUE, a random location is chosen for where the effect will be applied to (most applicable for beams or projectiles).

The target and the duration of this effect depend on what kind of VFX_ constant is being used. Testing usually helps. See below.


Warning icon orange.png Caution: This section documents changes arising in NWN: Enhanced Edition content. The content is available in both the classic version and the Enhanced Edition of the game. However, the behavior may vary in each version. More details may be available in the [1] NWN Enhanced Edition patch notes.

As of 1.80.8193.14, this function now takes optional parameters that allow the scripter to apply visual transforms to the visual effect. This patch also allows some previously hardcoded types of visual effect to be altered, for instance new beams can be added to the game.

Remarks

The visual effect ID is simply a link to a line in visualeffects.2da - there are a lot of lines that have no equivalent nwscript.nss constant.

There are several "Categories" of visual effects, all which should have a certain type of application to a target or location:

  • VFX_BEAM_ - Beams between the source and target. Only apply this effect with EffectBeam().
  • VFX_COM_ - "Common" or "Combat" visual effects. Many need a duration, others can be applied instantly.
  • VFX_DUR_ - "Duration" visual effects, you normally only apply these to objects, as VFX_IMP_, but with a duration.
  • VFX_EYES_ - "Eyes" visual effects, which tend to work only on the default phenotypes.
  • VFX_FNF_ - "Fire and forget" visual effects, which tend to be applied instantly with ApplyEffectAtLocation(), although you can apply them to a target, it usually doesn't look as good
  • VFX_IMP_ - "Impact" visual effects, which tend to be applied instantly but several include durations. These requires the use of a an instantly-applied, ApplyEffectToObject(). Normally can never be applied at an location, as it requires certain "nodes" to fire effects from.

Also note that many visual effects have sounds. Also, this can be a cause of slowdown in FPS, as visual effects are of course, along with the sounds they produce, memory and graphically intensive.

Visual effects, because they can be applied instantly and for durations, can be put in EffectLinkEffects() as long as they are no the only effects in the link. They can be got as normal if they are applied for a duration with GetFirstEffect()/GetNextEffect().

Known Bugs

When a visual effect is applied to a placeable, it may become impossible to remove. This is a known issue with VFX_DUR_CUTSCENE_INVISIBILITY and some others, but has not been tested for all visual effects. It occurs when the last player leaves the area or enters cutscene mode. It can be prevented by removing the effect in those situations, reapplying it when a player enters again.

Version

This function was updated in 1.80.8193.14 of NWN:EE.

Example

// 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);
}

See Also

functions: 

ItemPropertyVisualEffect EffectBeam



 author: Michael Nork, editors: Jasperre, Mistress, additional contributors: Jasperre, Kolyana