Creature Event System: Difference between revisions

From Sinfar
(Showed how to use events)
 
(Category, Tableification)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== Creature Event System ==
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.
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.


[[File:Scripts Onto Monsters.png|thumb|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:
The default scripts are as following:


[ResRefs]
{| class="wikitable" border=1
 
!Field!!Default Script
OnBlocked=nw_c2_defaulte
|-
 
|OnBlocked||nw_c2_defaulte
OnDamaged=nw_c2_default6
|-
 
|OnDamaged||nw_c2_default6
OnDeath=nw_c2_default7
|-
 
|OnDeath||nw_c2_default7
OnConversation=nw_c2_default4
|-
 
|OnConversation||nw_c2_default4
OnDisturbed=nw_c2_default8
|-
 
|OnDisturbed||nw_c2_default8
OnCombatRoundEnd=nw_c2_default3
|-
 
|OnCombatRoundEnd||nw_c2_default3
OnHeartbeat=nw_c2_default1
|-
 
|OnHeartbeat||nw_c2_default1
OnPhysicalAttacked=nw_c2_default5
|-
 
|OnPhysicalAttacked||nw_c2_default5
OnPerception=nw_c2_default2
|-
 
|OnPerception||nw_c2_default2
OnRested=x2_def_rested
|-
 
|OnRested||x2_def_rested
OnSpawn=nw_c2_default9
|-
 
|OnSpawn||nw_c2_default9
OnSpellCast=nw_c2_defaultb
|-
 
|OnSpellCast||nw_c2_defaultb
OnUserDefined=x2_def_userdef
|-
 
|OnUserDefined||x2_def_userdef
|}


- The only script that isn't defined by Sinfar edits is OnUserDefined (as far as I know).  
- 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.
- 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.
[[File:Scripts Onto Monsters.png|thumb|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 variables ===
=== The variables: ===
[[File:Image.png|thumb|Example of the EVENT_AI_DEATH use]]
The variables in bold are what you would use to put on your monster.
The variables in bold are what you would use to put on your monster.
[[File:Image.png|thumb|Example of the EVENT_AI_DEATH use]]
<div style="clear: right;">
 
{| class="wikitable" border=1
 
!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_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_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_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_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_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_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_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_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_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_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.
|}
</div>


nw_c2_defaulte - On Blocked event : '''EVENT_AI_BLOCKED''' (string) - Script name for pre-event use.
[[File:OnUserDefinedScreenshot.png|thumb|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]].


For OnUserDefined Functions, you would apply the script -directly- onto the monster.
[[Category:Builders Tools]]
[[File:OnUserDefinedScreenshot.png|thumb|At the very bottom, you would hardcode and directly use the script name on the OnUserDefined event.]]

Latest revision as of 22:10, 17 January 2024

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.