OnUserDefined
The script attached to this event fires depending on settings made during the OnSpawn event for creatures and some general level blanket signals for all objects (including creatures). Typically this script is a switch/case statement that does something different depending on the signal (numerical value) sent to it by an event that calls the script. This event makes it very easy to retain the default behavior of an object while adding custom mannerisms of your own.
Trigger
A script has used the SignalEvent() function with EventUserDefined as the parameter.
For associates, such as henchmen or summons, the game also triggers event ID 20000 + ACTION_MODE_* constant, so for instance ACTION_MODE_SEARCH will toggle UDE of 20000, while ACTION_MODE_POWER_ATTACK is 20003. This seems to be undocumented in nwscript.nss but you can see examples of it in the Bioware AI files. This allows the AI to mimic the players actions.
Function(s)
GetUserDefinedEventNumber() to return the user defined event number being sent.
Remarks
In a script that generates a user-defined event, use the EventUserDefined(int) function to generate the appropriate internal event identification number which can be consumed in the OnUserDefined script. Also note that the UserDefined Death event is considered unreliable by Bioware. This is because the UserDefined event runs after the calling event has finished, in this case OnDeath. And as such, a call to DestroyObject(OBJECT_SELF) in the OnDeath event will remove the object, closing its action queue and thus prevent the UserDefined Death event from executing.
Example
// to invoke it for a module, try something like...
// SignalEvent(GetModule(), EventUserDefined(112));
// then say we want to capture user-defined event number 112
// in our module's OnUserDefined event...
void main()
{
switch (GetUserDefinedEventNumber())
{
case 112:
PrintString("Event #112 occurred!");
break;
// ... additional case statements for other user-defined
// events can be added as necessary
}
}
See Also
functions: | |
constants: |
Event Constants ACTION_MODE_* constants |