Module Event

This core module models the dispatching of DCS Events to subscribed MOOSE classes, following a given priority.

Banner Image


1) Event Handling Overview

Objects

Within a running mission, various DCS events occur. Units are dynamically created, crash, die, shoot stuff, get hit etc. This module provides a mechanism to dispatch those events occuring within your running mission, to the different objects orchestrating your mission.

Objects

Objects can subscribe to different events. The Event dispatcher will publish the received DCS events to the subscribed MOOSE objects, in a specified order. In this way, the subscribed MOOSE objects are kept in sync with your evolving running mission.

1.1) Event Dispatching

Objects

The _EVENTDISPATCHER object is automatically created within MOOSE, and handles the dispatching of DCS Events occurring in the simulator to the subscribed objects in the correct processing order.

Objects

There are 5 levels of kind of objects that the _EVENTDISPATCHER services:

  • _DATABASE object: The core of the MOOSE objects. Any object that is created, deleted or updated, is done in this database.
  • SET_ derived classes: Subsets of the _DATABASE object. These subsets are updated by the _EVENTDISPATCHER as the second priority.
  • UNIT objects: UNIT objects can subscribe to DCS events. Each DCS event will be directly published to teh subscribed UNIT object.
  • GROUP objects: GROUP objects can subscribe to DCS events. Each DCS event will be directly published to the subscribed GROUP object.
  • Any other object: Various other objects can subscribe to DCS events. Each DCS event triggered will be published to each subscribed object.

Objects

For most DCS events, the above order of updating will be followed.

Objects

But for some DCS events, the publishing order is reversed. This is due to the fact that objects need to be erased instead of added.

1.2) Event Handling

Objects

The actual event subscribing and handling is not facilitated through the _EVENTDISPATCHER, but it is done through the BASE class, UNIT class and GROUP class. The _EVENTDISPATCHER is a component that is quietly working in the background of MOOSE.

Objects

The BASE class provides methods to catch DCS Events. These are events that are triggered from within the DCS simulator, and handled through lua scripting. MOOSE provides an encapsulation to handle these events more efficiently.

1.2.1 Subscribe / Unsubscribe to DCS Events

At first, the mission designer will need to Subscribe to a specific DCS event for the class. So, when the DCS event occurs, the class will be notified of that event. There are two functions which you use to subscribe to or unsubscribe from an event.

1.3.2 Event Handling of DCS Events

Once the class is subscribed to the event, an Event Handling method on the object or class needs to be written that will be called when the DCS event occurs. The Event Handling method receives an Event#EVENTDATA structure, which contains a lot of information about the event that occurred.

Find below an example of the prototype how to write an event handling function for two units:

 local Tank1 = UNIT:FindByName( "Tank A" )
 local Tank2 = UNIT:FindByName( "Tank B" )

 -- Here we subscribe to the Dead events. So, if one of these tanks dies, the Tank1 or Tank2 objects will be notified.
 Tank1:HandleEvent( EVENTS.Dead )
 Tank2:HandleEvent( EVENTS.Dead )

 --- This function is an Event Handling function that will be called when Tank1 is Dead.
 -- @param Wrapper.Unit#UNIT self 
 -- @param Core.Event#EVENTDATA EventData
 function Tank1:OnEventDead( EventData )

   self:SmokeGreen()
 end

 --- This function is an Event Handling function that will be called when Tank2 is Dead.
 -- @param Wrapper.Unit#UNIT self 
 -- @param Core.Event#EVENTDATA EventData
 function Tank2:OnEventDead( EventData )

   self:SmokeBlue()
 end

1.3.3 Event Handling methods that are automatically called upon subscribed DCS events

Objects

The following list outlines which EVENTS item in the structure corresponds to which Event Handling method. Always ensure that your event handling methods align with the events being subscribed to, or nothing will be executed.

2) EVENTS type

The EVENTS structure contains names for all the different DCS events that objects can subscribe to using the Base#BASE.HandleEvent() method.

3) EVENTDATA type

