EVENT scripts: Difference between revisions

Added the GAMEEVENT_LEVEL_INIT event.
m (Don't forget to mention the activators of GAMEEVENT_DOMINATION_CONTROL and GAMEEVENT_DOMINATION_POINT.)
Tag: Source edit
(Added the GAMEEVENT_LEVEL_INIT event.)
 
(3 intermediate revisions by 2 users not shown)
Line 37: Line 37:
;{{Devfeature|3.2|alpha}} GAMEEVENT_DOMINATION_POINT 14
;{{Devfeature|3.2|alpha}} GAMEEVENT_DOMINATION_POINT 14
:When a team gets a point for controlling point sector in [[Game Modes#Domination|Domination]]. The activator is always the world, <tt>arg1</tt> is the team index that occupies the sector, and <tt>arg2</tt> is a dynamic ACS string containing the name of the sector.
:When a team gets a point for controlling point sector in [[Game Modes#Domination|Domination]]. The activator is always the world, <tt>arg1</tt> is the team index that occupies the sector, and <tt>arg2</tt> is a dynamic ACS string containing the name of the sector.
;{{Devfeature|3.2|alpha}} GAMEEVENT_PLAYERLEAVESSERVER 15
:When a player disconnects from the server (the opposite of GAMEEVENT_PLAYERCONNECT). This is not to be confused with {{Zdoomwiki|Script types#DISCONNECT|DISCONNECT scripts}} which fire when a player leaves the game, including becoming a spectator. The activator is the world, <tt>arg1</tt> is the number of the player who disconnected, and <tt>arg2</tt> indicates the reason the player disconnected - see [[#Leave reasons|Leave reasons]] below.
;{{Devfeature|3.2|alpha}} GAMEEVENT_LEVEL_INIT 16
:This event is executed early in map initialization, before things are spawned, OPEN scripts executed, etc. This script is usable as a way to manipulate map features early where the regular OPEN script doesn't work. This is not to be confused with said {{Zdoomwiki|Script types#OPEN|OPEN scripts}} which fire when a level initialized, happening much later down the line. The activator is the world.


== Event handling==
== Event handling==
Line 56: Line 60:
==Additional information==
==Additional information==
Due to risks of performance drops, '''GAMEEVENT_ACTOR_SPAWNED''', '''GAMEEVENT_ACTOR_DAMAGED''', and '''GAMEEVENT_ACTOR_ARMORDAMAGED''' are disabled by default. There are two methods for enabling these event types:
Due to risks of performance drops, '''GAMEEVENT_ACTOR_SPAWNED''', '''GAMEEVENT_ACTOR_DAMAGED''', and '''GAMEEVENT_ACTOR_ARMORDAMAGED''' are disabled by default. There are two methods for enabling these event types:
*'''Method A''': Add the properties <tt>ForceSpawnEventScripts</tt> or <tt>ForceDamageEventScripts</tt> in the [[zdoom:GameInfo_definition|GameInfo Definition]]. This helps if you want all actors to execute these events. Note that using this method in the case of '''GAMEEVENT_ACTOR_SPAWNED''', actors with the <tt>NOBLOCKMAP</tt> or <tt>NOSECTOR</tt> flags still won't execute the event. This way, only the non-trivial actors are accounted for.
*'''Method A''': Add the properties <tt>ForceSpawnEventScripts</tt> or <tt>ForceDamageEventScripts</tt> in the [[zdoom:GameInfo_definition|GameInfo Definition]]. This helps if you want all actors to execute these events. Note that using this method in the case of '''GAMEEVENT_ACTOR_SPAWNED''', actors with the <tt>NOBLOCKMAP</tt> (actors with <tt>ISMISSILE</tt> will still execute the event) or <tt>NOSECTOR</tt> flags still won't execute the event. This way, only the non-trivial actors are accounted for.
*'''Method B''': Add the <tt>USESPAWNEVENTSCRIPT</tt> or <tt>USEDAMAGEEVENTSCRIPT</tt> flags to the actor that you wish have execute the events. These are useful if you only want certain actors to trigger the events and not all of them, which can optimize your mod better.
*'''Method B''': Add the <tt>USESPAWNEVENTSCRIPT</tt> or <tt>USEDAMAGEEVENTSCRIPT</tt> flags to the actor that you wish have execute the events. These are useful if you only want certain actors to trigger the events and not all of them, which can optimize your mod better.


Line 71: Line 75:
It's recommended not to use these three event types in conjunction with <tt>CLIENTSIDE</tt> scripts, since the server must tell clients to execute the scripts every time the events are fired. Due to their frequent occurrence, this can create lots of network traffic, resulting in a huge drop in performance. Furthermore, the extra actor pointers available in damage events, along with the damage type stored in <tt>arg2</tt>, do not work properly in <tt>CLIENTSIDE</tt> scripts.
It's recommended not to use these three event types in conjunction with <tt>CLIENTSIDE</tt> scripts, since the server must tell clients to execute the scripts every time the events are fired. Due to their frequent occurrence, this can create lots of network traffic, resulting in a huge drop in performance. Furthermore, the extra actor pointers available in damage events, along with the damage type stored in <tt>arg2</tt>, do not work properly in <tt>CLIENTSIDE</tt> scripts.
[[Category:Level Development]]
[[Category:Level Development]]
=== Leave reasons ===
The second argument passed to '''GAMEEVENT_PLAYERLEAVESSERVER''' indicates the reason a player disconnected from the server:
;LEAVEREASON_LEFT 0
:The player disconnected from the server of their own accord.
;LEAVEREASON_KICKED 1
:The player was kicked from the server by an admin.
;LEAVEREASON_ERROR 2
:The client was disconnected due to an error.
;LEAVEREASON_TIMEOUT 3
:The player timed out.
;LEAVEREASON_RECONNECT 4
:The player is re-connecting; e.g. the <tt>map</tt> command was used.


==Examples ==
==Examples ==