Creature Event System

From Sinfar

Sinfar uses a custom system by which you can assign default scripts to a monster then use variables to inject a script and its behavior onto the monster based on the event.

Screenshot of what the script and save scriptset/load script set buttons look like in the toolset underneath the 'scripts' tab on creature editors.

The default scripts are as following:

Field Default Script
OnBlocked nw_c2_defaulte
OnDamaged nw_c2_default6
OnDeath nw_c2_default7
OnConversation nw_c2_default4
OnDisturbed nw_c2_default8
OnCombatRoundEnd nw_c2_default3
OnHeartbeat nw_c2_default1
OnPhysicalAttacked nw_c2_default5
OnPerception nw_c2_default2
OnRested x2_def_rested
OnSpawn nw_c2_default9
OnSpellCast nw_c2_defaultb
OnUserDefined x2_def_userdef

- The only script that isn't defined by Sinfar edits is OnUserDefined (as far as I know).

- It is recommended you create a monster and assign the default scripts to it in the toolset, and 'save the script set' and inject it to all monsters hereon. This way you can use 'load script' to inject all the code at once.

The variables

Example of the EVENT_AI_DEATH use

The variables in bold are what you would use to put on your monster.

Script Script description Event Name String Pre-event description
nw_c2_default1 On Heartbeat event EVENT_AI_HEARTBEAT (string) Script name for pre-event use.
nw_c2_default2 On Perception event EVENT_AI_PERCEPTION (string) Script name for pre-event use.
nw_c2_default3 On Combat Round End event EVENT_AI_ENDCOMBATROUND (string) Script name for pre-event use.
nw_c2_default4 On Conversation event EVENT_AI_CONVERSATION (string) Script name for pre-event use.
nw_c2_default5 On Attacked event EVENT_AI_ATTACKED (string) Script name for pre-event use.
nw_c2_default6 On Damaged event EVENT_AI_DAMAGED (string) Script name for pre-event use.
nw_c2_default7 On Death event EVENT_AI_DEATH (string) Script name for pre-event use.
nw_c2_default8 On Disturbed event EVENT_AI_DISTURBED (string) Script name for pre-event use.
nw_c2_default9 On Spawned event EVENT_AI_SPAWN (string) Script name for pre-event use.
nw_c2_defaultb On Spell Cast At event EVENT_AI_CASTAT (string) Script name for pre-event use.
nw_c2_defaulte On Blocked event EVENT_AI_BLOCKED (string) Script name for pre-event use.
At the very bottom, you would hardcode and directly use the script name on the OnUserDefined event.

For OnUserDefined functions, you would apply the script directly onto the monster.

Note : nw_c2_default9 uses the variable ENTIRE_APPEARANCE2 already

You can also register these events dynamically using Variable Based Events.