The EVENTDATA contains all the fields that are populated with event information before an Event Handler method is being called by the event dispatcher. The Event Handler received the EVENTDATA object as a parameter, and can be used to investigate further the different events. There are basically 4 main categories of information stored in the EVENTDATA structure:

  • Initiator Unit data: Several fields documenting the initiator unit related to the event.
  • Target Unit data: Several fields documenting the target unit related to the event.
  • Weapon data: Certain events populate weapon information.
  • Place data: Certain events populate place information.

Find below an overview which events populate which information categories:

Objects

IMPORTANT NOTE: Some events can involve not just UNIT objects, but also STATIC objects!!! In that case the initiator or target unit fields will refer to a STATIC object! In case a STATIC object is involved, the documentation indicates which fields will and won't not be populated. The fields IniObjectCategory and TgtObjectCategory contain the indicator which kind of object is involved in the event. You can use the enumerator Object.Category.UNIT and Object.Category.STATIC to check on IniObjectCategory and TgtObjectCategory. Example code snippet:

 if Event.IniObjectCategory == Object.Category.UNIT then
  ...
 end
 if Event.IniObjectCategory == Object.Category.STATIC then
  ...
 end 

When a static object is involved in the event, the Group and Player fields won't be populated.


API CHANGE HISTORY

The underlying change log documents the API changes. Please read this carefully. The following notation is used:

  • Added parts are expressed in bold type face.
  • Removed parts are expressed in italic type face.

YYYY-MM-DD: CLASS:NewFunction( Params ) replaces CLASS:OldFunction( Params ) YYYY-MM-DD: CLASS:NewFunction( Params ) added

Hereby the change log:

  • 2016-02-07: Did a complete revision of the Event Handing API and underlying mechanisms.

AUTHORS and CONTRIBUTIONS

Contributions:

Authors:

Global(s)

EVENT
EVENTHANDLER
EVENTS

Type EVENT

EVENT.ClassID
EVENT.ClassName
EVENT:EventText(EventID)
EVENT.Events
EVENT:Init(EventID, EventClass)

Initializes the Events structure for the event

EVENT:New()
EVENT:OnBirth(EventFunction, EventClass)

Set a new listener for an SEVENTBIRTH event, and registers the unit born.

EVENT:OnBirthForTemplate(EventGroup, EventFunction, EventClass, EventTemplate)

Create an OnBirth event handler for a group

EVENT:OnBirthForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTBIRTH event.

EVENT:OnBirthRemove(EventClass)

Stop listening to SEVENTBIRTH event.

EVENT:OnCrash(EventFunction, EventClass)

Set a new listener for an SEVENTCRASH event.

EVENT:OnCrashForTemplate(EventGroup, EventFunction, EventClass, EventTemplate)

Create an OnCrash event handler for a group

EVENT:OnCrashForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTCRASH event.

EVENT:OnCrashRemove(EventClass)

Stop listening to SEVENTCRASH event.

EVENT:OnDead(EventFunction, EventClass)

Set a new listener for an SEVENTDEAD event.

EVENT:OnDeadForTemplate(EventGroup, EventFunction, EventClass, EventTemplate)

Create an OnDead event handler for a group

EVENT:OnDeadForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTDEAD event.

EVENT:OnDeadRemove(EventClass)

Stop listening to SEVENTDEAD event.

EVENT:OnEngineShutDownForTemplate(EventTemplate, EventFunction, EventClass)

Create an OnDead event handler for a group

EVENT:OnEngineShutDownForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTENGINE_SHUTDOWN event.

EVENT:OnEngineShutDownRemove(EventClass)

Stop listening to SEVENTENGINE_SHUTDOWN event.

EVENT:OnEngineStartUpForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTENGINE_STARTUP event.

EVENT:OnEngineStartUpRemove(EventClass)

Stop listening to SEVENTENGINE_STARTUP event.

EVENT:OnEventForTemplate(EventTemplate, EventFunction, EventClass, OnEventFunction)

Create an OnDead event handler for a group

EVENT:OnEventForUnit(EventDCSUnitName, EventFunction, EventClass, EventID)

Set a new listener for an SEVENTX event

EVENT:OnEventGeneric(EventFunction, EventClass, EventID)

Set a new listener for an SEVENTX event independent from a unit or a weapon.

EVENT:OnHit(EventFunction, EventClass)

Set a new listener for an SEVENTHIT event.

EVENT:OnHitForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTHIT event.

