GetEventScript(object, int)

From NWN Lexicon
Jump to: navigation, search
Nwnee logo.jpg Note: This article documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.
Returns the event script for the given object and handler.
string GetEventScript(
    object oObject,
    int nHandler


The object to get the event script from
An EVENT_SCRIPT_* constant matching the event to get the script from.


Returns the event script for the given object and handler.

Will return "" if unset, the object is invalid, or the object cannot have the requested handler. Note PC's will return "default" as their default script. See remarks.


While this can get creature events from the PC, the only events that actually work on PCs are OnConversation, OnDeath, OnHeartbeat, and OnUserDefined. In development build 1.74.8171, OnCombatRoundEnd, OnPerception, and OnSpellCastAt now work for PCs as well. Others may also work, these are untested.

From testing PCs have scripts actually set to the word "default" by default - any changes made are not saved to a .bic file. Therefore be careful you do not create a script called "default" since it might run many times in creature events you don't expect!

It also means the GetEventScript will never return a blank entry for a PC unless specifically set using SetEventScript.

When a DM "disables creature AI" this will essentially make event scripts blank (and likely calls ClearAllActions). These scripts are not truly blanked - when the AI is re-enabled the original scripts are put back silently. If an event script is altered in this state it's unknown what happens when the AI is restored.


This function was added in 1.74.8164 of NWN:EE.

See Also

functions: SetEventScript()
constants: EVENT_SCRIPT_* Constant Group