EffectDarkness()

From NWN Lexicon
Jump to: navigation, search

Returns a new Darkness effect object.

Description

Create a Darkness effect.

Darkness makes the person Blind (50% miss chance, cannot target people with spells directly), unless they have EffectUltravision or EffectTrueSeeing applied, and so can see through magical darkness.

It also applies a hidden EffectInvisibility(INVISIBILITY_TYPE_DARKNESS) to the person, so people trying to see/fire into the darkness cannot see them by default, have a miss chance if they can hear them and are slightly outside the darkness. It's quite neat and self contained.

This is NOT a good way to create an on-screen visual of darkening a room, or the perception of a PC. Use VFX_DUR_BLIND or similar VFX lines for that.

The target this effect is applied to must be a creature for it to work. This effect should not be applied instantly, only temporarily or permanently.


Remarks

This should be only really used with the SPELL_DARKNESS AOE because it appears even more buggy if you use it elsewhere.

The penalties should be the same as EffectBlindness, so that FEAT_BLINDFIGHT should work for a re-roll, and it not stack with normal Blindness (only the highest would apply, and they are both 50% chance to miss).

Effect functions are Constructors, which are special methods that help construct effect "objects". You can declare and link effects, and apply them using an ApplyEffectToObject() Command. Once applied, each effect can be got separately via. looping valid effects on the target (GetFirst/NextEffect()). See the Effect Tutorial for more details.


Effect Breakdown

There are by default no effect integers to retrieve with this. The EffectInvisibility mentioned above and interactions with Ultravision and True Seeing are engine coded, there's no optional features of this effect.

This means it is not valid for passing into VersusAlignmentEffect or VersusRacialTypeEffect, since of course Darkness doesn't care about alignment or racial type - so the invisibility is set to no racial type and no alignment.


Known Bugs

Using this outside of the SPELL_DARKNESS applied AOE object seems to come with some...flaws. Even when using it with it, it appears to be buggy in relation to True Seeing.

Applying EffectTrueSeeing seems to remove EffectDarkness instead of suppressing it when used outside of the Darkness spell AOE object (ie just applying EffectDarkness then applying and removing EffectTrueSeeing). When the spell AOE is involved it also bugs if you remove the True Seeing while standing in the AOE - your screen goes black again (yay!) but the effect is...not available to scripts and doesn't apply an effect icon. This means you are perpetually trapped in darkness.

Version

1.62


Example

// Sample code for applying darkness to a target
 
void main()
{
    // This is the Object to apply the effect to.
    object oTarget = OBJECT_SELF;
 
    // Create the effect to apply
    effect eDark = EffectDarkness();
 
    // Create the visual portion of the effect. This is instantly
    // applied and not persistent with whether or not we have the
    // above effect.
    effect eVis = EffectVisualEffect(VFX_IMP_REDUCE_ABILITY_SCORE);
 
    // Apply the visual effect to the target
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
    // Apply the effect to the object   
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDark, oTarget);
}

See Also

functions:

EffectInvisibility EffectUltravision EffectTrueSeeing

events:

OnPerception




 author: Michael Nork, editor: Jasperre, additional contributor(s): Jasperre