EVENT scripts: Difference between revisions

m
GAMEEVENT_ACTOR_ARMORDAMAGED is a new event type in 3.1.
(Added some more information about GAMEEVENT_ACTOR_SPAWNED and GAMEEVENT_ACTOR_DAMAGED, and added an example.)
m (GAMEEVENT_ACTOR_ARMORDAMAGED is a new event type in 3.1.)
Line 30: Line 30:
;GAMEEVENT_ACTOR_DAMAGED 11 {{Devfeature|3.1|alpha}}
;GAMEEVENT_ACTOR_DAMAGED 11 {{Devfeature|3.1|alpha}}
:When an actor is just about to take damage, after all damage modifications are applied. The activator is the actor taking damage, <tt>arg1</tt> is the amount of damage received, and <tt>arg2</tt> is a dynamic ACS string containing the damage type.
:When an actor is just about to take damage, after all damage modifications are applied. The activator is the actor taking damage, <tt>arg1</tt> is the amount of damage received, and <tt>arg2</tt> is a dynamic ACS string containing the damage type.
;GAMEEVENT_ACTOR_ARMORDAMAGED 12 {{Devfeature|3.1|alpha}}
:Behaves exactly like GAMEEVENT_ACTOR_DAMAGED but is triggered slightly earlier, just before an actor's armor can absorb any damage.


== Additional information ==
== Additional information ==
Due to risks of performance drops because of how often they might be called, '''GAMEEVENT_ACTOR_SPAWNED''' and '''GAMEEVENT_ACTOR_DAMAGED''' 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 [https://zdoom.org/wiki/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 [https://zdoom.org/wiki/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 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 39: Line 41:




In addition, '''GAMEEVENT_ACTOR_DAMAGED''' enables special actor pointers that give you access to the actors involved in the <tt>P_DamageMobj</tt> call:
In addition, '''GAMEEVENT_ACTOR_DAMAGED''' and '''GAMEEVENT_ACTOR_ARMORDAMAGED''' enable special actor pointers that give you access to the actors involved in the <tt>P_DamageMobj</tt> call:
*AAPTR_DAMAGE_SOURCE: Accesses the "shooter" responsible for making the attack.
*AAPTR_DAMAGE_SOURCE: Accesses the "shooter" responsible for making the attack.
*AAPTR_DAMAGE_INFLICTOR: Accesses the actor directly responsible for causing damage (e.g. a barrel or projectile).
*AAPTR_DAMAGE_INFLICTOR: Accesses the actor directly responsible for causing damage (e.g. a barrel or projectile).
Line 46: Line 48:




It's recommended not to use '''GAMEEVENT_ACTOR_SPAWNED''' or '''GAMEEVENT_ACTOR_DAMAGED''' 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 the latter, 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]]