ApplyEffectToObject(int, effect, object, float)

Applies an effect (visual or actual) to an object.

void ApplyEffectToObject(
    int nDurationType,
    effect eEffect,
    object oTarget,
    float fDuration = 0.0f
);

Parameters

nDurationType

DURATION_TYPE_*

eEffect

The effect to apply.

oTarget

The target of the effect.

fDuration

The duration of temporary effects. (Default: 0.0f)


Description

Applies an effect to an object. Effects range from the purely visual (EffectVisualEffect) through beneficial (EffectHeal), wide-ranging (EffectAreaOfEffect) to fatal (EffectDeath), with many variations in between.

Effects need to be constructed before they can be applied, and the valid nDurationType values depend on the Effect constructed. Refer to the individual Effect functions for details on the effect you want to apply.

Effects can also be flagged as 'Extraordinary', 'Magical' or 'Supernatural', so an effect applied as 'Extraordinary' should not be dispelled by magical means.



Remarks

The object that this command is applied to has to be useable. However using ApplyEffectAtLocation and GetLocation avoids having to have a useable object.

The object the script is running on will be the effect creator (See GetEffectCreator), so any damage/death done by an object, that object's name will appear as the killer/damager, a module and area appears as "Unknown".


Known Bugs

If you apply any tempoary/permament effect (For example, EffectSpellResistanceDecrease) as DURATION_TYPE_INSTANT, it can never be removed in any way what so ever.


Version

1.26

Example

// In the Actions Taken of a conversation node... this PC
// has made a near-fatal faux pas.
void main() {
  object oPC = GetPCSpeaker();
  int iHealth = GetCurrentHitPoints(oPC) -1;
  effect eOuch = ExtraordinaryEffect(EffectDamage(iHealth, DAMAGE_TYPE_DIVINE));
  ApplyEffectToObject(DURATION_TYPE_INSTANT, eOuch, oPC);
}

See Also

functions: ApplyEffectAtLocation | EffectAbilityDecrease | EffectAbilityIncrease | EffectACDecrease | EffectACIncrease | EffectAppear | EffectSpellResistanceIncrease | EffectStunned | EffectSummonCreature | EffectSwarm | EffectTrueSeeing | ExtraordinaryEffect | MagicalEffect | Petrify | SupernaturalEffect | VersusAlignmentEffect
categories: Effects Functions | Spell Casting Effects Functions | Visual Effects Functions
constants: DURATION_TYPE_* Constants
events: OnAcquireItem Event | OnActivateItem Event | OnSpellCastAt Event


 author: Iskander Merriman, editor: Jasperre, additional contributor(s): Adrian Bates, Matt Andrew, Jasperre
 Send comments on this topic.