diff --git a/Moose Development/Moose/AI/AI_CAS.lua b/Moose Development/Moose/AI/AI_CAS.lua
index 583caa899..812af56a8 100644
--- a/Moose Development/Moose/AI/AI_CAS.lua
+++ b/Moose Development/Moose/AI/AI_CAS.lua
@@ -350,7 +350,7 @@ function AI_CAS_ZONE:onafterStart( Controllable, From, Event, To )
-- Call the parent Start event handler
self:GetParent(self).onafterStart( self, Controllable, From, Event, To )
- self:EventOnDead( self.OnDead )
+ self:HandleEvent( EVENTS.Dead, self.OnDead )
self:SetDetectionDeactivated() -- When not engaging, set the detection off.
end
diff --git a/Moose Development/Moose/AI/AI_Patrol.lua b/Moose Development/Moose/AI/AI_Patrol.lua
index ff059d709..58b6fc030 100644
--- a/Moose Development/Moose/AI/AI_Patrol.lua
+++ b/Moose Development/Moose/AI/AI_Patrol.lua
@@ -591,9 +591,9 @@ function AI_PATROL_ZONE:onafterStart( Controllable, From, Event, To )
self:__Status( 60 ) -- Check status status every 30 seconds.
self:SetDetectionActivated()
- self:EventOnPilotDead( self.OnPilotDead )
- self:EventOnCrash( self.OnCrash )
- self:EventOnEjection( self.OnEjection )
+ self:HandleEvent( EVENTS.PilotDead, self.OnPilotDead )
+ self:HandleEvent( EVENTS.Crash, self.OnCrash )
+ self:HandleEvent( EVENTS.Ejection, self.OnEjection )
Controllable:OptionROEHoldFire()
Controllable:OptionROTVertical()
diff --git a/Moose Development/Moose/Actions/Act_Account.lua b/Moose Development/Moose/Actions/Act_Account.lua
index 18854aa18..862079368 100644
--- a/Moose Development/Moose/Actions/Act_Account.lua
+++ b/Moose Development/Moose/Actions/Act_Account.lua
@@ -117,7 +117,7 @@ do -- ACT_ACCOUNT
-- @param #string To
function ACT_ACCOUNT:onafterStart( ProcessUnit, From, Event, To )
- self:EventOnDead( self.onfuncEventDead )
+ self:HandleEvent( EVENTS.Dead, self.onfuncEventDead )
self:__Wait( 1 )
end
diff --git a/Moose Development/Moose/Core/Base.lua b/Moose Development/Moose/Core/Base.lua
index a25db9edb..2eb7f97e9 100644
--- a/Moose Development/Moose/Core/Base.lua
+++ b/Moose Development/Moose/Core/Base.lua
@@ -59,53 +59,50 @@
--
-- 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.
--- Therefore, the BASE class exposes the following event handling functions:
--
--- * @{#BASE.EventOnBirth}(): Handle the birth of a new unit.
--- * @{#BASE.EventOnBaseCaptured}(): Handle the capturing of an airbase or a helipad.
--- * @{#BASE.EventOnCrash}(): Handle the crash of a unit.
--- * @{#BASE.EventOnDead}(): Handle the death of a unit.
--- * @{#BASE.EventOnEjection}(): Handle the ejection of a player out of an airplane.
--- * @{#BASE.EventOnEngineShutdown}(): Handle the shutdown of an engine.
--- * @{#BASE.EventOnEngineStartup}(): Handle the startup of an engine.
--- * @{#BASE.EventOnHit}(): Handle the hit of a shell to a unit.
--- * @{#BASE.EventOnHumanFailure}(): No a clue ...
--- * @{#BASE.EventOnLand}(): Handle the event when a unit lands.
--- * @{#BASE.EventOnMissionStart}(): Handle the start of the mission.
--- * @{#BASE.EventOnPilotDead}(): Handle the event when a pilot is dead.
--- * @{#BASE.EventOnPlayerComment}(): Handle the event when a player posts a comment.
--- * @{#BASE.EventOnPlayerEnterUnit}(): Handle the event when a player enters a unit.
--- * @{#BASE.EventOnPlayerLeaveUnit}(): Handle the event when a player leaves a unit.
--- * @{#BASE.EventOnBirthPlayerMissionEnd}(): Handle the event when a player ends the mission. (Not a clue what that does).
--- * @{#BASE.EventOnRefueling}(): Handle the event when a unit is refueling.
--- * @{#BASE.EventOnShootingEnd}(): Handle the event when a unit starts shooting (guns).
--- * @{#BASE.EventOnShootingStart}(): Handle the event when a unit ends shooting (guns).
--- * @{#BASE.EventOnShot}(): Handle the event when a unit shot a missile.
--- * @{#BASE.EventOnTakeOff}(): Handle the event when a unit takes off from a runway.
--- * @{#BASE.EventOnTookControl}(): Handle the event when a player takes control of a unit.
+-- ### 1.3.1 Subscribe / Unsubscribe to DCS Events
--
--- The EventOn() methods provide the @{Event#EVENTDATA} structure to the event handling function.
--- The @{Event#EVENTDATA} structure contains an enriched data set of information about the event being handled.
+-- 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.
--
--- Find below an example of the prototype how to write an event handling function:
+-- * @{#BASE.HandleEvent}(): Subscribe to a DCS Event.
+-- * @{#BASE.UnHandleEvent}(): Unsubscribe from a DCS 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:
--
--- CommandCenter:EventOnPlayerEnterUnit(
--- --- @param #COMMANDCENTER self
--- -- @param Core.Event#EVENTDATA EventData
--- function( self, EventData )
--- local PlayerUnit = EventData.IniUnit
--- for MissionID, Mission in pairs( self:GetMissions() ) do
--- local Mission = Mission -- Tasking.Mission#MISSION
--- Mission:JoinUnit( PlayerUnit )
--- Mission:ReportDetails()
--- end
--- end
--- )
+-- 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
--
--- Note the function( self, EventData ). It takes two parameters:
--
--- * self = the object that is handling the EventOnPlayerEnterUnit.
--- * EventData = the @{Event#EVENTDATA} structure, containing more information of the Event.
+--
+-- See the @{Event} module for more information about event handling.
--
-- ## 1.4) Class identification methods
--
@@ -288,389 +285,202 @@ function BASE:GetClassID()
return self.ClassID
end
---- Get the Class @{Event} processing Priority.
--- The Event processing Priority is a number from 1 to 10,
--- reflecting the order of the classes subscribed to the Event to be processed.
--- @param #BASE self
--- @return #number The @{Event} processing Priority.
-function BASE:GetEventPriority()
- return self._Private.EventPriority or 5
-end
+do -- Event Handling
---- Set the Class @{Event} processing Priority.
--- The Event processing Priority is a number from 1 to 10,
--- reflecting the order of the classes subscribed to the Event to be processed.
--- @param #BASE self
--- @param #number EventPriority The @{Event} processing Priority.
--- @return self
-function BASE:SetEventPriority( EventPriority )
- self._Private.EventPriority = EventPriority
-end
-
-
---- Set a new listener for the class.
--- @param self
--- @param Dcs.DCSTypes#Event Event
--- @param #function EventFunction
--- @return #BASE
-function BASE:AddEvent( Event, EventFunction )
- self:F( Event )
-
- self.Events[#self.Events+1] = {}
- self.Events[#self.Events].Event = Event
- self.Events[#self.Events].EventFunction = EventFunction
- self.Events[#self.Events].EventEnabled = false
-
- return self
-end
-
---- Returns the event dispatcher
--- @param #BASE self
--- @return Core.Event#EVENT
-function BASE:Event()
-
- return _EVENTDISPATCHER
-end
-
---- Remove all subscribed events
--- @param #BASE self
--- @return #BASE
-function BASE:EventRemoveAll()
-
- _EVENTDISPATCHER:RemoveAll( self )
+ --- Returns the event dispatcher
+ -- @param #BASE self
+ -- @return Core.Event#EVENT
+ function BASE:EventDispatcher()
- return self
-end
-
---- Subscribe to a S_EVENT\_SHOT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShot( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOT )
+ return _EVENTDISPATCHER
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_HIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnHit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_HIT )
- return self
-end
-
---- Subscribe to a S_EVENT\_TAKEOFF event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnTakeOff( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_TAKEOFF )
+ --- Get the Class @{Event} processing Priority.
+ -- The Event processing Priority is a number from 1 to 10,
+ -- reflecting the order of the classes subscribed to the Event to be processed.
+ -- @param #BASE self
+ -- @return #number The @{Event} processing Priority.
+ function BASE:GetEventPriority()
+ return self._Private.EventPriority or 5
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_LAND event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnLand( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_LAND )
+ --- Set the Class @{Event} processing Priority.
+ -- The Event processing Priority is a number from 1 to 10,
+ -- reflecting the order of the classes subscribed to the Event to be processed.
+ -- @param #BASE self
+ -- @param #number EventPriority The @{Event} processing Priority.
+ -- @return self
+ function BASE:SetEventPriority( EventPriority )
+ self._Private.EventPriority = EventPriority
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_CRASH event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnCrash( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_CRASH )
+ --- Remove all subscribed events
+ -- @param #BASE self
+ -- @return #BASE
+ function BASE:EventRemoveAll()
- return self
-end
-
---- Subscribe to a S_EVENT\_EJECTION event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEjection( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_EJECTION )
+ self:EventDispatcher():RemoveAll( self )
+
+ return self
+ end
- return self
-end
-
-
---- Subscribe to a S_EVENT\_REFUELING event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnRefueling( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_REFUELING )
+ --- Subscribe to a DCS Event.
+ -- @param #BASE self
+ -- @param Core.Event#EVENTS Event
+ -- @param #function EventFunction (optional) The function to be called when the event occurs for the unit.
+ -- @return #BASE
+ function BASE:HandleEvent( Event, EventFunction )
- return self
-end
-
---- Subscribe to a S_EVENT\_DEAD event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnDead( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_DEAD )
+ self:EventDispatcher():OnEventGeneric( EventFunction, self, Event )
+
+ return self
+ end
- return self
-end
-
---- Subscribe to a S_EVENT_PILOT\_DEAD event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPilotDead( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PILOT_DEAD )
+ --- UnSubscribe to a DCS event.
+ -- @param #BASE self
+ -- @param Core.Event#EVENTS Event
+ -- @return #BASE
+ function BASE:UnHandleEvent( Event )
- return self
-end
-
---- Subscribe to a S_EVENT_BASE\_CAPTURED event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnBaseCaptured( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_BASE_CAPTURED )
+ self:EventDispatcher():Remove( self, Event )
+
+ return self
+ end
- return self
-end
-
---- Subscribe to a S_EVENT_MISSION\_START event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnMissionStart( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_MISSION_START )
+ -- Event handling function prototypes
- return self
+ --- Occurs whenever any unit in a mission fires a weapon. But not any machine gun or autocannon based weapon, those are handled by EVENT.ShootingStart.
+ -- @function [parent=#BASE] OnEventShot
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs whenever an object is hit by a weapon.
+ -- initiator : The unit object the fired the weapon
+ -- weapon: Weapon object that hit the target
+ -- target: The Object that was hit.
+ -- @function [parent=#BASE] OnEventHit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft takes off from an airbase, farp, or ship.
+ -- initiator : The unit that tookoff
+ -- place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships
+ -- @function [parent=#BASE] OnEventTakeoff
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft lands at an airbase, farp or ship
+ -- initiator : The unit that has landed
+ -- place: Object that the unit landed on. Can be an Airbase Object, FARP, or Ships
+ -- @function [parent=#BASE] OnEventLand
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft crashes into the ground and is completely destroyed.
+ -- initiator : The unit that has crashed
+ -- @function [parent=#BASE] OnEventCrash
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a pilot ejects from an aircraft
+ -- initiator : The unit that has ejected
+ -- @function [parent=#BASE] OnEventEjection
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft connects with a tanker and begins taking on fuel.
+ -- initiator : The unit that is receiving fuel.
+ -- @function [parent=#BASE] OnEventRefueling
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an object is completely destroyed.
+ -- initiator : The unit that is was destroyed.
+ -- @function [parent=#BASE] OnEvent
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when the pilot of an aircraft is killed. Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane.
+ -- initiator : The unit that the pilot has died in.
+ -- @function [parent=#BASE] OnEventPilotDead
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a ground unit captures either an airbase or a farp.
+ -- initiator : The unit that captured the base
+ -- place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.
+ -- @function [parent=#BASE] OnEventBaseCaptured
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a mission starts
+ -- @function [parent=#BASE] OnEventMissionStart
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a mission ends
+ -- @function [parent=#BASE] OnEventMissionEnd
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft is finished taking fuel.
+ -- initiator : The unit that was receiving fuel.
+ -- @function [parent=#BASE] OnEventRefuelingStop
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any object is spawned into the mission.
+ -- initiator : The unit that was spawned
+ -- @function [parent=#BASE] OnEventBirth
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any system fails on a human controlled aircraft.
+ -- initiator : The unit that had the failure
+ -- @function [parent=#BASE] OnEventHumanFailure
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft starts its engines.
+ -- initiator : The unit that is starting its engines.
+ -- @function [parent=#BASE] OnEventEngineStartup
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft shuts down its engines.
+ -- initiator : The unit that is stopping its engines.
+ -- @function [parent=#BASE] OnEventEngineShutdown
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any player assumes direct control of a unit.
+ -- initiator : The unit that is being taken control of.
+ -- @function [parent=#BASE] OnEventPlayerEnterUnit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any player relieves control of a unit to the AI.
+ -- initiator : The unit that the player left.
+ -- @function [parent=#BASE] OnEventPlayerLeaveUnit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any unit begins firing a weapon that has a high rate of fire. Most common with aircraft cannons (GAU-8), autocannons, and machine guns.
+ -- initiator : The unit that is doing the shooing.
+ -- target: The unit that is being targeted.
+ -- @function [parent=#BASE] OnEventShootingStart
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any unit stops firing its weapon. Event will always correspond with a shooting start event.
+ -- initiator : The unit that was doing the shooing.
+ -- @function [parent=#BASE] OnEventShootingEnd
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
end
-
---- Subscribe to a S_EVENT_MISSION\_END event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerMissionEnd( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_MISSION_END )
-
- return self
-end
-
---- Subscribe to a S_EVENT_TOOK\_CONTROL event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnTookControl( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_TOOK_CONTROL )
-
- return self
-end
-
---- Subscribe to a S_EVENT_REFUELING\_STOP event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnRefuelingStop( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_REFUELING_STOP )
-
- return self
-end
-
---- Subscribe to a S_EVENT\_BIRTH event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnBirth( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_BIRTH )
-
- return self
-end
-
---- Subscribe to a S_EVENT_HUMAN\_FAILURE event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnHumanFailure( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_HUMAN_FAILURE )
-
- return self
-end
-
---- Subscribe to a S_EVENT_ENGINE\_STARTUP event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEngineStartup( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_ENGINE_STARTUP )
-
- return self
-end
-
---- Subscribe to a S_EVENT_ENGINE\_SHUTDOWN event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEngineShutdown( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_ENGINE_SHUTDOWN )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER_ENTER\_UNIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerEnterUnit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_ENTER_UNIT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER_LEAVE\_UNIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerLeaveUnit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_LEAVE_UNIT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER\_COMMENT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerComment( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_COMMENT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_SHOOTING\_START event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShootingStart( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOOTING_START )
-
- return self
-end
-
---- Subscribe to a S_EVENT_SHOOTING\_END event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShootingEnd( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOOTING_END )
-
- return self
-end
-
-
-
-
-
-
-
---- Enable the event listeners for the class.
--- @param #BASE self
--- @return #BASE
-function BASE:EnableEvents()
- self:F( #self.Events )
-
- for EventID, Event in pairs( self.Events ) do
- Event.Self = self
- Event.EventEnabled = true
- end
- self.Events.Handler = world.addEventHandler( self )
-
- return self
-end
-
-
---- Disable the event listeners for the class.
--- @param #BASE self
--- @return #BASE
-function BASE:DisableEvents()
- self:F()
-
- world.removeEventHandler( self )
- for EventID, Event in pairs( self.Events ) do
- Event.Self = nil
- Event.EventEnabled = false
- end
-
- return self
-end
-
-
-local BaseEventCodes = {
- "S_EVENT_SHOT",
- "S_EVENT_HIT",
- "S_EVENT_TAKEOFF",
- "S_EVENT_LAND",
- "S_EVENT_CRASH",
- "S_EVENT_EJECTION",
- "S_EVENT_REFUELING",
- "S_EVENT_DEAD",
- "S_EVENT_PILOT_DEAD",
- "S_EVENT_BASE_CAPTURED",
- "S_EVENT_MISSION_START",
- "S_EVENT_MISSION_END",
- "S_EVENT_TOOK_CONTROL",
- "S_EVENT_REFUELING_STOP",
- "S_EVENT_BIRTH",
- "S_EVENT_HUMAN_FAILURE",
- "S_EVENT_ENGINE_STARTUP",
- "S_EVENT_ENGINE_SHUTDOWN",
- "S_EVENT_PLAYER_ENTER_UNIT",
- "S_EVENT_PLAYER_LEAVE_UNIT",
- "S_EVENT_PLAYER_COMMENT",
- "S_EVENT_SHOOTING_START",
- "S_EVENT_SHOOTING_END",
- "S_EVENT_MAX",
-}
---onEvent( {[1]="S_EVENT_BIRTH",[2]={["subPlace"]=5,["time"]=0,["initiator"]={["id_"]=16884480,},["place"]={["id_"]=5000040,},["id"]=15,["IniUnitName"]="US F-15C@RAMP-Air Support Mountains#001-01",},}
--- Event = {
--- id = enum world.event,
--- time = Time,
--- initiator = Unit,
--- target = Unit,
--- place = Unit,
--- subPlace = enum world.BirthPlace,
--- weapon = Weapon
--- }
--- Creation of a Birth Event.
-- @param #BASE self
diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua
index 4c3f48540..8165bbf9d 100644
--- a/Moose Development/Moose/Core/Database.lua
+++ b/Moose Development/Moose/Core/Database.lua
@@ -86,13 +86,13 @@ function DATABASE:New()
self:SetEventPriority( 1 )
- _EVENTDISPATCHER:OnBirth( self._EventOnBirth, self )
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
+ self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
-- Follow alive players and clients
- _EVENTDISPATCHER:OnPlayerEnterUnit( self._EventOnPlayerEnterUnit, self )
- _EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventOnPlayerLeaveUnit, self )
+ self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit )
+ self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit )
self:_RegisterTemplates()
self:_RegisterGroupsAndUnits()
diff --git a/Moose Development/Moose/Core/Event.lua b/Moose Development/Moose/Core/Event.lua
index 7f092d571..cd5a3a24c 100644
--- a/Moose Development/Moose/Core/Event.lua
+++ b/Moose Development/Moose/Core/Event.lua
@@ -33,58 +33,149 @@ EVENT = {
ClassID = 0,
}
-local _EVENTCODES = {
- "S_EVENT_SHOT",
- "S_EVENT_HIT",
- "S_EVENT_TAKEOFF",
- "S_EVENT_LAND",
- "S_EVENT_CRASH",
- "S_EVENT_EJECTION",
- "S_EVENT_REFUELING",
- "S_EVENT_DEAD",
- "S_EVENT_PILOT_DEAD",
- "S_EVENT_BASE_CAPTURED",
- "S_EVENT_MISSION_START",
- "S_EVENT_MISSION_END",
- "S_EVENT_TOOK_CONTROL",
- "S_EVENT_REFUELING_STOP",
- "S_EVENT_BIRTH",
- "S_EVENT_HUMAN_FAILURE",
- "S_EVENT_ENGINE_STARTUP",
- "S_EVENT_ENGINE_SHUTDOWN",
- "S_EVENT_PLAYER_ENTER_UNIT",
- "S_EVENT_PLAYER_LEAVE_UNIT",
- "S_EVENT_PLAYER_COMMENT",
- "S_EVENT_SHOOTING_START",
- "S_EVENT_SHOOTING_END",
- "S_EVENT_MAX",
+EVENTS = {
+ Shot = world.event.S_EVENT_SHOT,
+ Hit = world.event.S_EVENT_HIT,
+ Takeoff = world.event.S_EVENT_TAKEOFF,
+ Land = world.event.S_EVENT_LAND,
+ Crash = world.event.S_EVENT_CRASH,
+ Ejection = world.event.S_EVENT_EJECTION,
+ Refueling = world.event.S_EVENT_REFUELING,
+ Dead = world.event.S_EVENT_DEAD,
+ PilotDead = world.event.S_EVENT_PILOT_DEAD,
+ BaseCaptured = world.event.S_EVENT_BASE_CAPTURED,
+ MissionStart = world.event.S_EVENT_MISSION_START,
+ MissionEnd = world.event.S_EVENT_MISSION_END,
+ TookControl = world.event.S_EVENT_TOOK_CONTROL,
+ RefuelingStop = world.event.S_EVENT_REFUELING_STOP,
+ Birth = world.event.S_EVENT_BIRTH,
+ HumanFailure = world.event.S_EVENT_HUMAN_FAILURE,
+ EngineStartup = world.event.S_EVENT_ENGINE_STARTUP,
+ EngineShutdown = world.event.S_EVENT_ENGINE_SHUTDOWN,
+ PlayerEnterUnit = world.event.S_EVENT_PLAYER_ENTER_UNIT,
+ PlayerLeaveUnit = world.event.S_EVENT_PLAYER_LEAVE_UNIT,
+ PlayerComment = world.event.S_EVENT_PLAYER_COMMENT,
+ ShootingStart = world.event.S_EVENT_SHOOTING_START,
+ ShootingEnd = world.event.S_EVENT_SHOOTING_END,
}
-local _EVENTORDER = {
- [world.event.S_EVENT_SHOT] = 1,
- [world.event.S_EVENT_HIT] = 1,
- [world.event.S_EVENT_TAKEOFF] = 1,
- [world.event.S_EVENT_LAND] = 1,
- [world.event.S_EVENT_CRASH] = -1,
- [world.event.S_EVENT_EJECTION] = -1,
- [world.event.S_EVENT_REFUELING] = 1,
- [world.event.S_EVENT_DEAD] = -1,
- [world.event.S_EVENT_PILOT_DEAD] = -1,
- [world.event.S_EVENT_BASE_CAPTURED] = 1,
- [world.event.S_EVENT_MISSION_START] = 1,
- [world.event.S_EVENT_MISSION_END] = -1,
- [world.event.S_EVENT_TOOK_CONTROL] = 1,
- [world.event.S_EVENT_REFUELING_STOP] = 1,
- [world.event.S_EVENT_BIRTH] = 1,
- [world.event.S_EVENT_HUMAN_FAILURE] = 1,
- [world.event.S_EVENT_ENGINE_STARTUP] = 1,
- [world.event.S_EVENT_ENGINE_SHUTDOWN] = 1,
- [world.event.S_EVENT_PLAYER_ENTER_UNIT] = 1,
- [world.event.S_EVENT_PLAYER_LEAVE_UNIT] = -1,
- [world.event.S_EVENT_PLAYER_COMMENT] = 1,
- [world.event.S_EVENT_SHOOTING_START] = 1,
- [world.event.S_EVENT_SHOOTING_END] = 1,
- [world.event.S_EVENT_MAX] = 1,
+
+local _EVENTMETA = {
+ [world.event.S_EVENT_SHOT] = {
+ Order = 1,
+ Event = "OnEventShot",
+ Text = "S_EVENT_SHOT"
+ },
+ [world.event.S_EVENT_HIT] = {
+ Order = 1,
+ Event = "OnEventHit",
+ Text = "S_EVENT_HIT"
+ },
+ [world.event.S_EVENT_TAKEOFF] = {
+ Order = 1,
+ Event = "OnEventTakeOff",
+ Text = "S_EVENT_TAKEOFF"
+ },
+ [world.event.S_EVENT_LAND] = {
+ Order = 1,
+ Event = "OnEventLand",
+ Text = "S_EVENT_LAND"
+ },
+ [world.event.S_EVENT_CRASH] = {
+ Order = -1,
+ Event = "OnEventCrash",
+ Text = "S_EVENT_CRASH"
+ },
+ [world.event.S_EVENT_EJECTION] = {
+ Order = 1,
+ Event = "OnEventEjection",
+ Text = "S_EVENT_EJECTION"
+ },
+ [world.event.S_EVENT_REFUELING] = {
+ Order = 1,
+ Event = "OnEventRefueling",
+ Text = "S_EVENT_REFUELING"
+ },
+ [world.event.S_EVENT_DEAD] = {
+ Order = -1,
+ Event = "OnEventDead",
+ Text = "S_EVENT_DEAD"
+ },
+ [world.event.S_EVENT_PILOT_DEAD] = {
+ Order = 1,
+ Event = "OnEventPilotDead",
+ Text = "S_EVENT_PILOT_DEAD"
+ },
+ [world.event.S_EVENT_BASE_CAPTURED] = {
+ Order = 1,
+ Event = "OnEventBaseCaptured",
+ Text = "S_EVENT_BASE_CAPTURED"
+ },
+ [world.event.S_EVENT_MISSION_START] = {
+ Order = 1,
+ Event = "OnEventMissionStart",
+ Text = "S_EVENT_MISSION_START"
+ },
+ [world.event.S_EVENT_MISSION_END] = {
+ Order = 1,
+ Event = "OnEventMissionEnd",
+ Text = "S_EVENT_MISSION_END"
+ },
+ [world.event.S_EVENT_TOOK_CONTROL] = {
+ Order = 1,
+ Event = "OnEventTookControl",
+ Text = "S_EVENT_TOOK_CONTROL"
+ },
+ [world.event.S_EVENT_REFUELING_STOP] = {
+ Order = 1,
+ Event = "OnEventRefuelingStop",
+ Text = "S_EVENT_REFUELING_STOP"
+ },
+ [world.event.S_EVENT_BIRTH] = {
+ Order = 1,
+ Event = "OnEventBirth",
+ Text = "S_EVENT_BIRTH"
+ },
+ [world.event.S_EVENT_HUMAN_FAILURE] = {
+ Order = 1,
+ Event = "OnEventHumanFailure",
+ Text = "S_EVENT_HUMAN_FAILURE"
+ },
+ [world.event.S_EVENT_ENGINE_STARTUP] = {
+ Order = 1,
+ Event = "OnEventEngineStartup",
+ Text = "S_EVENT_ENGINE_STARTUP"
+ },
+ [world.event.S_EVENT_ENGINE_SHUTDOWN] = {
+ Order = 1,
+ Event = "OnEventEngineShutdown",
+ Text = "S_EVENT_ENGINE_SHUTDOWN"
+ },
+ [world.event.S_EVENT_PLAYER_ENTER_UNIT] = {
+ Order = 1,
+ Event = "OnEventPlayerEnterUnit",
+ Text = "S_EVENT_PLAYER_ENTER_UNIT"
+ },
+ [world.event.S_EVENT_PLAYER_LEAVE_UNIT] = {
+ Order = -1,
+ Event = "OnEventPlayerLeaveUnit",
+ Text = "S_EVENT_PLAYER_LEAVE_UNIT"
+ },
+ [world.event.S_EVENT_PLAYER_COMMENT] = {
+ Order = 1,
+ Event = "OnEventPlayerComment",
+ Text = "S_EVENT_PLAYER_COMMENT"
+ },
+ [world.event.S_EVENT_SHOOTING_START] = {
+ Order = 1,
+ Event = "OnEventShootingStart",
+ Text = "S_EVENT_SHOOTING_START"
+ },
+ [world.event.S_EVENT_SHOOTING_END] = {
+ Order = 1,
+ Event = "OnEventShootingEnd",
+ Text = "S_EVENT_SHOOTING_END"
+ },
}
--- The Event structure
@@ -122,7 +213,7 @@ end
function EVENT:EventText( EventID )
- local EventText = _EVENTCODES[EventID]
+ local EventText = _EVENTMETA[EventID].Text
return EventText
end
@@ -134,7 +225,7 @@ end
-- @param Core.Base#BASE EventClass
-- @return #EVENT.Events
function EVENT:Init( EventID, EventClass )
- self:F3( { _EVENTCODES[EventID], EventClass } )
+ self:F3( { _EVENTMETA[EventID].Text, EventClass } )
if not self.Events[EventID] then
-- Create a WEAK table to ensure that the garbage collector is cleaning the event links when the object usage is cleaned.
@@ -159,13 +250,27 @@ end
-- @param Dcs.DCSWorld#world.event EventID
-- @return #EVENT.Events
function EVENT:Remove( EventClass, EventID )
- self:F3( { EventClass, _EVENTCODES[EventID] } )
+ self:F3( { EventClass, _EVENTMETA[EventID].Text } )
local EventClass = EventClass
local EventPriority = EventClass:GetEventPriority()
self.Events[EventID][EventPriority][EventClass] = nil
end
+--- Removes an Events entry for a Unit
+-- @param #EVENT self
+-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
+-- @param Dcs.DCSWorld#world.event EventID
+-- @return #EVENT.Events
+function EVENT:RemoveForUnit( UnitName, EventClass, EventID )
+ self:F3( { EventClass, _EVENTMETA[EventID].Text } )
+
+ local EventClass = EventClass
+ local EventPriority = EventClass:GetEventPriority()
+ local Event = self.Events[EventID][EventPriority][EventClass]
+ Event.IniUnit[UnitName] = nil
+end
+
--- Clears all event subscriptions for a @{Base#BASE} derived object.
-- @param #EVENT self
-- @param Core.Base#BASE EventObject
@@ -809,11 +914,11 @@ function EVENT:onEvent( Event )
--Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
end
- local PriorityOrder = _EVENTORDER[Event.id]
+ local PriorityOrder = _EVENTMETA[Event.id].Order
local PriorityBegin = PriorityOrder == -1 and 5 or 1
local PriorityEnd = PriorityOrder == -1 and 1 or 5
- self:E( { _EVENTCODES[Event.id], Event, Event.IniDCSUnitName, Event.TgtDCSUnitName, PriorityOrder } )
+ self:E( { _EVENTMETA[Event.id].Text, Event, Event.IniDCSUnitName, Event.TgtDCSUnitName, PriorityOrder } )
for EventPriority = PriorityBegin, PriorityEnd, PriorityOrder do
@@ -824,19 +929,71 @@ function EVENT:onEvent( Event )
-- If the EventData is for a UNIT, the call directly the EventClass EventFunction for that UNIT.
if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then
- self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), ", Unit ", Event.IniUnitName, EventPriority } )
- Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
- local Result, Value = xpcall( function() return EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventData.IniUnit[Event.IniDCSUnitName].EventClass, Event ) end, ErrorHandler )
- --EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventData.IniUnit[Event.IniDCSUnitName].EventClass, Event )
+
+ -- First test if a EventFunction is Set, otherwise search for the default function
+ if EventData.IniUnit[Event.IniDCSUnitName].EventFunction then
+
+ self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), ", Unit ", Event.IniUnitName, EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventClass, Event )
+ end, ErrorHandler )
+
+ else
+
+ -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
+ local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ]
+ if EventFunction and type( EventFunction ) == "function" then
+
+ -- Now call the default event function.
+ self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ end
+
+ end
+
else
+
-- If the EventData is not bound to a specific unit, then call the EventClass EventFunction.
-- Note that here the EventFunction will need to implement and determine the logic for the relevant source- or target unit, or weapon.
if Event.IniDCSUnit and not EventData.IniUnit then
+
if EventClass == EventData.EventClass then
- self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), EventPriority } )
- Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
- local Result, Value = xpcall( function() return EventData.EventFunction( EventData.EventClass, Event ) end, ErrorHandler )
- --EventData.EventFunction( EventData.EventClass, Event )
+
+ -- First test if a EventFunction is Set, otherwise search for the default function
+ if EventData.EventFunction then
+
+ -- There is an EventFunction defined, so call the EventFunction.
+ self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventData.EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ else
+
+ -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
+ local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ]
+ if EventFunction and type( EventFunction ) == "function" then
+
+ -- Now call the default event function.
+ self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ end
+ end
end
end
end
@@ -844,7 +1001,7 @@ function EVENT:onEvent( Event )
end
end
else
- self:E( { _EVENTCODES[Event.id], Event } )
+ self:E( { _EVENTMETA[Event.id].Text, Event } )
end
end
diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua
index 0966b39c8..a069e6138 100644
--- a/Moose Development/Moose/Core/Set.lua
+++ b/Moose Development/Moose/Core/Set.lua
@@ -453,13 +453,13 @@ function SET_BASE:_FilterStart()
end
end
- _EVENTDISPATCHER:OnBirth( self._EventOnBirth, self )
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
+ self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
-- Follow alive players and clients
- _EVENTDISPATCHER:OnPlayerEnterUnit( self._EventOnPlayerEnterUnit, self )
- _EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventOnPlayerLeaveUnit, self )
+ self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit )
+ self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit )
return self
@@ -470,9 +470,9 @@ end
-- @return #SET_BASE self
function SET_BASE:FilterStop()
- _EVENTDISPATCHER:OnBirthRemove( self )
- _EVENTDISPATCHER:OnDeadRemove( self )
- _EVENTDISPATCHER:OnCrashRemove( self )
+ self:UnHandleEvent( EVENTS.Birth )
+ self:UnHandleEvent( EVENTS.Dead )
+ self:UnHandleEvent( EVENTS.Crash )
return self
end
diff --git a/Moose Development/Moose/Functional/Scoring.lua b/Moose Development/Moose/Functional/Scoring.lua
index 32e4a21f2..e2a6a5f46 100644
--- a/Moose Development/Moose/Functional/Scoring.lua
+++ b/Moose Development/Moose/Functional/Scoring.lua
@@ -51,9 +51,9 @@ function SCORING:New( GameName )
end
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnHit( self._EventOnHit, self )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Hit, self._EventOnHit )
--self.SchedulerId = routines.scheduleFunction( SCORING._FollowPlayersScheduled, { self }, 0, 5 )
self.SchedulerId = SCHEDULER:New( self, self._FollowPlayersScheduled, {}, 0, 5 )
diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua
index 83b5d3581..967aa84b1 100644
--- a/Moose Development/Moose/Tasking/CommandCenter.lua
+++ b/Moose Development/Moose/Tasking/CommandCenter.lua
@@ -66,7 +66,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
self.Missions = {}
- self:EventOnBirth(
+ self:HandleEvent( EVENTS.Birth,
--- @param #COMMANDCENTER self
--- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -94,7 +94,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- - Set the correct menu.
-- - Assign the PlayerUnit to the Task if required.
-- - Send a message to the other players in the group that this player has joined.
- self:EventOnPlayerEnterUnit(
+ self:HandleEvent( EVENTS.PlayerEnterUnit,
--- @param #COMMANDCENTER self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -111,7 +111,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- Handle when a player leaves a slot and goes back to spectators ...
-- The PlayerUnit will be UnAssigned from the Task.
-- When there is no Unit left running the Task, the Task goes into Abort...
- self:EventOnPlayerLeaveUnit(
+ self:HandleEvent( EVENTS.PlayerLeaveUnit,
--- @param #TASK self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -126,7 +126,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- Handle when a player leaves a slot and goes back to spectators ...
-- The PlayerUnit will be UnAssigned from the Task.
-- When there is no Unit left running the Task, the Task goes into Abort...
- self:EventOnCrash(
+ self:HandleEvent( EVENTS.Crash,
--- @param #TASK self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua
index 694cd269e..63e846363 100644
--- a/Moose Development/Moose/Tasking/Task.lua
+++ b/Moose Development/Moose/Tasking/Task.lua
@@ -181,31 +181,6 @@ function TASK:New( Mission, SetGroupAssign, TaskName, TaskType )
self.TaskBriefing = "You are invited for the task: " .. self.TaskName .. "."
self.FsmTemplate = self.FsmTemplate or FSM_PROCESS:New()
-
- -- Handle the birth of new planes within the assigned set.
-
-
- -- Handle when a player crashes ...
- -- The Task is UnAssigned from the Unit.
- -- When there is no Unit left running the Task, and all of the Players crashed, the Task goes into Failed ...
--- self:EventOnCrash(
--- --- @param #TASK self
--- -- @param Core.Event#EVENTDATA EventData
--- function( self, EventData )
--- self:E( "In LeaveUnit" )
--- self:E( { "State", self:GetState() } )
--- if self:IsStateAssigned() then
--- local TaskUnit = EventData.IniUnit
--- local TaskGroup = EventData.IniUnit:GetGroup()
--- self:E( self.SetGroup:IsIncludeObject( TaskGroup ) )
--- if self.SetGroup:IsIncludeObject( TaskGroup ) then
--- self:UnAssignFromUnit( TaskUnit )
--- end
--- self:MessageToGroups( TaskUnit:GetPlayerName() .. " crashed!, and has aborted Task " .. self:GetName() )
--- end
--- end
--- )
---
Mission:AddTask( self )
diff --git a/Moose Development/Moose/Wrapper/Unit.lua b/Moose Development/Moose/Wrapper/Unit.lua
index 6f58e404c..101174af0 100644
--- a/Moose Development/Moose/Wrapper/Unit.lua
+++ b/Moose Development/Moose/Wrapper/Unit.lua
@@ -838,3 +838,29 @@ function UNIT:InAir()
return nil
end
+do -- Event Handling
+
+ --- Subscribe to a DCS Event.
+ -- @param #UNIT self
+ -- @param Core.Event#EVENTS Event
+ -- @param #function EventFunction (optional) The function to be called when the event occurs for the unit.
+ -- @return #UNIT
+ function UNIT:HandleEvent( Event, EventFunction )
+
+ self:EventDispatcher():OnEventForUnit( self:GetName(), EventFunction, self, Event )
+
+ return self
+ end
+
+ --- UnSubscribe to a DCS event.
+ -- @param #UNIT self
+ -- @param Core.Event#EVENTS Event
+ -- @return #UNIT
+ function UNIT:UnHandleEvent( Event )
+
+ self:EventDispatcher():RemoveForUnit( self:GetName(), self, Event )
+
+ return self
+ end
+
+end
\ No newline at end of file
diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua
index 6aaf693e6..748b52623 100644
--- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua
+++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua
@@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
-env.info( 'Moose Generation Timestamp: 20170206_1456' )
+env.info( 'Moose Generation Timestamp: 20170207_1336' )
local base = _G
Include = {}
@@ -2851,53 +2851,50 @@ end
--
-- 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.
--- Therefore, the BASE class exposes the following event handling functions:
--
--- * @{#BASE.EventOnBirth}(): Handle the birth of a new unit.
--- * @{#BASE.EventOnBaseCaptured}(): Handle the capturing of an airbase or a helipad.
--- * @{#BASE.EventOnCrash}(): Handle the crash of a unit.
--- * @{#BASE.EventOnDead}(): Handle the death of a unit.
--- * @{#BASE.EventOnEjection}(): Handle the ejection of a player out of an airplane.
--- * @{#BASE.EventOnEngineShutdown}(): Handle the shutdown of an engine.
--- * @{#BASE.EventOnEngineStartup}(): Handle the startup of an engine.
--- * @{#BASE.EventOnHit}(): Handle the hit of a shell to a unit.
--- * @{#BASE.EventOnHumanFailure}(): No a clue ...
--- * @{#BASE.EventOnLand}(): Handle the event when a unit lands.
--- * @{#BASE.EventOnMissionStart}(): Handle the start of the mission.
--- * @{#BASE.EventOnPilotDead}(): Handle the event when a pilot is dead.
--- * @{#BASE.EventOnPlayerComment}(): Handle the event when a player posts a comment.
--- * @{#BASE.EventOnPlayerEnterUnit}(): Handle the event when a player enters a unit.
--- * @{#BASE.EventOnPlayerLeaveUnit}(): Handle the event when a player leaves a unit.
--- * @{#BASE.EventOnBirthPlayerMissionEnd}(): Handle the event when a player ends the mission. (Not a clue what that does).
--- * @{#BASE.EventOnRefueling}(): Handle the event when a unit is refueling.
--- * @{#BASE.EventOnShootingEnd}(): Handle the event when a unit starts shooting (guns).
--- * @{#BASE.EventOnShootingStart}(): Handle the event when a unit ends shooting (guns).
--- * @{#BASE.EventOnShot}(): Handle the event when a unit shot a missile.
--- * @{#BASE.EventOnTakeOff}(): Handle the event when a unit takes off from a runway.
--- * @{#BASE.EventOnTookControl}(): Handle the event when a player takes control of a unit.
+-- ### 1.3.1 Subscribe / Unsubscribe to DCS Events
--
--- The EventOn() methods provide the @{Event#EVENTDATA} structure to the event handling function.
--- The @{Event#EVENTDATA} structure contains an enriched data set of information about the event being handled.
+-- 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.
--
--- Find below an example of the prototype how to write an event handling function:
+-- * @{#BASE.HandleEvent}(): Subscribe to a DCS Event.
+-- * @{#BASE.UnHandleEvent}(): Unsubscribe from a DCS 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:
--
--- CommandCenter:EventOnPlayerEnterUnit(
--- --- @param #COMMANDCENTER self
--- -- @param Core.Event#EVENTDATA EventData
--- function( self, EventData )
--- local PlayerUnit = EventData.IniUnit
--- for MissionID, Mission in pairs( self:GetMissions() ) do
--- local Mission = Mission -- Tasking.Mission#MISSION
--- Mission:JoinUnit( PlayerUnit )
--- Mission:ReportDetails()
--- end
--- end
--- )
+-- 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
--
--- Note the function( self, EventData ). It takes two parameters:
--
--- * self = the object that is handling the EventOnPlayerEnterUnit.
--- * EventData = the @{Event#EVENTDATA} structure, containing more information of the Event.
+--
+-- See the @{Event} module for more information about event handling.
--
-- ## 1.4) Class identification methods
--
@@ -3080,389 +3077,202 @@ function BASE:GetClassID()
return self.ClassID
end
---- Get the Class @{Event} processing Priority.
--- The Event processing Priority is a number from 1 to 10,
--- reflecting the order of the classes subscribed to the Event to be processed.
--- @param #BASE self
--- @return #number The @{Event} processing Priority.
-function BASE:GetEventPriority()
- return self._Private.EventPriority or 5
-end
+do -- Event Handling
---- Set the Class @{Event} processing Priority.
--- The Event processing Priority is a number from 1 to 10,
--- reflecting the order of the classes subscribed to the Event to be processed.
--- @param #BASE self
--- @param #number EventPriority The @{Event} processing Priority.
--- @return self
-function BASE:SetEventPriority( EventPriority )
- self._Private.EventPriority = EventPriority
-end
-
-
---- Set a new listener for the class.
--- @param self
--- @param Dcs.DCSTypes#Event Event
--- @param #function EventFunction
--- @return #BASE
-function BASE:AddEvent( Event, EventFunction )
- self:F( Event )
-
- self.Events[#self.Events+1] = {}
- self.Events[#self.Events].Event = Event
- self.Events[#self.Events].EventFunction = EventFunction
- self.Events[#self.Events].EventEnabled = false
-
- return self
-end
-
---- Returns the event dispatcher
--- @param #BASE self
--- @return Core.Event#EVENT
-function BASE:Event()
-
- return _EVENTDISPATCHER
-end
-
---- Remove all subscribed events
--- @param #BASE self
--- @return #BASE
-function BASE:EventRemoveAll()
-
- _EVENTDISPATCHER:RemoveAll( self )
+ --- Returns the event dispatcher
+ -- @param #BASE self
+ -- @return Core.Event#EVENT
+ function BASE:EventDispatcher()
- return self
-end
-
---- Subscribe to a S_EVENT\_SHOT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShot( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOT )
+ return _EVENTDISPATCHER
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_HIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnHit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_HIT )
- return self
-end
-
---- Subscribe to a S_EVENT\_TAKEOFF event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnTakeOff( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_TAKEOFF )
+ --- Get the Class @{Event} processing Priority.
+ -- The Event processing Priority is a number from 1 to 10,
+ -- reflecting the order of the classes subscribed to the Event to be processed.
+ -- @param #BASE self
+ -- @return #number The @{Event} processing Priority.
+ function BASE:GetEventPriority()
+ return self._Private.EventPriority or 5
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_LAND event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnLand( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_LAND )
+ --- Set the Class @{Event} processing Priority.
+ -- The Event processing Priority is a number from 1 to 10,
+ -- reflecting the order of the classes subscribed to the Event to be processed.
+ -- @param #BASE self
+ -- @param #number EventPriority The @{Event} processing Priority.
+ -- @return self
+ function BASE:SetEventPriority( EventPriority )
+ self._Private.EventPriority = EventPriority
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_CRASH event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnCrash( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_CRASH )
+ --- Remove all subscribed events
+ -- @param #BASE self
+ -- @return #BASE
+ function BASE:EventRemoveAll()
- return self
-end
-
---- Subscribe to a S_EVENT\_EJECTION event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEjection( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_EJECTION )
+ self:EventDispatcher():RemoveAll( self )
+
+ return self
+ end
- return self
-end
-
-
---- Subscribe to a S_EVENT\_REFUELING event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnRefueling( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_REFUELING )
+ --- Subscribe to a DCS Event.
+ -- @param #BASE self
+ -- @param Core.Event#EVENTS Event
+ -- @param #function EventFunction (optional) The function to be called when the event occurs for the unit.
+ -- @return #BASE
+ function BASE:HandleEvent( Event, EventFunction )
- return self
-end
-
---- Subscribe to a S_EVENT\_DEAD event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnDead( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_DEAD )
+ self:EventDispatcher():OnEventGeneric( EventFunction, self, Event )
+
+ return self
+ end
- return self
-end
-
---- Subscribe to a S_EVENT_PILOT\_DEAD event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPilotDead( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PILOT_DEAD )
+ --- UnSubscribe to a DCS event.
+ -- @param #BASE self
+ -- @param Core.Event#EVENTS Event
+ -- @return #BASE
+ function BASE:UnHandleEvent( Event )
- return self
-end
-
---- Subscribe to a S_EVENT_BASE\_CAPTURED event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnBaseCaptured( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_BASE_CAPTURED )
+ self:EventDispatcher():Remove( self, Event )
+
+ return self
+ end
- return self
-end
-
---- Subscribe to a S_EVENT_MISSION\_START event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnMissionStart( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_MISSION_START )
+ -- Event handling function prototypes
- return self
+ --- Occurs whenever any unit in a mission fires a weapon. But not any machine gun or autocannon based weapon, those are handled by EVENT.ShootingStart.
+ -- @function [parent=#BASE] OnEventShot
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs whenever an object is hit by a weapon.
+ -- initiator : The unit object the fired the weapon
+ -- weapon: Weapon object that hit the target
+ -- target: The Object that was hit.
+ -- @function [parent=#BASE] OnEventHit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft takes off from an airbase, farp, or ship.
+ -- initiator : The unit that tookoff
+ -- place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships
+ -- @function [parent=#BASE] OnEventTakeoff
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft lands at an airbase, farp or ship
+ -- initiator : The unit that has landed
+ -- place: Object that the unit landed on. Can be an Airbase Object, FARP, or Ships
+ -- @function [parent=#BASE] OnEventLand
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft crashes into the ground and is completely destroyed.
+ -- initiator : The unit that has crashed
+ -- @function [parent=#BASE] OnEventCrash
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a pilot ejects from an aircraft
+ -- initiator : The unit that has ejected
+ -- @function [parent=#BASE] OnEventEjection
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft connects with a tanker and begins taking on fuel.
+ -- initiator : The unit that is receiving fuel.
+ -- @function [parent=#BASE] OnEventRefueling
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an object is completely destroyed.
+ -- initiator : The unit that is was destroyed.
+ -- @function [parent=#BASE] OnEvent
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when the pilot of an aircraft is killed. Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane.
+ -- initiator : The unit that the pilot has died in.
+ -- @function [parent=#BASE] OnEventPilotDead
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a ground unit captures either an airbase or a farp.
+ -- initiator : The unit that captured the base
+ -- place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.
+ -- @function [parent=#BASE] OnEventBaseCaptured
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a mission starts
+ -- @function [parent=#BASE] OnEventMissionStart
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a mission ends
+ -- @function [parent=#BASE] OnEventMissionEnd
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft is finished taking fuel.
+ -- initiator : The unit that was receiving fuel.
+ -- @function [parent=#BASE] OnEventRefuelingStop
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any object is spawned into the mission.
+ -- initiator : The unit that was spawned
+ -- @function [parent=#BASE] OnEventBirth
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any system fails on a human controlled aircraft.
+ -- initiator : The unit that had the failure
+ -- @function [parent=#BASE] OnEventHumanFailure
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft starts its engines.
+ -- initiator : The unit that is starting its engines.
+ -- @function [parent=#BASE] OnEventEngineStartup
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft shuts down its engines.
+ -- initiator : The unit that is stopping its engines.
+ -- @function [parent=#BASE] OnEventEngineShutdown
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any player assumes direct control of a unit.
+ -- initiator : The unit that is being taken control of.
+ -- @function [parent=#BASE] OnEventPlayerEnterUnit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any player relieves control of a unit to the AI.
+ -- initiator : The unit that the player left.
+ -- @function [parent=#BASE] OnEventPlayerLeaveUnit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any unit begins firing a weapon that has a high rate of fire. Most common with aircraft cannons (GAU-8), autocannons, and machine guns.
+ -- initiator : The unit that is doing the shooing.
+ -- target: The unit that is being targeted.
+ -- @function [parent=#BASE] OnEventShootingStart
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any unit stops firing its weapon. Event will always correspond with a shooting start event.
+ -- initiator : The unit that was doing the shooing.
+ -- @function [parent=#BASE] OnEventShootingEnd
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
end
-
---- Subscribe to a S_EVENT_MISSION\_END event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerMissionEnd( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_MISSION_END )
-
- return self
-end
-
---- Subscribe to a S_EVENT_TOOK\_CONTROL event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnTookControl( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_TOOK_CONTROL )
-
- return self
-end
-
---- Subscribe to a S_EVENT_REFUELING\_STOP event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnRefuelingStop( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_REFUELING_STOP )
-
- return self
-end
-
---- Subscribe to a S_EVENT\_BIRTH event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnBirth( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_BIRTH )
-
- return self
-end
-
---- Subscribe to a S_EVENT_HUMAN\_FAILURE event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnHumanFailure( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_HUMAN_FAILURE )
-
- return self
-end
-
---- Subscribe to a S_EVENT_ENGINE\_STARTUP event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEngineStartup( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_ENGINE_STARTUP )
-
- return self
-end
-
---- Subscribe to a S_EVENT_ENGINE\_SHUTDOWN event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEngineShutdown( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_ENGINE_SHUTDOWN )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER_ENTER\_UNIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerEnterUnit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_ENTER_UNIT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER_LEAVE\_UNIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerLeaveUnit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_LEAVE_UNIT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER\_COMMENT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerComment( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_COMMENT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_SHOOTING\_START event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShootingStart( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOOTING_START )
-
- return self
-end
-
---- Subscribe to a S_EVENT_SHOOTING\_END event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShootingEnd( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOOTING_END )
-
- return self
-end
-
-
-
-
-
-
-
---- Enable the event listeners for the class.
--- @param #BASE self
--- @return #BASE
-function BASE:EnableEvents()
- self:F( #self.Events )
-
- for EventID, Event in pairs( self.Events ) do
- Event.Self = self
- Event.EventEnabled = true
- end
- self.Events.Handler = world.addEventHandler( self )
-
- return self
-end
-
-
---- Disable the event listeners for the class.
--- @param #BASE self
--- @return #BASE
-function BASE:DisableEvents()
- self:F()
-
- world.removeEventHandler( self )
- for EventID, Event in pairs( self.Events ) do
- Event.Self = nil
- Event.EventEnabled = false
- end
-
- return self
-end
-
-
-local BaseEventCodes = {
- "S_EVENT_SHOT",
- "S_EVENT_HIT",
- "S_EVENT_TAKEOFF",
- "S_EVENT_LAND",
- "S_EVENT_CRASH",
- "S_EVENT_EJECTION",
- "S_EVENT_REFUELING",
- "S_EVENT_DEAD",
- "S_EVENT_PILOT_DEAD",
- "S_EVENT_BASE_CAPTURED",
- "S_EVENT_MISSION_START",
- "S_EVENT_MISSION_END",
- "S_EVENT_TOOK_CONTROL",
- "S_EVENT_REFUELING_STOP",
- "S_EVENT_BIRTH",
- "S_EVENT_HUMAN_FAILURE",
- "S_EVENT_ENGINE_STARTUP",
- "S_EVENT_ENGINE_SHUTDOWN",
- "S_EVENT_PLAYER_ENTER_UNIT",
- "S_EVENT_PLAYER_LEAVE_UNIT",
- "S_EVENT_PLAYER_COMMENT",
- "S_EVENT_SHOOTING_START",
- "S_EVENT_SHOOTING_END",
- "S_EVENT_MAX",
-}
---onEvent( {[1]="S_EVENT_BIRTH",[2]={["subPlace"]=5,["time"]=0,["initiator"]={["id_"]=16884480,},["place"]={["id_"]=5000040,},["id"]=15,["IniUnitName"]="US F-15C@RAMP-Air Support Mountains#001-01",},}
--- Event = {
--- id = enum world.event,
--- time = Time,
--- initiator = Unit,
--- target = Unit,
--- place = Unit,
--- subPlace = enum world.BirthPlace,
--- weapon = Weapon
--- }
--- Creation of a Birth Event.
-- @param #BASE self
@@ -4244,58 +4054,149 @@ EVENT = {
ClassID = 0,
}
-local _EVENTCODES = {
- "S_EVENT_SHOT",
- "S_EVENT_HIT",
- "S_EVENT_TAKEOFF",
- "S_EVENT_LAND",
- "S_EVENT_CRASH",
- "S_EVENT_EJECTION",
- "S_EVENT_REFUELING",
- "S_EVENT_DEAD",
- "S_EVENT_PILOT_DEAD",
- "S_EVENT_BASE_CAPTURED",
- "S_EVENT_MISSION_START",
- "S_EVENT_MISSION_END",
- "S_EVENT_TOOK_CONTROL",
- "S_EVENT_REFUELING_STOP",
- "S_EVENT_BIRTH",
- "S_EVENT_HUMAN_FAILURE",
- "S_EVENT_ENGINE_STARTUP",
- "S_EVENT_ENGINE_SHUTDOWN",
- "S_EVENT_PLAYER_ENTER_UNIT",
- "S_EVENT_PLAYER_LEAVE_UNIT",
- "S_EVENT_PLAYER_COMMENT",
- "S_EVENT_SHOOTING_START",
- "S_EVENT_SHOOTING_END",
- "S_EVENT_MAX",
+EVENTS = {
+ Shot = world.event.S_EVENT_SHOT,
+ Hit = world.event.S_EVENT_HIT,
+ Takeoff = world.event.S_EVENT_TAKEOFF,
+ Land = world.event.S_EVENT_LAND,
+ Crash = world.event.S_EVENT_CRASH,
+ Ejection = world.event.S_EVENT_EJECTION,
+ Refueling = world.event.S_EVENT_REFUELING,
+ Dead = world.event.S_EVENT_DEAD,
+ PilotDead = world.event.S_EVENT_PILOT_DEAD,
+ BaseCaptured = world.event.S_EVENT_BASE_CAPTURED,
+ MissionStart = world.event.S_EVENT_MISSION_START,
+ MissionEnd = world.event.S_EVENT_MISSION_END,
+ TookControl = world.event.S_EVENT_TOOK_CONTROL,
+ RefuelingStop = world.event.S_EVENT_REFUELING_STOP,
+ Birth = world.event.S_EVENT_BIRTH,
+ HumanFailure = world.event.S_EVENT_HUMAN_FAILURE,
+ EngineStartup = world.event.S_EVENT_ENGINE_STARTUP,
+ EngineShutdown = world.event.S_EVENT_ENGINE_SHUTDOWN,
+ PlayerEnterUnit = world.event.S_EVENT_PLAYER_ENTER_UNIT,
+ PlayerLeaveUnit = world.event.S_EVENT_PLAYER_LEAVE_UNIT,
+ PlayerComment = world.event.S_EVENT_PLAYER_COMMENT,
+ ShootingStart = world.event.S_EVENT_SHOOTING_START,
+ ShootingEnd = world.event.S_EVENT_SHOOTING_END,
}
-local _EVENTORDER = {
- [world.event.S_EVENT_SHOT] = 1,
- [world.event.S_EVENT_HIT] = 1,
- [world.event.S_EVENT_TAKEOFF] = 1,
- [world.event.S_EVENT_LAND] = 1,
- [world.event.S_EVENT_CRASH] = -1,
- [world.event.S_EVENT_EJECTION] = -1,
- [world.event.S_EVENT_REFUELING] = 1,
- [world.event.S_EVENT_DEAD] = -1,
- [world.event.S_EVENT_PILOT_DEAD] = -1,
- [world.event.S_EVENT_BASE_CAPTURED] = 1,
- [world.event.S_EVENT_MISSION_START] = 1,
- [world.event.S_EVENT_MISSION_END] = -1,
- [world.event.S_EVENT_TOOK_CONTROL] = 1,
- [world.event.S_EVENT_REFUELING_STOP] = 1,
- [world.event.S_EVENT_BIRTH] = 1,
- [world.event.S_EVENT_HUMAN_FAILURE] = 1,
- [world.event.S_EVENT_ENGINE_STARTUP] = 1,
- [world.event.S_EVENT_ENGINE_SHUTDOWN] = 1,
- [world.event.S_EVENT_PLAYER_ENTER_UNIT] = 1,
- [world.event.S_EVENT_PLAYER_LEAVE_UNIT] = -1,
- [world.event.S_EVENT_PLAYER_COMMENT] = 1,
- [world.event.S_EVENT_SHOOTING_START] = 1,
- [world.event.S_EVENT_SHOOTING_END] = 1,
- [world.event.S_EVENT_MAX] = 1,
+
+local _EVENTMETA = {
+ [world.event.S_EVENT_SHOT] = {
+ Order = 1,
+ Event = "OnEventShot",
+ Text = "S_EVENT_SHOT"
+ },
+ [world.event.S_EVENT_HIT] = {
+ Order = 1,
+ Event = "OnEventHit",
+ Text = "S_EVENT_HIT"
+ },
+ [world.event.S_EVENT_TAKEOFF] = {
+ Order = 1,
+ Event = "OnEventTakeOff",
+ Text = "S_EVENT_TAKEOFF"
+ },
+ [world.event.S_EVENT_LAND] = {
+ Order = 1,
+ Event = "OnEventLand",
+ Text = "S_EVENT_LAND"
+ },
+ [world.event.S_EVENT_CRASH] = {
+ Order = -1,
+ Event = "OnEventCrash",
+ Text = "S_EVENT_CRASH"
+ },
+ [world.event.S_EVENT_EJECTION] = {
+ Order = 1,
+ Event = "OnEventEjection",
+ Text = "S_EVENT_EJECTION"
+ },
+ [world.event.S_EVENT_REFUELING] = {
+ Order = 1,
+ Event = "OnEventRefueling",
+ Text = "S_EVENT_REFUELING"
+ },
+ [world.event.S_EVENT_DEAD] = {
+ Order = -1,
+ Event = "OnEventDead",
+ Text = "S_EVENT_DEAD"
+ },
+ [world.event.S_EVENT_PILOT_DEAD] = {
+ Order = 1,
+ Event = "OnEventPilotDead",
+ Text = "S_EVENT_PILOT_DEAD"
+ },
+ [world.event.S_EVENT_BASE_CAPTURED] = {
+ Order = 1,
+ Event = "OnEventBaseCaptured",
+ Text = "S_EVENT_BASE_CAPTURED"
+ },
+ [world.event.S_EVENT_MISSION_START] = {
+ Order = 1,
+ Event = "OnEventMissionStart",
+ Text = "S_EVENT_MISSION_START"
+ },
+ [world.event.S_EVENT_MISSION_END] = {
+ Order = 1,
+ Event = "OnEventMissionEnd",
+ Text = "S_EVENT_MISSION_END"
+ },
+ [world.event.S_EVENT_TOOK_CONTROL] = {
+ Order = 1,
+ Event = "OnEventTookControl",
+ Text = "S_EVENT_TOOK_CONTROL"
+ },
+ [world.event.S_EVENT_REFUELING_STOP] = {
+ Order = 1,
+ Event = "OnEventRefuelingStop",
+ Text = "S_EVENT_REFUELING_STOP"
+ },
+ [world.event.S_EVENT_BIRTH] = {
+ Order = 1,
+ Event = "OnEventBirth",
+ Text = "S_EVENT_BIRTH"
+ },
+ [world.event.S_EVENT_HUMAN_FAILURE] = {
+ Order = 1,
+ Event = "OnEventHumanFailure",
+ Text = "S_EVENT_HUMAN_FAILURE"
+ },
+ [world.event.S_EVENT_ENGINE_STARTUP] = {
+ Order = 1,
+ Event = "OnEventEngineStartup",
+ Text = "S_EVENT_ENGINE_STARTUP"
+ },
+ [world.event.S_EVENT_ENGINE_SHUTDOWN] = {
+ Order = 1,
+ Event = "OnEventEngineShutdown",
+ Text = "S_EVENT_ENGINE_SHUTDOWN"
+ },
+ [world.event.S_EVENT_PLAYER_ENTER_UNIT] = {
+ Order = 1,
+ Event = "OnEventPlayerEnterUnit",
+ Text = "S_EVENT_PLAYER_ENTER_UNIT"
+ },
+ [world.event.S_EVENT_PLAYER_LEAVE_UNIT] = {
+ Order = -1,
+ Event = "OnEventPlayerLeaveUnit",
+ Text = "S_EVENT_PLAYER_LEAVE_UNIT"
+ },
+ [world.event.S_EVENT_PLAYER_COMMENT] = {
+ Order = 1,
+ Event = "OnEventPlayerComment",
+ Text = "S_EVENT_PLAYER_COMMENT"
+ },
+ [world.event.S_EVENT_SHOOTING_START] = {
+ Order = 1,
+ Event = "OnEventShootingStart",
+ Text = "S_EVENT_SHOOTING_START"
+ },
+ [world.event.S_EVENT_SHOOTING_END] = {
+ Order = 1,
+ Event = "OnEventShootingEnd",
+ Text = "S_EVENT_SHOOTING_END"
+ },
}
--- The Event structure
@@ -4333,7 +4234,7 @@ end
function EVENT:EventText( EventID )
- local EventText = _EVENTCODES[EventID]
+ local EventText = _EVENTMETA[EventID].Text
return EventText
end
@@ -4345,7 +4246,7 @@ end
-- @param Core.Base#BASE EventClass
-- @return #EVENT.Events
function EVENT:Init( EventID, EventClass )
- self:F3( { _EVENTCODES[EventID], EventClass } )
+ self:F3( { _EVENTMETA[EventID].Text, EventClass } )
if not self.Events[EventID] then
-- Create a WEAK table to ensure that the garbage collector is cleaning the event links when the object usage is cleaned.
@@ -4370,13 +4271,27 @@ end
-- @param Dcs.DCSWorld#world.event EventID
-- @return #EVENT.Events
function EVENT:Remove( EventClass, EventID )
- self:F3( { EventClass, _EVENTCODES[EventID] } )
+ self:F3( { EventClass, _EVENTMETA[EventID].Text } )
local EventClass = EventClass
local EventPriority = EventClass:GetEventPriority()
self.Events[EventID][EventPriority][EventClass] = nil
end
+--- Removes an Events entry for a Unit
+-- @param #EVENT self
+-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
+-- @param Dcs.DCSWorld#world.event EventID
+-- @return #EVENT.Events
+function EVENT:RemoveForUnit( UnitName, EventClass, EventID )
+ self:F3( { EventClass, _EVENTMETA[EventID].Text } )
+
+ local EventClass = EventClass
+ local EventPriority = EventClass:GetEventPriority()
+ local Event = self.Events[EventID][EventPriority][EventClass]
+ Event.IniUnit[UnitName] = nil
+end
+
--- Clears all event subscriptions for a @{Base#BASE} derived object.
-- @param #EVENT self
-- @param Core.Base#BASE EventObject
@@ -5020,11 +4935,11 @@ function EVENT:onEvent( Event )
--Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
end
- local PriorityOrder = _EVENTORDER[Event.id]
+ local PriorityOrder = _EVENTMETA[Event.id].Order
local PriorityBegin = PriorityOrder == -1 and 5 or 1
local PriorityEnd = PriorityOrder == -1 and 1 or 5
- self:E( { _EVENTCODES[Event.id], Event, Event.IniDCSUnitName, Event.TgtDCSUnitName, PriorityOrder } )
+ self:E( { _EVENTMETA[Event.id].Text, Event, Event.IniDCSUnitName, Event.TgtDCSUnitName, PriorityOrder } )
for EventPriority = PriorityBegin, PriorityEnd, PriorityOrder do
@@ -5035,19 +4950,71 @@ function EVENT:onEvent( Event )
-- If the EventData is for a UNIT, the call directly the EventClass EventFunction for that UNIT.
if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then
- self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), ", Unit ", Event.IniUnitName, EventPriority } )
- Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
- local Result, Value = xpcall( function() return EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventData.IniUnit[Event.IniDCSUnitName].EventClass, Event ) end, ErrorHandler )
- --EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventData.IniUnit[Event.IniDCSUnitName].EventClass, Event )
+
+ -- First test if a EventFunction is Set, otherwise search for the default function
+ if EventData.IniUnit[Event.IniDCSUnitName].EventFunction then
+
+ self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), ", Unit ", Event.IniUnitName, EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventClass, Event )
+ end, ErrorHandler )
+
+ else
+
+ -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
+ local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ]
+ if EventFunction and type( EventFunction ) == "function" then
+
+ -- Now call the default event function.
+ self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ end
+
+ end
+
else
+
-- If the EventData is not bound to a specific unit, then call the EventClass EventFunction.
-- Note that here the EventFunction will need to implement and determine the logic for the relevant source- or target unit, or weapon.
if Event.IniDCSUnit and not EventData.IniUnit then
+
if EventClass == EventData.EventClass then
- self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), EventPriority } )
- Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
- local Result, Value = xpcall( function() return EventData.EventFunction( EventData.EventClass, Event ) end, ErrorHandler )
- --EventData.EventFunction( EventData.EventClass, Event )
+
+ -- First test if a EventFunction is Set, otherwise search for the default function
+ if EventData.EventFunction then
+
+ -- There is an EventFunction defined, so call the EventFunction.
+ self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventData.EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ else
+
+ -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
+ local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ]
+ if EventFunction and type( EventFunction ) == "function" then
+
+ -- Now call the default event function.
+ self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ end
+ end
end
end
end
@@ -5055,7 +5022,7 @@ function EVENT:onEvent( Event )
end
end
else
- self:E( { _EVENTCODES[Event.id], Event } )
+ self:E( { _EVENTMETA[Event.id].Text, Event } )
end
end
@@ -6873,13 +6840,13 @@ function DATABASE:New()
self:SetEventPriority( 1 )
- _EVENTDISPATCHER:OnBirth( self._EventOnBirth, self )
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
+ self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
-- Follow alive players and clients
- _EVENTDISPATCHER:OnPlayerEnterUnit( self._EventOnPlayerEnterUnit, self )
- _EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventOnPlayerLeaveUnit, self )
+ self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit )
+ self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit )
self:_RegisterTemplates()
self:_RegisterGroupsAndUnits()
@@ -8027,13 +7994,13 @@ function SET_BASE:_FilterStart()
end
end
- _EVENTDISPATCHER:OnBirth( self._EventOnBirth, self )
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
+ self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
-- Follow alive players and clients
- _EVENTDISPATCHER:OnPlayerEnterUnit( self._EventOnPlayerEnterUnit, self )
- _EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventOnPlayerLeaveUnit, self )
+ self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit )
+ self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit )
return self
@@ -8044,9 +8011,9 @@ end
-- @return #SET_BASE self
function SET_BASE:FilterStop()
- _EVENTDISPATCHER:OnBirthRemove( self )
- _EVENTDISPATCHER:OnDeadRemove( self )
- _EVENTDISPATCHER:OnCrashRemove( self )
+ self:UnHandleEvent( EVENTS.Birth )
+ self:UnHandleEvent( EVENTS.Dead )
+ self:UnHandleEvent( EVENTS.Crash )
return self
end
@@ -16681,7 +16648,32 @@ function UNIT:InAir()
return nil
end
---- This module contains the CLIENT class.
+do -- Event Handling
+
+ --- Subscribe to a DCS Event.
+ -- @param #UNIT self
+ -- @param Core.Event#EVENTS Event
+ -- @param #function EventFunction (optional) The function to be called when the event occurs for the unit.
+ -- @return #UNIT
+ function UNIT:HandleEvent( Event, EventFunction )
+
+ self:EventDispatcher():OnEventForUnit( self:GetName(), EventFunction, self, Event )
+
+ return self
+ end
+
+ --- UnSubscribe to a DCS event.
+ -- @param #UNIT self
+ -- @param Core.Event#EVENTS Event
+ -- @return #UNIT
+ function UNIT:UnHandleEvent( Event )
+
+ self:EventDispatcher():RemoveForUnit( self:GetName(), self, Event )
+
+ return self
+ end
+
+end--- This module contains the CLIENT class.
--
-- 1) @{Client#CLIENT} class, extends @{Unit#UNIT}
-- ===============================================
@@ -17397,9 +17389,9 @@ function SCORING:New( GameName )
end
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnHit( self._EventOnHit, self )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Hit, self._EventOnHit )
--self.SchedulerId = routines.scheduleFunction( SCORING._FollowPlayersScheduled, { self }, 0, 5 )
self.SchedulerId = SCHEDULER:New( self, self._FollowPlayersScheduled, {}, 0, 5 )
@@ -25425,9 +25417,9 @@ function AI_PATROL_ZONE:onafterStart( Controllable, From, Event, To )
self:__Status( 60 ) -- Check status status every 30 seconds.
self:SetDetectionActivated()
- self:EventOnPilotDead( self.OnPilotDead )
- self:EventOnCrash( self.OnCrash )
- self:EventOnEjection( self.OnEjection )
+ self:HandleEvent( EVENTS.PilotDead, self.OnPilotDead )
+ self:HandleEvent( EVENTS.Crash, self.OnCrash )
+ self:HandleEvent( EVENTS.Ejection, self.OnEjection )
Controllable:OptionROEHoldFire()
Controllable:OptionROTVertical()
@@ -26072,7 +26064,7 @@ function AI_CAS_ZONE:onafterStart( Controllable, From, Event, To )
-- Call the parent Start event handler
self:GetParent(self).onafterStart( self, Controllable, From, Event, To )
- self:EventOnDead( self.OnDead )
+ self:HandleEvent( EVENTS.Dead, self.OnDead )
self:SetDetectionDeactivated() -- When not engaging, set the detection off.
end
@@ -28512,7 +28504,7 @@ do -- ACT_ACCOUNT
-- @param #string To
function ACT_ACCOUNT:onafterStart( ProcessUnit, From, Event, To )
- self:EventOnDead( self.onfuncEventDead )
+ self:HandleEvent( EVENTS.Dead, self.onfuncEventDead )
self:__Wait( 1 )
end
@@ -28932,7 +28924,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
self.Missions = {}
- self:EventOnBirth(
+ self:HandleEvent( EVENTS.Birth,
--- @param #COMMANDCENTER self
--- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -28960,7 +28952,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- - Set the correct menu.
-- - Assign the PlayerUnit to the Task if required.
-- - Send a message to the other players in the group that this player has joined.
- self:EventOnPlayerEnterUnit(
+ self:HandleEvent( EVENTS.PlayerEnterUnit,
--- @param #COMMANDCENTER self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -28977,7 +28969,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- Handle when a player leaves a slot and goes back to spectators ...
-- The PlayerUnit will be UnAssigned from the Task.
-- When there is no Unit left running the Task, the Task goes into Abort...
- self:EventOnPlayerLeaveUnit(
+ self:HandleEvent( EVENTS.PlayerLeaveUnit,
--- @param #TASK self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -28992,7 +28984,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- Handle when a player leaves a slot and goes back to spectators ...
-- The PlayerUnit will be UnAssigned from the Task.
-- When there is no Unit left running the Task, the Task goes into Abort...
- self:EventOnCrash(
+ self:HandleEvent( EVENTS.Crash,
--- @param #TASK self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -30284,31 +30276,6 @@ function TASK:New( Mission, SetGroupAssign, TaskName, TaskType )
self.TaskBriefing = "You are invited for the task: " .. self.TaskName .. "."
self.FsmTemplate = self.FsmTemplate or FSM_PROCESS:New()
-
- -- Handle the birth of new planes within the assigned set.
-
-
- -- Handle when a player crashes ...
- -- The Task is UnAssigned from the Unit.
- -- When there is no Unit left running the Task, and all of the Players crashed, the Task goes into Failed ...
--- self:EventOnCrash(
--- --- @param #TASK self
--- -- @param Core.Event#EVENTDATA EventData
--- function( self, EventData )
--- self:E( "In LeaveUnit" )
--- self:E( { "State", self:GetState() } )
--- if self:IsStateAssigned() then
--- local TaskUnit = EventData.IniUnit
--- local TaskGroup = EventData.IniUnit:GetGroup()
--- self:E( self.SetGroup:IsIncludeObject( TaskGroup ) )
--- if self.SetGroup:IsIncludeObject( TaskGroup ) then
--- self:UnAssignFromUnit( TaskUnit )
--- end
--- self:MessageToGroups( TaskUnit:GetPlayerName() .. " crashed!, and has aborted Task " .. self:GetName() )
--- end
--- end
--- )
---
Mission:AddTask( self )
diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua
index 6aaf693e6..748b52623 100644
--- a/Moose Mission Setup/Moose.lua
+++ b/Moose Mission Setup/Moose.lua
@@ -1,5 +1,5 @@
env.info( '*** MOOSE STATIC INCLUDE START *** ' )
-env.info( 'Moose Generation Timestamp: 20170206_1456' )
+env.info( 'Moose Generation Timestamp: 20170207_1336' )
local base = _G
Include = {}
@@ -2851,53 +2851,50 @@ end
--
-- 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.
--- Therefore, the BASE class exposes the following event handling functions:
--
--- * @{#BASE.EventOnBirth}(): Handle the birth of a new unit.
--- * @{#BASE.EventOnBaseCaptured}(): Handle the capturing of an airbase or a helipad.
--- * @{#BASE.EventOnCrash}(): Handle the crash of a unit.
--- * @{#BASE.EventOnDead}(): Handle the death of a unit.
--- * @{#BASE.EventOnEjection}(): Handle the ejection of a player out of an airplane.
--- * @{#BASE.EventOnEngineShutdown}(): Handle the shutdown of an engine.
--- * @{#BASE.EventOnEngineStartup}(): Handle the startup of an engine.
--- * @{#BASE.EventOnHit}(): Handle the hit of a shell to a unit.
--- * @{#BASE.EventOnHumanFailure}(): No a clue ...
--- * @{#BASE.EventOnLand}(): Handle the event when a unit lands.
--- * @{#BASE.EventOnMissionStart}(): Handle the start of the mission.
--- * @{#BASE.EventOnPilotDead}(): Handle the event when a pilot is dead.
--- * @{#BASE.EventOnPlayerComment}(): Handle the event when a player posts a comment.
--- * @{#BASE.EventOnPlayerEnterUnit}(): Handle the event when a player enters a unit.
--- * @{#BASE.EventOnPlayerLeaveUnit}(): Handle the event when a player leaves a unit.
--- * @{#BASE.EventOnBirthPlayerMissionEnd}(): Handle the event when a player ends the mission. (Not a clue what that does).
--- * @{#BASE.EventOnRefueling}(): Handle the event when a unit is refueling.
--- * @{#BASE.EventOnShootingEnd}(): Handle the event when a unit starts shooting (guns).
--- * @{#BASE.EventOnShootingStart}(): Handle the event when a unit ends shooting (guns).
--- * @{#BASE.EventOnShot}(): Handle the event when a unit shot a missile.
--- * @{#BASE.EventOnTakeOff}(): Handle the event when a unit takes off from a runway.
--- * @{#BASE.EventOnTookControl}(): Handle the event when a player takes control of a unit.
+-- ### 1.3.1 Subscribe / Unsubscribe to DCS Events
--
--- The EventOn() methods provide the @{Event#EVENTDATA} structure to the event handling function.
--- The @{Event#EVENTDATA} structure contains an enriched data set of information about the event being handled.
+-- 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.
--
--- Find below an example of the prototype how to write an event handling function:
+-- * @{#BASE.HandleEvent}(): Subscribe to a DCS Event.
+-- * @{#BASE.UnHandleEvent}(): Unsubscribe from a DCS 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:
--
--- CommandCenter:EventOnPlayerEnterUnit(
--- --- @param #COMMANDCENTER self
--- -- @param Core.Event#EVENTDATA EventData
--- function( self, EventData )
--- local PlayerUnit = EventData.IniUnit
--- for MissionID, Mission in pairs( self:GetMissions() ) do
--- local Mission = Mission -- Tasking.Mission#MISSION
--- Mission:JoinUnit( PlayerUnit )
--- Mission:ReportDetails()
--- end
--- end
--- )
+-- 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
--
--- Note the function( self, EventData ). It takes two parameters:
--
--- * self = the object that is handling the EventOnPlayerEnterUnit.
--- * EventData = the @{Event#EVENTDATA} structure, containing more information of the Event.
+--
+-- See the @{Event} module for more information about event handling.
--
-- ## 1.4) Class identification methods
--
@@ -3080,389 +3077,202 @@ function BASE:GetClassID()
return self.ClassID
end
---- Get the Class @{Event} processing Priority.
--- The Event processing Priority is a number from 1 to 10,
--- reflecting the order of the classes subscribed to the Event to be processed.
--- @param #BASE self
--- @return #number The @{Event} processing Priority.
-function BASE:GetEventPriority()
- return self._Private.EventPriority or 5
-end
+do -- Event Handling
---- Set the Class @{Event} processing Priority.
--- The Event processing Priority is a number from 1 to 10,
--- reflecting the order of the classes subscribed to the Event to be processed.
--- @param #BASE self
--- @param #number EventPriority The @{Event} processing Priority.
--- @return self
-function BASE:SetEventPriority( EventPriority )
- self._Private.EventPriority = EventPriority
-end
-
-
---- Set a new listener for the class.
--- @param self
--- @param Dcs.DCSTypes#Event Event
--- @param #function EventFunction
--- @return #BASE
-function BASE:AddEvent( Event, EventFunction )
- self:F( Event )
-
- self.Events[#self.Events+1] = {}
- self.Events[#self.Events].Event = Event
- self.Events[#self.Events].EventFunction = EventFunction
- self.Events[#self.Events].EventEnabled = false
-
- return self
-end
-
---- Returns the event dispatcher
--- @param #BASE self
--- @return Core.Event#EVENT
-function BASE:Event()
-
- return _EVENTDISPATCHER
-end
-
---- Remove all subscribed events
--- @param #BASE self
--- @return #BASE
-function BASE:EventRemoveAll()
-
- _EVENTDISPATCHER:RemoveAll( self )
+ --- Returns the event dispatcher
+ -- @param #BASE self
+ -- @return Core.Event#EVENT
+ function BASE:EventDispatcher()
- return self
-end
-
---- Subscribe to a S_EVENT\_SHOT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShot( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOT )
+ return _EVENTDISPATCHER
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_HIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnHit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_HIT )
- return self
-end
-
---- Subscribe to a S_EVENT\_TAKEOFF event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnTakeOff( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_TAKEOFF )
+ --- Get the Class @{Event} processing Priority.
+ -- The Event processing Priority is a number from 1 to 10,
+ -- reflecting the order of the classes subscribed to the Event to be processed.
+ -- @param #BASE self
+ -- @return #number The @{Event} processing Priority.
+ function BASE:GetEventPriority()
+ return self._Private.EventPriority or 5
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_LAND event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnLand( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_LAND )
+ --- Set the Class @{Event} processing Priority.
+ -- The Event processing Priority is a number from 1 to 10,
+ -- reflecting the order of the classes subscribed to the Event to be processed.
+ -- @param #BASE self
+ -- @param #number EventPriority The @{Event} processing Priority.
+ -- @return self
+ function BASE:SetEventPriority( EventPriority )
+ self._Private.EventPriority = EventPriority
+ end
- return self
-end
-
---- Subscribe to a S_EVENT\_CRASH event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnCrash( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_CRASH )
+ --- Remove all subscribed events
+ -- @param #BASE self
+ -- @return #BASE
+ function BASE:EventRemoveAll()
- return self
-end
-
---- Subscribe to a S_EVENT\_EJECTION event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEjection( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_EJECTION )
+ self:EventDispatcher():RemoveAll( self )
+
+ return self
+ end
- return self
-end
-
-
---- Subscribe to a S_EVENT\_REFUELING event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnRefueling( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_REFUELING )
+ --- Subscribe to a DCS Event.
+ -- @param #BASE self
+ -- @param Core.Event#EVENTS Event
+ -- @param #function EventFunction (optional) The function to be called when the event occurs for the unit.
+ -- @return #BASE
+ function BASE:HandleEvent( Event, EventFunction )
- return self
-end
-
---- Subscribe to a S_EVENT\_DEAD event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnDead( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_DEAD )
+ self:EventDispatcher():OnEventGeneric( EventFunction, self, Event )
+
+ return self
+ end
- return self
-end
-
---- Subscribe to a S_EVENT_PILOT\_DEAD event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPilotDead( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PILOT_DEAD )
+ --- UnSubscribe to a DCS event.
+ -- @param #BASE self
+ -- @param Core.Event#EVENTS Event
+ -- @return #BASE
+ function BASE:UnHandleEvent( Event )
- return self
-end
-
---- Subscribe to a S_EVENT_BASE\_CAPTURED event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnBaseCaptured( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_BASE_CAPTURED )
+ self:EventDispatcher():Remove( self, Event )
+
+ return self
+ end
- return self
-end
-
---- Subscribe to a S_EVENT_MISSION\_START event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnMissionStart( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_MISSION_START )
+ -- Event handling function prototypes
- return self
+ --- Occurs whenever any unit in a mission fires a weapon. But not any machine gun or autocannon based weapon, those are handled by EVENT.ShootingStart.
+ -- @function [parent=#BASE] OnEventShot
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs whenever an object is hit by a weapon.
+ -- initiator : The unit object the fired the weapon
+ -- weapon: Weapon object that hit the target
+ -- target: The Object that was hit.
+ -- @function [parent=#BASE] OnEventHit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft takes off from an airbase, farp, or ship.
+ -- initiator : The unit that tookoff
+ -- place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships
+ -- @function [parent=#BASE] OnEventTakeoff
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft lands at an airbase, farp or ship
+ -- initiator : The unit that has landed
+ -- place: Object that the unit landed on. Can be an Airbase Object, FARP, or Ships
+ -- @function [parent=#BASE] OnEventLand
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft crashes into the ground and is completely destroyed.
+ -- initiator : The unit that has crashed
+ -- @function [parent=#BASE] OnEventCrash
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a pilot ejects from an aircraft
+ -- initiator : The unit that has ejected
+ -- @function [parent=#BASE] OnEventEjection
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft connects with a tanker and begins taking on fuel.
+ -- initiator : The unit that is receiving fuel.
+ -- @function [parent=#BASE] OnEventRefueling
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an object is completely destroyed.
+ -- initiator : The unit that is was destroyed.
+ -- @function [parent=#BASE] OnEvent
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when the pilot of an aircraft is killed. Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane.
+ -- initiator : The unit that the pilot has died in.
+ -- @function [parent=#BASE] OnEventPilotDead
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a ground unit captures either an airbase or a farp.
+ -- initiator : The unit that captured the base
+ -- place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.
+ -- @function [parent=#BASE] OnEventBaseCaptured
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a mission starts
+ -- @function [parent=#BASE] OnEventMissionStart
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when a mission ends
+ -- @function [parent=#BASE] OnEventMissionEnd
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when an aircraft is finished taking fuel.
+ -- initiator : The unit that was receiving fuel.
+ -- @function [parent=#BASE] OnEventRefuelingStop
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any object is spawned into the mission.
+ -- initiator : The unit that was spawned
+ -- @function [parent=#BASE] OnEventBirth
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any system fails on a human controlled aircraft.
+ -- initiator : The unit that had the failure
+ -- @function [parent=#BASE] OnEventHumanFailure
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft starts its engines.
+ -- initiator : The unit that is starting its engines.
+ -- @function [parent=#BASE] OnEventEngineStartup
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any aircraft shuts down its engines.
+ -- initiator : The unit that is stopping its engines.
+ -- @function [parent=#BASE] OnEventEngineShutdown
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any player assumes direct control of a unit.
+ -- initiator : The unit that is being taken control of.
+ -- @function [parent=#BASE] OnEventPlayerEnterUnit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any player relieves control of a unit to the AI.
+ -- initiator : The unit that the player left.
+ -- @function [parent=#BASE] OnEventPlayerLeaveUnit
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any unit begins firing a weapon that has a high rate of fire. Most common with aircraft cannons (GAU-8), autocannons, and machine guns.
+ -- initiator : The unit that is doing the shooing.
+ -- target: The unit that is being targeted.
+ -- @function [parent=#BASE] OnEventShootingStart
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
+ --- Occurs when any unit stops firing its weapon. Event will always correspond with a shooting start event.
+ -- initiator : The unit that was doing the shooing.
+ -- @function [parent=#BASE] OnEventShootingEnd
+ -- @param #BASE self
+ -- @param Core.Event#EVENTDATA EventData The EventData structure.
+
end
-
---- Subscribe to a S_EVENT_MISSION\_END event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerMissionEnd( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_MISSION_END )
-
- return self
-end
-
---- Subscribe to a S_EVENT_TOOK\_CONTROL event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnTookControl( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_TOOK_CONTROL )
-
- return self
-end
-
---- Subscribe to a S_EVENT_REFUELING\_STOP event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnRefuelingStop( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_REFUELING_STOP )
-
- return self
-end
-
---- Subscribe to a S_EVENT\_BIRTH event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnBirth( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_BIRTH )
-
- return self
-end
-
---- Subscribe to a S_EVENT_HUMAN\_FAILURE event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnHumanFailure( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_HUMAN_FAILURE )
-
- return self
-end
-
---- Subscribe to a S_EVENT_ENGINE\_STARTUP event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEngineStartup( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_ENGINE_STARTUP )
-
- return self
-end
-
---- Subscribe to a S_EVENT_ENGINE\_SHUTDOWN event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnEngineShutdown( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_ENGINE_SHUTDOWN )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER_ENTER\_UNIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerEnterUnit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_ENTER_UNIT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER_LEAVE\_UNIT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerLeaveUnit( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_LEAVE_UNIT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_PLAYER\_COMMENT event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnPlayerComment( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_PLAYER_COMMENT )
-
- return self
-end
-
---- Subscribe to a S_EVENT_SHOOTING\_START event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShootingStart( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOOTING_START )
-
- return self
-end
-
---- Subscribe to a S_EVENT_SHOOTING\_END event.
--- @param #BASE self
--- @param #function EventFunction The function to be called when the event occurs for the unit.
--- @return #BASE
-function BASE:EventOnShootingEnd( EventFunction )
-
- _EVENTDISPATCHER:OnEventGeneric( EventFunction, self, world.event.S_EVENT_SHOOTING_END )
-
- return self
-end
-
-
-
-
-
-
-
---- Enable the event listeners for the class.
--- @param #BASE self
--- @return #BASE
-function BASE:EnableEvents()
- self:F( #self.Events )
-
- for EventID, Event in pairs( self.Events ) do
- Event.Self = self
- Event.EventEnabled = true
- end
- self.Events.Handler = world.addEventHandler( self )
-
- return self
-end
-
-
---- Disable the event listeners for the class.
--- @param #BASE self
--- @return #BASE
-function BASE:DisableEvents()
- self:F()
-
- world.removeEventHandler( self )
- for EventID, Event in pairs( self.Events ) do
- Event.Self = nil
- Event.EventEnabled = false
- end
-
- return self
-end
-
-
-local BaseEventCodes = {
- "S_EVENT_SHOT",
- "S_EVENT_HIT",
- "S_EVENT_TAKEOFF",
- "S_EVENT_LAND",
- "S_EVENT_CRASH",
- "S_EVENT_EJECTION",
- "S_EVENT_REFUELING",
- "S_EVENT_DEAD",
- "S_EVENT_PILOT_DEAD",
- "S_EVENT_BASE_CAPTURED",
- "S_EVENT_MISSION_START",
- "S_EVENT_MISSION_END",
- "S_EVENT_TOOK_CONTROL",
- "S_EVENT_REFUELING_STOP",
- "S_EVENT_BIRTH",
- "S_EVENT_HUMAN_FAILURE",
- "S_EVENT_ENGINE_STARTUP",
- "S_EVENT_ENGINE_SHUTDOWN",
- "S_EVENT_PLAYER_ENTER_UNIT",
- "S_EVENT_PLAYER_LEAVE_UNIT",
- "S_EVENT_PLAYER_COMMENT",
- "S_EVENT_SHOOTING_START",
- "S_EVENT_SHOOTING_END",
- "S_EVENT_MAX",
-}
---onEvent( {[1]="S_EVENT_BIRTH",[2]={["subPlace"]=5,["time"]=0,["initiator"]={["id_"]=16884480,},["place"]={["id_"]=5000040,},["id"]=15,["IniUnitName"]="US F-15C@RAMP-Air Support Mountains#001-01",},}
--- Event = {
--- id = enum world.event,
--- time = Time,
--- initiator = Unit,
--- target = Unit,
--- place = Unit,
--- subPlace = enum world.BirthPlace,
--- weapon = Weapon
--- }
--- Creation of a Birth Event.
-- @param #BASE self
@@ -4244,58 +4054,149 @@ EVENT = {
ClassID = 0,
}
-local _EVENTCODES = {
- "S_EVENT_SHOT",
- "S_EVENT_HIT",
- "S_EVENT_TAKEOFF",
- "S_EVENT_LAND",
- "S_EVENT_CRASH",
- "S_EVENT_EJECTION",
- "S_EVENT_REFUELING",
- "S_EVENT_DEAD",
- "S_EVENT_PILOT_DEAD",
- "S_EVENT_BASE_CAPTURED",
- "S_EVENT_MISSION_START",
- "S_EVENT_MISSION_END",
- "S_EVENT_TOOK_CONTROL",
- "S_EVENT_REFUELING_STOP",
- "S_EVENT_BIRTH",
- "S_EVENT_HUMAN_FAILURE",
- "S_EVENT_ENGINE_STARTUP",
- "S_EVENT_ENGINE_SHUTDOWN",
- "S_EVENT_PLAYER_ENTER_UNIT",
- "S_EVENT_PLAYER_LEAVE_UNIT",
- "S_EVENT_PLAYER_COMMENT",
- "S_EVENT_SHOOTING_START",
- "S_EVENT_SHOOTING_END",
- "S_EVENT_MAX",
+EVENTS = {
+ Shot = world.event.S_EVENT_SHOT,
+ Hit = world.event.S_EVENT_HIT,
+ Takeoff = world.event.S_EVENT_TAKEOFF,
+ Land = world.event.S_EVENT_LAND,
+ Crash = world.event.S_EVENT_CRASH,
+ Ejection = world.event.S_EVENT_EJECTION,
+ Refueling = world.event.S_EVENT_REFUELING,
+ Dead = world.event.S_EVENT_DEAD,
+ PilotDead = world.event.S_EVENT_PILOT_DEAD,
+ BaseCaptured = world.event.S_EVENT_BASE_CAPTURED,
+ MissionStart = world.event.S_EVENT_MISSION_START,
+ MissionEnd = world.event.S_EVENT_MISSION_END,
+ TookControl = world.event.S_EVENT_TOOK_CONTROL,
+ RefuelingStop = world.event.S_EVENT_REFUELING_STOP,
+ Birth = world.event.S_EVENT_BIRTH,
+ HumanFailure = world.event.S_EVENT_HUMAN_FAILURE,
+ EngineStartup = world.event.S_EVENT_ENGINE_STARTUP,
+ EngineShutdown = world.event.S_EVENT_ENGINE_SHUTDOWN,
+ PlayerEnterUnit = world.event.S_EVENT_PLAYER_ENTER_UNIT,
+ PlayerLeaveUnit = world.event.S_EVENT_PLAYER_LEAVE_UNIT,
+ PlayerComment = world.event.S_EVENT_PLAYER_COMMENT,
+ ShootingStart = world.event.S_EVENT_SHOOTING_START,
+ ShootingEnd = world.event.S_EVENT_SHOOTING_END,
}
-local _EVENTORDER = {
- [world.event.S_EVENT_SHOT] = 1,
- [world.event.S_EVENT_HIT] = 1,
- [world.event.S_EVENT_TAKEOFF] = 1,
- [world.event.S_EVENT_LAND] = 1,
- [world.event.S_EVENT_CRASH] = -1,
- [world.event.S_EVENT_EJECTION] = -1,
- [world.event.S_EVENT_REFUELING] = 1,
- [world.event.S_EVENT_DEAD] = -1,
- [world.event.S_EVENT_PILOT_DEAD] = -1,
- [world.event.S_EVENT_BASE_CAPTURED] = 1,
- [world.event.S_EVENT_MISSION_START] = 1,
- [world.event.S_EVENT_MISSION_END] = -1,
- [world.event.S_EVENT_TOOK_CONTROL] = 1,
- [world.event.S_EVENT_REFUELING_STOP] = 1,
- [world.event.S_EVENT_BIRTH] = 1,
- [world.event.S_EVENT_HUMAN_FAILURE] = 1,
- [world.event.S_EVENT_ENGINE_STARTUP] = 1,
- [world.event.S_EVENT_ENGINE_SHUTDOWN] = 1,
- [world.event.S_EVENT_PLAYER_ENTER_UNIT] = 1,
- [world.event.S_EVENT_PLAYER_LEAVE_UNIT] = -1,
- [world.event.S_EVENT_PLAYER_COMMENT] = 1,
- [world.event.S_EVENT_SHOOTING_START] = 1,
- [world.event.S_EVENT_SHOOTING_END] = 1,
- [world.event.S_EVENT_MAX] = 1,
+
+local _EVENTMETA = {
+ [world.event.S_EVENT_SHOT] = {
+ Order = 1,
+ Event = "OnEventShot",
+ Text = "S_EVENT_SHOT"
+ },
+ [world.event.S_EVENT_HIT] = {
+ Order = 1,
+ Event = "OnEventHit",
+ Text = "S_EVENT_HIT"
+ },
+ [world.event.S_EVENT_TAKEOFF] = {
+ Order = 1,
+ Event = "OnEventTakeOff",
+ Text = "S_EVENT_TAKEOFF"
+ },
+ [world.event.S_EVENT_LAND] = {
+ Order = 1,
+ Event = "OnEventLand",
+ Text = "S_EVENT_LAND"
+ },
+ [world.event.S_EVENT_CRASH] = {
+ Order = -1,
+ Event = "OnEventCrash",
+ Text = "S_EVENT_CRASH"
+ },
+ [world.event.S_EVENT_EJECTION] = {
+ Order = 1,
+ Event = "OnEventEjection",
+ Text = "S_EVENT_EJECTION"
+ },
+ [world.event.S_EVENT_REFUELING] = {
+ Order = 1,
+ Event = "OnEventRefueling",
+ Text = "S_EVENT_REFUELING"
+ },
+ [world.event.S_EVENT_DEAD] = {
+ Order = -1,
+ Event = "OnEventDead",
+ Text = "S_EVENT_DEAD"
+ },
+ [world.event.S_EVENT_PILOT_DEAD] = {
+ Order = 1,
+ Event = "OnEventPilotDead",
+ Text = "S_EVENT_PILOT_DEAD"
+ },
+ [world.event.S_EVENT_BASE_CAPTURED] = {
+ Order = 1,
+ Event = "OnEventBaseCaptured",
+ Text = "S_EVENT_BASE_CAPTURED"
+ },
+ [world.event.S_EVENT_MISSION_START] = {
+ Order = 1,
+ Event = "OnEventMissionStart",
+ Text = "S_EVENT_MISSION_START"
+ },
+ [world.event.S_EVENT_MISSION_END] = {
+ Order = 1,
+ Event = "OnEventMissionEnd",
+ Text = "S_EVENT_MISSION_END"
+ },
+ [world.event.S_EVENT_TOOK_CONTROL] = {
+ Order = 1,
+ Event = "OnEventTookControl",
+ Text = "S_EVENT_TOOK_CONTROL"
+ },
+ [world.event.S_EVENT_REFUELING_STOP] = {
+ Order = 1,
+ Event = "OnEventRefuelingStop",
+ Text = "S_EVENT_REFUELING_STOP"
+ },
+ [world.event.S_EVENT_BIRTH] = {
+ Order = 1,
+ Event = "OnEventBirth",
+ Text = "S_EVENT_BIRTH"
+ },
+ [world.event.S_EVENT_HUMAN_FAILURE] = {
+ Order = 1,
+ Event = "OnEventHumanFailure",
+ Text = "S_EVENT_HUMAN_FAILURE"
+ },
+ [world.event.S_EVENT_ENGINE_STARTUP] = {
+ Order = 1,
+ Event = "OnEventEngineStartup",
+ Text = "S_EVENT_ENGINE_STARTUP"
+ },
+ [world.event.S_EVENT_ENGINE_SHUTDOWN] = {
+ Order = 1,
+ Event = "OnEventEngineShutdown",
+ Text = "S_EVENT_ENGINE_SHUTDOWN"
+ },
+ [world.event.S_EVENT_PLAYER_ENTER_UNIT] = {
+ Order = 1,
+ Event = "OnEventPlayerEnterUnit",
+ Text = "S_EVENT_PLAYER_ENTER_UNIT"
+ },
+ [world.event.S_EVENT_PLAYER_LEAVE_UNIT] = {
+ Order = -1,
+ Event = "OnEventPlayerLeaveUnit",
+ Text = "S_EVENT_PLAYER_LEAVE_UNIT"
+ },
+ [world.event.S_EVENT_PLAYER_COMMENT] = {
+ Order = 1,
+ Event = "OnEventPlayerComment",
+ Text = "S_EVENT_PLAYER_COMMENT"
+ },
+ [world.event.S_EVENT_SHOOTING_START] = {
+ Order = 1,
+ Event = "OnEventShootingStart",
+ Text = "S_EVENT_SHOOTING_START"
+ },
+ [world.event.S_EVENT_SHOOTING_END] = {
+ Order = 1,
+ Event = "OnEventShootingEnd",
+ Text = "S_EVENT_SHOOTING_END"
+ },
}
--- The Event structure
@@ -4333,7 +4234,7 @@ end
function EVENT:EventText( EventID )
- local EventText = _EVENTCODES[EventID]
+ local EventText = _EVENTMETA[EventID].Text
return EventText
end
@@ -4345,7 +4246,7 @@ end
-- @param Core.Base#BASE EventClass
-- @return #EVENT.Events
function EVENT:Init( EventID, EventClass )
- self:F3( { _EVENTCODES[EventID], EventClass } )
+ self:F3( { _EVENTMETA[EventID].Text, EventClass } )
if not self.Events[EventID] then
-- Create a WEAK table to ensure that the garbage collector is cleaning the event links when the object usage is cleaned.
@@ -4370,13 +4271,27 @@ end
-- @param Dcs.DCSWorld#world.event EventID
-- @return #EVENT.Events
function EVENT:Remove( EventClass, EventID )
- self:F3( { EventClass, _EVENTCODES[EventID] } )
+ self:F3( { EventClass, _EVENTMETA[EventID].Text } )
local EventClass = EventClass
local EventPriority = EventClass:GetEventPriority()
self.Events[EventID][EventPriority][EventClass] = nil
end
+--- Removes an Events entry for a Unit
+-- @param #EVENT self
+-- @param Core.Base#BASE EventClass The self instance of the class for which the event is.
+-- @param Dcs.DCSWorld#world.event EventID
+-- @return #EVENT.Events
+function EVENT:RemoveForUnit( UnitName, EventClass, EventID )
+ self:F3( { EventClass, _EVENTMETA[EventID].Text } )
+
+ local EventClass = EventClass
+ local EventPriority = EventClass:GetEventPriority()
+ local Event = self.Events[EventID][EventPriority][EventClass]
+ Event.IniUnit[UnitName] = nil
+end
+
--- Clears all event subscriptions for a @{Base#BASE} derived object.
-- @param #EVENT self
-- @param Core.Base#BASE EventObject
@@ -5020,11 +4935,11 @@ function EVENT:onEvent( Event )
--Event.WeaponTgtDCSUnit = Event.Weapon:getTarget()
end
- local PriorityOrder = _EVENTORDER[Event.id]
+ local PriorityOrder = _EVENTMETA[Event.id].Order
local PriorityBegin = PriorityOrder == -1 and 5 or 1
local PriorityEnd = PriorityOrder == -1 and 1 or 5
- self:E( { _EVENTCODES[Event.id], Event, Event.IniDCSUnitName, Event.TgtDCSUnitName, PriorityOrder } )
+ self:E( { _EVENTMETA[Event.id].Text, Event, Event.IniDCSUnitName, Event.TgtDCSUnitName, PriorityOrder } )
for EventPriority = PriorityBegin, PriorityEnd, PriorityOrder do
@@ -5035,19 +4950,71 @@ function EVENT:onEvent( Event )
-- If the EventData is for a UNIT, the call directly the EventClass EventFunction for that UNIT.
if Event.IniDCSUnitName and EventData.IniUnit and EventData.IniUnit[Event.IniDCSUnitName] then
- self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), ", Unit ", Event.IniUnitName, EventPriority } )
- Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
- local Result, Value = xpcall( function() return EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventData.IniUnit[Event.IniDCSUnitName].EventClass, Event ) end, ErrorHandler )
- --EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventData.IniUnit[Event.IniDCSUnitName].EventClass, Event )
+
+ -- First test if a EventFunction is Set, otherwise search for the default function
+ if EventData.IniUnit[Event.IniDCSUnitName].EventFunction then
+
+ self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), ", Unit ", Event.IniUnitName, EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventData.IniUnit[Event.IniDCSUnitName].EventFunction( EventClass, Event )
+ end, ErrorHandler )
+
+ else
+
+ -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
+ local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ]
+ if EventFunction and type( EventFunction ) == "function" then
+
+ -- Now call the default event function.
+ self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ end
+
+ end
+
else
+
-- If the EventData is not bound to a specific unit, then call the EventClass EventFunction.
-- Note that here the EventFunction will need to implement and determine the logic for the relevant source- or target unit, or weapon.
if Event.IniDCSUnit and not EventData.IniUnit then
+
if EventClass == EventData.EventClass then
- self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), EventPriority } )
- Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
- local Result, Value = xpcall( function() return EventData.EventFunction( EventData.EventClass, Event ) end, ErrorHandler )
- --EventData.EventFunction( EventData.EventClass, Event )
+
+ -- First test if a EventFunction is Set, otherwise search for the default function
+ if EventData.EventFunction then
+
+ -- There is an EventFunction defined, so call the EventFunction.
+ self:E( { "Calling EventFunction for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventData.EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ else
+
+ -- There is no EventFunction defined, so try to find if a default OnEvent function is defined on the object.
+ local EventFunction = EventClass[ _EVENTMETA[Event.id].Event ]
+ if EventFunction and type( EventFunction ) == "function" then
+
+ -- Now call the default event function.
+ self:E( { "Calling " .. _EVENTMETA[Event.id].Event .. " for Class ", EventClass:GetClassNameAndID(), EventPriority } )
+ Event.IniGroup = GROUP:FindByName( Event.IniDCSGroupName )
+
+ local Result, Value = xpcall(
+ function()
+ return EventFunction( EventClass, Event )
+ end, ErrorHandler )
+ end
+ end
end
end
end
@@ -5055,7 +5022,7 @@ function EVENT:onEvent( Event )
end
end
else
- self:E( { _EVENTCODES[Event.id], Event } )
+ self:E( { _EVENTMETA[Event.id].Text, Event } )
end
end
@@ -6873,13 +6840,13 @@ function DATABASE:New()
self:SetEventPriority( 1 )
- _EVENTDISPATCHER:OnBirth( self._EventOnBirth, self )
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
+ self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
-- Follow alive players and clients
- _EVENTDISPATCHER:OnPlayerEnterUnit( self._EventOnPlayerEnterUnit, self )
- _EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventOnPlayerLeaveUnit, self )
+ self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit )
+ self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit )
self:_RegisterTemplates()
self:_RegisterGroupsAndUnits()
@@ -8027,13 +7994,13 @@ function SET_BASE:_FilterStart()
end
end
- _EVENTDISPATCHER:OnBirth( self._EventOnBirth, self )
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
+ self:HandleEvent( EVENTS.Birth, self._EventOnBirth )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
-- Follow alive players and clients
- _EVENTDISPATCHER:OnPlayerEnterUnit( self._EventOnPlayerEnterUnit, self )
- _EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventOnPlayerLeaveUnit, self )
+ self:HandleEvent( EVENTS.PlayerEnterUnit, self._EventOnPlayerEnterUnit )
+ self:HandleEvent( EVENTS.PlayerLeaveUnit, self._EventOnPlayerLeaveUnit )
return self
@@ -8044,9 +8011,9 @@ end
-- @return #SET_BASE self
function SET_BASE:FilterStop()
- _EVENTDISPATCHER:OnBirthRemove( self )
- _EVENTDISPATCHER:OnDeadRemove( self )
- _EVENTDISPATCHER:OnCrashRemove( self )
+ self:UnHandleEvent( EVENTS.Birth )
+ self:UnHandleEvent( EVENTS.Dead )
+ self:UnHandleEvent( EVENTS.Crash )
return self
end
@@ -16681,7 +16648,32 @@ function UNIT:InAir()
return nil
end
---- This module contains the CLIENT class.
+do -- Event Handling
+
+ --- Subscribe to a DCS Event.
+ -- @param #UNIT self
+ -- @param Core.Event#EVENTS Event
+ -- @param #function EventFunction (optional) The function to be called when the event occurs for the unit.
+ -- @return #UNIT
+ function UNIT:HandleEvent( Event, EventFunction )
+
+ self:EventDispatcher():OnEventForUnit( self:GetName(), EventFunction, self, Event )
+
+ return self
+ end
+
+ --- UnSubscribe to a DCS event.
+ -- @param #UNIT self
+ -- @param Core.Event#EVENTS Event
+ -- @return #UNIT
+ function UNIT:UnHandleEvent( Event )
+
+ self:EventDispatcher():RemoveForUnit( self:GetName(), self, Event )
+
+ return self
+ end
+
+end--- This module contains the CLIENT class.
--
-- 1) @{Client#CLIENT} class, extends @{Unit#UNIT}
-- ===============================================
@@ -17397,9 +17389,9 @@ function SCORING:New( GameName )
end
- _EVENTDISPATCHER:OnDead( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnCrash( self._EventOnDeadOrCrash, self )
- _EVENTDISPATCHER:OnHit( self._EventOnHit, self )
+ self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
+ self:HandleEvent( EVENTS.Hit, self._EventOnHit )
--self.SchedulerId = routines.scheduleFunction( SCORING._FollowPlayersScheduled, { self }, 0, 5 )
self.SchedulerId = SCHEDULER:New( self, self._FollowPlayersScheduled, {}, 0, 5 )
@@ -25425,9 +25417,9 @@ function AI_PATROL_ZONE:onafterStart( Controllable, From, Event, To )
self:__Status( 60 ) -- Check status status every 30 seconds.
self:SetDetectionActivated()
- self:EventOnPilotDead( self.OnPilotDead )
- self:EventOnCrash( self.OnCrash )
- self:EventOnEjection( self.OnEjection )
+ self:HandleEvent( EVENTS.PilotDead, self.OnPilotDead )
+ self:HandleEvent( EVENTS.Crash, self.OnCrash )
+ self:HandleEvent( EVENTS.Ejection, self.OnEjection )
Controllable:OptionROEHoldFire()
Controllable:OptionROTVertical()
@@ -26072,7 +26064,7 @@ function AI_CAS_ZONE:onafterStart( Controllable, From, Event, To )
-- Call the parent Start event handler
self:GetParent(self).onafterStart( self, Controllable, From, Event, To )
- self:EventOnDead( self.OnDead )
+ self:HandleEvent( EVENTS.Dead, self.OnDead )
self:SetDetectionDeactivated() -- When not engaging, set the detection off.
end
@@ -28512,7 +28504,7 @@ do -- ACT_ACCOUNT
-- @param #string To
function ACT_ACCOUNT:onafterStart( ProcessUnit, From, Event, To )
- self:EventOnDead( self.onfuncEventDead )
+ self:HandleEvent( EVENTS.Dead, self.onfuncEventDead )
self:__Wait( 1 )
end
@@ -28932,7 +28924,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
self.Missions = {}
- self:EventOnBirth(
+ self:HandleEvent( EVENTS.Birth,
--- @param #COMMANDCENTER self
--- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -28960,7 +28952,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- - Set the correct menu.
-- - Assign the PlayerUnit to the Task if required.
-- - Send a message to the other players in the group that this player has joined.
- self:EventOnPlayerEnterUnit(
+ self:HandleEvent( EVENTS.PlayerEnterUnit,
--- @param #COMMANDCENTER self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -28977,7 +28969,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- Handle when a player leaves a slot and goes back to spectators ...
-- The PlayerUnit will be UnAssigned from the Task.
-- When there is no Unit left running the Task, the Task goes into Abort...
- self:EventOnPlayerLeaveUnit(
+ self:HandleEvent( EVENTS.PlayerLeaveUnit,
--- @param #TASK self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -28992,7 +28984,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
-- Handle when a player leaves a slot and goes back to spectators ...
-- The PlayerUnit will be UnAssigned from the Task.
-- When there is no Unit left running the Task, the Task goes into Abort...
- self:EventOnCrash(
+ self:HandleEvent( EVENTS.Crash,
--- @param #TASK self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
@@ -30284,31 +30276,6 @@ function TASK:New( Mission, SetGroupAssign, TaskName, TaskType )
self.TaskBriefing = "You are invited for the task: " .. self.TaskName .. "."
self.FsmTemplate = self.FsmTemplate or FSM_PROCESS:New()
-
- -- Handle the birth of new planes within the assigned set.
-
-
- -- Handle when a player crashes ...
- -- The Task is UnAssigned from the Unit.
- -- When there is no Unit left running the Task, and all of the Players crashed, the Task goes into Failed ...
--- self:EventOnCrash(
--- --- @param #TASK self
--- -- @param Core.Event#EVENTDATA EventData
--- function( self, EventData )
--- self:E( "In LeaveUnit" )
--- self:E( { "State", self:GetState() } )
--- if self:IsStateAssigned() then
--- local TaskUnit = EventData.IniUnit
--- local TaskGroup = EventData.IniUnit:GetGroup()
--- self:E( self.SetGroup:IsIncludeObject( TaskGroup ) )
--- if self.SetGroup:IsIncludeObject( TaskGroup ) then
--- self:UnAssignFromUnit( TaskUnit )
--- end
--- self:MessageToGroups( TaskUnit:GetPlayerName() .. " crashed!, and has aborted Task " .. self:GetName() )
--- end
--- end
--- )
---
Mission:AddTask( self )
diff --git a/Moose Presentations/EVENT.pptx b/Moose Presentations/EVENT.pptx
new file mode 100644
index 000000000..49b176540
Binary files /dev/null and b/Moose Presentations/EVENT.pptx differ
diff --git a/Moose Test Missions/ABP - Airbase Police/APL-001 - Caucasus/APL-001 - Caucasus.miz b/Moose Test Missions/ABP - Airbase Police/APL-001 - Caucasus/APL-001 - Caucasus.miz
index 9fceec1b3..4cd1a6d4b 100644
Binary files a/Moose Test Missions/ABP - Airbase Police/APL-001 - Caucasus/APL-001 - Caucasus.miz and b/Moose Test Missions/ABP - Airbase Police/APL-001 - Caucasus/APL-001 - Caucasus.miz differ
diff --git a/Moose Test Missions/ABP - Airbase Police/APL-002 - Nevada/APL-002 - Nevada.miz b/Moose Test Missions/ABP - Airbase Police/APL-002 - Nevada/APL-002 - Nevada.miz
index f7ab753dd..4a1f6140f 100644
Binary files a/Moose Test Missions/ABP - Airbase Police/APL-002 - Nevada/APL-002 - Nevada.miz and b/Moose Test Missions/ABP - Airbase Police/APL-002 - Nevada/APL-002 - Nevada.miz differ
diff --git a/Moose Test Missions/ACL - Airbase Cleaner/ACL-001 - Airbase CleanUp/ACL-001 - Airbase CleanUp.miz b/Moose Test Missions/ACL - Airbase Cleaner/ACL-001 - Airbase CleanUp/ACL-001 - Airbase CleanUp.miz
index 13ecfc73f..1f7f342f0 100644
Binary files a/Moose Test Missions/ACL - Airbase Cleaner/ACL-001 - Airbase CleanUp/ACL-001 - Airbase CleanUp.miz and b/Moose Test Missions/ACL - Airbase Cleaner/ACL-001 - Airbase CleanUp/ACL-001 - Airbase CleanUp.miz differ
diff --git a/Moose Test Missions/AIB - AI Balancing/AIB-001 - Spawned AI/AIB-001 - Spawned AI.miz b/Moose Test Missions/AIB - AI Balancing/AIB-001 - Spawned AI/AIB-001 - Spawned AI.miz
index e8d990081..8d85065e0 100644
Binary files a/Moose Test Missions/AIB - AI Balancing/AIB-001 - Spawned AI/AIB-001 - Spawned AI.miz and b/Moose Test Missions/AIB - AI Balancing/AIB-001 - Spawned AI/AIB-001 - Spawned AI.miz differ
diff --git a/Moose Test Missions/AIB - AI Balancing/AIB-002 - Patrol AI/AIB-002 - Patrol AI.miz b/Moose Test Missions/AIB - AI Balancing/AIB-002 - Patrol AI/AIB-002 - Patrol AI.miz
index cd8bf3cec..3879d39b7 100644
Binary files a/Moose Test Missions/AIB - AI Balancing/AIB-002 - Patrol AI/AIB-002 - Patrol AI.miz and b/Moose Test Missions/AIB - AI Balancing/AIB-002 - Patrol AI/AIB-002 - Patrol AI.miz differ
diff --git a/Moose Test Missions/AIB - AI Balancing/AIB-003 - Two coalitions InitCleanUp test/AIB-003 - Two coalitions InitCleanUp test.miz b/Moose Test Missions/AIB - AI Balancing/AIB-003 - Two coalitions InitCleanUp test/AIB-003 - Two coalitions InitCleanUp test.miz
index b8d6b9553..7bd4c7cbc 100644
Binary files a/Moose Test Missions/AIB - AI Balancing/AIB-003 - Two coalitions InitCleanUp test/AIB-003 - Two coalitions InitCleanUp test.miz and b/Moose Test Missions/AIB - AI Balancing/AIB-003 - Two coalitions InitCleanUp test/AIB-003 - Two coalitions InitCleanUp test.miz differ
diff --git a/Moose Test Missions/AIB - AI Balancing/AIB-004 - Respawn Test when Destroyed/AIB-004 - Respawn Test when Destroyed.miz b/Moose Test Missions/AIB - AI Balancing/AIB-004 - Respawn Test when Destroyed/AIB-004 - Respawn Test when Destroyed.miz
index cec024bba..b403035f9 100644
Binary files a/Moose Test Missions/AIB - AI Balancing/AIB-004 - Respawn Test when Destroyed/AIB-004 - Respawn Test when Destroyed.miz and b/Moose Test Missions/AIB - AI Balancing/AIB-004 - Respawn Test when Destroyed/AIB-004 - Respawn Test when Destroyed.miz differ
diff --git a/Moose Test Missions/AIB - AI Balancing/AIB-005 - Patrol AI and Randomize Zones/AIB-005 - Patrol AI and Randomize Zones.miz b/Moose Test Missions/AIB - AI Balancing/AIB-005 - Patrol AI and Randomize Zones/AIB-005 - Patrol AI and Randomize Zones.miz
index e56d925ff..ed3a556a6 100644
Binary files a/Moose Test Missions/AIB - AI Balancing/AIB-005 - Patrol AI and Randomize Zones/AIB-005 - Patrol AI and Randomize Zones.miz and b/Moose Test Missions/AIB - AI Balancing/AIB-005 - Patrol AI and Randomize Zones/AIB-005 - Patrol AI and Randomize Zones.miz differ
diff --git a/Moose Test Missions/AIB - AI Balancing/AIB-006 - Declutter AI at Airbases/AIB-006 - Declutter AI at Airbases.miz b/Moose Test Missions/AIB - AI Balancing/AIB-006 - Declutter AI at Airbases/AIB-006 - Declutter AI at Airbases.miz
index 51a805a27..5b824913b 100644
Binary files a/Moose Test Missions/AIB - AI Balancing/AIB-006 - Declutter AI at Airbases/AIB-006 - Declutter AI at Airbases.miz and b/Moose Test Missions/AIB - AI Balancing/AIB-006 - Declutter AI at Airbases/AIB-006 - Declutter AI at Airbases.miz differ
diff --git a/Moose Test Missions/CAP - Combat Air Patrol/CAP-001 - Combat Air Patrol/CAP-001 - Combat Air Patrol.miz b/Moose Test Missions/CAP - Combat Air Patrol/CAP-001 - Combat Air Patrol/CAP-001 - Combat Air Patrol.miz
index 5aca7d7a7..0c80b0723 100644
Binary files a/Moose Test Missions/CAP - Combat Air Patrol/CAP-001 - Combat Air Patrol/CAP-001 - Combat Air Patrol.miz and b/Moose Test Missions/CAP - Combat Air Patrol/CAP-001 - Combat Air Patrol/CAP-001 - Combat Air Patrol.miz differ
diff --git a/Moose Test Missions/CAP - Combat Air Patrol/CAP-010 - CAP and Engage within Range/CAP-010 - CAP and Engage within Range.miz b/Moose Test Missions/CAP - Combat Air Patrol/CAP-010 - CAP and Engage within Range/CAP-010 - CAP and Engage within Range.miz
index cef6877a8..649e60c7d 100644
Binary files a/Moose Test Missions/CAP - Combat Air Patrol/CAP-010 - CAP and Engage within Range/CAP-010 - CAP and Engage within Range.miz and b/Moose Test Missions/CAP - Combat Air Patrol/CAP-010 - CAP and Engage within Range/CAP-010 - CAP and Engage within Range.miz differ
diff --git a/Moose Test Missions/CAP - Combat Air Patrol/CAP-011 - CAP and Engage within Zone/CAP-011 - CAP and Engage within Zone.miz b/Moose Test Missions/CAP - Combat Air Patrol/CAP-011 - CAP and Engage within Zone/CAP-011 - CAP and Engage within Zone.miz
index 90d13c096..423b31580 100644
Binary files a/Moose Test Missions/CAP - Combat Air Patrol/CAP-011 - CAP and Engage within Zone/CAP-011 - CAP and Engage within Zone.miz and b/Moose Test Missions/CAP - Combat Air Patrol/CAP-011 - CAP and Engage within Zone/CAP-011 - CAP and Engage within Zone.miz differ
diff --git a/Moose Test Missions/CAS - Close Air Support/CAS-001 - CAS in a Zone by Airplane Group/CAS-001 - CAS in a ZONE-ME Test.miz b/Moose Test Missions/CAS - Close Air Support/CAS-001 - CAS in a Zone by Airplane Group/CAS-001 - CAS in a ZONE-ME Test.miz
index 811b4c591..eb8be7022 100644
Binary files a/Moose Test Missions/CAS - Close Air Support/CAS-001 - CAS in a Zone by Airplane Group/CAS-001 - CAS in a ZONE-ME Test.miz and b/Moose Test Missions/CAS - Close Air Support/CAS-001 - CAS in a Zone by Airplane Group/CAS-001 - CAS in a ZONE-ME Test.miz differ
diff --git a/Moose Test Missions/CAS - Close Air Support/CAS-001 - CAS in a Zone by Airplane Group/CAS-001 - CAS in a Zone by Airplane Group.miz b/Moose Test Missions/CAS - Close Air Support/CAS-001 - CAS in a Zone by Airplane Group/CAS-001 - CAS in a Zone by Airplane Group.miz
index ec3839ac4..7aa69b746 100644
Binary files a/Moose Test Missions/CAS - Close Air Support/CAS-001 - CAS in a Zone by Airplane Group/CAS-001 - CAS in a Zone by Airplane Group.miz and b/Moose Test Missions/CAS - Close Air Support/CAS-001 - CAS in a Zone by Airplane Group/CAS-001 - CAS in a Zone by Airplane Group.miz differ
diff --git a/Moose Test Missions/CAS - Close Air Support/CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed/CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed.miz b/Moose Test Missions/CAS - Close Air Support/CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed/CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed.miz
index 43f703640..706169028 100644
Binary files a/Moose Test Missions/CAS - Close Air Support/CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed/CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed.miz and b/Moose Test Missions/CAS - Close Air Support/CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed/CAS-002 - CAS in a Zone by Airplane Group - Engage with Speed.miz differ
diff --git a/Moose Test Missions/CAS - Close Air Support/CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude/CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude.miz b/Moose Test Missions/CAS - Close Air Support/CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude/CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude.miz
index aff25a6e6..0d690bf58 100644
Binary files a/Moose Test Missions/CAS - Close Air Support/CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude/CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude.miz and b/Moose Test Missions/CAS - Close Air Support/CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude/CAS-003 - CAS in a Zone by Airplane Group - Engage with Speed and Altitude.miz differ
diff --git a/Moose Test Missions/CAS - Close Air Support/CAS-010 - CAS in a Zone by Helicopter/CAS-010 - CAS in a Zone by Helicopter.miz b/Moose Test Missions/CAS - Close Air Support/CAS-010 - CAS in a Zone by Helicopter/CAS-010 - CAS in a Zone by Helicopter.miz
index 1bae9708e..5b78f9e58 100644
Binary files a/Moose Test Missions/CAS - Close Air Support/CAS-010 - CAS in a Zone by Helicopter/CAS-010 - CAS in a Zone by Helicopter.miz and b/Moose Test Missions/CAS - Close Air Support/CAS-010 - CAS in a Zone by Helicopter/CAS-010 - CAS in a Zone by Helicopter.miz differ
diff --git a/Moose Test Missions/CAS - Close Air Support/CAS-011 - CAS in a Zone by Helicopter Group/CAS-011 - CAS in a Zone by Helicopter Group.miz b/Moose Test Missions/CAS - Close Air Support/CAS-011 - CAS in a Zone by Helicopter Group/CAS-011 - CAS in a Zone by Helicopter Group.miz
index 57e0d7723..bfaafdabb 100644
Binary files a/Moose Test Missions/CAS - Close Air Support/CAS-011 - CAS in a Zone by Helicopter Group/CAS-011 - CAS in a Zone by Helicopter Group.miz and b/Moose Test Missions/CAS - Close Air Support/CAS-011 - CAS in a Zone by Helicopter Group/CAS-011 - CAS in a Zone by Helicopter Group.miz differ
diff --git a/Moose Test Missions/CAS - Close Air Support/CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups/CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups.miz b/Moose Test Missions/CAS - Close Air Support/CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups/CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups.miz
index eb0c3892b..276f55c4d 100644
Binary files a/Moose Test Missions/CAS - Close Air Support/CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups/CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups.miz and b/Moose Test Missions/CAS - Close Air Support/CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups/CAS-111 - Multiple CAS in 1 Radius Zone by Helicopter and AirPlane Groups.miz differ
diff --git a/Moose Test Missions/CGO - Cargo/CGO-001 - Unit Boarding/CGO-001 - Unit Boarding.miz b/Moose Test Missions/CGO - Cargo/CGO-001 - Unit Boarding/CGO-001 - Unit Boarding.miz
index 95bfce1cd..b34101351 100644
Binary files a/Moose Test Missions/CGO - Cargo/CGO-001 - Unit Boarding/CGO-001 - Unit Boarding.miz and b/Moose Test Missions/CGO - Cargo/CGO-001 - Unit Boarding/CGO-001 - Unit Boarding.miz differ
diff --git a/Moose Test Missions/CGO - Cargo/CGO-002 - Unit Unboarding/CGO-002 - Unit Unboarding.miz b/Moose Test Missions/CGO - Cargo/CGO-002 - Unit Unboarding/CGO-002 - Unit Unboarding.miz
index 38f1c0682..d607a3791 100644
Binary files a/Moose Test Missions/CGO - Cargo/CGO-002 - Unit Unboarding/CGO-002 - Unit Unboarding.miz and b/Moose Test Missions/CGO - Cargo/CGO-002 - Unit Unboarding/CGO-002 - Unit Unboarding.miz differ
diff --git a/Moose Test Missions/CGO - Cargo/CGO-003 - Unit Transferring/CGO-003 - Unit Transferring.miz b/Moose Test Missions/CGO - Cargo/CGO-003 - Unit Transferring/CGO-003 - Unit Transferring.miz
index a1fb3cec6..9581e3321 100644
Binary files a/Moose Test Missions/CGO - Cargo/CGO-003 - Unit Transferring/CGO-003 - Unit Transferring.miz and b/Moose Test Missions/CGO - Cargo/CGO-003 - Unit Transferring/CGO-003 - Unit Transferring.miz differ
diff --git a/Moose Test Missions/CGO - Cargo/CGO-101 - Group Boarding/CGO-101 - Group Boarding.miz b/Moose Test Missions/CGO - Cargo/CGO-101 - Group Boarding/CGO-101 - Group Boarding.miz
index d88e1cc2b..682f07602 100644
Binary files a/Moose Test Missions/CGO - Cargo/CGO-101 - Group Boarding/CGO-101 - Group Boarding.miz and b/Moose Test Missions/CGO - Cargo/CGO-101 - Group Boarding/CGO-101 - Group Boarding.miz differ
diff --git a/Moose Test Missions/CGO - Cargo/CGO-102 - Group Unboarding/CGO-102 - Group Unboarding.miz b/Moose Test Missions/CGO - Cargo/CGO-102 - Group Unboarding/CGO-102 - Group Unboarding.miz
index 7fc67e274..5f0f76bb4 100644
Binary files a/Moose Test Missions/CGO - Cargo/CGO-102 - Group Unboarding/CGO-102 - Group Unboarding.miz and b/Moose Test Missions/CGO - Cargo/CGO-102 - Group Unboarding/CGO-102 - Group Unboarding.miz differ
diff --git a/Moose Test Missions/CGO - Cargo/CGO-103 - Group Transferring/CGO-103 - Group Transferring.miz b/Moose Test Missions/CGO - Cargo/CGO-103 - Group Transferring/CGO-103 - Group Transferring.miz
index 1d12c3868..1657c2050 100644
Binary files a/Moose Test Missions/CGO - Cargo/CGO-103 - Group Transferring/CGO-103 - Group Transferring.miz and b/Moose Test Missions/CGO - Cargo/CGO-103 - Group Transferring/CGO-103 - Group Transferring.miz differ
diff --git a/Moose Test Missions/CGO - Cargo/CGO-201 - Package Boarding/CGO-201 - Package Boarding.miz b/Moose Test Missions/CGO - Cargo/CGO-201 - Package Boarding/CGO-201 - Package Boarding.miz
index 2e8f25756..d24e4961a 100644
Binary files a/Moose Test Missions/CGO - Cargo/CGO-201 - Package Boarding/CGO-201 - Package Boarding.miz and b/Moose Test Missions/CGO - Cargo/CGO-201 - Package Boarding/CGO-201 - Package Boarding.miz differ
diff --git a/Moose Test Missions/CGO - Cargo/CGO-202 - Package Unboarding/CGO-202 - Package Unboarding.miz b/Moose Test Missions/CGO - Cargo/CGO-202 - Package Unboarding/CGO-202 - Package Unboarding.miz
index d8c089fcd..059074c5c 100644
Binary files a/Moose Test Missions/CGO - Cargo/CGO-202 - Package Unboarding/CGO-202 - Package Unboarding.miz and b/Moose Test Missions/CGO - Cargo/CGO-202 - Package Unboarding/CGO-202 - Package Unboarding.miz differ
diff --git a/Moose Test Missions/DET - Detection/DET-001 - Detection Areas/DET-001 - Detection Areas.miz b/Moose Test Missions/DET - Detection/DET-001 - Detection Areas/DET-001 - Detection Areas.miz
index 52737a2b7..c90d7ae99 100644
Binary files a/Moose Test Missions/DET - Detection/DET-001 - Detection Areas/DET-001 - Detection Areas.miz and b/Moose Test Missions/DET - Detection/DET-001 - Detection Areas/DET-001 - Detection Areas.miz differ
diff --git a/Moose Test Missions/DET - Detection/DET-101 - Detection Reporting/DET-101 - Detection Reporting.miz b/Moose Test Missions/DET - Detection/DET-101 - Detection Reporting/DET-101 - Detection Reporting.miz
index 942d4771b..8487d80e7 100644
Binary files a/Moose Test Missions/DET - Detection/DET-101 - Detection Reporting/DET-101 - Detection Reporting.miz and b/Moose Test Missions/DET - Detection/DET-101 - Detection Reporting/DET-101 - Detection Reporting.miz differ
diff --git a/Moose Test Missions/ESC - Escorting/ESC-001 - Escorting Helicopters/ESC-001 - Escorting Helicopters.miz b/Moose Test Missions/ESC - Escorting/ESC-001 - Escorting Helicopters/ESC-001 - Escorting Helicopters.miz
index b0da05899..272002a80 100644
Binary files a/Moose Test Missions/ESC - Escorting/ESC-001 - Escorting Helicopters/ESC-001 - Escorting Helicopters.miz and b/Moose Test Missions/ESC - Escorting/ESC-001 - Escorting Helicopters/ESC-001 - Escorting Helicopters.miz differ
diff --git a/Moose Test Missions/EVT - Event Handling/EVT-001 - API Demo 1/EVT-001 - API Demo 1.lua b/Moose Test Missions/EVT - Event Handling/EVT-001 - API Demo 1/EVT-001 - API Demo 1.lua
new file mode 100644
index 000000000..b2257c66a
--- /dev/null
+++ b/Moose Test Missions/EVT - Event Handling/EVT-001 - API Demo 1/EVT-001 - API Demo 1.lua
@@ -0,0 +1,40 @@
+---
+-- Name: EVT-001 - API Demo 1
+-- Author: FlightControl
+-- Date Created: 7 February 2017
+--
+-- # Situation:
+--
+-- A task shoots another tank. If one of the is dead, the event will be catched.
+--
+-- # Test cases:
+--
+-- 1. Observe the tanks shooting each other.
+-- 2. If one of the tanks die, an event will be catched.
+-- 3. Observe the surviving unit smoking.
+
+
+local Tank1 = UNIT:FindByName( "Tank A" )
+local Tank2 = UNIT:FindByName( "Tank B" )
+
+Tank1:HandleEvent( EVENTS.Dead )
+
+Tank2:HandleEvent( EVENTS.Dead )
+
+--- @param Wrapper.Unit#UNIT self
+function Tank1:OnEventDead( EventData )
+
+ self:SmokeGreen()
+end
+
+--- @param Wrapper.Unit#UNIT self
+function Tank2:OnEventDead( EventData )
+
+ self:SmokeBlue()
+end
+
+function Tank2:OnEventCrash(EventData)
+
+end
+
+
diff --git a/Moose Test Missions/EVT - Event Handling/EVT-001 - API Demo 1/EVT-001 - API Demo 1.miz b/Moose Test Missions/EVT - Event Handling/EVT-001 - API Demo 1/EVT-001 - API Demo 1.miz
new file mode 100644
index 000000000..6b280e3e9
Binary files /dev/null and b/Moose Test Missions/EVT - Event Handling/EVT-001 - API Demo 1/EVT-001 - API Demo 1.miz differ
diff --git a/Moose Test Missions/EVT - Event Handling/EVT-100 - OnEventShot Example/EVT-100 - OnEventShot Example.lua b/Moose Test Missions/EVT - Event Handling/EVT-100 - OnEventShot Example/EVT-100 - OnEventShot Example.lua
new file mode 100644
index 000000000..92b008506
--- /dev/null
+++ b/Moose Test Missions/EVT - Event Handling/EVT-100 - OnEventShot Example/EVT-100 - OnEventShot Example.lua
@@ -0,0 +1,25 @@
+---
+-- Name: EVT-100 - OnEventShot Example
+-- Author: FlightControl
+-- Date Created: 7 February 2017
+--
+-- # Situation:
+--
+-- A plane is flying in the air and shoots an missile to a ground target.
+--
+-- # Test cases:
+--
+-- 1. Observe the plane shooting the missile.
+-- 2. Observe when the plane shoots the missile, a dcs.log entry is written in the logging.
+-- 3. Check the contents of the fields of the S_EVENT_SHOT entry.
+
+local Plane = UNIT:FindByName( "Plane" )
+
+Plane:HandleEvent( EVENTS.Shot )
+
+function Plane:OnEventShot( EventData )
+
+ Plane:MessageToAll( "I just fired a missile!", 15, "Alert!" )
+end
+
+
diff --git a/Moose Test Missions/EVT - Event Handling/EVT-100 - OnEventShot Example/EVT-100 - OnEventShot Example.miz b/Moose Test Missions/EVT - Event Handling/EVT-100 - OnEventShot Example/EVT-100 - OnEventShot Example.miz
new file mode 100644
index 000000000..98c1ffe4d
Binary files /dev/null and b/Moose Test Missions/EVT - Event Handling/EVT-100 - OnEventShot Example/EVT-100 - OnEventShot Example.miz differ
diff --git a/Moose Test Missions/EVT - Event Handling/EVT-101 - OnEventHit Example/EVT-101 - OnEventHit Example.lua b/Moose Test Missions/EVT - Event Handling/EVT-101 - OnEventHit Example/EVT-101 - OnEventHit Example.lua
new file mode 100644
index 000000000..26c89daf5
--- /dev/null
+++ b/Moose Test Missions/EVT - Event Handling/EVT-101 - OnEventHit Example/EVT-101 - OnEventHit Example.lua
@@ -0,0 +1,32 @@
+---
+-- Name: EVT-101 - OnEventHit Example
+-- Author: FlightControl
+-- Date Created: 7 February 2017
+--
+-- # Situation:
+--
+-- A plane is flying in the air and shoots an missile to a ground target.
+--
+-- # Test cases:
+--
+-- 1. Observe the plane shooting the missile.
+-- 2. Observe when the missile hits the target, a dcs.log entry is written in the logging.
+-- 3. Check the contents of the fields of the S_EVENT_HIT entry.
+
+local Plane = UNIT:FindByName( "Plane" )
+
+local Tank = UNIT:FindByName( "Tank" )
+
+Plane:HandleEvent( EVENTS.Hit )
+Tank:HandleEvent( EVENTS.Hit )
+
+function Plane:OnEventHit( EventData )
+
+ Plane:MessageToAll( "I just got hit!", 15, "Alert!" )
+end
+
+function Tank:OnEventHit( EventData )
+ Tank:MessageToAll( "I just got hit!", 15, "Alert!" )
+end
+
+
diff --git a/Moose Test Missions/EVT - Event Handling/EVT-101 - OnEventHit Example/EVT-101 - OnEventHit Example.miz b/Moose Test Missions/EVT - Event Handling/EVT-101 - OnEventHit Example/EVT-101 - OnEventHit Example.miz
new file mode 100644
index 000000000..c39af9fd9
Binary files /dev/null and b/Moose Test Missions/EVT - Event Handling/EVT-101 - OnEventHit Example/EVT-101 - OnEventHit Example.miz differ
diff --git a/Moose Test Missions/EVT - Event Handling/EVT-102 - OnEventTakeoff Example/EVT-102 - OnEventTakeoff Example.lua b/Moose Test Missions/EVT - Event Handling/EVT-102 - OnEventTakeoff Example/EVT-102 - OnEventTakeoff Example.lua
new file mode 100644
index 000000000..4b36e09ec
--- /dev/null
+++ b/Moose Test Missions/EVT - Event Handling/EVT-102 - OnEventTakeoff Example/EVT-102 - OnEventTakeoff Example.lua
@@ -0,0 +1,33 @@
+---
+-- Name: EVT-102 - OnEventTakeoff Example
+-- Author: FlightControl
+-- Date Created: 7 February 2017
+--
+-- # Situation:
+--
+-- A human plane and an AI plane are taking off from an airfield.
+--
+-- # Test cases:
+--
+-- 1. Take-Off the planes from the runway.
+-- 2. When the planes take-off, observe the message being sent.
+-- 3. Check the contents of the fields of the S_EVENT_TAKEOFF entry in the dcs.log file.
+
+local PlaneAI = UNIT:FindByName( "PlaneAI" )
+
+local PlaneHuman = UNIT:FindByName( "PlaneHuman" )
+
+PlaneAI:HandleEvent( EVENTS.Takeoff )
+PlaneHuman:HandleEvent( EVENTS.Takeoff )
+
+function PlaneAI:OnEventTakeoff( EventData )
+
+ PlaneHuman:MessageToAll( "AI Taking Off", 15, "Alert!" )
+end
+
+function PlaneHuman:OnEventTakeoff( EventData )
+
+ PlaneHuman:MessageToAll( "Player " .. PlaneHuman:GetPlayerName() .. " is Taking Off", 15, "Alert!" )
+end
+
+
diff --git a/Moose Test Missions/EVT - Event Handling/EVT-102 - OnEventTakeoff Example/EVT-102 - OnEventTakeoff Example.miz b/Moose Test Missions/EVT - Event Handling/EVT-102 - OnEventTakeoff Example/EVT-102 - OnEventTakeoff Example.miz
new file mode 100644
index 000000000..ca99dde15
Binary files /dev/null and b/Moose Test Missions/EVT - Event Handling/EVT-102 - OnEventTakeoff Example/EVT-102 - OnEventTakeoff Example.miz differ
diff --git a/Moose Test Missions/FSM - Finite State Machine/FSM-100 - Transition Explanation/FSM-100 - Transition Explanation.miz b/Moose Test Missions/FSM - Finite State Machine/FSM-100 - Transition Explanation/FSM-100 - Transition Explanation.miz
index 9d273692e..910cf1700 100644
Binary files a/Moose Test Missions/FSM - Finite State Machine/FSM-100 - Transition Explanation/FSM-100 - Transition Explanation.miz and b/Moose Test Missions/FSM - Finite State Machine/FSM-100 - Transition Explanation/FSM-100 - Transition Explanation.miz differ
diff --git a/Moose Test Missions/GRP - Group Commands/GRP-200 - Follow Group/GRP-200 - Follow Group.miz b/Moose Test Missions/GRP - Group Commands/GRP-200 - Follow Group/GRP-200 - Follow Group.miz
index 850fb90e0..271036cd1 100644
Binary files a/Moose Test Missions/GRP - Group Commands/GRP-200 - Follow Group/GRP-200 - Follow Group.miz and b/Moose Test Missions/GRP - Group Commands/GRP-200 - Follow Group/GRP-200 - Follow Group.miz differ
diff --git a/Moose Test Missions/GRP - Group Commands/GRP-300 - Switch WayPoints/GRP-300 - Switch WayPoints.miz b/Moose Test Missions/GRP - Group Commands/GRP-300 - Switch WayPoints/GRP-300 - Switch WayPoints.miz
index d9c875a3a..dabb339d1 100644
Binary files a/Moose Test Missions/GRP - Group Commands/GRP-300 - Switch WayPoints/GRP-300 - Switch WayPoints.miz and b/Moose Test Missions/GRP - Group Commands/GRP-300 - Switch WayPoints/GRP-300 - Switch WayPoints.miz differ
diff --git a/Moose Test Missions/GRP - Group Commands/Moose_Test_WRAPPER.miz b/Moose Test Missions/GRP - Group Commands/Moose_Test_WRAPPER.miz
index 506f8fc42..ed4cda24a 100644
Binary files a/Moose Test Missions/GRP - Group Commands/Moose_Test_WRAPPER.miz and b/Moose Test Missions/GRP - Group Commands/Moose_Test_WRAPPER.miz differ
diff --git a/Moose Test Missions/MEN - Menu Options/MEN-001 - Menu Client/MEN-001 - Menu Client.miz b/Moose Test Missions/MEN - Menu Options/MEN-001 - Menu Client/MEN-001 - Menu Client.miz
index 5b141c699..8524d7957 100644
Binary files a/Moose Test Missions/MEN - Menu Options/MEN-001 - Menu Client/MEN-001 - Menu Client.miz and b/Moose Test Missions/MEN - Menu Options/MEN-001 - Menu Client/MEN-001 - Menu Client.miz differ
diff --git a/Moose Test Missions/MEN - Menu Options/MEN-002 - Menu Coalition/MEN-002 - Menu Coalition.miz b/Moose Test Missions/MEN - Menu Options/MEN-002 - Menu Coalition/MEN-002 - Menu Coalition.miz
index 07457707a..485ca570d 100644
Binary files a/Moose Test Missions/MEN - Menu Options/MEN-002 - Menu Coalition/MEN-002 - Menu Coalition.miz and b/Moose Test Missions/MEN - Menu Options/MEN-002 - Menu Coalition/MEN-002 - Menu Coalition.miz differ
diff --git a/Moose Test Missions/MEN - Menu Options/MEN-003 - Menu Group/MEN-003 - Menu Group.miz b/Moose Test Missions/MEN - Menu Options/MEN-003 - Menu Group/MEN-003 - Menu Group.miz
index d85b8b9ad..01035850c 100644
Binary files a/Moose Test Missions/MEN - Menu Options/MEN-003 - Menu Group/MEN-003 - Menu Group.miz and b/Moose Test Missions/MEN - Menu Options/MEN-003 - Menu Group/MEN-003 - Menu Group.miz differ
diff --git a/Moose Test Missions/MIT - Missile Trainer/MIT-001 - Missile Trainer/MIT-001 - Missile Trainer.miz b/Moose Test Missions/MIT - Missile Trainer/MIT-001 - Missile Trainer/MIT-001 - Missile Trainer.miz
index 1fa34c97b..e7c62c75a 100644
Binary files a/Moose Test Missions/MIT - Missile Trainer/MIT-001 - Missile Trainer/MIT-001 - Missile Trainer.miz and b/Moose Test Missions/MIT - Missile Trainer/MIT-001 - Missile Trainer/MIT-001 - Missile Trainer.miz differ
diff --git a/Moose Test Missions/MOOSE_Test_Template.miz b/Moose Test Missions/MOOSE_Test_Template.miz
index 543242cd0..8a0bd6009 100644
Binary files a/Moose Test Missions/MOOSE_Test_Template.miz and b/Moose Test Missions/MOOSE_Test_Template.miz differ
diff --git a/Moose Test Missions/PAT - Patrolling/PAT-001 - Switching Patrol Zones/PAT-001 - Switching Patrol Zones.miz b/Moose Test Missions/PAT - Patrolling/PAT-001 - Switching Patrol Zones/PAT-001 - Switching Patrol Zones.miz
index 7fbbaca77..561bf17d4 100644
Binary files a/Moose Test Missions/PAT - Patrolling/PAT-001 - Switching Patrol Zones/PAT-001 - Switching Patrol Zones.miz and b/Moose Test Missions/PAT - Patrolling/PAT-001 - Switching Patrol Zones/PAT-001 - Switching Patrol Zones.miz differ
diff --git a/Moose Test Missions/SCH - Scheduler/SCH-000 - Simple Scheduling/SCH-000 - Simple Scheduling.miz b/Moose Test Missions/SCH - Scheduler/SCH-000 - Simple Scheduling/SCH-000 - Simple Scheduling.miz
index ad72eb378..7732cfcbf 100644
Binary files a/Moose Test Missions/SCH - Scheduler/SCH-000 - Simple Scheduling/SCH-000 - Simple Scheduling.miz and b/Moose Test Missions/SCH - Scheduler/SCH-000 - Simple Scheduling/SCH-000 - Simple Scheduling.miz differ
diff --git a/Moose Test Missions/SCH - Scheduler/SCH-001 - Simple Object Scheduling/SCH-001 - Simple Object Scheduling.miz b/Moose Test Missions/SCH - Scheduler/SCH-001 - Simple Object Scheduling/SCH-001 - Simple Object Scheduling.miz
index ce6fffd63..a0fd6f3fb 100644
Binary files a/Moose Test Missions/SCH - Scheduler/SCH-001 - Simple Object Scheduling/SCH-001 - Simple Object Scheduling.miz and b/Moose Test Missions/SCH - Scheduler/SCH-001 - Simple Object Scheduling/SCH-001 - Simple Object Scheduling.miz differ
diff --git a/Moose Test Missions/SCH - Scheduler/SCH-100 - Simple Repeat Scheduling/SCH-100 - Simple Repeat Scheduling.miz b/Moose Test Missions/SCH - Scheduler/SCH-100 - Simple Repeat Scheduling/SCH-100 - Simple Repeat Scheduling.miz
index bcc6d063a..d51494e21 100644
Binary files a/Moose Test Missions/SCH - Scheduler/SCH-100 - Simple Repeat Scheduling/SCH-100 - Simple Repeat Scheduling.miz and b/Moose Test Missions/SCH - Scheduler/SCH-100 - Simple Repeat Scheduling/SCH-100 - Simple Repeat Scheduling.miz differ
diff --git a/Moose Test Missions/SCH - Scheduler/SCH-110 - Object Repeat Scheduling/SCH-110 - Object Repeat Scheduling.miz b/Moose Test Missions/SCH - Scheduler/SCH-110 - Object Repeat Scheduling/SCH-110 - Object Repeat Scheduling.miz
index f9855f387..c40844f25 100644
Binary files a/Moose Test Missions/SCH - Scheduler/SCH-110 - Object Repeat Scheduling/SCH-110 - Object Repeat Scheduling.miz and b/Moose Test Missions/SCH - Scheduler/SCH-110 - Object Repeat Scheduling/SCH-110 - Object Repeat Scheduling.miz differ
diff --git a/Moose Test Missions/SCH - Scheduler/SCH-200 - Simple Repeat Scheduling Stop and Start/SCH-200 - Simple Repeat Scheduling Stop and Start.miz b/Moose Test Missions/SCH - Scheduler/SCH-200 - Simple Repeat Scheduling Stop and Start/SCH-200 - Simple Repeat Scheduling Stop and Start.miz
index eed9d6159..b451e136c 100644
Binary files a/Moose Test Missions/SCH - Scheduler/SCH-200 - Simple Repeat Scheduling Stop and Start/SCH-200 - Simple Repeat Scheduling Stop and Start.miz and b/Moose Test Missions/SCH - Scheduler/SCH-200 - Simple Repeat Scheduling Stop and Start/SCH-200 - Simple Repeat Scheduling Stop and Start.miz differ
diff --git a/Moose Test Missions/SCH - Scheduler/SCH-300 - GC Simple Object Scheduling/SCH-300 - GC Simple Object Scheduling.miz b/Moose Test Missions/SCH - Scheduler/SCH-300 - GC Simple Object Scheduling/SCH-300 - GC Simple Object Scheduling.miz
index 131391dc1..f3252f423 100644
Binary files a/Moose Test Missions/SCH - Scheduler/SCH-300 - GC Simple Object Scheduling/SCH-300 - GC Simple Object Scheduling.miz and b/Moose Test Missions/SCH - Scheduler/SCH-300 - GC Simple Object Scheduling/SCH-300 - GC Simple Object Scheduling.miz differ
diff --git a/Moose Test Missions/SCH - Scheduler/SCH-310 - GC Object Repeat Scheduling/SCH-310 - GC Object Repeat Scheduling.miz b/Moose Test Missions/SCH - Scheduler/SCH-310 - GC Object Repeat Scheduling/SCH-310 - GC Object Repeat Scheduling.miz
index ce90eec27..6026b9e74 100644
Binary files a/Moose Test Missions/SCH - Scheduler/SCH-310 - GC Object Repeat Scheduling/SCH-310 - GC Object Repeat Scheduling.miz and b/Moose Test Missions/SCH - Scheduler/SCH-310 - GC Object Repeat Scheduling/SCH-310 - GC Object Repeat Scheduling.miz differ
diff --git a/Moose Test Missions/SET - Data Sets/SET-001 - Airbase Sets/SET-001 - Airbase Sets.miz b/Moose Test Missions/SET - Data Sets/SET-001 - Airbase Sets/SET-001 - Airbase Sets.miz
index f2a6395cb..5707660ce 100644
Binary files a/Moose Test Missions/SET - Data Sets/SET-001 - Airbase Sets/SET-001 - Airbase Sets.miz and b/Moose Test Missions/SET - Data Sets/SET-001 - Airbase Sets/SET-001 - Airbase Sets.miz differ
diff --git a/Moose Test Missions/SET - Data Sets/SET-101 - Group Sets/SET-101 - Group Sets.miz b/Moose Test Missions/SET - Data Sets/SET-101 - Group Sets/SET-101 - Group Sets.miz
index 5f1b4cfea..000386c31 100644
Binary files a/Moose Test Missions/SET - Data Sets/SET-101 - Group Sets/SET-101 - Group Sets.miz and b/Moose Test Missions/SET - Data Sets/SET-101 - Group Sets/SET-101 - Group Sets.miz differ
diff --git a/Moose Test Missions/SET - Data Sets/SET-201 - Client Sets/SET-201 - Client Sets.miz b/Moose Test Missions/SET - Data Sets/SET-201 - Client Sets/SET-201 - Client Sets.miz
index 43f9bb552..bb26416c7 100644
Binary files a/Moose Test Missions/SET - Data Sets/SET-201 - Client Sets/SET-201 - Client Sets.miz and b/Moose Test Missions/SET - Data Sets/SET-201 - Client Sets/SET-201 - Client Sets.miz differ
diff --git a/Moose Test Missions/SEV - SEAD Evasion/SEV-001 - SEAD Evasion/SEV-001 - SEAD Evasion.miz b/Moose Test Missions/SEV - SEAD Evasion/SEV-001 - SEAD Evasion/SEV-001 - SEAD Evasion.miz
index 727d8a865..07964bfce 100644
Binary files a/Moose Test Missions/SEV - SEAD Evasion/SEV-001 - SEAD Evasion/SEV-001 - SEAD Evasion.miz and b/Moose Test Missions/SEV - SEAD Evasion/SEV-001 - SEAD Evasion/SEV-001 - SEAD Evasion.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-010 - Spawn Demo/SPA-010 - Spawn Demo.miz b/Moose Test Missions/SPA - Spawning/SPA-010 - Spawn Demo/SPA-010 - Spawn Demo.miz
index d8cdb1557..04e59286c 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-010 - Spawn Demo/SPA-010 - Spawn Demo.miz and b/Moose Test Missions/SPA - Spawning/SPA-010 - Spawn Demo/SPA-010 - Spawn Demo.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-011 - Ground Ops - Simple Spawning/SPA-011 - Ground Ops - Simple Spawning.miz b/Moose Test Missions/SPA - Spawning/SPA-011 - Ground Ops - Simple Spawning/SPA-011 - Ground Ops - Simple Spawning.miz
index 5e2b91c20..5e8b8ea20 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-011 - Ground Ops - Simple Spawning/SPA-011 - Ground Ops - Simple Spawning.miz and b/Moose Test Missions/SPA - Spawning/SPA-011 - Ground Ops - Simple Spawning/SPA-011 - Ground Ops - Simple Spawning.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-012 - Ground Ops - Multiple Spawns/SPA-012 - Ground Ops - Multiple Spawns.miz b/Moose Test Missions/SPA - Spawning/SPA-012 - Ground Ops - Multiple Spawns/SPA-012 - Ground Ops - Multiple Spawns.miz
index 8af904750..bc0bd317a 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-012 - Ground Ops - Multiple Spawns/SPA-012 - Ground Ops - Multiple Spawns.miz and b/Moose Test Missions/SPA - Spawning/SPA-012 - Ground Ops - Multiple Spawns/SPA-012 - Ground Ops - Multiple Spawns.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-013 - Ground Ops - Scheduled Spawns/SPA-013 - Ground Ops - Scheduled Spawns.miz b/Moose Test Missions/SPA - Spawning/SPA-013 - Ground Ops - Scheduled Spawns/SPA-013 - Ground Ops - Scheduled Spawns.miz
index 784756eb4..4f315db02 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-013 - Ground Ops - Scheduled Spawns/SPA-013 - Ground Ops - Scheduled Spawns.miz and b/Moose Test Missions/SPA - Spawning/SPA-013 - Ground Ops - Scheduled Spawns/SPA-013 - Ground Ops - Scheduled Spawns.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-014 - Ground Ops - Scheduled Spawns Limited/SPA-014 - Ground Ops - Scheduled Spawns Limited.miz b/Moose Test Missions/SPA - Spawning/SPA-014 - Ground Ops - Scheduled Spawns Limited/SPA-014 - Ground Ops - Scheduled Spawns Limited.miz
index 6f1986876..1b4be216a 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-014 - Ground Ops - Scheduled Spawns Limited/SPA-014 - Ground Ops - Scheduled Spawns Limited.miz and b/Moose Test Missions/SPA - Spawning/SPA-014 - Ground Ops - Scheduled Spawns Limited/SPA-014 - Ground Ops - Scheduled Spawns Limited.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-015 - Ground Ops - Randomize Route/SPA-015 - Ground Ops - Randomize Route.miz b/Moose Test Missions/SPA - Spawning/SPA-015 - Ground Ops - Randomize Route/SPA-015 - Ground Ops - Randomize Route.miz
index 68364394f..fc77b6d0d 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-015 - Ground Ops - Randomize Route/SPA-015 - Ground Ops - Randomize Route.miz and b/Moose Test Missions/SPA - Spawning/SPA-015 - Ground Ops - Randomize Route/SPA-015 - Ground Ops - Randomize Route.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-016 - Ground Ops - Randomize Zones/SPA-016 - Ground Ops - Randomize Zones.miz b/Moose Test Missions/SPA - Spawning/SPA-016 - Ground Ops - Randomize Zones/SPA-016 - Ground Ops - Randomize Zones.miz
index 650bac775..99c868ae3 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-016 - Ground Ops - Randomize Zones/SPA-016 - Ground Ops - Randomize Zones.miz and b/Moose Test Missions/SPA - Spawning/SPA-016 - Ground Ops - Randomize Zones/SPA-016 - Ground Ops - Randomize Zones.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-017 - Ground Ops - Set AI inactive while spawning/SPA-017 - Ground Ops - Set AI inactive while spawning.miz b/Moose Test Missions/SPA - Spawning/SPA-017 - Ground Ops - Set AI inactive while spawning/SPA-017 - Ground Ops - Set AI inactive while spawning.miz
index 8042a8245..0dd4e6629 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-017 - Ground Ops - Set AI inactive while spawning/SPA-017 - Ground Ops - Set AI inactive while spawning.miz and b/Moose Test Missions/SPA - Spawning/SPA-017 - Ground Ops - Set AI inactive while spawning/SPA-017 - Ground Ops - Set AI inactive while spawning.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-018 - Ground Ops - Randomize Templates/SPA-018 - Ground Ops - Randomize Templates.miz b/Moose Test Missions/SPA - Spawning/SPA-018 - Ground Ops - Randomize Templates/SPA-018 - Ground Ops - Randomize Templates.miz
index 1dbbc778f..2401d86bc 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-018 - Ground Ops - Randomize Templates/SPA-018 - Ground Ops - Randomize Templates.miz and b/Moose Test Missions/SPA - Spawning/SPA-018 - Ground Ops - Randomize Templates/SPA-018 - Ground Ops - Randomize Templates.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-100 - CleanUp Inactive Units/SPA-100 - CleanUp Inactive Units.miz b/Moose Test Missions/SPA - Spawning/SPA-100 - CleanUp Inactive Units/SPA-100 - CleanUp Inactive Units.miz
index 9df71da2d..516367d6b 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-100 - CleanUp Inactive Units/SPA-100 - CleanUp Inactive Units.miz and b/Moose Test Missions/SPA - Spawning/SPA-100 - CleanUp Inactive Units/SPA-100 - CleanUp Inactive Units.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-110 - Limit Spawning/SPA-110 - Limit Spawning.miz b/Moose Test Missions/SPA - Spawning/SPA-110 - Limit Spawning/SPA-110 - Limit Spawning.miz
index 4c72cb2fb..a7c2c3df7 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-110 - Limit Spawning/SPA-110 - Limit Spawning.miz and b/Moose Test Missions/SPA - Spawning/SPA-110 - Limit Spawning/SPA-110 - Limit Spawning.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-120 - Repeat Spawning/SPA-120 - Repeat Spawning.miz b/Moose Test Missions/SPA - Spawning/SPA-120 - Repeat Spawning/SPA-120 - Repeat Spawning.miz
index f7d1f7b3d..e59bb848c 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-120 - Repeat Spawning/SPA-120 - Repeat Spawning.miz and b/Moose Test Missions/SPA - Spawning/SPA-120 - Repeat Spawning/SPA-120 - Repeat Spawning.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-121 - Air Ops - Scheduled Spawns with Repeat on Landing with Limit/SPA-121 - Air Ops - Scheduled Spawns with Repeat on Landing with Limit.miz b/Moose Test Missions/SPA - Spawning/SPA-121 - Air Ops - Scheduled Spawns with Repeat on Landing with Limit/SPA-121 - Air Ops - Scheduled Spawns with Repeat on Landing with Limit.miz
index 64c93030f..2b3ec0bf0 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-121 - Air Ops - Scheduled Spawns with Repeat on Landing with Limit/SPA-121 - Air Ops - Scheduled Spawns with Repeat on Landing with Limit.miz and b/Moose Test Missions/SPA - Spawning/SPA-121 - Air Ops - Scheduled Spawns with Repeat on Landing with Limit/SPA-121 - Air Ops - Scheduled Spawns with Repeat on Landing with Limit.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-130 - Uncontrolled Spawning/SPA-130 - Uncontrolled Spawning.miz b/Moose Test Missions/SPA - Spawning/SPA-130 - Uncontrolled Spawning/SPA-130 - Uncontrolled Spawning.miz
index 1d25f2237..fb00ff34f 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-130 - Uncontrolled Spawning/SPA-130 - Uncontrolled Spawning.miz and b/Moose Test Missions/SPA - Spawning/SPA-130 - Uncontrolled Spawning/SPA-130 - Uncontrolled Spawning.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-200 - Randomize Unit Types/SPA-200 - Randomize Unit Types.miz b/Moose Test Missions/SPA - Spawning/SPA-200 - Randomize Unit Types/SPA-200 - Randomize Unit Types.miz
index 3f0943965..8ca5f7d35 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-200 - Randomize Unit Types/SPA-200 - Randomize Unit Types.miz and b/Moose Test Missions/SPA - Spawning/SPA-200 - Randomize Unit Types/SPA-200 - Randomize Unit Types.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-220 - Randomize Zones/SPA-220 - Randomize Zones.miz b/Moose Test Missions/SPA - Spawning/SPA-220 - Randomize Zones/SPA-220 - Randomize Zones.miz
index df86d81eb..28be1489c 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-220 - Randomize Zones/SPA-220 - Randomize Zones.miz and b/Moose Test Missions/SPA - Spawning/SPA-220 - Randomize Zones/SPA-220 - Randomize Zones.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-310 - Spawn at Static position/SPA-310 - Spawn at Static position.miz b/Moose Test Missions/SPA - Spawning/SPA-310 - Spawn at Static position/SPA-310 - Spawn at Static position.miz
index cfc79c50b..7b3f05e30 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-310 - Spawn at Static position/SPA-310 - Spawn at Static position.miz and b/Moose Test Missions/SPA - Spawning/SPA-310 - Spawn at Static position/SPA-310 - Spawn at Static position.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-320 - Spawn at Unit position/SPA-320 - Spawn at Unit position.miz b/Moose Test Missions/SPA - Spawning/SPA-320 - Spawn at Unit position/SPA-320 - Spawn at Unit position.miz
index 7b140dc2c..572a4915e 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-320 - Spawn at Unit position/SPA-320 - Spawn at Unit position.miz and b/Moose Test Missions/SPA - Spawning/SPA-320 - Spawn at Unit position/SPA-320 - Spawn at Unit position.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-330 - Spawn at Vec2 position/SPA-330 - Spawn at Vec2 position.miz b/Moose Test Missions/SPA - Spawning/SPA-330 - Spawn at Vec2 position/SPA-330 - Spawn at Vec2 position.miz
index cabec00e5..58e723346 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-330 - Spawn at Vec2 position/SPA-330 - Spawn at Vec2 position.miz and b/Moose Test Missions/SPA - Spawning/SPA-330 - Spawn at Vec2 position/SPA-330 - Spawn at Vec2 position.miz differ
diff --git a/Moose Test Missions/SPA - Spawning/SPA-340 - Spawn at Vec3 position/SPA-340 - Spawn at Vec3 position.miz b/Moose Test Missions/SPA - Spawning/SPA-340 - Spawn at Vec3 position/SPA-340 - Spawn at Vec3 position.miz
index 90b5d5199..4b2037be4 100644
Binary files a/Moose Test Missions/SPA - Spawning/SPA-340 - Spawn at Vec3 position/SPA-340 - Spawn at Vec3 position.miz and b/Moose Test Missions/SPA - Spawning/SPA-340 - Spawn at Vec3 position/SPA-340 - Spawn at Vec3 position.miz differ
diff --git a/Moose Test Missions/TAD - Task Dispatching/TAD-010 - Task Dispatching Demo/TAD-010 - Task Dispatching Demo.miz b/Moose Test Missions/TAD - Task Dispatching/TAD-010 - Task Dispatching Demo/TAD-010 - Task Dispatching Demo.miz
index d748e3649..dc0359a19 100644
Binary files a/Moose Test Missions/TAD - Task Dispatching/TAD-010 - Task Dispatching Demo/TAD-010 - Task Dispatching Demo.miz and b/Moose Test Missions/TAD - Task Dispatching/TAD-010 - Task Dispatching Demo/TAD-010 - Task Dispatching Demo.miz differ
diff --git a/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.miz b/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.miz
index 9cccc3798..f71bbb704 100644
Binary files a/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.miz and b/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.miz differ
diff --git a/Moose Test Missions/TSK - Task Modelling/TSK-020 - Task Modelling - Pickup/TSK-020 - Task Modelling - Pickup.miz b/Moose Test Missions/TSK - Task Modelling/TSK-020 - Task Modelling - Pickup/TSK-020 - Task Modelling - Pickup.miz
index 5fe108e5c..aa99e48b0 100644
Binary files a/Moose Test Missions/TSK - Task Modelling/TSK-020 - Task Modelling - Pickup/TSK-020 - Task Modelling - Pickup.miz and b/Moose Test Missions/TSK - Task Modelling/TSK-020 - Task Modelling - Pickup/TSK-020 - Task Modelling - Pickup.miz differ
diff --git a/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz b/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz
index d84117bce..085395bb7 100644
Binary files a/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-100 - Normal Zone/ZON-100 - Normal Zone.miz differ
diff --git a/Moose Test Missions/ZON - Zones/ZON-200 - Group Zone/ZON-200 - Group Zone.miz b/Moose Test Missions/ZON - Zones/ZON-200 - Group Zone/ZON-200 - Group Zone.miz
index fa61a23c9..83c06dcd8 100644
Binary files a/Moose Test Missions/ZON - Zones/ZON-200 - Group Zone/ZON-200 - Group Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-200 - Group Zone/ZON-200 - Group Zone.miz differ
diff --git a/Moose Test Missions/ZON - Zones/ZON-300 - Unit Zone/ZON-300 - Unit Zone.miz b/Moose Test Missions/ZON - Zones/ZON-300 - Unit Zone/ZON-300 - Unit Zone.miz
index c5d7dbf9d..0a92206c5 100644
Binary files a/Moose Test Missions/ZON - Zones/ZON-300 - Unit Zone/ZON-300 - Unit Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-300 - Unit Zone/ZON-300 - Unit Zone.miz differ
diff --git a/Moose Test Missions/ZON - Zones/ZON-400 - Radius Zone/ZON-400 - Radius Zone.miz b/Moose Test Missions/ZON - Zones/ZON-400 - Radius Zone/ZON-400 - Radius Zone.miz
index 807b7251c..99cd9fccf 100644
Binary files a/Moose Test Missions/ZON - Zones/ZON-400 - Radius Zone/ZON-400 - Radius Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-400 - Radius Zone/ZON-400 - Radius Zone.miz differ
diff --git a/Moose Test Missions/ZON - Zones/ZON-500 - Polygon Zone/ZON-500 - Polygon Zone.miz b/Moose Test Missions/ZON - Zones/ZON-500 - Polygon Zone/ZON-500 - Polygon Zone.miz
index 17e5df92e..4d046e5d9 100644
Binary files a/Moose Test Missions/ZON - Zones/ZON-500 - Polygon Zone/ZON-500 - Polygon Zone.miz and b/Moose Test Missions/ZON - Zones/ZON-500 - Polygon Zone/ZON-500 - Polygon Zone.miz differ
diff --git a/Moose Test Missions/ZON - Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones.miz b/Moose Test Missions/ZON - Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones.miz
index 67cceab8c..942851881 100644
Binary files a/Moose Test Missions/ZON - Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones.miz and b/Moose Test Missions/ZON - Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones/ZON-510 - Send message if Clients fly the first time in the Polygon Zones.miz differ
diff --git a/docs/Documentation/AI_Cas.html b/docs/Documentation/AI_Cas.html
index bae974427..a18c40a16 100644
--- a/docs/Documentation/AI_Cas.html
+++ b/docs/Documentation/AI_Cas.html
@@ -262,6 +262,36 @@ It can be notified to go RTB through the RTB event.
AI_CAS_ZONE:Engage() |
Synchronous Event Trigger for Event Engage.
+ |
+
+
+ | AI_CAS_ZONE.EngageAltitude |
+
+
+ |
+
+
+ | AI_CAS_ZONE.EngageAttackQty |
+
+
+ |
+
+
+ | AI_CAS_ZONE.EngageDirection |
+
+
+ |
+
+
+ | AI_CAS_ZONE.EngageSpeed |
+
+
+ |
+
+
+ | AI_CAS_ZONE.EngageWeaponExpend |
+
+
|
@@ -301,7 +331,7 @@ It can be notified to go RTB through the RTB event.
- | AI_CAS_ZONE:OnAfterEngage(Controllable, From, Event, To) |
+ AI_CAS_ZONE:OnAfterEngage(Controllable, From, Event, To, EngageSpeed, EngageWeaponExpend, EngageAltitude, EngageAttackQty, EngageDirection) |
OnAfter Transition Handler for Event Engage.
|
@@ -331,7 +361,7 @@ It can be notified to go RTB through the RTB event.
- | AI_CAS_ZONE:OnBeforeEngage(Controllable, From, Event, To) |
+ AI_CAS_ZONE:OnBeforeEngage(Controllable, From, Event, To, EngageSpeed, EngageWeaponExpend, EngageAltitude, EngageAttackQty, EngageDirection) |
OnBefore Transition Handler for Event Engage.
|
@@ -415,7 +445,7 @@ It can be notified to go RTB through the RTB event.
- | AI_CAS_ZONE:onafterEngage(Controllable, From, Event, To) |
+ AI_CAS_ZONE:onafterEngage(Controllable, From, Event, To, EngageSpeed, EngageWeaponExpend, EngageAltitude, EngageAttackQty, EngageDirection) |
|
@@ -424,6 +454,12 @@ It can be notified to go RTB through the RTB event.
AI_CAS_ZONE:onafterStart(Controllable, From, Event, To) |
onafter State Transition for Event Start.
+ |
+
+
+ | AI_CAS_ZONE:onafterTarget(Controllable, From, Event, To) |
+
+
|
@@ -569,6 +605,74 @@ It can be notified to go RTB through the RTB event.
Synchronous Event Trigger for Event Engage.
+
+
+
+-
+
+
+AI_CAS_ZONE.EngageAltitude
+
+
+-
+
+
+
+
+
+
+-
+
+
+
+AI_CAS_ZONE.EngageAttackQty
+
+
+-
+
+
+
+
+
+
+-
+
+
+
+AI_CAS_ZONE.EngageDirection
+
+
+-
+
+
+
+
+
+
+-
+
+
+AI_CAS_ZONE.EngageSpeed
+
+
+-
+
+
+
+
+
+
+-
+
+
+
+AI_CAS_ZONE.EngageWeaponExpend
+
+
+-
+
+
+
@@ -784,7 +888,7 @@ The To State string.
-
-AI_CAS_ZONE:OnAfterEngage(Controllable, From, Event, To)
+AI_CAS_ZONE:OnAfterEngage(Controllable, From, Event, To, EngageSpeed, EngageWeaponExpend, EngageAltitude, EngageAttackQty, EngageDirection)
-
@@ -816,6 +920,36 @@ The Event string.
#string To :
The To State string.
+
+ -
+
+
#number EngageSpeed :
+(optional) The speed the Group will hold when engaging to the target zone.
+
+
+ -
+
+
Dcs.DCSTypes#AI.Task.WeaponExpend EngageWeaponExpend :
+(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion.
+
+
+ -
+
+
Dcs.DCSTypes#Distance EngageAltitude :
+(optional) Desired altitude to perform the unit engagement.
+
+
+ -
+
+
#number EngageAttackQty :
+(optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo.
+
+
+ -
+
+
Dcs.DCSTypes#Azimuth EngageDirection :
+(optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction.
+
@@ -999,7 +1133,7 @@ Return false to cancel Transition.
-
-AI_CAS_ZONE:OnBeforeEngage(Controllable, From, Event, To)
+AI_CAS_ZONE:OnBeforeEngage(Controllable, From, Event, To, EngageSpeed, EngageWeaponExpend, EngageAltitude, EngageAttackQty, EngageDirection)
-
@@ -1032,12 +1166,37 @@ The Event string.
The To State string.
-
-
Return value
+ -
-
#boolean:
-Return false to cancel Transition.
+#number EngageSpeed :
+(optional) The speed the Group will hold when engaging to the target zone.
+
+ -
+
+
Dcs.DCSTypes#AI.Task.WeaponExpend EngageWeaponExpend :
+(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion.
+
+
+ -
+
+
Dcs.DCSTypes#Distance EngageAltitude :
+(optional) Desired altitude to perform the unit engagement.
+
+
+ -
+
+
#number EngageAttackQty :
+(optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo.
+
+
+ -
+
+
Dcs.DCSTypes#Azimuth EngageDirection :
+(optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction.
+
+
+
@@ -1434,13 +1593,83 @@ The To State string.
-
-AI_CAS_ZONE:onafterEngage(Controllable, From, Event, To)
+AI_CAS_ZONE:onafterEngage(Controllable, From, Event, To, EngageSpeed, EngageWeaponExpend, EngageAltitude, EngageAttackQty, EngageDirection)
-
+
Parameters
+
+ -
+
+
Wrapper.Controllable#CONTROLLABLE Controllable :
+The Controllable Object managed by the FSM.
+
+
+ -
+
+
#string From :
+The From State string.
+
+
+ -
+
+
#string Event :
+The Event string.
+
+
+ -
+
+
#string To :
+The To State string.
+
+
+ -
+
+
#number EngageSpeed :
+(optional) The speed the Group will hold when engaging to the target zone.
+
+
+ -
+
+
Dcs.DCSTypes#AI.Task.WeaponExpend EngageWeaponExpend :
+(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / controllable will choose expend on its own discretion.
+
+
+ -
+
+
Dcs.DCSTypes#Distance EngageAltitude :
+(optional) Desired altitude to perform the unit engagement.
+
+
+ -
+
+
#number EngageAttackQty :
+(optional) This parameter limits maximal quantity of attack. The aicraft/controllable will not make more attack than allowed even if the target controllable not destroyed and the aicraft/controllable still have ammo. If not defined the aircraft/controllable will attack target until it will be destroyed or until the aircraft/controllable will run out of ammo.
+
+
+ -
+
+
Dcs.DCSTypes#Azimuth EngageDirection :
+(optional) Desired ingress direction from the target to the attacking aircraft. Controllable/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain controllable/aircraft will choose another direction.
+
+
+
+
+
+
+-
+
+
+AI_CAS_ZONE:onafterStart(Controllable, From, Event, To)
+
+
+-
+
+
onafter State Transition for Event Start.
+
Parameters
-
@@ -1473,13 +1702,13 @@ The To State string.
-
-
-AI_CAS_ZONE:onafterStart(Controllable, From, Event, To)
+
+AI_CAS_ZONE:onafterTarget(Controllable, From, Event, To)
-
-
onafter State Transition for Event Start.
+
Parameters
diff --git a/docs/Documentation/AI_Patrol.html b/docs/Documentation/AI_Patrol.html
index 9510146aa..c2d613229 100644
--- a/docs/Documentation/AI_Patrol.html
+++ b/docs/Documentation/AI_Patrol.html
@@ -265,6 +265,12 @@ Use the method AIPATROLZONE.M
| AI_PATROL_ZONE.ClassName |
+ |
+
+
+ | AI_PATROL_ZONE:ClearDetectedUnits() |
+
+ Clears the list of Unit#UNITs that were detected by the AI.
|
@@ -751,6 +757,19 @@ Use the method AIPATROLZONE.M
+
+
+
+-
+
+
+AI_PATROL_ZONE:ClearDetectedUnits()
+
+
+-
+
+
Clears the list of Unit#UNITs that were detected by the AI.
+
@@ -861,9 +880,6 @@ Use the method AIPATROLZONE.M
-
- This table contains the targets detected during patrol.
-
diff --git a/docs/Documentation/Base.html b/docs/Documentation/Base.html
index f57d62e02..39c311970 100644
--- a/docs/Documentation/Base.html
+++ b/docs/Documentation/Base.html
@@ -139,59 +139,54 @@ These tracing levels were defined to avoid bulks of tracing to be generated by l
1.3 DCS simulator Event Handling
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.
-Therefore, the BASE class exposes the following event handling functions:
+and handled through lua scripting. MOOSE provides an encapsulation to handle these events more efficiently.
+
+1.3.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.
-The EventOn() methods provide the Event#EVENTDATA structure to the event handling function.
-The Event#EVENTDATA structure contains an enriched data set of information about the event being handled.
+1.3.2 Event Handling of DCS Events
-Find below an example of the prototype how to write an event handling function:
+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.
- CommandCenter:EventOnPlayerEnterUnit(
- --- @param #COMMANDCENTER self
- -- @param Core.Event#EVENTDATA EventData
- function( self, EventData )
- local PlayerUnit = EventData.IniUnit
- for MissionID, Mission in pairs( self:GetMissions() ) do
- local Mission = Mission -- Tasking.Mission#MISSION
- Mission:JoinUnit( PlayerUnit )
- Mission:ReportDetails()
- end
- end
- )
+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
-Note the function( self, EventData ). It takes two parameters:
-
- - self = the object that is handling the EventOnPlayerEnterUnit.
- - EventData = the Event#EVENTDATA structure, containing more information of the Event.
-
+
+See the Event module for more information about event handling.
1.4) Class identification methods
@@ -276,12 +271,6 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
- | BASE:AddEvent(Event, EventFunction) |
-
- Set a new listener for the class.
- |
-
-
| BASE.ClassID |
The ID number of the class.
@@ -315,12 +304,6 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
| BASE:CreateEventCrash(EventTime, Initiator) |
Creation of a Crash Event.
- |
-
-
- | BASE:DisableEvents() |
-
- Disable the event listeners for the class.
|
@@ -330,153 +313,9 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
- | BASE:EnableEvents() |
-
- Enable the event listeners for the class.
- |
-
-
- | BASE:Event() |
+ BASE:EventDispatcher() |
Returns the event dispatcher
- |
-
-
- | BASE:EventOnBaseCaptured(EventFunction) |
-
- Subscribe to a SEVENTBASE_CAPTURED event.
- |
-
-
- | BASE:EventOnBirth(EventFunction) |
-
- Subscribe to a S_EVENT_BIRTH event.
- |
-
-
- | BASE:EventOnCrash(EventFunction) |
-
- Subscribe to a S_EVENT_CRASH event.
- |
-
-
- | BASE:EventOnDead(EventFunction) |
-
- Subscribe to a S_EVENT_DEAD event.
- |
-
-
- | BASE:EventOnEjection(EventFunction) |
-
- Subscribe to a S_EVENT_EJECTION event.
- |
-
-
- | BASE:EventOnEngineShutdown(EventFunction) |
-
- Subscribe to a SEVENTENGINE_SHUTDOWN event.
- |
-
-
- | BASE:EventOnEngineStartup(EventFunction) |
-
- Subscribe to a SEVENTENGINE_STARTUP event.
- |
-
-
- | BASE:EventOnHit(EventFunction) |
-
- Subscribe to a S_EVENT_HIT event.
- |
-
-
- | BASE:EventOnHumanFailure(EventFunction) |
-
- Subscribe to a SEVENTHUMAN_FAILURE event.
- |
-
-
- | BASE:EventOnLand(EventFunction) |
-
- Subscribe to a S_EVENT_LAND event.
- |
-
-
- | BASE:EventOnMissionStart(EventFunction) |
-
- Subscribe to a SEVENTMISSION_START event.
- |
-
-
- | BASE:EventOnPilotDead(EventFunction) |
-
- Subscribe to a SEVENTPILOT_DEAD event.
- |
-
-
- | BASE:EventOnPlayerComment(EventFunction) |
-
- Subscribe to a SEVENTPLAYER_COMMENT event.
- |
-
-
- | BASE:EventOnPlayerEnterUnit(EventFunction) |
-
- Subscribe to a SEVENTPLAYER_ENTER_UNIT event.
- |
-
-
- | BASE:EventOnPlayerLeaveUnit(EventFunction) |
-
- Subscribe to a SEVENTPLAYER_LEAVE_UNIT event.
- |
-
-
- | BASE:EventOnPlayerMissionEnd(EventFunction) |
-
- Subscribe to a SEVENTMISSION_END event.
- |
-
-
- | BASE:EventOnRefueling(EventFunction) |
-
- Subscribe to a S_EVENT_REFUELING event.
- |
-
-
- | BASE:EventOnRefuelingStop(EventFunction) |
-
- Subscribe to a SEVENTREFUELING_STOP event.
- |
-
-
- | BASE:EventOnShootingEnd(EventFunction) |
-
- Subscribe to a SEVENTSHOOTING_END event.
- |
-
-
- | BASE:EventOnShootingStart(EventFunction) |
-
- Subscribe to a SEVENTSHOOTING_START event.
- |
-
-
- | BASE:EventOnShot(EventFunction) |
-
- Subscribe to a S_EVENT_SHOT event.
- |
-
-
- | BASE:EventOnTakeOff(EventFunction) |
-
- Subscribe to a S_EVENT_TAKEOFF event.
- |
-
-
- | BASE:EventOnTookControl(EventFunction) |
-
- Subscribe to a SEVENTTOOK_CONTROL event.
|
@@ -543,6 +382,12 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
| BASE:GetState(Object, Key, Value) |
Get a Value given a Key from the Object.
+ |
+
+
+ | BASE:HandleEvent(Event, EventFunction) |
+
+ Subscribe to a DCS Event.
|
@@ -561,6 +406,135 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
| BASE:New() |
+ |
+
+
+ | BASE:OnEvent(EventData) |
+
+ Occurs when an object is completely destroyed.
+ |
+
+
+ | BASE:OnEventBaseCaptured(EventData) |
+
+ Occurs when a ground unit captures either an airbase or a farp.
+ |
+
+
+ | BASE:OnEventBirth(EventData) |
+
+ Occurs when any object is spawned into the mission.
+ |
+
+
+ | BASE:OnEventCrash(EventData) |
+
+ Occurs when any aircraft crashes into the ground and is completely destroyed.
+ |
+
+
+ | BASE:OnEventEjection(EventData) |
+
+ Occurs when a pilot ejects from an aircraft
+initiator : The unit that has ejected
+ |
+
+
+ | BASE:OnEventEngineShutdown(EventData) |
+
+ Occurs when any aircraft shuts down its engines.
+ |
+
+
+ | BASE:OnEventEngineStartup(EventData) |
+
+ Occurs when any aircraft starts its engines.
+ |
+
+
+ | BASE:OnEventHit(EventData) |
+
+ Occurs whenever an object is hit by a weapon.
+ |
+
+
+ | BASE:OnEventHumanFailure(EventData) |
+
+ Occurs when any system fails on a human controlled aircraft.
+ |
+
+
+ | BASE:OnEventLand(EventData) |
+
+ Occurs when an aircraft lands at an airbase, farp or ship
+initiator : The unit that has landed
+place: Object that the unit landed on.
+ |
+
+
+ | BASE:OnEventMissionEnd(EventData) |
+
+ Occurs when a mission ends
+ |
+
+
+ | BASE:OnEventMissionStart(EventData) |
+
+ Occurs when a mission starts
+ |
+
+
+ | BASE:OnEventPilotDead(EventData) |
+
+ Occurs when the pilot of an aircraft is killed.
+ |
+
+
+ | BASE:OnEventPlayerEnterUnit(EventData) |
+
+ Occurs when any player assumes direct control of a unit.
+ |
+
+
+ | BASE:OnEventPlayerLeaveUnit(EventData) |
+
+ Occurs when any player relieves control of a unit to the AI.
+ |
+
+
+ | BASE:OnEventRefueling(EventData) |
+
+ Occurs when an aircraft connects with a tanker and begins taking on fuel.
+ |
+
+
+ | BASE:OnEventRefuelingStop(EventData) |
+
+ Occurs when an aircraft is finished taking fuel.
+ |
+
+
+ | BASE:OnEventShootingEnd(EventData) |
+
+ Occurs when any unit stops firing its weapon.
+ |
+
+
+ | BASE:OnEventShootingStart(EventData) |
+
+ Occurs when any unit begins firing a weapon that has a high rate of fire.
+ |
+
+
+ | BASE:OnEventShot(EventData) |
+
+ Occurs whenever any unit in a mission fires a weapon.
+ |
+
+
+ | BASE:OnEventTakeoff(EventData) |
+
+ Occurs when an aircraft takes off from an airbase, farp, or ship.
|
@@ -629,6 +603,12 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
Set trace on or off
Note that when trace is off, no debug statement is performed, increasing performance!
When Moose is loaded statically, (as one file), tracing is switched off by default.
+
+
+
+ | BASE:UnHandleEvent(Event) |
+
+ UnSubscribe to a DCS event.
|
@@ -718,37 +698,6 @@ When Moose is loaded statically, (as one file), tracing is switched off by defau
-
-
-BASE:AddEvent(Event, EventFunction)
-
-
--
-
-
Set a new listener for the class.
-
- Parameters
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
BASE.ClassID
@@ -886,24 +835,6 @@ The initiating object of the event.
-
-
-BASE:DisableEvents()
-
-
--
-
-
Disable the event listeners for the class.
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
BASE:E(Arguments)
@@ -929,26 +860,8 @@ A #table or any field.
-
-
-BASE:EnableEvents()
-
-
--
-
-
Enable the event listeners for the class.
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:Event()
+
+BASE:EventDispatcher()
-
@@ -960,627 +873,6 @@ A #table or any field.
Core.Event#EVENT:
-
-
-
--
-
-
-BASE:EventOnBaseCaptured(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTBASE_CAPTURED event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnBirth(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_BIRTH event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnCrash(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_CRASH event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnDead(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_DEAD event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnEjection(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_EJECTION event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnEngineShutdown(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTENGINE_SHUTDOWN event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnEngineStartup(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTENGINE_STARTUP event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnHit(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_HIT event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnHumanFailure(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTHUMAN_FAILURE event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnLand(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_LAND event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnMissionStart(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTMISSION_START event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnPilotDead(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTPILOT_DEAD event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-
--
-
-
Subscribe to a SEVENTPLAYER_COMMENT event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnPlayerEnterUnit(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTPLAYER_ENTER_UNIT event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnPlayerLeaveUnit(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTPLAYER_LEAVE_UNIT event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnPlayerMissionEnd(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTMISSION_END event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnRefueling(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_REFUELING event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnRefuelingStop(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTREFUELING_STOP event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnShootingEnd(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTSHOOTING_END event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnShootingStart(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTSHOOTING_START event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnShot(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_SHOT event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnTakeOff(EventFunction)
-
-
--
-
-
Subscribe to a S_EVENT_TAKEOFF event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
-
-
-
--
-
-
-BASE:EventOnTookControl(EventFunction)
-
-
--
-
-
Subscribe to a SEVENTTOOK_CONTROL event.
-
- Parameter
-
- Return value
-
-#BASE:
-
-
@@ -1836,6 +1128,38 @@ The value to is stored in the Object.
The Value retrieved.
+
+
+
+-
+
+
+BASE:HandleEvent(Event, EventFunction)
+
+
+-
+
+
Subscribe to a DCS Event.
+
+ Parameters
+
+ Return value
+
+#BASE:
+
+
@@ -1908,6 +1232,533 @@ Child
-
+
+BASE:OnEvent(EventData)
+
+
+-
+
+
Occurs when an object is completely destroyed.
+
+
+initiator : The unit that is was destroyed.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventBaseCaptured(EventData)
+
+
+-
+
+
Occurs when a ground unit captures either an airbase or a farp.
+
+
+initiator : The unit that captured the base
+place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventBirth(EventData)
+
+
+-
+
+
Occurs when any object is spawned into the mission.
+
+
+initiator : The unit that was spawned
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventCrash(EventData)
+
+
+-
+
+
Occurs when any aircraft crashes into the ground and is completely destroyed.
+
+
+initiator : The unit that has crashed
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventEjection(EventData)
+
+
+-
+
+
Occurs when a pilot ejects from an aircraft
+initiator : The unit that has ejected
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventEngineShutdown(EventData)
+
+
+-
+
+
Occurs when any aircraft shuts down its engines.
+
+
+initiator : The unit that is stopping its engines.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventEngineStartup(EventData)
+
+
+-
+
+
Occurs when any aircraft starts its engines.
+
+
+initiator : The unit that is starting its engines.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventHit(EventData)
+
+
+-
+
+
Occurs whenever an object is hit by a weapon.
+
+
+initiator : The unit object the fired the weapon
+weapon: Weapon object that hit the target
+target: The Object that was hit.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventHumanFailure(EventData)
+
+
+-
+
+
Occurs when any system fails on a human controlled aircraft.
+
+
+initiator : The unit that had the failure
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventLand(EventData)
+
+
+-
+
+
Occurs when an aircraft lands at an airbase, farp or ship
+initiator : The unit that has landed
+place: Object that the unit landed on.
+
+
+Can be an Airbase Object, FARP, or Ships
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventMissionEnd(EventData)
+
+
+-
+
+
Occurs when a mission ends
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventMissionStart(EventData)
+
+
+-
+
+
Occurs when a mission starts
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventPilotDead(EventData)
+
+
+-
+
+
Occurs when the pilot of an aircraft is killed.
+
+
+Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane.
+initiator : The unit that the pilot has died in.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventPlayerEnterUnit(EventData)
+
+
+-
+
+
Occurs when any player assumes direct control of a unit.
+
+
+initiator : The unit that is being taken control of.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventPlayerLeaveUnit(EventData)
+
+
+-
+
+
Occurs when any player relieves control of a unit to the AI.
+
+
+initiator : The unit that the player left.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventRefueling(EventData)
+
+
+-
+
+
Occurs when an aircraft connects with a tanker and begins taking on fuel.
+
+
+initiator : The unit that is receiving fuel.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventRefuelingStop(EventData)
+
+
+-
+
+
Occurs when an aircraft is finished taking fuel.
+
+
+initiator : The unit that was receiving fuel.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventShootingEnd(EventData)
+
+
+-
+
+
Occurs when any unit stops firing its weapon.
+
+
+Event will always correspond with a shooting start event.
+initiator : The unit that was doing the shooing.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventShootingStart(EventData)
+
+
+-
+
+
Occurs when any unit begins firing a weapon that has a high rate of fire.
+
+
+Most common with aircraft cannons (GAU-8), autocannons, and machine guns.
+initiator : The unit that is doing the shooing.
+target: The unit that is being targeted.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventShot(EventData)
+
+
+-
+
+
Occurs whenever any unit in a mission fires a weapon.
+
+
+But not any machine gun or autocannon based weapon, those are handled by EVENT.ShootingStart.
+
+ Parameter
+
+
+
+
+-
+
+
+BASE:OnEventTakeoff(EventData)
+
+
+-
+
+
Occurs when an aircraft takes off from an airbase, farp, or ship.
+
+
+initiator : The unit that tookoff
+place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships
+
+ Parameter
+
+
+
+
+-
+
BASE:SetEventPriority(EventPriority)
@@ -2200,6 +2051,32 @@ BASE:TraceOnOff( true )
-- Switch the tracing Off
BASE:TraceOnOff( false )
+
+
+
+-
+
+
+BASE:UnHandleEvent(Event)
+
+
+-
+
+
UnSubscribe to a DCS event.
+
+ Parameter
+
+ Return value
+
+#BASE:
+
+
diff --git a/docs/Documentation/Controllable.html b/docs/Documentation/Controllable.html
index c2a5442eb..c9540f79e 100644
--- a/docs/Documentation/Controllable.html
+++ b/docs/Documentation/Controllable.html
@@ -292,7 +292,7 @@ This is different from the EnRoute tasks, where the targets of the task need to
- | CONTROLLABLE:EnRouteTaskEngageUnit(AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, ControllableAttack) |
+ CONTROLLABLE:EnRouteTaskEngageUnit(EngageUnit, Priority, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, Visible, ControllableAttack) |
(AIR) Attack the Unit.
|
@@ -1064,7 +1064,7 @@ The DCS task structure.
-
-CONTROLLABLE:EnRouteTaskEngageUnit(AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, ControllableAttack)
+CONTROLLABLE:EnRouteTaskEngageUnit(EngageUnit, Priority, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, Visible, ControllableAttack)
-
@@ -1075,20 +1075,20 @@ The DCS task structure.
-
-
Wrapper.Unit#UNIT AttackUnit :
+
Wrapper.Unit#UNIT EngageUnit :
The UNIT.
-
#number Priority :
-All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.
+(optional) All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.
-
-
#number WeaponType :
-(optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.
+#boolean GroupAttack :
+(optional) If true, all units in the group will attack the Unit when found.
-
@@ -1111,8 +1111,14 @@ All en-route tasks have the priority parameter. This is a number (less value - h
-
-
#boolean AttackQtyLimit :
-(optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackControllable" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks.
+Dcs.DCSTypes#Distance Altitude :
+(optional) Desired altitude to perform the unit engagement.
+
+
+ -
+
+
#boolean Visible :
+(optional) Unit must be visible.
-
diff --git a/docs/Documentation/Event.html b/docs/Documentation/Event.html
index ff3d6630e..c37b270e2 100644
--- a/docs/Documentation/Event.html
+++ b/docs/Documentation/Event.html
@@ -71,10 +71,21 @@
Module Event
-
This module contains the EVENT class.
+
This module contains the EVENT class, which models the dispatching of DCS Events to subscribed MOOSE classes,
+following a given priority.
+
+
+

+
+
+
+
+ - This module contains the EVENT class.
+
+
Takes care of EVENT dispatching between DCS events and event handling functions defined in MOOSE classes.
@@ -95,6 +106,12 @@
EVENT |
+ |
+
+
+ | EVENTS |
+
+
|
@@ -125,7 +142,7 @@
- | EVENT:Init(EventID, EventPriority, EventClass) |
+ EVENT:Init(EventID, EventClass) |
Initializes the Events structure for the event
|
@@ -380,6 +397,12 @@
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
|
@@ -537,6 +560,20 @@
+
+
+
+-
+
+
+
+EVENTS
+
+
+-
+
+
+
@@ -613,7 +650,7 @@
-EVENT:Init(EventID, EventPriority, EventClass)
+EVENT:Init(EventID, EventClass)
@@ -629,12 +666,6 @@
-#number EventPriority :
-The priority of the EventClass.
-
-
-
-
Core.Base#BASE EventClass :
@@ -2006,6 +2037,43 @@ The self instance of the class for which the event is.
-
+
+EVENT:RemoveForUnit(EventClass, EventID, UnitName)
+
+
+-
+
+
Removes an Events entry for a Unit
+
+ Parameters
+
+ Return value
+
+#EVENT.Events:
+
+
+
+
+
+-
+
EVENT:onEvent(Event)
diff --git a/docs/Documentation/Fsm.html b/docs/Documentation/Fsm.html
index 712e2566e..3ef15c2df 100644
--- a/docs/Documentation/Fsm.html
+++ b/docs/Documentation/Fsm.html
@@ -571,6 +571,12 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
| FSM._EndStates |
+ |
+
+
+ | FSM._EventSchedules |
+
+
|
@@ -604,7 +610,7 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
- | FSM:_call_handler(handler, params) |
+ FSM:_call_handler(handler, params, EventName) |
|
@@ -728,7 +734,7 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
- | FSM_CONTROLLABLE:_call_handler(handler, params) |
+ FSM_CONTROLLABLE:_call_handler(handler, params, EventName) |
|
@@ -856,7 +862,7 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
- | FSM_SET:_call_handler(handler, params) |
+ FSM_SET:_call_handler(handler, params, EventName) |
|
@@ -884,7 +890,7 @@ YYYY-MM-DD: CLASS:NewFunction( Params ) added
- | FSM_TASK:_call_handler(handler, params) |
+ FSM_TASK:_call_handler(handler, params, EventName) |
|
@@ -1452,6 +1458,20 @@ A string defining the start state.
+
+
+
+-
+
+
+
+FSM._EventSchedules
+
+
+-
+
+
+
@@ -1540,7 +1560,7 @@ A string defining the start state.
-
-FSM:_call_handler(handler, params)
+FSM:_call_handler(handler, params, EventName)
-
@@ -1558,6 +1578,11 @@ A string defining the start state.
params :
+
+ -
+
+
EventName :
+
@@ -1967,7 +1992,7 @@ Finite State Machine Table
-
-FSM_CONTROLLABLE:_call_handler(handler, params)
+FSM_CONTROLLABLE:_call_handler(handler, params, EventName)
-
@@ -1985,6 +2010,11 @@ Finite State Machine Table
params :
+
+ -
+
+
EventName :
+
@@ -2436,7 +2466,7 @@ FSMSet (optional) The Set object that the FSM_SET governs.
-
-FSM_SET:_call_handler(handler, params)
+FSM_SET:_call_handler(handler, params, EventName)
-
@@ -2454,6 +2484,11 @@ FSMSet (optional) The Set object that the FSM_SET governs.
params :
+
+ -
+
+
EventName :
+
@@ -2532,7 +2567,7 @@ FSMSet (optional) The Set object that the FSM_SET governs.
-
-FSM_TASK:_call_handler(handler, params)
+FSM_TASK:_call_handler(handler, params, EventName)
-
@@ -2550,6 +2585,11 @@ FSMSet (optional) The Set object that the FSM_SET governs.
params :
+
+ -
+
+
EventName :
+
diff --git a/docs/Documentation/Scheduler.html b/docs/Documentation/Scheduler.html
index 4d8e5962b..e4d0d899f 100644
--- a/docs/Documentation/Scheduler.html
+++ b/docs/Documentation/Scheduler.html
@@ -290,7 +290,7 @@ Specifies the amount of seconds when the scheduler will be stopped.
#SCHEDULER:
-self
+self.
diff --git a/docs/Documentation/Spawn.html b/docs/Documentation/Spawn.html
index ddcc34cd2..5237d7f0e 100644
--- a/docs/Documentation/Spawn.html
+++ b/docs/Documentation/Spawn.html
@@ -1758,6 +1758,9 @@ The group that was spawned. You can use this group for further actions.
+
+ Don't repeat the group from Take-Off till Landing and back Take-Off by ReSpawning.
+
@@ -2528,7 +2531,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
-
-
+ #boolean
SPAWN.SpawnUnControlled
@@ -2552,7 +2555,7 @@ Spawn_BE_KA50 = SPAWN:New( 'BE KA-50@RAMP-Ground Defense' ):Schedule( 600, 0.5 )
-
Flag that indicates if all the Groups of the SpawnGroup need to be visible when Spawned.
+ When the first Spawn executes, all the Groups need to be made visible before start.
diff --git a/docs/Documentation/Unit.html b/docs/Documentation/Unit.html
index d1f39c968..7a731ad48 100644
--- a/docs/Documentation/Unit.html
+++ b/docs/Documentation/Unit.html
@@ -289,6 +289,12 @@ If you want to obtain the complete 3D position including ori�
UNIT:GetUnits() |
Returns the UNIT in a UNIT list of one element.
+ |
+
+
+ | UNIT:HandleEvent(Event, EventFunction) |
+
+ Subscribe to a DCS Event.
|
@@ -409,6 +415,12 @@ If you want to obtain the complete 3D position including ori�
| UNIT:SmokeWhite() |
Smoke the UNIT White.
+ |
+
+
+ | UNIT:UnHandleEvent(Event) |
+
+ UnSubscribe to a DCS event.
|
@@ -1024,6 +1036,38 @@ The DCS Unit is not existing or alive.
#list:
Wrapper.Unit#UNIT> The UNITs wrappers.
+
+
+
+-
+
+
+UNIT:HandleEvent(Event, EventFunction)
+
+
+-
+
+
Subscribe to a DCS Event.
+
+ Parameters
+
+ Return value
+
+#UNIT:
+
+
@@ -1505,6 +1549,32 @@ The name of the DCS unit.
Smoke the UNIT White.
+
+
+
+-
+
+
+UNIT:UnHandleEvent(Event)
+
+
+-
+
+
UnSubscribe to a DCS event.
+
+ Parameter
+
+ Return value
+
+#UNIT:
+
+
diff --git a/docs/Documentation/index.html b/docs/Documentation/index.html
index 19605f3fe..b9f027a75 100644
--- a/docs/Documentation/index.html
+++ b/docs/Documentation/index.html
@@ -231,7 +231,8 @@ and automatically engage any airborne enemies that are within a certain range or
| Event |
- This module contains the EVENT class.
+This module contains the EVENT class, which models the dispatching of DCS Events to subscribed MOOSE classes,
+following a given priority.
|