Event Handlers – Arma 2

From Bohemia Interactive Community
Revision as of 04:09, 24 December 2009 by General Barron (talk | contribs) (removed Arma 1 event handlers. Now only new Arma 2 ehs, or A1 ehs that behave differently in A2, are listed here)
Jump to navigation Jump to search

Introduction

In addition to all the ArmA 1 event handlers, the following event handlers can be added in Arma 2.

Event Handler List

AnimStateChanged

Arma2 1.00.gif
(placeholder)

FiredNear

Arma2 1.00.gif
Triggered when a weapon is fired somewhere near the unit or vehicle.
It is also triggered if the unit itself is firing.

Global. (Exception(s): the Throw weapon wont broadcast the FiredNear event)

Passed array: [unit, firer, distance, weapon, muzzle, mode, ammo]

  • unit: Object - Object the event handler is assigned to
  • firer: Object - Object which fires a weapon near the unit
  • distance: Number - Distance in meters between the unit and firer (max. distance ~69m)
  • weapon: String - Fired weapon
  • muzzle: String - Muzzle that was used
  • mode: String - Current mode of the fired weapon
  • ammo: String - Ammo used

HandleDamage

Arma2 1.00.gif

Triggered when the unit is damaged. Works with all vehicles. Code provided must return a value what should be the damage of given part after processing. Adding this eventhandler with no return value or with return value 0 replaces damage handling by the engine, making the object invulnerable if damage is not scripted in the eventhandler. If you want default processing to be done, be sure to return _this select 2. See setDamage and setHit for more information regarding damage handling.

Unknown locality

This EH is triggered separately for every selection of the damaged object.

Passed array: [unit, selectionName, damage, source, projectile]

  • unit: Object - Object the event handler is assigned to.
  • selectionName: String - Name of the selection where the unit was damaged. "" for over-all structural damage, "?" for unknown selections.
  • damage: Number - Resulting level of damage for the selection.
  • source: Object - The source unit that caused the damage.
  • projectile: String - Classname of the projectile that caused inflicted the damage. ("" for unknown, such as falling damage.)


Example:

HANDLE = TargetSoldier addeventhandler ["HandleDamage",{diag_log text format ["T=%1 : %2", time, _this];_this select 2;} ];

When shooting the soldier once in the head, and once in the torso, ArmA2.RPT shows:

T=6.754 : [TargetSoldier,"",0.350463,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=6.754 : [TargetSoldier,"head_hit",3.23586,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=6.754 : [TargetSoldier,"body",0.0743558,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=6.754 : [TargetSoldier,"hands",0.667459,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=6.754 : [TargetSoldier,"legs",0.00307311,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=10.078 : [TargetSoldier,"",0.350179,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=10.078 : [TargetSoldier,"head_hit",0.230999,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=10.078 : [TargetSoldier,"body",1.52881,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=10.078 : [TargetSoldier,"hands",0.105206,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]
T=10.078 : [TargetSoldier,"legs",0.0211435,B 1-1-A:1 (Matthijs),"B_556x45_Ball"]

HandleHeal

Arma2 1.00.gif

Passed array: [unit, healer, healercanheal]