EVENT:OnHitRemove(EventClass)

Stop listening to SEVENTHIT event.

EVENT:OnLandForTemplate(EventTemplate, EventFunction, EventClass)
EVENT:OnLandForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTLAND event.

EVENT:OnLandRemove(EventClass)

Stop listening to SEVENTLAND event.

EVENT:OnPilotDead(EventFunction, EventClass)

Set a new listener for an SEVENTPILOT_DEAD event.

EVENT:OnPilotDeadForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTPILOT_DEAD event.

EVENT:OnPilotDeadRemove(EventClass)

Stop listening to SEVENTPILOT_DEAD event.

EVENT:OnPlayerEnterRemove(EventClass)

Stop listening to SEVENTPLAYERENTERUNIT event.

EVENT:OnPlayerEnterUnit(EventFunction, EventClass)

Set a new listener for an SEVENTPLAYERENTERUNIT event.

EVENT:OnPlayerLeaveRemove(EventClass)

Stop listening to SEVENTPLAYERLEAVEUNIT event.

EVENT:OnPlayerLeaveUnit(EventFunction, EventClass)
EVENT:OnShot(EventFunction, EventClass)
EVENT:OnShotForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTSHOT event for a unit.

EVENT:OnShotRemove(EventClass)

Stop listening to SEVENTSHOT event.

EVENT:OnTakeOffForTemplate(EventTemplate, EventFunction, EventClass)
EVENT:OnTakeOffForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTTAKEOFF event.

EVENT:OnTakeOffRemove(EventClass)

Stop listening to SEVENTTAKEOFF event.

EVENT:Remove(EventClass, EventID)

Removes an Events entry

EVENT:RemoveAll(EventObject)

Clears all event subscriptions for a Base#BASE derived object.

EVENT:RemoveForUnit(EventClass, EventID, UnitName)

Removes an Events entry for a Unit

EVENT:onEvent(Event)

Type EVENT.Events

EVENT.Events.IniUnit

Type EVENTDATA

EVENTDATA.IniCategory
  (UNIT) The category of the initiator.
EVENTDATA.IniCoalition
 (UNIT) The coalition of the initiator.
