mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixes and framework stabilization
This commit is contained in:
@@ -158,11 +158,6 @@ function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
-- @param #number EngageSpeed (optional) The speed the Group will hold when engaging to the target zone.
|
||||
-- @param 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.
|
||||
-- @param Dcs.DCSTypes#Distance EngageAltitude (optional) Desired altitude to perform the unit engagement.
|
||||
-- @param #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.
|
||||
-- @param 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.
|
||||
|
||||
-- @return #boolean Return false to cancel Transition.
|
||||
|
||||
@@ -173,20 +168,25 @@ function AI_CAS_ZONE:New( PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
-- @param #number EngageSpeed (optional) The speed the Group will hold when engaging to the target zone.
|
||||
-- @param 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.
|
||||
-- @param Dcs.DCSTypes#Distance EngageAltitude (optional) Desired altitude to perform the unit engagement.
|
||||
-- @param #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.
|
||||
-- @param 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.
|
||||
|
||||
--- Synchronous Event Trigger for Event Engage.
|
||||
-- @function [parent=#AI_CAS_ZONE] Engage
|
||||
-- @param #AI_CAS_ZONE self
|
||||
-- @param #number EngageSpeed (optional) The speed the Group will hold when engaging to the target zone.
|
||||
-- @param Dcs.DCSTypes#Distance EngageAltitude (optional) Desired altitude to perform the unit engagement.
|
||||
-- @param 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.
|
||||
-- @param #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.
|
||||
-- @param 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.
|
||||
|
||||
--- Asynchronous Event Trigger for Event Engage.
|
||||
-- @function [parent=#AI_CAS_ZONE] __Engage
|
||||
-- @param #AI_CAS_ZONE self
|
||||
-- @param #number Delay The delay in seconds.
|
||||
-- @param #number EngageSpeed (optional) The speed the Group will hold when engaging to the target zone.
|
||||
-- @param Dcs.DCSTypes#Distance EngageAltitude (optional) Desired altitude to perform the unit engagement.
|
||||
-- @param 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.
|
||||
-- @param #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.
|
||||
-- @param 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.
|
||||
|
||||
--- OnLeave Transition Handler for State Engaging.
|
||||
-- @function [parent=#AI_CAS_ZONE] OnLeaveEngaging
|
||||
@@ -394,7 +394,7 @@ function AI_CAS_ZONE:onafterTarget( Controllable, From, Event, To )
|
||||
if Detected == true then
|
||||
self:E( {"Target: ", DetectedUnit } )
|
||||
self.DetectedUnits[DetectedUnit] = false
|
||||
local AttackTask = Controllable:EnRouteTaskEngageUnit( DetectedUnit, 1, true, self.EngageWeaponExpend, self.EngageAttackQty, self.EngageDirection, self.EngageAltitude, nil )
|
||||
local AttackTask = Controllable:TaskAttackUnit( DetectedUnit, false, self.EngageWeaponExpend, self.EngageAttackQty, self.EngageDirection, self.EngageAltitude, nil )
|
||||
self.Controllable:PushTask( AttackTask, 1 )
|
||||
end
|
||||
end
|
||||
@@ -416,8 +416,8 @@ end
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
-- @param #number EngageSpeed (optional) The speed the Group will hold when engaging to the target zone.
|
||||
-- @param 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.
|
||||
-- @param Dcs.DCSTypes#Distance EngageAltitude (optional) Desired altitude to perform the unit engagement.
|
||||
-- @param 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.
|
||||
-- @param #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.
|
||||
-- @param 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.
|
||||
function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To, EngageSpeed, EngageAltitude, EngageWeaponExpend, EngageAttackQty, EngageDirection )
|
||||
@@ -452,28 +452,28 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To, EngageSpeed,
|
||||
EngageRoute[#EngageRoute+1] = CurrentRoutePoint
|
||||
|
||||
|
||||
if self.Controllable:IsNotInZone( self.EngageZone ) then
|
||||
|
||||
-- Find a random 2D point in EngageZone.
|
||||
local ToEngageZoneVec2 = self.EngageZone:GetRandomVec2()
|
||||
self:T2( ToEngageZoneVec2 )
|
||||
|
||||
-- Obtain a 3D @{Point} from the 2D point + altitude.
|
||||
local ToEngageZonePointVec3 = POINT_VEC3:New( ToEngageZoneVec2.x, self.EngageAltitude, ToEngageZoneVec2.y )
|
||||
|
||||
-- Create a route point of type air.
|
||||
local ToEngageZoneRoutePoint = ToEngageZonePointVec3:RoutePointAir(
|
||||
self.PatrolAltType,
|
||||
POINT_VEC3.RoutePointType.TurningPoint,
|
||||
POINT_VEC3.RoutePointAction.TurningPoint,
|
||||
self.EngageSpeed,
|
||||
true
|
||||
)
|
||||
|
||||
EngageRoute[#EngageRoute+1] = ToEngageZoneRoutePoint
|
||||
|
||||
end
|
||||
|
||||
-- if self.Controllable:IsNotInZone( self.EngageZone ) then
|
||||
--
|
||||
-- -- Find a random 2D point in EngageZone.
|
||||
-- local ToEngageZoneVec2 = self.EngageZone:GetRandomVec2()
|
||||
-- self:T2( ToEngageZoneVec2 )
|
||||
--
|
||||
-- -- Obtain a 3D @{Point} from the 2D point + altitude.
|
||||
-- local ToEngageZonePointVec3 = POINT_VEC3:New( ToEngageZoneVec2.x, self.EngageAltitude, ToEngageZoneVec2.y )
|
||||
--
|
||||
-- -- Create a route point of type air.
|
||||
-- local ToEngageZoneRoutePoint = ToEngageZonePointVec3:RoutePointAir(
|
||||
-- self.PatrolAltType,
|
||||
-- POINT_VEC3.RoutePointType.TurningPoint,
|
||||
-- POINT_VEC3.RoutePointAction.TurningPoint,
|
||||
-- self.EngageSpeed,
|
||||
-- true
|
||||
-- )
|
||||
--
|
||||
-- EngageRoute[#EngageRoute+1] = ToEngageZoneRoutePoint
|
||||
--
|
||||
-- end
|
||||
--
|
||||
--- Define a random point in the @{Zone}. The AI will fly to that point within the zone.
|
||||
|
||||
--- Find a random 2D point in EngageZone.
|
||||
@@ -528,9 +528,9 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To, EngageSpeed,
|
||||
--- NOW ROUTE THE GROUP!
|
||||
self.Controllable:WayPointExecute( 1 )
|
||||
|
||||
self:SetDetectionInterval( 10 )
|
||||
self:SetDetectionInterval( 2 )
|
||||
self:SetDetectionActivated()
|
||||
self:__Target( -10 ) -- Start Targetting
|
||||
self:__Target( -2 ) -- Start Targetting
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -56,8 +56,7 @@ function PROCESS_JTAC:New( Task, ProcessUnit, TargetSetUnit, FACUnit )
|
||||
endstates = { 'Failed' }
|
||||
} )
|
||||
|
||||
|
||||
_EVENTDISPATCHER:OnDead( self.EventDead, self )
|
||||
self:HandleEvent( EVENTS.Dead, self.EventDead )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@@ -425,11 +425,11 @@ end
|
||||
-- @param EventClass The instance of the class for which the event is.
|
||||
-- @param #function OnEventFunction
|
||||
-- @return #EVENT
|
||||
function EVENT:OnEventForTemplate( EventTemplate, EventFunction, EventClass, OnEventFunction )
|
||||
function EVENT:OnEventForTemplate( EventTemplate, EventFunction, EventClass, EventID )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
for EventUnitID, EventUnit in pairs( EventTemplate.units ) do
|
||||
OnEventFunction( self, EventUnit.name, EventFunction, EventClass )
|
||||
self:OnEventForUnit( EventUnit.name, EventFunction, EventClass, EventID )
|
||||
end
|
||||
return self
|
||||
end
|
||||
@@ -482,51 +482,11 @@ do -- OnBirth
|
||||
function EVENT:OnBirthForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, self.OnBirthForUnit )
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, EVENTS.Birth )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_BIRTH event, and registers the unit born.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnBirth( EventFunction, EventClass )
|
||||
self:F2()
|
||||
|
||||
self:OnEventGeneric( EventFunction, EventClass, world.event.S_EVENT_BIRTH )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_BIRTH event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName The id of the unit for the event to be handled.
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnBirthForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_BIRTH )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_BIRTH event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnBirthRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_BIRTH )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
do -- OnCrash
|
||||
@@ -540,49 +500,10 @@ do -- OnCrash
|
||||
function EVENT:OnCrashForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, self.OnCrashForUnit )
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, EVENTS.Crash )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_CRASH event.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnCrash( EventFunction, EventClass )
|
||||
self:F2()
|
||||
|
||||
self:OnEventGeneric( EventFunction, EventClass, world.event.S_EVENT_CRASH )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_CRASH event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnCrashForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_CRASH )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_CRASH event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnCrashRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_CRASH )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -597,96 +518,13 @@ do -- OnDead
|
||||
function EVENT:OnDeadForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, self.OnDeadForUnit )
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, EVENTS.Dead )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_DEAD event.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnDead( EventFunction, EventClass )
|
||||
self:F2()
|
||||
|
||||
self:OnEventGeneric( EventFunction, EventClass, world.event.S_EVENT_DEAD )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set a new listener for an S_EVENT_DEAD event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnDeadForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_DEAD )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_DEAD event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnDeadRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_DEAD )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
do -- OnPilotDead
|
||||
|
||||
--- Set a new listener for an S_EVENT_PILOT_DEAD event.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnPilotDead( EventFunction, EventClass )
|
||||
self:F2()
|
||||
|
||||
self:OnEventGeneric( EventFunction, EventClass, world.event.S_EVENT_PILOT_DEAD )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_PILOT_DEAD event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnPilotDeadForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_PILOT_DEAD )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_PILOT_DEAD event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnPilotDeadRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_PILOT_DEAD )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- OnLand
|
||||
--- Create an OnLand event handler for a group
|
||||
@@ -698,38 +536,11 @@ do -- OnLand
|
||||
function EVENT:OnLandForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, self.OnLandForUnit )
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, EVENTS.Land )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_LAND event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnLandForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_LAND )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_LAND event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnLandRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_LAND )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
do -- OnTakeOff
|
||||
@@ -742,38 +553,11 @@ do -- OnTakeOff
|
||||
function EVENT:OnTakeOffForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, self.OnTakeOffForUnit )
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, EVENTS.Takeoff )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_TAKEOFF event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnTakeOffForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_TAKEOFF )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_TAKEOFF event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnTakeOffRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_TAKEOFF )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
do -- OnEngineShutDown
|
||||
@@ -787,213 +571,13 @@ do -- OnEngineShutDown
|
||||
function EVENT:OnEngineShutDownForTemplate( EventTemplate, EventFunction, EventClass )
|
||||
self:F2( EventTemplate.name )
|
||||
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, self.OnEngineShutDownForUnit )
|
||||
self:OnEventForTemplate( EventTemplate, EventFunction, EventClass, EVENTS.EngineShutdown )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_ENGINE_SHUTDOWN event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnEngineShutDownForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_ENGINE_SHUTDOWN )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_ENGINE_SHUTDOWN event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnEngineShutDownRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_ENGINE_SHUTDOWN )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- OnEngineStartUp
|
||||
|
||||
--- Set a new listener for an S_EVENT_ENGINE_STARTUP event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnEngineStartUpForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_ENGINE_STARTUP )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_ENGINE_STARTUP event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnEngineStartUpRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_ENGINE_STARTUP )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- OnShot
|
||||
--- Set a new listener for an S_EVENT_SHOT event.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnShot( EventFunction, EventClass )
|
||||
self:F2()
|
||||
|
||||
self:OnEventGeneric( EventFunction, EventClass, world.event.S_EVENT_SHOT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_SHOT event for a unit.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnShotForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_SHOT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_SHOT event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnShotRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_SHOT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
do -- OnHit
|
||||
|
||||
--- Set a new listener for an S_EVENT_HIT event.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnHit( EventFunction, EventClass )
|
||||
self:F2()
|
||||
|
||||
self:OnEventGeneric( EventFunction, EventClass, world.event.S_EVENT_HIT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set a new listener for an S_EVENT_HIT event.
|
||||
-- @param #EVENT self
|
||||
-- @param #string EventDCSUnitName
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnHitForUnit( EventDCSUnitName, EventFunction, EventClass )
|
||||
self:F2( EventDCSUnitName )
|
||||
|
||||
self:OnEventForUnit( EventDCSUnitName, EventFunction, EventClass, world.event.S_EVENT_HIT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_HIT event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnHitRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_HIT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- OnPlayerEnterUnit
|
||||
|
||||
--- Set a new listener for an S_EVENT_PLAYER_ENTER_UNIT event.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnPlayerEnterUnit( EventFunction, EventClass )
|
||||
self:F2()
|
||||
|
||||
self:OnEventGeneric( EventFunction, EventClass, world.event.S_EVENT_PLAYER_ENTER_UNIT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_PLAYER_ENTER_UNIT event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnPlayerEnterRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_PLAYER_ENTER_UNIT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- OnPlayerLeaveUnit
|
||||
--- Set a new listener for an S_EVENT_PLAYER_LEAVE_UNIT event.
|
||||
-- @param #EVENT self
|
||||
-- @param #function EventFunction The function to be called when the event occurs for the unit.
|
||||
-- @param Base#BASE EventClass The self instance of the class for which the event is.
|
||||
-- @return #EVENT
|
||||
function EVENT:OnPlayerLeaveUnit( EventFunction, EventClass )
|
||||
self:F2()
|
||||
|
||||
self:OnEventGeneric( EventFunction, EventClass, world.event.S_EVENT_PLAYER_LEAVE_UNIT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stop listening to S_EVENT_PLAYER_LEAVE_UNIT event.
|
||||
-- @param #EVENT self
|
||||
-- @param Base#BASE EventClass
|
||||
-- @return #EVENT
|
||||
function EVENT:OnPlayerLeaveRemove( EventClass )
|
||||
self:F2()
|
||||
|
||||
self:Remove( EventClass, world.event.S_EVENT_PLAYER_LEAVE_UNIT )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- @param #EVENT self
|
||||
-- @param #EVENTDATA Event
|
||||
|
||||
@@ -728,8 +728,66 @@ do -- FSM_CONTROLLABLE
|
||||
self:SetControllable( Controllable )
|
||||
end
|
||||
|
||||
self:AddTransition( "*", "Stop", "Stopped" )
|
||||
|
||||
--- OnBefore Transition Handler for Event Stop.
|
||||
-- @function [parent=#FSM_CONTROLLABLE] OnBeforeStop
|
||||
-- @param #FSM_CONTROLLABLE self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
-- @return #boolean Return false to cancel Transition.
|
||||
|
||||
--- OnAfter Transition Handler for Event Stop.
|
||||
-- @function [parent=#FSM_CONTROLLABLE] OnAfterStop
|
||||
-- @param #FSM_CONTROLLABLE self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
|
||||
--- Synchronous Event Trigger for Event Stop.
|
||||
-- @function [parent=#FSM_CONTROLLABLE] Stop
|
||||
-- @param #FSM_CONTROLLABLE self
|
||||
|
||||
--- Asynchronous Event Trigger for Event Stop.
|
||||
-- @function [parent=#FSM_CONTROLLABLE] __Stop
|
||||
-- @param #FSM_CONTROLLABLE self
|
||||
-- @param #number Delay The delay in seconds.
|
||||
|
||||
--- OnLeave Transition Handler for State Stopped.
|
||||
-- @function [parent=#FSM_CONTROLLABLE] OnLeaveStopped
|
||||
-- @param #FSM_CONTROLLABLE self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
-- @return #boolean Return false to cancel Transition.
|
||||
|
||||
--- OnEnter Transition Handler for State Stopped.
|
||||
-- @function [parent=#FSM_CONTROLLABLE] OnEnterStopped
|
||||
-- @param #FSM_CONTROLLABLE self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- OnAfter Transition Handler for Event Stop.
|
||||
-- @function [parent=#FSM_CONTROLLABLE] OnAfterStop
|
||||
-- @param #FSM_CONTROLLABLE self
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE Controllable The Controllable Object managed by the FSM.
|
||||
-- @param #string From The From State string.
|
||||
-- @param #string Event The Event string.
|
||||
-- @param #string To The To State string.
|
||||
function FSM_CONTROLLABLE:OnAfterStop(Controllable,From,Event,To)
|
||||
|
||||
-- Clear all pending schedules
|
||||
self.CallScheduler:Clear()
|
||||
end
|
||||
|
||||
--- Sets the CONTROLLABLE object that the FSM_CONTROLLABLE governs.
|
||||
-- @param #FSM_CONTROLLABLE self
|
||||
|
||||
@@ -206,5 +206,13 @@ function SCHEDULEDISPATCHER:Stop( Scheduler, CallID )
|
||||
end
|
||||
end
|
||||
|
||||
function SCHEDULEDISPATCHER:Clear( Scheduler )
|
||||
self:F2( { Scheduler = Scheduler } )
|
||||
|
||||
for CallID, Schedule in pairs( self.Schedule[Scheduler] ) do
|
||||
self:Stop( Scheduler, CallID ) -- Recursive
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -147,6 +147,13 @@ function SCHEDULER:Remove( ScheduleID )
|
||||
_SCHEDULEDISPATCHER:Remove( self, ScheduleID )
|
||||
end
|
||||
|
||||
--- Clears all pending schedules.
|
||||
-- @param #SCHEDULER self
|
||||
function SCHEDULER:Clear()
|
||||
self:F3( )
|
||||
|
||||
_SCHEDULEDISPATCHER:Clear( self )
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,9 @@ CLEANUP = {
|
||||
-- or
|
||||
-- CleanUpTbilisi = CLEANUP:New( 'CLEAN Tbilisi', 150 )
|
||||
-- CleanUpKutaisi = CLEANUP:New( 'CLEAN Kutaisi', 600 )
|
||||
function CLEANUP:New( ZoneNames, TimeInterval ) local self = BASE:Inherit( self, BASE:New() )
|
||||
function CLEANUP:New( ZoneNames, TimeInterval )
|
||||
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- #CLEANUP
|
||||
self:F( { ZoneNames, TimeInterval } )
|
||||
|
||||
if type( ZoneNames ) == 'table' then
|
||||
@@ -41,7 +43,7 @@ function CLEANUP:New( ZoneNames, TimeInterval ) local self = BASE:Inherit( self,
|
||||
self.TimeInterval = TimeInterval
|
||||
end
|
||||
|
||||
_EVENTDISPATCHER:OnBirth( self._OnEventBirth, self )
|
||||
self:HandleEvent( EVENTS.Birth )
|
||||
|
||||
self.CleanUpScheduler = SCHEDULER:New( self, self._CleanUpScheduler, {}, 1, TimeInterval )
|
||||
|
||||
@@ -102,32 +104,24 @@ function CLEANUP:_DestroyMissile( MissileObject )
|
||||
end
|
||||
end
|
||||
|
||||
function CLEANUP:_OnEventBirth( Event )
|
||||
self:F( { Event } )
|
||||
--- @param #CLEANUP self
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
function CLEANUP:_OnEventBirth( EventData )
|
||||
self:F( { EventData } )
|
||||
|
||||
self.CleanUpList[Event.IniDCSUnitName] = {}
|
||||
self.CleanUpList[Event.IniDCSUnitName].CleanUpUnit = Event.IniDCSUnit
|
||||
self.CleanUpList[Event.IniDCSUnitName].CleanUpGroup = Event.IniDCSGroup
|
||||
self.CleanUpList[Event.IniDCSUnitName].CleanUpGroupName = Event.IniDCSGroupName
|
||||
self.CleanUpList[Event.IniDCSUnitName].CleanUpUnitName = Event.IniDCSUnitName
|
||||
|
||||
_EVENTDISPATCHER:OnEngineShutDownForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
||||
_EVENTDISPATCHER:OnEngineStartUpForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
||||
_EVENTDISPATCHER:OnHitForUnit( Event.IniDCSUnitName, self._EventAddForCleanUp, self )
|
||||
_EVENTDISPATCHER:OnPilotDeadForUnit( Event.IniDCSUnitName, self._EventCrash, self )
|
||||
_EVENTDISPATCHER:OnDeadForUnit( Event.IniDCSUnitName, self._EventCrash, self )
|
||||
_EVENTDISPATCHER:OnCrashForUnit( Event.IniDCSUnitName, self._EventCrash, self )
|
||||
_EVENTDISPATCHER:OnShotForUnit( Event.IniDCSUnitName, self._EventShot, self )
|
||||
|
||||
--self:AddEvent( world.event.S_EVENT_ENGINE_SHUTDOWN, self._EventAddForCleanUp )
|
||||
--self:AddEvent( world.event.S_EVENT_ENGINE_STARTUP, self._EventAddForCleanUp )
|
||||
-- self:AddEvent( world.event.S_EVENT_HIT, self._EventAddForCleanUp ) -- , self._EventHitCleanUp )
|
||||
-- self:AddEvent( world.event.S_EVENT_CRASH, self._EventCrash ) -- , self._EventHitCleanUp )
|
||||
-- --self:AddEvent( world.event.S_EVENT_DEAD, self._EventCrash )
|
||||
-- self:AddEvent( world.event.S_EVENT_SHOT, self._EventShot )
|
||||
--
|
||||
-- self:EnableEvents()
|
||||
self.CleanUpList[EventData.IniDCSUnitName] = {}
|
||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnit = EventData.IniDCSUnit
|
||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpGroup = EventData.IniDCSGroup
|
||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpGroupName = EventData.IniDCSGroupName
|
||||
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnitName = EventData.IniDCSUnitName
|
||||
|
||||
EventData.IniUnit:HandleEvent( EVENTS.EngineShutdown , self._EventAddForCleanUp )
|
||||
EventData.IniUnit:HandleEvent( EVENTS.EngineStartup, self._EventAddForCleanUp )
|
||||
EventData.IniUnit:HandleEvent( EVENTS.Hit, self._EventAddForCleanUp )
|
||||
EventData.IniUnit:HandleEvent( EVENTS.PilotDead, self._EventCrash )
|
||||
EventData.IniUnit:HandleEvent( EVENTS.Dead, self._EventCrash )
|
||||
EventData.IniUnit:HandleEvent( EVENTS.Crash, self._EventCrash )
|
||||
EventData.IniUnit:HandleEvent( EVENTS.Shot, self._EventShot )
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -218,9 +218,10 @@ function ESCORT:New( EscortClient, EscortGroup, EscortName, EscortBriefing )
|
||||
self.FollowDistance = 100
|
||||
self.CT1 = 0
|
||||
self.GT1 = 0
|
||||
self.FollowScheduler = SCHEDULER:New( self, self._FollowScheduler, {}, 1, .5, .01 )
|
||||
self.FollowScheduler, self.FollowSchedule = SCHEDULER:New( self, self._FollowScheduler, {}, 1, .5, .01 )
|
||||
self.FollowScheduler:Stop( self.FollowSchedule )
|
||||
|
||||
self.EscortMode = ESCORT.MODE.MISSION
|
||||
self.FollowScheduler:Stop()
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -669,7 +670,7 @@ function ESCORT._HoldPosition( MenuParam )
|
||||
local OrbitHeight = MenuParam.ParamHeight
|
||||
local OrbitSeconds = MenuParam.ParamSeconds -- Not implemented yet
|
||||
|
||||
self.FollowScheduler:Stop()
|
||||
self.FollowScheduler:Stop( self.FollowSchedule )
|
||||
|
||||
local PointFrom = {}
|
||||
local GroupVec3 = EscortGroup:GetUnit(1):GetVec3()
|
||||
@@ -721,7 +722,7 @@ end
|
||||
function ESCORT:JoinUpAndFollow( EscortGroup, EscortClient, Distance )
|
||||
self:F( { EscortGroup, EscortClient, Distance } )
|
||||
|
||||
self.FollowScheduler:Stop()
|
||||
self.FollowScheduler:Stop( self.FollowSchedule )
|
||||
|
||||
EscortGroup:OptionROEHoldFire()
|
||||
EscortGroup:OptionROTPassiveDefense()
|
||||
@@ -730,7 +731,7 @@ function ESCORT:JoinUpAndFollow( EscortGroup, EscortClient, Distance )
|
||||
|
||||
self.CT1 = 0
|
||||
self.GT1 = 0
|
||||
self.FollowScheduler:Start()
|
||||
self.FollowScheduler:Start( self.FollowSchedule )
|
||||
|
||||
EscortGroup:MessageToClient( "Rejoining and Following at " .. Distance .. "!", 30, EscortClient )
|
||||
end
|
||||
@@ -785,7 +786,7 @@ function ESCORT._SwitchReportNearbyTargets( MenuParam )
|
||||
|
||||
if self.ReportTargets then
|
||||
if not self.ReportTargetsScheduler then
|
||||
self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, 30 )
|
||||
self.ReportTargetsScheduler:Schedule( self, self._ReportTargetsScheduler, {}, 1, 30 )
|
||||
end
|
||||
else
|
||||
routines.removeFunction( self.ReportTargetsScheduler )
|
||||
@@ -802,7 +803,7 @@ function ESCORT._ScanTargets( MenuParam )
|
||||
|
||||
local ScanDuration = MenuParam.ParamScanDuration
|
||||
|
||||
self.FollowScheduler:Stop()
|
||||
self.FollowScheduler:Stop( self.FollowSchedule )
|
||||
|
||||
if EscortGroup:IsHelicopter() then
|
||||
SCHEDULER:New( EscortGroup, EscortGroup.PushTask,
|
||||
@@ -827,7 +828,7 @@ function ESCORT._ScanTargets( MenuParam )
|
||||
EscortGroup:MessageToClient( "Scanning targets for " .. ScanDuration .. " seconds.", ScanDuration, EscortClient )
|
||||
|
||||
if self.EscortMode == ESCORT.MODE.FOLLOW then
|
||||
self.FollowScheduler:Start()
|
||||
self.FollowScheduler:Start( self.FollowSchedule )
|
||||
end
|
||||
|
||||
end
|
||||
@@ -853,7 +854,7 @@ function ESCORT._AttackTarget( MenuParam )
|
||||
local EscortClient = self.EscortClient
|
||||
local AttackUnit = MenuParam.ParamUnit -- Wrapper.Unit#UNIT
|
||||
|
||||
self.FollowScheduler:Stop()
|
||||
self.FollowScheduler:Stop( self.FollowSchedule )
|
||||
|
||||
self:T( AttackUnit )
|
||||
|
||||
@@ -894,7 +895,7 @@ function ESCORT._AssistTarget( MenuParam )
|
||||
local EscortGroupAttack = MenuParam.ParamEscortGroup
|
||||
local AttackUnit = MenuParam.ParamUnit -- Wrapper.Unit#UNIT
|
||||
|
||||
self.FollowScheduler:Stop()
|
||||
self.FollowScheduler:Stop( self.FollowSchedule )
|
||||
|
||||
self:T( AttackUnit )
|
||||
|
||||
@@ -961,7 +962,7 @@ function ESCORT._ResumeMission( MenuParam )
|
||||
|
||||
local WayPoint = MenuParam.ParamWayPoint
|
||||
|
||||
self.FollowScheduler:Stop()
|
||||
self.FollowScheduler:Stop( self.FollowSchedule )
|
||||
|
||||
local WayPoints = EscortGroup:GetTaskRoute()
|
||||
self:T( WayPoint, WayPoints )
|
||||
|
||||
@@ -171,7 +171,7 @@ function MISSILETRAINER:New( Distance, Briefing )
|
||||
|
||||
self.Distance = Distance / 1000
|
||||
|
||||
_EVENTDISPATCHER:OnShot( self._EventShot, self )
|
||||
self:HandleEvent( EVENTS.Shot )
|
||||
|
||||
self.DBClients = SET_CLIENT:New():FilterStart()
|
||||
|
||||
@@ -449,14 +449,14 @@ end
|
||||
|
||||
--- Detects if an SA site was shot with an anti radiation missile. In this case, take evasive actions based on the skill level set within the ME.
|
||||
-- @param #MISSILETRAINER self
|
||||
-- @param Core.Event#EVENTDATA Event
|
||||
function MISSILETRAINER:_EventShot( Event )
|
||||
self:F( { Event } )
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
function MISSILETRAINER:OnEventShot( EVentData )
|
||||
self:F( { EVentData } )
|
||||
|
||||
local TrainerSourceDCSUnit = Event.IniDCSUnit
|
||||
local TrainerSourceDCSUnitName = Event.IniDCSUnitName
|
||||
local TrainerWeapon = Event.Weapon -- Identify the weapon fired
|
||||
local TrainerWeaponName = Event.WeaponName -- return weapon type
|
||||
local TrainerSourceDCSUnit = EVentData.IniDCSUnit
|
||||
local TrainerSourceDCSUnitName = EVentData.IniDCSUnitName
|
||||
local TrainerWeapon = EVentData.Weapon -- Identify the weapon fired
|
||||
local TrainerWeaponName = EVentData.WeaponName -- return weapon type
|
||||
|
||||
self:T( "Missile Launched = " .. TrainerWeaponName )
|
||||
|
||||
|
||||
@@ -3,10 +3,11 @@
|
||||
-- Performance: If in a DCSRTE there are a lot of moving GROUND units, then in a multi player mission, this WILL create lag if
|
||||
-- the main DCS execution core of your CPU is fully utilized. So, this class will limit the amount of simultaneous moving GROUND units
|
||||
-- on defined intervals (currently every minute).
|
||||
-- @module MOVEMENT
|
||||
-- @module Movement
|
||||
|
||||
--- the MOVEMENT class
|
||||
-- @type
|
||||
-- @type MOVEMENT
|
||||
-- @extends Core.Base#BASE
|
||||
MOVEMENT = {
|
||||
ClassName = "MOVEMENT",
|
||||
}
|
||||
@@ -20,7 +21,7 @@ MOVEMENT = {
|
||||
-- Movement_US_Platoons = MOVEMENT:New( { 'US Tank Platoon Left', 'US Tank Platoon Middle', 'US Tank Platoon Right', 'US CH-47D Troops' }, 15 )
|
||||
|
||||
function MOVEMENT:New( MovePrefixes, MoveMaximum )
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
local self = BASE:Inherit( self, BASE:New() ) -- #MOVEMENT
|
||||
self:F( { MovePrefixes, MoveMaximum } )
|
||||
|
||||
if type( MovePrefixes ) == 'table' then
|
||||
@@ -33,7 +34,7 @@ function MOVEMENT:New( MovePrefixes, MoveMaximum )
|
||||
self.AliveUnits = 0 -- Contains the counter how many units are currently alive
|
||||
self.MoveUnits = {} -- Reflects if the Moving for this MovePrefixes is going to be scheduled or not.
|
||||
|
||||
_EVENTDISPATCHER:OnBirth( self.OnBirth, self )
|
||||
self:HandleEvent( EVENTS.Birth )
|
||||
|
||||
-- self:AddEvent( world.event.S_EVENT_BIRTH, self.OnBirth )
|
||||
--
|
||||
@@ -60,24 +61,26 @@ end
|
||||
|
||||
--- Captures the birth events when new Units were spawned.
|
||||
-- @todo This method should become obsolete. The new @{DATABASE} class will handle the collection administration.
|
||||
function MOVEMENT:OnBirth( Event )
|
||||
self:F( { Event } )
|
||||
-- @param #MOVEMENT self
|
||||
-- @param Core.Event#EVENTDATA self
|
||||
function MOVEMENT:OnEventBirth( EventData )
|
||||
self:F( { EventData } )
|
||||
|
||||
if timer.getTime0() < timer.getAbsTime() then -- dont need to add units spawned in at the start of the mission if mist is loaded in init line
|
||||
if Event.IniDCSUnit then
|
||||
self:T( "Birth object : " .. Event.IniDCSUnitName )
|
||||
if Event.IniDCSGroup and Event.IniDCSGroup:isExist() then
|
||||
if EventData.IniDCSUnit then
|
||||
self:T( "Birth object : " .. EventData.IniDCSUnitName )
|
||||
if EventData.IniDCSGroup and EventData.IniDCSGroup:isExist() then
|
||||
for MovePrefixID, MovePrefix in pairs( self.MovePrefixes ) do
|
||||
if string.find( Event.IniDCSUnitName, MovePrefix, 1, true ) then
|
||||
if string.find( EventData.IniDCSUnitName, MovePrefix, 1, true ) then
|
||||
self.AliveUnits = self.AliveUnits + 1
|
||||
self.MoveUnits[Event.IniDCSUnitName] = Event.IniDCSGroupName
|
||||
self.MoveUnits[EventData.IniDCSUnitName] = EventData.IniDCSGroupName
|
||||
self:T( self.AliveUnits )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
_EVENTDISPATCHER:OnCrashForUnit( Event.IniDCSUnitName, self.OnDeadOrCrash, self )
|
||||
_EVENTDISPATCHER:OnDeadForUnit( Event.IniDCSUnitName, self.OnDeadOrCrash, self )
|
||||
|
||||
EventData.IniUnit:HandleEvent( EVENTS.DEAD, self.OnDeadOrCrash )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -36,25 +36,28 @@ function SEAD:New( SEADGroupPrefixes )
|
||||
else
|
||||
self.SEADGroupNames[SEADGroupPrefixes] = SEADGroupPrefixes
|
||||
end
|
||||
_EVENTDISPATCHER:OnShot( self.EventShot, self )
|
||||
|
||||
self:HandleEvent( EVENTS.Shot )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Detects if an SA site was shot with an anti radiation missile. In this case, take evasive actions based on the skill level set within the ME.
|
||||
-- @see SEAD
|
||||
function SEAD:EventShot( Event )
|
||||
self:F( { Event } )
|
||||
-- @param #SEAD
|
||||
-- @param Core.Event#EVENTDATA EventData
|
||||
function SEAD:OnEventShot( EventData )
|
||||
self:F( { EventData } )
|
||||
|
||||
local SEADUnit = Event.IniDCSUnit
|
||||
local SEADUnitName = Event.IniDCSUnitName
|
||||
local SEADWeapon = Event.Weapon -- Identify the weapon fired
|
||||
local SEADWeaponName = Event.WeaponName -- return weapon type
|
||||
local SEADUnit = EventData.IniDCSUnit
|
||||
local SEADUnitName = EventData.IniDCSUnitName
|
||||
local SEADWeapon = EventData.Weapon -- Identify the weapon fired
|
||||
local SEADWeaponName = EventData.WeaponName -- return weapon type
|
||||
-- Start of the 2nd loop
|
||||
self:T( "Missile Launched = " .. SEADWeaponName )
|
||||
if SEADWeaponName == "KH-58" or SEADWeaponName == "KH-25MPU" or SEADWeaponName == "AGM-88" or SEADWeaponName == "KH-31A" or SEADWeaponName == "KH-31P" then -- Check if the missile is a SEAD
|
||||
local _evade = math.random (1,100) -- random number for chance of evading action
|
||||
local _targetMim = Event.Weapon:getTarget() -- Identify target
|
||||
local _targetMim = EventData.Weapon:getTarget() -- Identify target
|
||||
local _targetMimname = Unit.getName(_targetMim)
|
||||
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon))
|
||||
local _targetMimgroupName = _targetMimgroup:getName()
|
||||
|
||||
@@ -63,13 +63,6 @@ do -- TASK_A2G
|
||||
self:Smoke()
|
||||
end
|
||||
|
||||
|
||||
|
||||
--_EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventPlayerLeaveUnit, self )
|
||||
--_EVENTDISPATCHER:OnDead( self._EventDead, self )
|
||||
--_EVENTDISPATCHER:OnCrash( self._EventDead, self )
|
||||
--_EVENTDISPATCHER:OnPilotDead( self._EventDead, self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -41,11 +41,6 @@ do -- TASK_PICKUP
|
||||
local self = BASE:Inherit( self, TASK:New( Mission, AssignedSetGroup, TaskName, TaskType, "PICKUP" ) )
|
||||
self:F()
|
||||
|
||||
_EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventPlayerLeaveUnit, self )
|
||||
_EVENTDISPATCHER:OnDead( self._EventDead, self )
|
||||
_EVENTDISPATCHER:OnCrash( self._EventDead, self )
|
||||
_EVENTDISPATCHER:OnPilotDead( self._EventDead, self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -62,11 +62,6 @@ do -- TASK_SEAD
|
||||
self:Smoke()
|
||||
end
|
||||
|
||||
-- _EVENTDISPATCHER:OnPlayerLeaveUnit( self._EventPlayerLeaveUnit, self )
|
||||
-- _EVENTDISPATCHER:OnDead( self._EventDead, self )
|
||||
-- _EVENTDISPATCHER:OnCrash( self._EventDead, self )
|
||||
-- _EVENTDISPATCHER:OnPilotDead( self._EventDead, self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
@@ -518,48 +518,36 @@ function CONTROLLABLE:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, At
|
||||
return DCSTask
|
||||
end
|
||||
|
||||
|
||||
--- (AIR) Attack the Unit.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param Wrapper.Unit#UNIT AttackUnit The unit.
|
||||
-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.
|
||||
-- @param Wrapper.Unit#UNIT AttackUnit The UNIT.
|
||||
-- @param #boolean GroupAttack (optional) If true, all units in the group will attack the Unit when found.
|
||||
-- @param Dcs.DCSTypes#AI.Task.WeaponExpend WeaponExpend (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.
|
||||
-- @param #number AttackQty (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.
|
||||
-- @param Dcs.DCSTypes#Azimuth Direction (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.
|
||||
-- @param #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.
|
||||
-- @param Dcs.DCSTypes#Distance Altitude (optional) Desired altitude to perform the unit engagement.
|
||||
-- @param #boolean Visible (optional) Unit must be visible.
|
||||
-- @param #boolean ControllableAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the controllable. Has effect only if the task is assigned to a controllable, not to a single aircraft.
|
||||
-- @return Dcs.DCSTasking.Task#Task The DCS task structure.
|
||||
function CONTROLLABLE:TaskAttackUnit( AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, ControllableAttack )
|
||||
self:F2( { self.ControllableName, AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, ControllableAttack } )
|
||||
|
||||
-- AttackUnit = {
|
||||
-- id = 'AttackUnit',
|
||||
-- params = {
|
||||
-- unitId = Unit.ID,
|
||||
-- weaponType = number,
|
||||
-- expend = enum AI.Task.WeaponExpend
|
||||
-- attackQty = number,
|
||||
-- direction = Azimuth,
|
||||
-- attackQtyLimit = boolean,
|
||||
-- controllableAttack = boolean,
|
||||
-- }
|
||||
-- }
|
||||
function CONTROLLABLE:TaskAttackUnit( AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, Visible, ControllableAttack )
|
||||
self:F2( { self.ControllableName, AttackUnit, GroupAttack, WeaponExpend, AttackQty, Direction, Altitude, Visible, ControllableAttack } )
|
||||
|
||||
local DCSTask
|
||||
DCSTask = {
|
||||
id = 'AttackUnit',
|
||||
params = {
|
||||
altitudeEnabled = true,
|
||||
unitId = AttackUnit:GetID(),
|
||||
attackQtyLimit = AttackQtyLimit or false,
|
||||
attackQty = AttackQty or 2,
|
||||
groupAttack = GroupAttack or false,
|
||||
visible = Visible or false,
|
||||
expend = WeaponExpend or "Auto",
|
||||
altitude = 2000,
|
||||
directionEnabled = true,
|
||||
groupAttack = true,
|
||||
--weaponType = WeaponType or 1073741822,
|
||||
direction = Direction or 0,
|
||||
}
|
||||
directionEnabled = Direction and true or false,
|
||||
direction = Direction,
|
||||
altitudeEnabled = Altitude and true or false,
|
||||
altitude = Altitude,
|
||||
attackQtyLimit = AttackQty and true or false,
|
||||
attackQty = AttackQty,
|
||||
controllableAttack = ControllableAttack,
|
||||
},
|
||||
}
|
||||
|
||||
self:E( DCSTask )
|
||||
@@ -1173,7 +1161,7 @@ function CONTROLLABLE:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType,
|
||||
end
|
||||
|
||||
|
||||
--- (AIR) Attack the Unit.
|
||||
--- (AIR) Search and attack the Unit.
|
||||
-- @param #CONTROLLABLE self
|
||||
-- @param Wrapper.Unit#UNIT EngageUnit The UNIT.
|
||||
-- @param #number Priority (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.
|
||||
|
||||
Reference in New Issue
Block a user