EVENT scripts: Difference between revisions
m
Added a note explaining that it's now possible to get an event's result value in Zandronum 3.2.
DrinkyBird (talk | contribs) m (word) Tag: Source edit |
m (Added a note explaining that it's now possible to get an event's result value in Zandronum 3.2.) |
||
Line 35: | Line 35: | ||
== Event handling == | == Event handling == | ||
You are allowed to modify the results of some events by changing the result value of the EVENT script itself via | You are allowed to modify the results of some events by changing the result value of the EVENT script itself via {{zdoomwiki|SetResultValue}}. The event types that current support this are: | ||
* '''GAMEEVENT_CHAT''': setting the result value to zero prevents the chat message from being printed onto the screen. If the result value is non-zero, the chat message will be printed like normal. | *'''GAMEEVENT_CHAT''': setting the result value to zero prevents the chat message from being printed onto the screen. If the result value is non-zero, the chat message will be printed like normal. | ||
* '''GAMEEVENT_ACTOR_DAMAGED''' and '''GAMEEVENT_ACTOR_ARMORDAMAGED''': changing the result value affects how much damage the actor actually takes. | * '''GAMEEVENT_ACTOR_DAMAGED''' and '''GAMEEVENT_ACTOR_ARMORDAMAGED''': changing the result value affects how much damage the actor actually takes. | ||
A few things to note are: | A few things to note are: | ||
* If there are multiple EVENT scripts, the result of the event will be transferred from one script to the next. If more than one script tries to change the result of the event, then whichever script is fired last decides the outcome of the event. | *If there are multiple EVENT scripts, the result of the event will be transferred from one script to the next. If more than one script tries to change the result of the event, then whichever script is fired last decides the outcome of the event. | ||
* Event handling does not work at all in <tt>CLIENTSIDE</tt> scripts. | *Event handling does not work at all in <tt>CLIENTSIDE</tt> scripts. | ||
It's recommended that you change the result value in only one script per event type, unless you know the order in which the scripts are fired (e.g. creating an addon of a mod that overrides the result of the event). | It's recommended that you change the result value in only one script per event type, unless you know the order in which the scripts are fired (e.g. creating an addon of a mod that overrides the result of the event). | ||
== Additional information == | {{Devfeature|3.2|alpha}}: It's possible to get the current result value with [[GetEventResult]]. | ||
==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 [ | *'''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 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. | ||
If you wish to forbid an actor from triggering these events, you can add the <tt>NOSPAWNEVENTSCRIPT</tt> or <tt>NODAMAGEEVENTSCRIPT</tt> flags to them. | If you wish to forbid an actor from triggering these events, you can add the <tt>NOSPAWNEVENTSCRIPT</tt> or <tt>NODAMAGEEVENTSCRIPT</tt> flags to them. | ||
Line 58: | Line 60: | ||
*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). | ||
*AAPTR_DAMAGE_TARGET: Accesses the "victim" taking the damage. By default, this actor is already the activator of the script. | *AAPTR_DAMAGE_TARGET: Accesses the "victim" taking the damage. By default, this actor is already the activator of the script. | ||
You may use these in ACS functions that deal with actor pointers, such as [ | You may use these in ACS functions that deal with actor pointers, such as [[zdoom:IsPointerEqual|IsPointerEqual]], [[zdoom:SetActivator|SetActivator]], [[zdoom:SetPointer|SetPointer]], or [[zdoom:Warp|Warp]]. | ||
Line 64: | Line 66: | ||
[[Category:Level Development]] | [[Category:Level Development]] | ||
== Examples == | == Examples== | ||
Let's say we want to use '''GAMEEVENT_ACTOR_SPAWNED''' and '''GAMEEVENT_ACTOR_DAMAGED''' for our mod. For the sake of simplicity, we want the events to be triggered by all actors, so we'll create a <tt>MAPINFO</tt> lump in our WAD file and add the following: | Let's say we want to use '''GAMEEVENT_ACTOR_SPAWNED''' and '''GAMEEVENT_ACTOR_DAMAGED''' for our mod. For the sake of simplicity, we want the events to be triggered by all actors, so we'll create a <tt>MAPINFO</tt> lump in our WAD file and add the following: |