Event Handlers – Arma Reforger
Jump to navigation
Jump to search
Lou Montana (talk | contribs) (Page creation) |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
(14 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__NOEDITSECTION__ | |||
{{TOC|side}} | |||
== Script Invokers == | |||
* An Event Handler can be created using a '''{{Link|enfusion://ScriptEditor/scripts/Game/Helpers/SCR_ScriptInvokerHelper.c|ScriptInvoker*}}''' class. | |||
* Any Script Invoker signature can be created using {{hl|{{Link|Arma Reforger:Scripting: Keywords#typedef|typedef}}}} - see {{Link|Arma Reforger:ScriptInvoker Usage#Signature Declaration}}. | |||
* Using the {{Link/Enfusion|armaR|ScriptInvoker}} class itself is considered bad practice and '''must''' be avoided. | |||
* As Script Invokers are big objects and can be numerous, it is good practice to '''not''' instanciate them by default but to rather create them on request, using their getter - saving memory. | |||
{{Feature|informative| | |||
See {{Link|Arma Reforger:ScriptInvoker Usage}} and its {{Link|Arma Reforger:ScriptInvoker Usage#Signature Declaration|Signature Declaration}} section for tutorials on how to use Script Invokers. | |||
}} | |||
== Common Event Handlers == | |||
{{Feature|informative|The following table is a list of the most useful events and is not an extensive list of each event handlers.}} | |||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
! | ! Class | ||
! Event | ! Event | ||
! class="unsortable" | Description | |||
! Description | |||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnDestroyed === | |||
| | | {{Link/Enfusion|armaR|DamageManagerComponent}} | ||
|when default hitzone is set to destroyed | | when default hitzone is set to destroyed | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnADSChanged === | |||
| | | rowspan="2" | {{Link/Enfusion|armaR|CharacterControllerComponent}} | ||
|on player character which switches to ADS | | on player character which switches to ADS | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnInspectionModeChanged === | |||
| on player character which switches in/out of inspection mode | | on player character which switches in/out of inspection mode | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnMagazineCountChanged === | |||
| | | {{Link/Enfusion|armaR|InventoryStorageManagerComponent}} | ||
| | | | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnCompartmentEntered === | |||
| | | rowspan="2" | {{Link/Enfusion|armaR|BaseCompartmentManagerComponent}} | ||
| | | | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnCompartmentLeft === | |||
| | | | ||
|- | |- | ||
|BaseMuzzleComponent | | style="font-size: 0.8em" | | ||
=== OnAmmoCountChanged === | |||
| {{Link/Enfusion|armaR|BaseMuzzleComponent}} | |||
|OnAmmoCountChanged | | Both weapon and character can raise the event (see {{Link|#BaseWeaponManagerComponent}}) | ||
| | |- | ||
|Both weapon and character can raise the event | | style="font-size: 0.8em" | | ||
=== OnAmmoCountChanged === | |||
| rowspan="3" | {{Link/Enfusion|armaR|BaseWeaponManagerComponent}} | |||
| Both weapon and character can raise the event (see {{Link|#BaseMuzzleComponent}}) | |||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnWeaponChanged === | |||
| | | | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnMagazineChanged === | |||
| | | | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnMuzzleChanged === | |||
| BaseWeaponComponent | | {{Link/Enfusion|armaR|BaseWeaponComponent}} | ||
| | | | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnFiremodeChanged === | |||
| | | {{Link/Enfusion|armaR|BaseMuzzleComponent}} | ||
| | | | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnZeroingChanged === | |||
| | | {{Link/Enfusion|armaR|BaseSightsComponent}} | ||
| currently does not carry currentMuzzle | | currently does not carry currentMuzzle | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnWeaponAttachmentChanged === | |||
| WeaponComponent | | {{Link/Enfusion|armaR|WeaponComponent}} | ||
| isAttached is true if attachmentEntity was attached to the weapon, and false if it was detached. | | {{hl|isAttached}} is true if attachmentEntity was attached to the weapon, and false if it was detached. | ||
|- | |- | ||
| | | style="font-size: 0.8em" | | ||
=== OnTurretReload === | |||
| | | {{Link/Enfusion|armaR|TurretControllerComponent}} | ||
| isFinished is true when reload is done and false when it started. | | isFinished is true when reload is done and false when it started. | ||
|} | |} | ||
== Entity Event Handlers == | |||
{{Feature|informative|See also {{Link|Arma Reforger:Entity Lifecycle}}.}} | |||
The following events are present and available in the '''{{Link/Enfusion|armaR|IEntity}}''' class - read the code documentation to learn more about them and how to use them. | |||
{{Feature|informative|'''E''' in e.g '''E'''OnInit stands for Event (not Entity).}} | |||
{| class="wikitable sortable valign-top" | |||
! Event | |||
! class="unsortable" | Description | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnInit === | |||
| Event after the entity is allocated and initialised. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnVisible === | |||
| This event triggers when the entity is made visible (versus being invisible). | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnFrame === | |||
| This event, as its name suggests, triggers on each simulation frame. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnPostFrame === | |||
| Triggers after physics update. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnFixedFrame === | |||
| {{Feature|warning|This event can be called on another thread than the main thread. This means that you must avoid any modifications on other entities during this event!}} | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnFixedPostFrame === | |||
| | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnAnimEvent === | |||
| Event from the animation system | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnPhysicsActive === | |||
| Triggers on (de)activation of the {{hl|RigidBody}}'s physics. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnPhysicsMove === | |||
| Triggers when the physics engine moves this entity. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnSimulate === | |||
| Happens before physics engine iteration - called from sub-iterations. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnPostSimulate === | |||
| Happens after physics engine iteration. Happens once per frame. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnJointBreak === | |||
| Triggers when a joint attached to this entity's {{hl|RigidBody}} is broken. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnTouch === | |||
| Event when touched by another entity. It requires the entity to have {{hl|TouchComponent}}. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnContact === | |||
| Triggers when contact with another {{hl|RigidBody}} has been registered. | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnDiag === | |||
| Happens every frame after {{Link|#EOnFrame}} when "Entity Diag" is enabled in the [[Arma Reforger:Diag Menu|Diag Menu]] (e.g {{GameCategory|armaR|Modding|Official Tools|text= Workbench}}). | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnUser0 === | |||
| | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnUser1 === | |||
| | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnUser2 === | |||
| | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnUser3 === | |||
| | |||
|- | |||
| style="font-size: 0.8em" | | |||
=== EOnUser4 === | |||
| | |||
|} | |||
{{GameCategory|armaR|Modding|Guidelines|Scripting}} | {{GameCategory|armaR|Modding|Guidelines|Scripting}} |
Latest revision as of 17:46, 30 April 2024
Script Invokers
- An Event Handler can be created using a ScriptInvoker* class.
- Any Script Invoker signature can be created using typedef - see ScriptInvoker Usage - Signature Declaration.
- Using the ScriptInvoker class itself is considered bad practice and must be avoided.
- As Script Invokers are big objects and can be numerous, it is good practice to not instanciate them by default but to rather create them on request, using their getter - saving memory.
Common Event Handlers
Class | Event | Description |
---|---|---|
OnDestroyed |
DamageManagerComponent | when default hitzone is set to destroyed |
OnADSChanged |
CharacterControllerComponent | on player character which switches to ADS |
OnInspectionModeChanged |
on player character which switches in/out of inspection mode | |
OnMagazineCountChanged |
InventoryStorageManagerComponent | |
OnCompartmentEntered |
BaseCompartmentManagerComponent | |
OnCompartmentLeft |
||
OnAmmoCountChanged |
BaseMuzzleComponent | Both weapon and character can raise the event (see BaseWeaponManagerComponent) |
OnAmmoCountChanged |
BaseWeaponManagerComponent | Both weapon and character can raise the event (see BaseMuzzleComponent) |
OnWeaponChanged |
||
OnMagazineChanged |
||
OnMuzzleChanged |
BaseWeaponComponent | |
OnFiremodeChanged |
BaseMuzzleComponent | |
OnZeroingChanged |
BaseSightsComponent | currently does not carry currentMuzzle |
OnWeaponAttachmentChanged |
WeaponComponent | isAttached is true if attachmentEntity was attached to the weapon, and false if it was detached. |
OnTurretReload |
TurretControllerComponent | isFinished is true when reload is done and false when it started. |
Entity Event Handlers
The following events are present and available in the IEntity class - read the code documentation to learn more about them and how to use them.
Event | Description |
---|---|
EOnInit |
Event after the entity is allocated and initialised. |
EOnVisible |
This event triggers when the entity is made visible (versus being invisible). |
EOnFrame |
This event, as its name suggests, triggers on each simulation frame. |
EOnPostFrame |
Triggers after physics update. |
EOnFixedFrame |
|
EOnFixedPostFrame |
|
EOnAnimEvent |
Event from the animation system |
EOnPhysicsActive |
Triggers on (de)activation of the RigidBody's physics. |
EOnPhysicsMove |
Triggers when the physics engine moves this entity. |
EOnSimulate |
Happens before physics engine iteration - called from sub-iterations. |
EOnPostSimulate |
Happens after physics engine iteration. Happens once per frame. |
EOnJointBreak |
Triggers when a joint attached to this entity's RigidBody is broken. |
EOnTouch |
Event when touched by another entity. It requires the entity to have TouchComponent. |
EOnContact |
Triggers when contact with another RigidBody has been registered. |
EOnDiag |
Happens every frame after EOnFrame when "Entity Diag" is enabled in the Diag Menu (e.g Workbench). |
EOnUser0 |
|
EOnUser1 |
|
EOnUser2 |
|
EOnUser3 |
|
EOnUser4 |