EffectAreaOfEffect(int, string, string, string)

From NWN Lexicon
Jump to: navigation, search

Returns a new effect object.

effect EffectAreaOfEffect(
    int nAreaEffectId,
    string sOnEnterScript = "",
    string sHeartbeatScript = "",
    string sOnExitScript = ""
);

Parameters

nAreaEffectId
The ID of the Area of Effect
sOnEnterScript
The script to use when a creature enters the radius of the Area of Effect. (Default: "")
sHeartbeatScript
The script to run on each of the Area of Effect's Heartbeats. (Default: "")
sOnExitScript
The script to run when a creature leaves the radius of an Area of Effect. (Default: "")

Description

Create an Area Of Effect effect in the area of the creature it is applied to. If the scripts are not specified, default ones will be used.

The target you can apply this to can be any valid (non static) object that ApplyEffectToObject works on, or a location. This effect should not be applied instantly, only temporarily or permanently.

Remarks

Question icon.png This article needs clarification. You can help the NWN Lexicon by explaining things better.

This can be applied to a location, where the effect will be static, or it can be applied to a creature, where it will basically follow the creature around.

If you want the Area of Effect to do nothing use "****" or point to an empty script.

The creator of the effect (GetAreaOfEffectCreator()) is the caller of the script that the effect is applied from - as this is not an effect if applied to a location, it will not have an GetEffectCreator().

This effect becomes an object after applied to creature or location and can be retrieved by a GetObjectByTag() function. The tag of the AOE object is the value of the column "LABEL" for a given AOE, defined in the vfx_persistent.2da file.

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.

Known Bugs

There are a few graphical problems with using MOB_ declared AOE's as location AOE's, and PER_ declared AOE's used as mobile (moving with the PC) AOE's. Also, in a huge modules the AOEs often do not move neither run their heartbeat script at all.

There are sometimes glitches with the usual spell functions when used inside the AOE's script - such as GetSpellId(), GetSpellSaveDC(), GetCasterLevel(), and so on, because of the fact the values can change after the AOE has been in place, and the other fact that sub-dial spells will not work correctly with GetSpellSaveDC() in the first place.

Version

1.62

Example

int AOE_BOG_STINK = 1500;
 
void main()
{
    //Declare the Area Of Effect, assign it an ID, and tell it what scripts to run when someone interacts with it.
    effect eAOE = EffectAreaOfEffect(AOE_BOG_STINK, "bog_on_enter", "bog_on_hb", "bog_on_exit");
    location lTarget = GetLocation(GetEnteringObject());
    int nDuration = 2;
    //Create an instance of the AOE Object using the Apply Effect function
    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eAOE, lTarget, RoundsToSeconds(nDuration));
}

See Also

functions:  ApplyEffectAtLocation


 author: John Shuell, editor: Jasperre, additional contributor(s): Peter Poe, Jasperre