EVENTDATA.IniDCSGroup
  (UNIT) The initiating {Dcs.DCSGroup#Group}.
EVENTDATA.IniDCSGroupName

(UNIT) The initiating Group name.

EVENTDATA.IniDCSUnit
   (UNIT/STATIC) The initiating <a href="Dcs.DCSUnit.html##(Unit)">Dcs.DCSUnit#Unit</a> or <a href="Dcs.DCSStaticObject.html##(StaticObject)">Dcs.DCSStaticObject#StaticObject</a>.
EVENTDATA.IniDCSUnitName

(UNIT/STATIC) The initiating Unit name.

EVENTDATA.IniGroup
     (UNIT) The initiating MOOSE wrapper <a href="Wrapper.Group.html##(GROUP)">Wrapper.Group#GROUP</a> of the initiator Group object.
EVENTDATA.IniGroupName
 (UNIT) The initiating GROUP name (same as IniDCSGroupName).
EVENTDATA.IniObjectCategory

(UNIT/STATIC/SCENERY) The initiator object category ( Object.Category.UNIT or Object.Category.STATIC ).

EVENTDATA.IniPlayerName
(UNIT) The name of the initiating player in case the Unit is a client or player slot.
EVENTDATA.IniTypeName
  (UNIT) The type name of the initiator.
EVENTDATA.IniUnit
      (UNIT/STATIC) The initiating MOOSE wrapper <a href="Wrapper.Unit.html##(UNIT)">Wrapper.Unit#UNIT</a> of the initiator Unit object.
EVENTDATA.IniUnitName
  (UNIT/STATIC) The initiating UNIT name (same as IniDCSUnitName).
EVENTDATA.TgtCategory
  (UNIT) The category of the target.
EVENTDATA.TgtCoalition
 (UNIT) The coalition of the target.
EVENTDATA.TgtDCSGroup
  (UNIT) The target {Dcs.DCSGroup#Group}.
EVENTDATA.TgtDCSGroupName

(UNIT) The target Group name.

EVENTDATA.TgtDCSUnit
   (UNIT/STATIC) The target <a href="Dcs.DCSUnit.html##(Unit)">Dcs.DCSUnit#Unit</a> or <a href="Dcs.DCSStaticObject.html##(StaticObject)">Dcs.DCSStaticObject#StaticObject</a>.
EVENTDATA.TgtDCSUnitName

(UNIT/STATIC) The target Unit name.

EVENTDATA.TgtGroup
     (UNIT) The target MOOSE wrapper <a href="Wrapper.Group.html##(GROUP)">Wrapper.Group#GROUP</a> of the target Group object.
EVENTDATA.TgtGroupName
 (UNIT) The target GROUP name (same as TgtDCSGroupName).
EVENTDATA.TgtObjectCategory
  (UNIT/STATIC) The target object category ( Object.Category.UNIT or Object.Category.STATIC ).
EVENTDATA.TgtPlayerName
(UNIT) The name of the target player in case the Unit is a client or player slot.
EVENTDATA.TgtTypeName
  (UNIT) The type name of the target.
EVENTDATA.TgtUnit
      (UNIT/STATIC) The target MOOSE wrapper <a href="Wrapper.Unit.html##(UNIT)">Wrapper.Unit#UNIT</a> of the target Unit object.
EVENTDATA.TgtUnitName
  (UNIT/STATIC) The target UNIT name (same as TgtDCSUnitName).
EVENTDATA.Weapon
EVENTDATA.WeaponName
EVENTDATA.WeaponTgtDCSUnit
EVENTDATA.id

The identifier of the event.

EVENTDATA.initiator
    (UNIT/STATIC/SCENERY) The initiating <a href="Dcs.DCSUnit.html##(Unit)">Dcs.DCSUnit#Unit</a> or <a href="Dcs.DCSStaticObject.html##(StaticObject)">Dcs.DCSStaticObject#StaticObject</a>.
EVENTDATA.target
       (UNIT/STATIC) The target <a href="Dcs.DCSUnit.html##(Unit)">Dcs.DCSUnit#Unit</a> or <a href="Dcs.DCSStaticObject.html##(StaticObject)">Dcs.DCSStaticObject#StaticObject</a>.
EVENTDATA.weapon

The weapon used during the event.

Type EVENTHANDLER

EVENTHANDLER.ClassID
EVENTHANDLER.ClassName
EVENTHANDLER:New()

The EVENTHANDLER constructor

Type EVENTS

EVENTS.BaseCaptured
EVENTS.Birth
EVENTS.Crash
EVENTS.Dead
EVENTS.Ejection
EVENTS.EngineShutdown
EVENTS.EngineStartup
EVENTS.Hit
EVENTS.HumanFailure
EVENTS.Land
EVENTS.MissionEnd
EVENTS.MissionStart
EVENTS.PilotDead
EVENTS.PlayerComment
EVENTS.PlayerEnterUnit
EVENTS.PlayerLeaveUnit
EVENTS.Refueling
EVENTS.RefuelingStop
EVENTS.ShootingEnd
EVENTS.ShootingStart
EVENTS.Shot
EVENTS.Takeoff
EVENTS.TookControl

Global(s)

#EVENT EVENT
#EVENTHANDLER EVENTHANDLER
#EVENTS EVENTS

Type Event

Type EVENT

The EVENT structure

Field(s)

#number EVENT.ClassID
#string EVENT.ClassName
EVENT:EventText(EventID)

Parameter

  • EventID :

#EVENT.Events EVENT.Events
EVENT:Init(EventID, EventClass)

Initializes the Events structure for the event

Parameters

Return value

#EVENT.Events:

EVENT:New()
EVENT:OnBirth(EventFunction, EventClass)

Set a new listener for an SEVENTBIRTH event, and registers the unit born.

Parameters

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass :

Return value

#EVENT:

EVENT:OnBirthForTemplate(EventGroup, EventFunction, EventClass, EventTemplate)

Create an OnBirth event handler for a group

Parameters

  • Wrapper.Group#GROUP EventGroup :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • EventClass : The self instance of the class for which the event is.

  • EventTemplate :

Return value

#EVENT:

EVENT:OnBirthForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTBIRTH event.

Parameters

  • #string EventDCSUnitName : The id of the unit for the event to be handled.

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass :

Return value

#EVENT:

EVENT:OnBirthRemove(EventClass)

Stop listening to SEVENTBIRTH event.

Parameter

Return value

#EVENT:

EVENT:OnCrash(EventFunction, EventClass)

Set a new listener for an SEVENTCRASH event.

Parameters

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass :

Return value

#EVENT:

EVENT:OnCrashForTemplate(EventGroup, EventFunction, EventClass, EventTemplate)

Create an OnCrash event handler for a group

Parameters

  • Wrapper.Group#GROUP EventGroup :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • EventClass : The self instance of the class for which the event is.

  • EventTemplate :

Return value

#EVENT:

EVENT:OnCrashForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTCRASH event.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnCrashRemove(EventClass)

Stop listening to SEVENTCRASH event.

Parameter

Return value

#EVENT:

EVENT:OnDead(EventFunction, EventClass)

Set a new listener for an SEVENTDEAD event.

Parameters

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass :

Return value

#EVENT:

EVENT:OnDeadForTemplate(EventGroup, EventFunction, EventClass, EventTemplate)

Create an OnDead event handler for a group

Parameters

  • Wrapper.Group#GROUP EventGroup :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • EventClass : The self instance of the class for which the event is.

  • EventTemplate :

Return value

#EVENT:

EVENT:OnDeadForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTDEAD event.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnDeadRemove(EventClass)

Stop listening to SEVENTDEAD event.

Parameter

Return value

#EVENT:

EVENT:OnEngineShutDownForTemplate(EventTemplate, EventFunction, EventClass)

Create an OnDead event handler for a group

Parameters

  • #table EventTemplate :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnEngineShutDownForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTENGINE_SHUTDOWN event.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnEngineShutDownRemove(EventClass)

Stop listening to SEVENTENGINE_SHUTDOWN event.

Parameter

Return value

#EVENT:

EVENT:OnEngineStartUpForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTENGINE_STARTUP event.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnEngineStartUpRemove(EventClass)

Stop listening to SEVENTENGINE_STARTUP event.

Parameter

Return value

#EVENT:

EVENT:OnEventForTemplate(EventTemplate, EventFunction, EventClass, OnEventFunction)

Create an OnDead event handler for a group

Parameters

  • #table EventTemplate :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • EventClass : The instance of the class for which the event is.

  • #function OnEventFunction :

Return value

#EVENT:

EVENT:OnEventForUnit(EventDCSUnitName, EventFunction, EventClass, EventID)

Set a new listener for an SEVENTX event

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Core.Base#BASE EventClass : The self instance of the class for which the event is.

  • EventID :

Return value

#EVENT:

EVENT:OnEventGeneric(EventFunction, EventClass, EventID)

Set a new listener for an SEVENTX event independent from a unit or a weapon.

Parameters

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Core.Base#BASE EventClass : The self instance of the class for which the event is captured. When the event happens, the event process will be called in this class provided.

  • EventID :

Return value

#EVENT:

EVENT:OnHit(EventFunction, EventClass)

Set a new listener for an SEVENTHIT event.

Parameters

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnHitForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTHIT event.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnHitRemove(EventClass)

Stop listening to SEVENTHIT event.

Parameter

Return value

#EVENT:

EVENT:OnLandForTemplate(EventTemplate, EventFunction, EventClass)

Parameters

  • EventTemplate :

  • EventFunction :

  • EventClass :

EVENT:OnLandForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTLAND event.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnLandRemove(EventClass)

Stop listening to SEVENTLAND event.

Parameter

Return value

#EVENT:

EVENT:OnPilotDead(EventFunction, EventClass)

Set a new listener for an SEVENTPILOT_DEAD event.

Parameters

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass :

Return value

#EVENT:

EVENT:OnPilotDeadForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTPILOT_DEAD event.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnPilotDeadRemove(EventClass)

Stop listening to SEVENTPILOT_DEAD event.

Parameter

Return value

#EVENT:

EVENT:OnPlayerEnterRemove(EventClass)

Stop listening to SEVENTPLAYERENTERUNIT event.

Parameter

Return value

#EVENT:

EVENT:OnPlayerEnterUnit(EventFunction, EventClass)

Set a new listener for an SEVENTPLAYERENTERUNIT event.

Parameters

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnPlayerLeaveRemove(EventClass)

Stop listening to SEVENTPLAYERLEAVEUNIT event.

Parameter

Return value

#EVENT:

EVENT:OnPlayerLeaveUnit(EventFunction, EventClass)

Parameters

  • EventFunction :

  • EventClass :

EVENT:OnShot(EventFunction, EventClass)

Parameters

  • EventFunction :

  • EventClass :

EVENT:OnShotForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTSHOT event for a unit.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnShotRemove(EventClass)

Stop listening to SEVENTSHOT event.

Parameter

Return value

#EVENT:

EVENT:OnTakeOffForTemplate(EventTemplate, EventFunction, EventClass)

Parameters

  • EventTemplate :

  • EventFunction :

  • EventClass :

EVENT:OnTakeOffForUnit(EventDCSUnitName, EventFunction, EventClass)

Set a new listener for an SEVENTTAKEOFF event.

Parameters

  • #string EventDCSUnitName :

  • #function EventFunction : The function to be called when the event occurs for the unit.

  • Base#BASE EventClass : The self instance of the class for which the event is.

Return value

#EVENT:

EVENT:OnTakeOffRemove(EventClass)

Stop listening to SEVENTTAKEOFF event.

Parameter

Return value

#EVENT:

EVENT:Remove(EventClass, EventID)

Removes an Events entry

Parameters

Return value

#EVENT.Events:

EVENT:RemoveAll(EventObject)

Clears all event subscriptions for a Base#BASE derived object.

Parameter

EVENT:RemoveForUnit(EventClass, EventID, UnitName)

Removes an Events entry for a Unit

Parameters

Return value

#EVENT.Events:

EVENT:onEvent(Event)

Parameter

Type EVENT.Events

The Events structure

Field(s)

#number EVENT.Events.IniUnit

Type EVENTDATA

The Event structure Note that at the beginning of each field description, there is an indication which field will be populated depending on the object type involved in the Event:

  • A (Object.Category.)UNIT : A UNIT object type is involved in the Event.
  • A (Object.Category.)STATIC : A STATIC object type is involved in the Event.µ

Field(s)

Dcs.DCSUnit#Unit.Category EVENTDATA.IniCategory
  (UNIT) The category of the initiator.
Dcs.DCScoalition#coalition.side EVENTDATA.IniCoalition
 (UNIT) The coalition of the initiator.
Dcs.DCSGroup#Group EVENTDATA.IniDCSGroup
  (UNIT) The initiating {Dcs.DCSGroup#Group}.
#string EVENTDATA.IniDCSGroupName

(UNIT) The initiating Group name.

Dcs.DCSUnit#Unit EVENTDATA.IniDCSUnit
   (UNIT/STATIC) The initiating <a href="Dcs.DCSUnit.html##(Unit)">Dcs.DCSUnit#Unit</a> or <a href="Dcs.DCSStaticObject.html##(StaticObject)">Dcs.DCSStaticObject#StaticObject</a>.
#string EVENTDATA.IniDCSUnitName

(UNIT/STATIC) The initiating Unit name.

Wrapper.Group#GROUP EVENTDATA.IniGroup
     (UNIT) The initiating MOOSE wrapper <a href="Wrapper.Group.html##(GROUP)">Wrapper.Group#GROUP</a> of the initiator Group object.
#string EVENTDATA.IniGroupName
 (UNIT) The initiating GROUP name (same as IniDCSGroupName).
Dcs.DCSObject#Object.Category EVENTDATA.IniObjectCategory

(UNIT/STATIC/SCENERY) The initiator object category ( Object.Category.UNIT or Object.Category.STATIC ).

#string EVENTDATA.IniPlayerName
(UNIT) The name of the initiating player in case the Unit is a client or player slot.
#string EVENTDATA.IniTypeName
  (UNIT) The type name of the initiator.
Wrapper.Unit#UNIT EVENTDATA.IniUnit
      (UNIT/STATIC) The initiating MOOSE wrapper <a href="Wrapper.Unit.html##(UNIT)">Wrapper.Unit#UNIT</a> of the initiator Unit object.
#string EVENTDATA.IniUnitName
  (UNIT/STATIC) The initiating UNIT name (same as IniDCSUnitName).
Dcs.DCSUnit#Unit.Category EVENTDATA.TgtCategory
  (UNIT) The category of the target.
Dcs.DCScoalition#coalition.side EVENTDATA.TgtCoalition
 (UNIT) The coalition of the target.
Dcs.DCSGroup#Group EVENTDATA.TgtDCSGroup
  (UNIT) The target {Dcs.DCSGroup#Group}.
#string EVENTDATA.TgtDCSGroupName

(UNIT) The target Group name.

Dcs.DCSUnit#Unit EVENTDATA.TgtDCSUnit
   (UNIT/STATIC) The target <a href="Dcs.DCSUnit.html##(Unit)">Dcs.DCSUnit#Unit</a> or <a href="Dcs.DCSStaticObject.html##(StaticObject)">Dcs.DCSStaticObject#StaticObject</a>.
#string EVENTDATA.TgtDCSUnitName

(UNIT/STATIC) The target Unit name.

Wrapper.Group#GROUP EVENTDATA.TgtGroup
     (UNIT) The target MOOSE wrapper <a href="Wrapper.Group.html##(GROUP)">Wrapper.Group#GROUP</a> of the target Group object.
#string EVENTDATA.TgtGroupName
 (UNIT) The target GROUP name (same as TgtDCSGroupName).
Dcs.DCSObject#Object.Category EVENTDATA.TgtObjectCategory
  (UNIT/STATIC) The target object category ( Object.Category.UNIT or Object.Category.STATIC ).
#string EVENTDATA.TgtPlayerName
(UNIT) The name of the target player in case the Unit is a client or player slot.
#string EVENTDATA.TgtTypeName
  (UNIT) The type name of the target.
Wrapper.Unit#UNIT EVENTDATA.TgtUnit
      (UNIT/STATIC) The target MOOSE wrapper <a href="Wrapper.Unit.html##(UNIT)">Wrapper.Unit#UNIT</a> of the target Unit object.
#string EVENTDATA.TgtUnitName
  (UNIT/STATIC) The target UNIT name (same as TgtDCSUnitName).
EVENTDATA.Weapon
EVENTDATA.WeaponName
EVENTDATA.WeaponTgtDCSUnit
#number EVENTDATA.id

The identifier of the event.

Dcs.DCSUnit#Unit EVENTDATA.initiator
    (UNIT/STATIC/SCENERY) The initiating <a href="Dcs.DCSUnit.html##(Unit)">Dcs.DCSUnit#Unit</a> or <a href="Dcs.DCSStaticObject.html##(StaticObject)">Dcs.DCSStaticObject#StaticObject</a>.
Dcs.DCSUnit#Unit EVENTDATA.target
       (UNIT/STATIC) The target <a href="Dcs.DCSUnit.html##(Unit)">Dcs.DCSUnit#Unit</a> or <a href="Dcs.DCSStaticObject.html##(StaticObject)">Dcs.DCSStaticObject#StaticObject</a>.
EVENTDATA.weapon

The weapon used during the event.

Type EVENTHANDLER

The EVENTHANDLER structure

Field(s)

#number EVENTHANDLER.ClassID
#string EVENTHANDLER.ClassName
EVENTHANDLER:New()

The EVENTHANDLER constructor

Return value

#EVENTHANDLER:

Type EVENTS

The different types of events supported by MOOSE.

Use this structure to subscribe to events using the Base#BASE.HandleEvent() method.

Field(s)

EVENTS.BaseCaptured
EVENTS.Birth
EVENTS.Crash
EVENTS.Dead
EVENTS.Ejection
EVENTS.EngineShutdown
EVENTS.EngineStartup
EVENTS.Hit
EVENTS.HumanFailure
EVENTS.Land
EVENTS.MissionEnd
EVENTS.MissionStart
EVENTS.PilotDead
EVENTS.PlayerComment
EVENTS.PlayerEnterUnit
EVENTS.PlayerLeaveUnit
EVENTS.Refueling
EVENTS.RefuelingStop
EVENTS.ShootingEnd
EVENTS.ShootingStart
EVENTS.Shot
EVENTS.Takeoff
EVENTS.TookControl