VBS2: Event Handlers

From Bohemia Interactive Community

Jump to: navigation, search

Contents

Introduction

In addition to all the ArmA Event Handlers, the following event handlers can be used in VBS2.

Event Handler List

AmmoExplode, AmmoHit

When making an addon, these events can be configured within CfgAmmo. AmmoHit runs when the ammunition hits something (even if it ricochets), while AmmoExplode only runs when the ammo explodes or terminally impacts something.

Passed array: [bullet, shooter, position, velocity, selection, ammo, direction, exploded]

  • bullet: Object - Object that was fired
  • shooter: Object - Unit that fired shot
  • target: Object - Object that was hit, or objnull if the ground was hit
  • position: Position3D - Position the bullet impacted in model coords (if an object was hit), or position ASL if ground was hit
  • velocity: Vector - 3D speed at which bullet impacted
  • selection: Array - Array of Strings with named selection of the object that were hit.
  • ammo: Array - Ammo info: [hit value, indirect hit value, indirect hit range, explosive damage, ammo class name]
  • direction: Vector3D - vector that is orthogonal (perpendicular) to the surface struck. For example, if a wall was hit, vector would be pointing out of the wall at a 90 degree angle
  • exploded: Boolean - true if the ammo exploded / was destroyed, false if it ricocheted

AttachTo

Runs whenever an object is attached to another using the AttachTo scripting command. Also runs when an object is detached from another object.

Passed array: [attached, stuckto, position]

  • attached: Object - Object that was attached to another; or objNull if an object was detached
  • stuckto: Object - Object that had an object attached to it
  • position: Position3D - Position where object was attached to, in model coordinates

CargoChanged

Runs whenever a weapon or magazine is added/removed from a vehicle's cargo space. This could occur as a result of scripting commands (such as addWeaponCargo or clearMagazineCargo), or it could happen as a result of in-game actions such as AI taking gear from the vehicle.

Note that these eventhandlers will be removed from nearby objects when a player uses the inventory, therefore these events can not be considered 100% reliable.

Passed array: [object]

  • object: Object - Object that had its cargo changed

Delete

Runs just before an object is deleted. Some examples of what could delete an object: the deleteVehicle command, the RTE, or LVC Game.

Passed array: [object]

  • object: Object - Object that was deleted

Fired

This is the same as the ArmA fired eventhandler, however extra parameters are passed. Additionally, for addons, this eventhandler can be configured to run from within CfgWeapons, in addition to CfgVehicles.

Passed array: [unit, weapon, muzzle, mode, ammo, magazine, projectile]

  • unit: Object - Object the event handler is assigned to
  • weapon: String - Fired weapon
  • muzzle: String - Muzzle which was used
  • mode: String - Current mode of the fired weapon
  • ammo: String - Ammo used
  • magazine: String - Magazine which was used
  • projectile: Object - Object of the projectile that was shot

GetInMan

Triggered when a unit enters a vehicle. It does not trigger upon a change of positions within the same vehicle. Note that this event is attached to a person, not a vehicle like the GetIn event.

Global.

Passed array: [vehicle, position, unit]

  • vehicle: Object - Vehicle the event handler is assigned to
  • position: String - Can be either "driver", "gunner", "commander" or "cargo"
  • unit: Object - Unit that entered the vehicle

GetOutMan

Triggered when a unit gets out of a vehicle, works the same way as GetInMan.

Global.

HitPart

Runs when the object it was added to gets hit by a weapon. It returns the position and component that was hit on the object.

Passed array: [target, shooter, bullet, position, velocity, selection, ammo, direction, radius, surface, direct]

  • target: Object - Object that got fired at
  • shooter: Object - Unit that fired shot
  • bullet: Object - Object that was fired
  • position: Position3D - Position the bullet impacted
  • velocity: Vector - 3D speed at which bullet impacted
  • selection: Array - Array of Strings with named selection of the object that were hit.
  • ammo: Array - Ammo info: [hit value, indirect hit value, indirect hit range, explosive damage, ammo class name] OR, if there is no shot object: [impulse value on object collided with,0,0,0]
  • direction: Vector3D - vector that is orthogonal (perpendicular) to the surface struck. For example, if a wall was hit, vector would be pointing out of the wall at a 90 degree angle
  • radius: Number - radius (size) of component hit
  • surface: String - surface type struck
  • direct: Boolean - true if object was directly hit, false if it was hit by indirect/splash damage

LoadOutChanged

Runs whenever a weapon or magazine is added/removed from a unit or vehicle. This could occur as a result of scripting commands (such as addWeapon or removeMagazine), or it could happen as a result of in-game actions such as reloading magazines, dropping weapons, etc.

Note that these eventhandlers will be removed from nearby objects when a player uses the inventory, therefore these events can not be considered 100% reliable.

Passed array: [object]

  • object: Object - Object that had its equipment changed

Respawn

Runs when the object respawns.

Passed array: [new unit, old unit]

  • new unit: Object - The player's new unit, after respawning
  • old unit: Object - The player's old unit, before respawning

Suppressed

Runs each time a unit is suppressed (by incoming rounds).

Passed array: [unit, who fired, type, distance, position]

  • unit: Object - The unit that was suppressed
  • who fired: Object - Object that fired the suppressing round
  • type: String - Classname of the round that caused suppression
  • distance: Number - Nearest distance that round came to suppressed unit
  • position: Position3D - AGL position where round was closest to suppressed unit

TurnIn

Triggered when a unit "turns in" in a vehicle's turret position.

Passed array: [vehicle, unit, turretpath]

  • vehicle: Object - Vehicle the unit is in
  • unit: Object - Unit that is turning in
  • turretpath: Array - [] for driver

TurnOut

Triggered when a unit "turns out" in a vehicle's turret position.
Arguments as is TurnIn.

Personal tools
Buy ArmA now!