diff --git a/Moose Development/Moose/.vscode/settings.json b/Moose Development/Moose/.vscode/settings.json index 13211d027..4656f0257 100644 --- a/Moose Development/Moose/.vscode/settings.json +++ b/Moose Development/Moose/.vscode/settings.json @@ -1,7 +1,17 @@ { - "Lua.workspace.preloadFileSize": 1000, + "Lua.workspace.preloadFileSize": 10000, "Lua.diagnostics.disable": [ - "undefined-doc-name" + "undefined-doc-name", + "duplicate-set-field", + "trailing-space", + "need-check-nil", + "ambiguity-1", + "undefined-doc-param", + "redundant-parameter", + "param-type-mismatch", + "deprecated", + "undefined-global", + "lowercase-global" ], "Lua.diagnostics.globals": [ "BASE", diff --git a/Moose Development/Moose/AI/AI_A2A_Cap.lua b/Moose Development/Moose/AI/AI_A2A_Cap.lua index 0c8aff8fa..d86c20bbe 100644 --- a/Moose Development/Moose/AI/AI_A2A_Cap.lua +++ b/Moose Development/Moose/AI/AI_A2A_Cap.lua @@ -11,7 +11,7 @@ -- @module AI.AI_A2A_Cap -- @image AI_Combat_Air_Patrol.JPG ---- @type AI_A2A_CAP +-- @type AI_A2A_CAP -- @extends AI.AI_Air_Patrol#AI_AIR_PATROL -- @extends AI.AI_Air_Engage#AI_AIR_ENGAGE diff --git a/Moose Development/Moose/AI/AI_A2A_Gci.lua b/Moose Development/Moose/AI/AI_A2A_Gci.lua index 626e36d60..8f85f3cd2 100644 --- a/Moose Development/Moose/AI/AI_A2A_Gci.lua +++ b/Moose Development/Moose/AI/AI_A2A_Gci.lua @@ -13,8 +13,8 @@ ---- @type AI_A2A_GCI --- @extends AI.AI_Air_Engage#AI_AIR_ENGAGE +-- @type AI_A2A_GCI +-- @extends AI.AI_A2A#AI_A2A --- Implements the core functions to intercept intruders. Use the Engage trigger to intercept intruders. @@ -39,6 +39,8 @@ -- -- ## 2. AI_A2A_GCI is a FSM -- +-- ![Process](..\Presentations\AI_GCI\Dia2.JPG) +-- -- ### 2.1 AI_A2A_GCI States -- -- * **None** ( Group ): The process is not started yet. diff --git a/Moose Development/Moose/AI/AI_A2A_Patrol.lua b/Moose Development/Moose/AI/AI_A2A_Patrol.lua index 1e66eb167..71b392db1 100644 --- a/Moose Development/Moose/AI/AI_A2A_Patrol.lua +++ b/Moose Development/Moose/AI/AI_A2A_Patrol.lua @@ -10,8 +10,8 @@ -- @image AI_Air_Patrolling.JPG ---- @type AI_A2A_PATROL --- @extends AI.AI_Air_Patrol#AI_AIR_PATROL +-- @type AI_A2A_PATROL +-- @extends AI.AI_A2A#AI_A2A --- Implements the core functions to patrol a @{Core.Zone} by an AI @{Wrapper.Group} or @{Wrapper.Group}. -- diff --git a/Moose Development/Moose/AI/AI_A2G_BAI.lua b/Moose Development/Moose/AI/AI_A2G_BAI.lua index 28acea07f..7a6a80fca 100644 --- a/Moose Development/Moose/AI/AI_A2G_BAI.lua +++ b/Moose Development/Moose/AI/AI_A2G_BAI.lua @@ -11,9 +11,8 @@ -- @module AI.AI_A2G_BAI -- @image AI_Air_To_Ground_Engage.JPG ---- @type AI_A2G_BAI --- @extends AI.AI_Air_Patrol#AI_AIR_PATROL --- @extends AI.AI_Air_Engage#AI_AIR_ENGAGE +-- @type AI_A2G_BAI +-- @extends AI.AI_A2A_Engage#AI_A2A_Engage -- TODO: Documentation. This class does not exist, unable to determine what it extends. --- Implements the core functions to intercept intruders. Use the Engage trigger to intercept intruders. -- @@ -47,7 +46,7 @@ AI_A2G_BAI = { function AI_A2G_BAI:New2( AIGroup, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) local AI_Air = AI_AIR:New( AIGroup ) - local AI_Air_Patrol = AI_AIR_PATROL:New( AI_Air, AIGroup, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) + local AI_Air_Patrol = AI_AIR_PATROL:New( AI_Air, AIGroup, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) -- #AI_AIR_PATROL local AI_Air_Engage = AI_AIR_ENGAGE:New( AI_Air_Patrol, AIGroup, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType ) local self = BASE:Inherit( self, AI_Air_Engage ) diff --git a/Moose Development/Moose/AI/AI_A2G_CAS.lua b/Moose Development/Moose/AI/AI_A2G_CAS.lua index 7bae80ea3..16c9cb976 100644 --- a/Moose Development/Moose/AI/AI_A2G_CAS.lua +++ b/Moose Development/Moose/AI/AI_A2G_CAS.lua @@ -11,9 +11,8 @@ -- @module AI.AI_A2G_CAS -- @image AI_Air_To_Ground_Engage.JPG ---- @type AI_A2G_CAS --- @extends AI.AI_Air_Patrol#AI_AIR_PATROL --- @extends AI.AI_Air_Engage#AI_AIR_ENGAGE +-- @type AI_A2G_CAS +-- @extends AI.AI_A2G_Patrol#AI_AIR_PATROL TODO: Documentation. This class does not exist, unable to determine what it extends. --- Implements the core functions to intercept intruders. Use the Engage trigger to intercept intruders. -- @@ -47,7 +46,7 @@ AI_A2G_CAS = { function AI_A2G_CAS:New2( AIGroup, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) local AI_Air = AI_AIR:New( AIGroup ) - local AI_Air_Patrol = AI_AIR_PATROL:New( AI_Air, AIGroup, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) + local AI_Air_Patrol = AI_AIR_PATROL:New( AI_Air, AIGroup, PatrolZone, PatrolFloorAltitude, PatrolCeilingAltitude, PatrolMinSpeed, PatrolMaxSpeed, PatrolAltType ) -- #AI_AIR_PATROL local AI_Air_Engage = AI_AIR_ENGAGE:New( AI_Air_Patrol, AIGroup, EngageMinSpeed, EngageMaxSpeed, EngageFloorAltitude, EngageCeilingAltitude, EngageAltType ) local self = BASE:Inherit( self, AI_Air_Engage ) diff --git a/Moose Development/Moose/AI/AI_A2G_SEAD.lua b/Moose Development/Moose/AI/AI_A2G_SEAD.lua index 42662862c..17f9f86f5 100644 --- a/Moose Development/Moose/AI/AI_A2G_SEAD.lua +++ b/Moose Development/Moose/AI/AI_A2G_SEAD.lua @@ -13,9 +13,8 @@ ---- @type AI_A2G_SEAD --- @extends AI.AI_Air_Patrol#AI_AIR_PATROL --- @extends AI.AI_Air_Engage#AI_AIR_ENGAGE +-- @type AI_A2G_SEAD +-- @extends AI.AI_A2G_Patrol#AI_AIR_PATROL --- Implements the core functions to SEAD intruders. Use the Engage trigger to intercept intruders. diff --git a/Moose Development/Moose/AI/AI_Air_Patrol.lua b/Moose Development/Moose/AI/AI_Air_Patrol.lua index 3185f987e..9950740a8 100644 --- a/Moose Development/Moose/AI/AI_Air_Patrol.lua +++ b/Moose Development/Moose/AI/AI_Air_Patrol.lua @@ -9,7 +9,7 @@ -- @module AI.AI_Air_Patrol -- @image AI_Air_To_Ground_Patrol.JPG ---- @type AI_AIR_PATROL +-- @type AI_AIR_PATROL -- @extends AI.AI_Air#AI_AIR --- The AI_AIR_PATROL class implements the core functions to patrol a @{Core.Zone} by an AI @{Wrapper.Group} diff --git a/Moose Development/Moose/AI/AI_BAI.lua b/Moose Development/Moose/AI/AI_BAI.lua index 9877ac51b..65fd78645 100644 --- a/Moose Development/Moose/AI/AI_BAI.lua +++ b/Moose Development/Moose/AI/AI_BAI.lua @@ -408,7 +408,7 @@ function AI_BAI_ZONE:onafterStart( Controllable, From, Event, To ) self:SetDetectionDeactivated() -- When not engaging, set the detection off. end ---- @param Wrapper.Controllable#CONTROLLABLE AIControllable +-- @param Wrapper.Controllable#CONTROLLABLE AIControllable function _NewEngageRoute( AIControllable ) AIControllable:T( "NewEngageRoute" ) @@ -417,7 +417,7 @@ function _NewEngageRoute( AIControllable ) end ---- @param #AI_BAI_ZONE self +-- @param #AI_BAI_ZONE 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. @@ -429,7 +429,7 @@ function AI_BAI_ZONE:onbeforeEngage( Controllable, From, Event, To ) end end ---- @param #AI_BAI_ZONE self +-- @param #AI_BAI_ZONE 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. @@ -478,7 +478,7 @@ function AI_BAI_ZONE:onafterTarget( Controllable, From, Event, To ) end ---- @param #AI_BAI_ZONE self +-- @param #AI_BAI_ZONE 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. @@ -488,7 +488,7 @@ function AI_BAI_ZONE:onafterAbort( Controllable, From, Event, To ) self:__Route( 1 ) end ---- @param #AI_BAI_ZONE self +-- @param #AI_BAI_ZONE 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. @@ -612,7 +612,7 @@ function AI_BAI_ZONE:onafterEngage( Controllable, From, Event, To, end ---- @param #AI_BAI_ZONE self +-- @param #AI_BAI_ZONE 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. @@ -623,7 +623,7 @@ function AI_BAI_ZONE:onafterAccomplish( Controllable, From, Event, To ) end ---- @param #AI_BAI_ZONE self +-- @param #AI_BAI_ZONE 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. @@ -637,7 +637,7 @@ function AI_BAI_ZONE:onafterDestroy( Controllable, From, Event, To, EventData ) end ---- @param #AI_BAI_ZONE self +-- @param #AI_BAI_ZONE self -- @param Core.Event#EVENTDATA EventData function AI_BAI_ZONE:OnEventDead( EventData ) self:F( { "EventDead", EventData } ) diff --git a/Moose Development/Moose/AI/AI_Balancer.lua b/Moose Development/Moose/AI/AI_Balancer.lua index b64e27057..6499a7fd5 100644 --- a/Moose Development/Moose/AI/AI_Balancer.lua +++ b/Moose Development/Moose/AI/AI_Balancer.lua @@ -27,7 +27,7 @@ -- @module AI.AI_Balancer -- @image AI_Balancing.JPG ---- @type AI_BALANCER +-- @type AI_BALANCER -- @field Core.Set#SET_CLIENT SetClient -- @field Core.Spawn#SPAWN SpawnAI -- @field Wrapper.Group#GROUP Test diff --git a/Moose Development/Moose/AI/AI_CAP.lua b/Moose Development/Moose/AI/AI_CAP.lua index d59931452..f4cfe55bf 100644 --- a/Moose Development/Moose/AI/AI_CAP.lua +++ b/Moose Development/Moose/AI/AI_CAP.lua @@ -31,7 +31,7 @@ -- @module AI.AI_CAP -- @image AI_Combat_Air_Patrol.JPG ---- @type AI_CAP_ZONE +-- @type AI_CAP_ZONE -- @field Wrapper.Controllable#CONTROLLABLE AIControllable The @{Wrapper.Controllable} patrolling. -- @field Core.Zone#ZONE_BASE TargetZone The @{Core.Zone} where the patrol needs to be executed. -- @extends AI.AI_Patrol#AI_PATROL_ZONE @@ -344,7 +344,7 @@ function AI_CAP_ZONE:onafterStart( Controllable, From, Event, To ) end ---- @param AI.AI_CAP#AI_CAP_ZONE +-- @param AI.AI_CAP#AI_CAP_ZONE -- @param Wrapper.Group#GROUP EngageGroup function AI_CAP_ZONE.EngageRoute( EngageGroup, Fsm ) @@ -355,7 +355,7 @@ function AI_CAP_ZONE.EngageRoute( EngageGroup, Fsm ) end end ---- @param #AI_CAP_ZONE self +-- @param #AI_CAP_ZONE 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. @@ -367,7 +367,7 @@ function AI_CAP_ZONE:onbeforeEngage( Controllable, From, Event, To ) end end ---- @param #AI_CAP_ZONE self +-- @param #AI_CAP_ZONE 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. @@ -395,7 +395,7 @@ function AI_CAP_ZONE:onafterDetected( Controllable, From, Event, To ) end end ---- @param #AI_CAP_ZONE self +-- @param #AI_CAP_ZONE 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. @@ -405,7 +405,7 @@ function AI_CAP_ZONE:onafterAbort( Controllable, From, Event, To ) self:__Route( 1 ) end ---- @param #AI_CAP_ZONE self +-- @param #AI_CAP_ZONE 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. @@ -505,7 +505,7 @@ function AI_CAP_ZONE:onafterEngage( Controllable, From, Event, To ) end end ---- @param #AI_CAP_ZONE self +-- @param #AI_CAP_ZONE 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. @@ -515,7 +515,7 @@ function AI_CAP_ZONE:onafterAccomplish( Controllable, From, Event, To ) self:SetDetectionOff() end ---- @param #AI_CAP_ZONE self +-- @param #AI_CAP_ZONE 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. @@ -528,7 +528,7 @@ function AI_CAP_ZONE:onafterDestroy( Controllable, From, Event, To, EventData ) end end ---- @param #AI_CAP_ZONE self +-- @param #AI_CAP_ZONE self -- @param Core.Event#EVENTDATA EventData function AI_CAP_ZONE:OnEventDead( EventData ) self:F( { "EventDead", EventData } ) diff --git a/Moose Development/Moose/AI/AI_CAS.lua b/Moose Development/Moose/AI/AI_CAS.lua index c6d2c11f4..7fb848d42 100644 --- a/Moose Development/Moose/AI/AI_CAS.lua +++ b/Moose Development/Moose/AI/AI_CAS.lua @@ -363,7 +363,7 @@ function AI_CAS_ZONE:onafterStart( Controllable, From, Event, To ) self:SetDetectionDeactivated() -- When not engaging, set the detection off. end ---- @param AI.AI_CAS#AI_CAS_ZONE +-- @param AI.AI_CAS#AI_CAS_ZONE -- @param Wrapper.Group#GROUP EngageGroup function AI_CAS_ZONE.EngageRoute( EngageGroup, Fsm ) @@ -375,7 +375,7 @@ function AI_CAS_ZONE.EngageRoute( EngageGroup, Fsm ) end ---- @param #AI_CAS_ZONE self +-- @param #AI_CAS_ZONE 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. @@ -387,7 +387,7 @@ function AI_CAS_ZONE:onbeforeEngage( Controllable, From, Event, To ) end end ---- @param #AI_CAS_ZONE self +-- @param #AI_CAS_ZONE 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. @@ -420,7 +420,7 @@ function AI_CAS_ZONE:onafterTarget( Controllable, From, Event, To ) end ---- @param #AI_CAS_ZONE self +-- @param #AI_CAS_ZONE 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. @@ -430,7 +430,7 @@ function AI_CAS_ZONE:onafterAbort( Controllable, From, Event, To ) self:__Route( 1 ) end ---- @param #AI_CAS_ZONE self +-- @param #AI_CAS_ZONE 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. @@ -530,7 +530,7 @@ function AI_CAS_ZONE:onafterEngage( Controllable, From, Event, To, end ---- @param #AI_CAS_ZONE self +-- @param #AI_CAS_ZONE 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. @@ -541,7 +541,7 @@ function AI_CAS_ZONE:onafterAccomplish( Controllable, From, Event, To ) end ---- @param #AI_CAS_ZONE self +-- @param #AI_CAS_ZONE 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. @@ -555,7 +555,7 @@ function AI_CAS_ZONE:onafterDestroy( Controllable, From, Event, To, EventData ) end ---- @param #AI_CAS_ZONE self +-- @param #AI_CAS_ZONE self -- @param Core.Event#EVENTDATA EventData function AI_CAS_ZONE:OnEventDead( EventData ) self:F( { "EventDead", EventData } ) diff --git a/Moose Development/Moose/AI/AI_Cargo_APC.lua b/Moose Development/Moose/AI/AI_Cargo_APC.lua index 6088ea865..fc9037fea 100644 --- a/Moose Development/Moose/AI/AI_Cargo_APC.lua +++ b/Moose Development/Moose/AI/AI_Cargo_APC.lua @@ -9,7 +9,7 @@ -- @module AI.AI_Cargo_APC -- @image AI_Cargo_Dispatching_For_APC.JPG ---- @type AI_CARGO_APC +-- @type AI_CARGO_APC -- @extends AI.AI_Cargo#AI_CARGO diff --git a/Moose Development/Moose/AI/AI_Cargo_Airplane.lua b/Moose Development/Moose/AI/AI_Cargo_Airplane.lua index 9dad75f25..6666eb379 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Airplane.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Airplane.lua @@ -9,7 +9,7 @@ -- @module AI.AI_Cargo_Airplane -- @image AI_Cargo_Dispatching_For_Airplanes.JPG ---- @type AI_CARGO_AIRPLANE +-- @type AI_CARGO_AIRPLANE -- @extends Core.Fsm#FSM_CONTROLLABLE diff --git a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_APC.lua b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_APC.lua index ab25a8e60..3d98522e1 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_APC.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_APC.lua @@ -30,7 +30,7 @@ -- @module AI.AI_Cargo_Dispatcher_APC -- @image AI_Cargo_Dispatching_For_APC.JPG ---- @type AI_CARGO_DISPATCHER_APC +-- @type AI_CARGO_DISPATCHER_APC -- @extends AI.AI_Cargo_Dispatcher#AI_CARGO_DISPATCHER diff --git a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Airplane.lua b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Airplane.lua index a971936f6..d3a7c78ac 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Airplane.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Airplane.lua @@ -24,7 +24,7 @@ -- @image AI_Cargo_Dispatching_For_Airplanes.JPG ---- @type AI_CARGO_DISPATCHER_AIRPLANE +-- @type AI_CARGO_DISPATCHER_AIRPLANE -- @extends AI.AI_Cargo_Dispatcher#AI_CARGO_DISPATCHER diff --git a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua index c391324e4..b219c78b0 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Helicopter.lua @@ -25,7 +25,7 @@ -- @module AI.AI_Cargo_Dispatcher_Helicopter -- @image AI_Cargo_Dispatching_For_Helicopters.JPG ---- @type AI_CARGO_DISPATCHER_HELICOPTER +-- @type AI_CARGO_DISPATCHER_HELICOPTER -- @extends AI.AI_Cargo_Dispatcher#AI_CARGO_DISPATCHER diff --git a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua index 152ea7881..6fc670e40 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Dispatcher_Ship.lua @@ -23,7 +23,7 @@ -- @module AI.AI_Cargo_Dispatcher_Ship -- @image AI_Cargo_Dispatcher.JPG ---- @type AI_CARGO_DISPATCHER_SHIP +-- @type AI_CARGO_DISPATCHER_SHIP -- @extends AI.AI_Cargo_Dispatcher#AI_CARGO_DISPATCHER @@ -160,7 +160,7 @@ AI_CARGO_DISPATCHER_SHIP = { -- local SetPickupZones = SET_ZONE:New():FilterPrefixes( "Pickup" ):FilterStart() -- local SetDeployZones = SET_ZONE:New():FilterPrefixes( "Deploy" ):FilterStart() -- NEED MORE THOUGHT - ShippingLane is part of Warehouse....... --- local ShippingLane = GROUP:New():FilterPrefixes( "ShippingLane" ):FilterStart() +-- local ShippingLane = SET_GROUP:New():FilterPrefixes( "ShippingLane" ):FilterOnce():GetSetObjects() -- -- AICargoDispatcherShip = AI_CARGO_DISPATCHER_SHIP:New( SetShip, SetCargoInfantry, SetPickupZones, SetDeployZones, ShippingLane ) -- AICargoDispatcherShip:Start() diff --git a/Moose Development/Moose/AI/AI_Cargo_Helicopter.lua b/Moose Development/Moose/AI/AI_Cargo_Helicopter.lua index 6edfc3894..cea586679 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Helicopter.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Helicopter.lua @@ -9,7 +9,7 @@ -- @module AI.AI_Cargo_Helicopter -- @image AI_Cargo_Dispatching_For_Helicopters.JPG ---- @type AI_CARGO_HELICOPTER +-- @type AI_CARGO_HELICOPTER -- @extends Core.Fsm#FSM_CONTROLLABLE @@ -287,7 +287,7 @@ function AI_CARGO_HELICOPTER:SetLandingSpeedAndHeight(speed, height) return self end ---- @param #AI_CARGO_HELICOPTER self +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter -- @param From -- @param Event @@ -326,7 +326,7 @@ function AI_CARGO_HELICOPTER:onafterLanded( Helicopter, From, Event, To ) end ---- @param #AI_CARGO_HELICOPTER self +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter -- @param From -- @param Event @@ -409,7 +409,7 @@ function AI_CARGO_HELICOPTER:onafterQueue( Helicopter, From, Event, To, Coordina end ---- @param #AI_CARGO_HELICOPTER self +-- @param #AI_CARGO_HELICOPTER self -- @param Wrapper.Group#GROUP Helicopter -- @param From -- @param Event diff --git a/Moose Development/Moose/AI/AI_Cargo_Ship.lua b/Moose Development/Moose/AI/AI_Cargo_Ship.lua index 669da09b5..5639c52da 100644 --- a/Moose Development/Moose/AI/AI_Cargo_Ship.lua +++ b/Moose Development/Moose/AI/AI_Cargo_Ship.lua @@ -9,7 +9,7 @@ -- @module AI.AI_Cargo_Ship -- @image AI_Cargo_Dispatcher.JPG ---- @type AI_CARGO_SHIP +-- @type AI_CARGO_SHIP -- @extends AI.AI_Cargo#AI_CARGO --- Brings a dynamic cargo handling capability for an AI naval group. diff --git a/Moose Development/Moose/AI/AI_Escort_Dispatcher_Request.lua b/Moose Development/Moose/AI/AI_Escort_Dispatcher_Request.lua index 0b3180910..160c2beed 100644 --- a/Moose Development/Moose/AI/AI_Escort_Dispatcher_Request.lua +++ b/Moose Development/Moose/AI/AI_Escort_Dispatcher_Request.lua @@ -15,7 +15,7 @@ -- @image MOOSE.JPG ---- @type AI_ESCORT_DISPATCHER_REQUEST +-- @type AI_ESCORT_DISPATCHER_REQUEST -- @extends Core.Fsm#FSM @@ -33,7 +33,7 @@ AI_ESCORT_DISPATCHER_REQUEST = { ClassName = "AI_ESCORT_DISPATCHER_REQUEST", } ---- @field #list +-- @field #list AI_ESCORT_DISPATCHER_REQUEST.AI_Escorts = {} @@ -80,7 +80,7 @@ function AI_ESCORT_DISPATCHER_REQUEST:onafterStart( From, Event, To ) end ---- @param #AI_ESCORT_DISPATCHER_REQUEST self +-- @param #AI_ESCORT_DISPATCHER_REQUEST self -- @param Core.Event#EVENTDATA EventData function AI_ESCORT_DISPATCHER_REQUEST:OnEventExit( EventData ) @@ -97,7 +97,7 @@ function AI_ESCORT_DISPATCHER_REQUEST:OnEventExit( EventData ) end ---- @param #AI_ESCORT_DISPATCHER_REQUEST self +-- @param #AI_ESCORT_DISPATCHER_REQUEST self -- @param Core.Event#EVENTDATA EventData function AI_ESCORT_DISPATCHER_REQUEST:OnEventBirth( EventData ) diff --git a/Moose Development/Moose/AI/AI_Escort_Request.lua b/Moose Development/Moose/AI/AI_Escort_Request.lua index 08bee2f64..3251d3717 100644 --- a/Moose Development/Moose/AI/AI_Escort_Request.lua +++ b/Moose Development/Moose/AI/AI_Escort_Request.lua @@ -136,12 +136,12 @@ -- -- Escort groups can have their own mission. This menu item will allow the escort group to resume their Mission from a given waypoint. -- Note that this is really fantastic, as you now have the dynamic of taking control of the escort groups, and allowing them to resume their path or mission. --- --- # Developer Note --- --- Note while this class still works, it is no longer supported as the original author stopped active development of MOOSE --- Therefore, this class is considered to be deprecated --- + -- + -- # Developer Note + -- + -- Note while this class still works, it is no longer supported as the original author stopped active development of MOOSE + -- Therefore, this class is considered to be deprecated + -- -- === -- -- ### Authors: **FlightControl** @@ -153,7 +153,7 @@ ---- @type AI_ESCORT_REQUEST +-- @type AI_ESCORT_REQUEST -- @extends AI.AI_Escort#AI_ESCORT --- AI_ESCORT_REQUEST class @@ -228,7 +228,7 @@ function AI_ESCORT_REQUEST:New( EscortUnit, EscortSpawn, EscortAirbase, EscortNa return self end ---- @param #AI_ESCORT_REQUEST self +-- @param #AI_ESCORT_REQUEST self function AI_ESCORT_REQUEST:SpawnEscort() local EscortGroup = self.EscortSpawn:SpawnAtAirbase( self.EscortAirbase, SPAWN.Takeoff.Hot ) @@ -253,7 +253,7 @@ function AI_ESCORT_REQUEST:SpawnEscort() self:_InitEscortMenus( EscortGroup ) self:_InitEscortRoute( EscortGroup ) - --- @param #AI_ESCORT self + -- @param #AI_ESCORT self -- @param Core.Event#EVENTDATA EventData function EscortGroup:OnEventDeadOrCrash( EventData ) self:F( { "EventDead", EventData } ) @@ -268,7 +268,7 @@ function AI_ESCORT_REQUEST:SpawnEscort() end ---- @param #AI_ESCORT_REQUEST self +-- @param #AI_ESCORT_REQUEST self -- @param Core.Set#SET_GROUP EscortGroupSet function AI_ESCORT_REQUEST:onafterStart( EscortGroupSet ) @@ -290,14 +290,14 @@ function AI_ESCORT_REQUEST:onafterStart( EscortGroupSet ) end ---- @param #AI_ESCORT_REQUEST self +-- @param #AI_ESCORT_REQUEST self -- @param Core.Set#SET_GROUP EscortGroupSet function AI_ESCORT_REQUEST:onafterStop( EscortGroupSet ) self:F() EscortGroupSet:ForEachGroup( - --- @param Wrapper.Group#GROUP EscortGroup + -- @param Core.Group#GROUP EscortGroup function( EscortGroup ) EscortGroup:WayPointInitialize() diff --git a/Moose Development/Moose/AI/AI_Formation.lua b/Moose Development/Moose/AI/AI_Formation.lua index d7d2d1966..4b01217c3 100644 --- a/Moose Development/Moose/AI/AI_Formation.lua +++ b/Moose Development/Moose/AI/AI_Formation.lua @@ -34,8 +34,8 @@ -- @field Core.Scheduler#SCHEDULER FollowScheduler The instance of the SCHEDULER class. -- @field #number FollowDistance The current follow distance. -- @field #boolean ReportTargets If true, nearby targets are reported. --- @field DCS#AI.Option.Air.val.ROE OptionROE Which ROE is set to the FollowGroup. --- @field DCS#AI.Option.Air.val.REACTION_ON_THREAT OptionReactionOnThreat Which REACTION_ON_THREAT is set to the FollowGroup. +-- @Field DCSTypes#AI.Option.Air.val.ROE OptionROE Which ROE is set to the FollowGroup. +-- @field DCSTypes#AI.Option.Air.val.REACTION_ON_THREAT OptionReactionOnThreat Which REACTION_ON_THREAT is set to the FollowGroup. -- @field #number dtFollow Time step between position updates. @@ -92,12 +92,12 @@ -- local LargeFormation = AI_FORMATION:New( LeaderUnit, FollowGroupSet, "Center Wing Formation", "Briefing" ) -- LargeFormation:FormationCenterWing( 500, 50, 0, 250, 250 ) -- LargeFormation:__Start( 1 ) --- --- # Developer Note --- --- Note while this class still works, it is no longer supported as the original author stopped active development of MOOSE --- Therefore, this class is considered to be deprecated --- + -- + -- # Developer Note + -- + -- Note while this class still works, it is no longer supported as the original author stopped active development of MOOSE + -- Therefore, this class is considered to be deprecated + -- -- @field #AI_FORMATION AI_FORMATION = { ClassName = "AI_FORMATION", @@ -117,7 +117,7 @@ AI_FORMATION = { AI_FORMATION.__Enum = {} ---- @type AI_FORMATION.__Enum.Formation +-- @type AI_FORMATION.__Enum.Formation -- @field #number None -- @field #number Line -- @field #number Trail @@ -142,7 +142,7 @@ AI_FORMATION.__Enum.Formation = { Box = 10, } ---- @type AI_FORMATION.__Enum.Mode +-- @type AI_FORMATION.__Enum.Mode -- @field #number Mission -- @field #number Formation AI_FORMATION.__Enum.Mode = { @@ -152,13 +152,13 @@ AI_FORMATION.__Enum.Mode = { Reconnaissance = "R", } ---- @type AI_FORMATION.__Enum.ReportType +-- @type AI_FORMATION.__Enum.ReportType -- @field #number All -- @field #number Airborne -- @field #number GroundRadar -- @field #number Ground AI_FORMATION.__Enum.ReportType = { - Airborne = "*", + All = "*", Airborne = "A", GroundRadar = "R", Ground = "G", @@ -996,7 +996,7 @@ function AI_FORMATION:SetFlightModeMission( FollowGroup ) FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Mission ) else self.FollowGroupSet:ForSomeGroupAlive( - --- @param Wrapper.Group#GROUP EscortGroup + -- @param Core.Group#GROUP EscortGroup function( FollowGroup ) FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) ) FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Mission ) @@ -1020,7 +1020,7 @@ function AI_FORMATION:SetFlightModeAttack( FollowGroup ) FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Attack ) else self.FollowGroupSet:ForSomeGroupAlive( - --- @param Wrapper.Group#GROUP EscortGroup + -- @param Core.Group#GROUP EscortGroup function( FollowGroup ) FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) ) FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Attack ) @@ -1044,7 +1044,7 @@ function AI_FORMATION:SetFlightModeFormation( FollowGroup ) FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Formation ) else self.FollowGroupSet:ForSomeGroupAlive( - --- @param Wrapper.Group#GROUP EscortGroup + -- @param Core.Group#GROUP EscortGroup function( FollowGroup ) FollowGroup:SetState( FollowGroup, "PreviousMode", FollowGroup:GetState( FollowGroup, "Mode" ) ) FollowGroup:SetState( FollowGroup, "Mode", self.__Enum.Mode.Formation ) @@ -1222,7 +1222,7 @@ function AI_FORMATION:FollowMe(FollowGroup, ClientUnit, CT1, CV1, CT2, CV2) local CVI = { x = CV2.x + CS * 10 * math.sin(Ca), y = GH2.y + Inclination, -- + FollowFormation.y, - y = GH2.y, + --y = GH2.y, z = CV2.z + CS * 10 * math.cos(Ca), } diff --git a/Moose Development/Moose/Actions/Act_Account.lua b/Moose Development/Moose/Actions/Act_Account.lua index 5b809af44..a72a7b445 100644 --- a/Moose Development/Moose/Actions/Act_Account.lua +++ b/Moose Development/Moose/Actions/Act_Account.lua @@ -274,7 +274,7 @@ do -- ACT_ACCOUNT_DEADS --- DCS Events - --- @param #ACT_ACCOUNT_DEADS self + -- @param #ACT_ACCOUNT_DEADS self -- @param Core.Event#EVENTDATA EventData function ACT_ACCOUNT_DEADS:OnEventHit( EventData ) self:T( { "EventDead", EventData } ) @@ -285,7 +285,7 @@ do -- ACT_ACCOUNT_DEADS end end - --- @param #ACT_ACCOUNT_DEADS self + -- @param #ACT_ACCOUNT_DEADS self -- @param Core.Event#EVENTDATA EventData function ACT_ACCOUNT_DEADS:onfuncEventDead( EventData ) self:T( { "EventDead", EventData } ) @@ -297,7 +297,7 @@ do -- ACT_ACCOUNT_DEADS --- DCS Events - --- @param #ACT_ACCOUNT_DEADS self + -- @param #ACT_ACCOUNT_DEADS self -- @param Core.Event#EVENTDATA EventData function ACT_ACCOUNT_DEADS:onfuncEventCrash( EventData ) self:T( { "EventDead", EventData } ) diff --git a/Moose Development/Moose/Actions/Act_Assist.lua b/Moose Development/Moose/Actions/Act_Assist.lua index 9b4744561..2ae132ac1 100644 --- a/Moose Development/Moose/Actions/Act_Assist.lua +++ b/Moose Development/Moose/Actions/Act_Assist.lua @@ -200,7 +200,7 @@ do -- ACT_ASSIST_SMOKE_TARGETS_ZONE function ACT_ASSIST_SMOKE_TARGETS_ZONE:onenterSmoking( ProcessUnit, From, Event, To ) self.TargetSetUnit:ForEachUnit( - --- @param Wrapper.Unit#UNIT SmokeUnit + -- @param Wrapper.Unit#UNIT SmokeUnit function( SmokeUnit ) if math.random( 1, ( 100 * self.TargetSetUnit:Count() ) / 4 ) <= 100 then SCHEDULER:New( self, diff --git a/Moose Development/Moose/Cargo/CargoCrate.lua b/Moose Development/Moose/Cargo/CargoCrate.lua index c0fbdd631..430032d0b 100644 --- a/Moose Development/Moose/Cargo/CargoCrate.lua +++ b/Moose Development/Moose/Cargo/CargoCrate.lua @@ -78,7 +78,7 @@ do -- CARGO_CRATE return self end - --- @param #CARGO_CRATE self + -- @param #CARGO_CRATE self -- @param Core.Event#EVENTDATA EventData function CARGO_CRATE:OnEventCargoDead( EventData ) diff --git a/Moose Development/Moose/Cargo/CargoGroup.lua b/Moose Development/Moose/Cargo/CargoGroup.lua index ca6a96a69..0af776c05 100644 --- a/Moose Development/Moose/Cargo/CargoGroup.lua +++ b/Moose Development/Moose/Cargo/CargoGroup.lua @@ -598,7 +598,7 @@ do -- CARGO_GROUP end - --- Get the amount of cargo units in the group. + --- Get the underlying GROUP object from the CARGO_GROUP. -- @param #CARGO_GROUP self -- @return #CARGO_GROUP function CARGO_GROUP:GetGroup( Cargo ) diff --git a/Moose Development/Moose/Cargo/CargoSlingload.lua b/Moose Development/Moose/Cargo/CargoSlingload.lua index ad26e8868..81bc5d95e 100644 --- a/Moose Development/Moose/Cargo/CargoSlingload.lua +++ b/Moose Development/Moose/Cargo/CargoSlingload.lua @@ -72,7 +72,7 @@ do -- CARGO_SLINGLOAD end - --- @param #CARGO_SLINGLOAD self + -- @param #CARGO_SLINGLOAD self -- @param Core.Event#EVENTDATA EventData function CARGO_SLINGLOAD:OnEventCargoDead( EventData ) diff --git a/Moose Development/Moose/Core/ClientMenu.lua b/Moose Development/Moose/Core/ClientMenu.lua index 9a7ace3fe..59ec7169c 100644 --- a/Moose Development/Moose/Core/ClientMenu.lua +++ b/Moose Development/Moose/Core/ClientMenu.lua @@ -417,7 +417,7 @@ end CLIENTMENUMANAGER = { ClassName = "CLIENTMENUMANAGER", lid = "", - version = "0.1.5a", + version = "0.1.6", name = nil, clientset = nil, menutree = {}, diff --git a/Moose Development/Moose/Core/Fsm.lua b/Moose Development/Moose/Core/Fsm.lua index b72ca63d9..e3fbd4f6c 100644 --- a/Moose Development/Moose/Core/Fsm.lua +++ b/Moose Development/Moose/Core/Fsm.lua @@ -79,7 +79,7 @@ do -- FSM - --- @type FSM + -- @type FSM -- @field #string ClassName Name of the class. -- @field Core.Scheduler#SCHEDULER CallScheduler Call scheduler. -- @field #table options Options. @@ -949,7 +949,7 @@ end do -- FSM_CONTROLLABLE - --- @type FSM_CONTROLLABLE + -- @type FSM_CONTROLLABLE -- @field Wrapper.Controllable#CONTROLLABLE Controllable -- @extends Core.Fsm#FSM @@ -1082,7 +1082,7 @@ end do -- FSM_PROCESS - --- @type FSM_PROCESS + -- @type FSM_PROCESS -- @field Tasking.Task#TASK Task -- @extends Core.Fsm#FSM_CONTROLLABLE diff --git a/Moose Development/Moose/Core/Goal.lua b/Moose Development/Moose/Core/Goal.lua index bc33246f6..cff272dbd 100644 --- a/Moose Development/Moose/Core/Goal.lua +++ b/Moose Development/Moose/Core/Goal.lua @@ -24,7 +24,7 @@ do -- Goal - --- @type GOAL + -- @type GOAL -- @extends Core.Fsm#FSM --- Models processes that have an objective with a defined achievement. Derived classes implement the ways how the achievements can be realized. @@ -71,10 +71,10 @@ do -- Goal ClassName = "GOAL", } - --- @field #table GOAL.Players + -- @field #table GOAL.Players GOAL.Players = {} - --- @field #number GOAL.TotalContributions + -- @field #number GOAL.TotalContributions GOAL.TotalContributions = 0 --- GOAL Constructor. @@ -145,7 +145,7 @@ do -- Goal self.TotalContributions = self.TotalContributions + 1 end - --- @param #GOAL self + -- @param #GOAL self -- @param #number Player contribution. function GOAL:GetPlayerContribution( PlayerName ) return self.Players[PlayerName] or 0 diff --git a/Moose Development/Moose/Core/Message.lua b/Moose Development/Moose/Core/Message.lua index 450b87db6..f432c08f3 100644 --- a/Moose Development/Moose/Core/Message.lua +++ b/Moose Development/Moose/Core/Message.lua @@ -177,7 +177,7 @@ end -- -- -- Send the 2 messages created with the @{New} method to the Client Group. -- -- Note that the Message of MessageClient2 is overwriting the Message of MessageClient1. --- Client = CLIENT:FindByName("UnitNameOfMyClient") +-- Client = CLIENT:FindByName("NameOfClientUnit") -- -- MessageClient1 = MESSAGE:New( "Congratulations, you've just hit a target", 25, "Score" ):ToClient( Client ) -- MessageClient2 = MESSAGE:New( "Congratulations, you've just killed a target", 25, "Score" ):ToClient( Client ) @@ -192,7 +192,7 @@ end -- function MESSAGE:ToClient( Client, Settings ) self:F( Client ) - self:ToUnit(Client, Settings) + self:ToUnit(Client,Settings) return self end @@ -239,6 +239,7 @@ function MESSAGE:ToUnit( Unit, Settings ) if self.MessageDuration ~= 0 then self:T( self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$","") .. " / " .. self.MessageDuration ) + local ID = Unit:GetID() trigger.action.outTextForUnit( Unit:GetID(), self.MessageCategory .. self.MessageText:gsub("\n$",""):gsub("\n$",""), self.MessageDuration, self.ClearScreen ) end end diff --git a/Moose Development/Moose/Core/Report.lua b/Moose Development/Moose/Core/Report.lua index d8225adcc..8d55f05d3 100644 --- a/Moose Development/Moose/Core/Report.lua +++ b/Moose Development/Moose/Core/Report.lua @@ -15,7 +15,8 @@ -- @module Core.Report -- @image Core_Report.JPG ---- @type REPORT +--- +-- @type REPORT -- @extends Core.Base#BASE --- Provides a handy means to create messages and reports. diff --git a/Moose Development/Moose/Core/ScheduleDispatcher.lua b/Moose Development/Moose/Core/ScheduleDispatcher.lua index 611cb6fba..5eb58e731 100644 --- a/Moose Development/Moose/Core/ScheduleDispatcher.lua +++ b/Moose Development/Moose/Core/ScheduleDispatcher.lua @@ -1,4 +1,4 @@ ---- **Core** - SCHEDULEDISPATCHER dispatches the different schedules. +---- **Core** - SCHEDULEDISPATCHER dispatches the different schedules. -- -- === -- diff --git a/Moose Development/Moose/Core/Settings.lua b/Moose Development/Moose/Core/Settings.lua index ca5ecc80b..81a60a7f8 100644 --- a/Moose Development/Moose/Core/Settings.lua +++ b/Moose Development/Moose/Core/Settings.lua @@ -29,7 +29,9 @@ -- @module Core.Settings -- @image Core_Settings.JPG ---- @type SETTINGS + +--- +-- @type SETTINGS -- @extends Core.Base#BASE --- Takes care of various settings that influence the behavior of certain functionalities and classes within the MOOSE framework. @@ -218,7 +220,8 @@ SETTINGS = { SETTINGS.__Enum = {} ---- @type SETTINGS.__Enum.Era +--- +-- @type SETTINGS.__Enum.Era -- @field #number WWII -- @field #number Korea -- @field #number Cold @@ -491,7 +494,7 @@ do -- SETTINGS return (self.A2ASystem and self.A2ASystem == "MGRS") or (not self.A2ASystem and _SETTINGS:IsA2A_MGRS()) end - --- @param #SETTINGS self + -- @param #SETTINGS self -- @param Wrapper.Group#GROUP MenuGroup Group for which to add menus. -- @param #table RootMenu Root menu table -- @return #SETTINGS @@ -945,49 +948,49 @@ do -- SETTINGS return self end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:A2GMenuSystem( MenuGroup, RootMenu, A2GSystem ) self.A2GSystem = A2GSystem MESSAGE:New( string.format( "Settings: Default A2G coordinate system set to %s for all players!", A2GSystem ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:A2AMenuSystem( MenuGroup, RootMenu, A2ASystem ) self.A2ASystem = A2ASystem MESSAGE:New( string.format( "Settings: Default A2A coordinate system set to %s for all players!", A2ASystem ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuLL_DDM_Accuracy( MenuGroup, RootMenu, LL_Accuracy ) self.LL_Accuracy = LL_Accuracy MESSAGE:New( string.format( "Settings: Default LL accuracy set to %s for all players!", LL_Accuracy ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuMGRS_Accuracy( MenuGroup, RootMenu, MGRS_Accuracy ) self.MGRS_Accuracy = MGRS_Accuracy MESSAGE:New( string.format( "Settings: Default MGRS accuracy set to %s for all players!", MGRS_Accuracy ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuMWSystem( MenuGroup, RootMenu, MW ) self.Metric = MW MESSAGE:New( string.format( "Settings: Default measurement format set to %s for all players!", MW and "Metric" or "Imperial" ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuMessageTimingsSystem( MenuGroup, RootMenu, MessageType, MessageTime ) self:SetMessageTime( MessageType, MessageTime ) MESSAGE:New( string.format( "Settings: Default message time set for %s to %d.", MessageType, MessageTime ), 5 ):ToAll() end do - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupA2GSystem( PlayerUnit, PlayerGroup, PlayerName, A2GSystem ) --BASE:E( {PlayerUnit:GetName(), A2GSystem } ) self.A2GSystem = A2GSystem @@ -998,7 +1001,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupA2ASystem( PlayerUnit, PlayerGroup, PlayerName, A2ASystem ) self.A2ASystem = A2ASystem MESSAGE:New( string.format( "Settings: A2A format set to %s for player %s.", A2ASystem, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1008,7 +1011,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupLL_DDM_AccuracySystem( PlayerUnit, PlayerGroup, PlayerName, LL_Accuracy ) self.LL_Accuracy = LL_Accuracy MESSAGE:New( string.format( "Settings: LL format accuracy set to %d decimal places for player %s.", LL_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1018,7 +1021,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupMGRS_AccuracySystem( PlayerUnit, PlayerGroup, PlayerName, MGRS_Accuracy ) self.MGRS_Accuracy = MGRS_Accuracy MESSAGE:New( string.format( "Settings: MGRS format accuracy set to %d for player %s.", MGRS_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1028,7 +1031,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupMWSystem( PlayerUnit, PlayerGroup, PlayerName, MW ) self.Metric = MW MESSAGE:New( string.format( "Settings: Measurement format set to %s for player %s.", MW and "Metric" or "Imperial", PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1038,7 +1041,7 @@ do -- SETTINGS end end - --- @param #SETTINGS self + -- @param #SETTINGS self function SETTINGS:MenuGroupMessageTimingsSystem( PlayerUnit, PlayerGroup, PlayerName, MessageType, MessageTime ) self:SetMessageTime( MessageType, MessageTime ) MESSAGE:New( string.format( "Settings: Default message time set for %s to %d.", MessageType, MessageTime ), 5 ):ToGroup( PlayerGroup ) diff --git a/Moose Development/Moose/Core/UserFlag.lua b/Moose Development/Moose/Core/UserFlag.lua index 1c47e787f..94bff742a 100644 --- a/Moose Development/Moose/Core/UserFlag.lua +++ b/Moose Development/Moose/Core/UserFlag.lua @@ -18,7 +18,7 @@ do -- UserFlag - --- @type USERFLAG + -- @type USERFLAG -- @field #string ClassName Name of the class -- @field #string UserFlagName Name of the flag. -- @extends Core.Base#BASE diff --git a/Moose Development/Moose/Core/Velocity.lua b/Moose Development/Moose/Core/Velocity.lua index e71282208..1181271c7 100644 --- a/Moose Development/Moose/Core/Velocity.lua +++ b/Moose Development/Moose/Core/Velocity.lua @@ -20,7 +20,7 @@ do -- Velocity - --- @type VELOCITY + -- @type VELOCITY -- @extends Core.Base#BASE @@ -127,7 +127,7 @@ end do -- VELOCITY_POSITIONABLE - --- @type VELOCITY_POSITIONABLE + -- @type VELOCITY_POSITIONABLE -- @extends Core.Base#BASE diff --git a/Moose Development/Moose/Core/Zone.lua b/Moose Development/Moose/Core/Zone.lua index 934188d98..7750851cb 100644 --- a/Moose Development/Moose/Core/Zone.lua +++ b/Moose Development/Moose/Core/Zone.lua @@ -3641,7 +3641,7 @@ do -- ZONE_ELASTIC end - --- Create a convec hull. + --- Create a convex hull. -- @param #ZONE_ELASTIC self -- @param #table pl Points -- @return #table Points diff --git a/Moose Development/Moose/Core/Zone_Detection.lua b/Moose Development/Moose/Core/Zone_Detection.lua index bb5424a37..385ac5247 100644 --- a/Moose Development/Moose/Core/Zone_Detection.lua +++ b/Moose Development/Moose/Core/Zone_Detection.lua @@ -2,7 +2,8 @@ -- @module Core.Zone_Detection -- @image MOOSE.JPG ---- @type ZONE_DETECTION +--- +-- @type ZONE_DETECTION -- @field DCS#Vec2 Vec2 The current location of the zone. -- @field DCS#Distance Radius The radius of the zone. -- @extends #ZONE_BASE diff --git a/Moose Development/Moose/Functional/AmmoTruck.lua b/Moose Development/Moose/Functional/AmmoTruck.lua index e59ab2872..d4181f1c8 100644 --- a/Moose Development/Moose/Functional/AmmoTruck.lua +++ b/Moose Development/Moose/Functional/AmmoTruck.lua @@ -77,7 +77,7 @@ -- ammotruck.monitor = -60 -- 1 minute - AMMOTRUCK checks run every one minute -- ammotruck.routeonroad = true -- Trucks will **try** to drive on roads -- ammotruck.usearmygroup = false -- If true, will make use of ARMYGROUP in the background (if used in DEV branch) --- ammotruck.reloads = 5 -- Maxn re-arms a truck can do before he needs to go home and restock. Set to -1 for unlimited +-- ammotruck.reloads = 5 -- Maxn re-arms a truck can do before he needs to go home and restock. Set to -1 for unlimited -- -- ## 3 FSM Events to shape mission -- diff --git a/Moose Development/Moose/Functional/Artillery.lua b/Moose Development/Moose/Functional/Artillery.lua index c1745cac0..f48e36d07 100644 --- a/Moose Development/Moose/Functional/Artillery.lua +++ b/Moose Development/Moose/Functional/Artillery.lua @@ -2301,12 +2301,12 @@ function ARTY:OnEventShot(EventData) self.Nukes=self.Nukes-1 end - -- Decrease available illuminatin shells because we just fired one. + -- Decrease available illumination shells because we just fired one. if self.currentTarget.weapontype==ARTY.WeaponType.IlluminationShells then self.Nillu=self.Nillu-1 end - -- Decrease available illuminatin shells because we just fired one. + -- Decrease available smoke shells because we just fired one. if self.currentTarget.weapontype==ARTY.WeaponType.SmokeShells then self.Nsmoke=self.Nsmoke-1 end @@ -3717,51 +3717,6 @@ function ARTY:_NuclearBlast(_coord) ignite(_fires) end ---[[ - local ZoneNuke=ZONE_RADIUS:New("Nukezone", _coord:GetVec2(), 2000) - - -- Scan for Scenery objects. - ZoneNuke:Scan(Object.Category.SCENERY) - - -- Array with all possible hideouts, i.e. scenery objects in the vicinity of the group. - local scenery={} - - for SceneryTypeName, SceneryData in pairs(ZoneNuke:GetScannedScenery()) do - for SceneryName, SceneryObject in pairs(SceneryData) do - - local SceneryObject = SceneryObject -- Wrapper.Scenery#SCENERY - - -- Position of the scenery object. - local spos=SceneryObject:GetCoordinate() - - -- Distance from group to impact point. - local distance= spos:Get2DDistance(_coord) - - -- Place markers on every possible scenery object. - if self.Debug then - local MarkerID=spos:MarkToAll(string.format("%s scenery object %s", self.Controllable:GetName(), SceneryObject:GetTypeName())) - local text=string.format("%s scenery: %s, Coord %s", self.Controllable:GetName(), SceneryObject:GetTypeName(), SceneryObject:GetCoordinate():ToStringLLDMS()) - self:T2(SUPPRESSION.id..text) - end - - -- Add to table. - table.insert(scenery, {object=SceneryObject, distance=distance}) - - --SceneryObject:Destroy() - end - end - - -- Sort scenery wrt to distance from impact point. --- local _sort = function(a,b) return a.distance < b.distance end --- table.sort(scenery,_sort) - --- for _,object in pairs(scenery) do --- local sobject=object -- Wrapper.Scenery#SCENERY --- sobject:Destroy() --- end - -]] - end --- Route group to a certain point. diff --git a/Moose Development/Moose/Functional/CleanUp.lua b/Moose Development/Moose/Functional/CleanUp.lua index 6bf5228f0..359922b5a 100644 --- a/Moose Development/Moose/Functional/CleanUp.lua +++ b/Moose Development/Moose/Functional/CleanUp.lua @@ -52,11 +52,13 @@ -- @module Functional.CleanUp -- @image CleanUp_Airbases.JPG ---- @type CLEANUP_AIRBASE.__ Methods which are not intended for mission designers, but which are used interally by the moose designer :-) +--- +-- @type CLEANUP_AIRBASE.__ Methods which are not intended for mission designers, but which are used interally by the moose designer :-) -- @field #map<#string,Wrapper.Airbase#AIRBASE> Airbases Map of Airbases. -- @extends Core.Base#BASE ---- @type CLEANUP_AIRBASE +--- +-- @type CLEANUP_AIRBASE -- @extends #CLEANUP_AIRBASE.__ --- Keeps airbases clean, and tries to guarantee continuous airbase operations, even under combat. @@ -93,7 +95,7 @@ CLEANUP_AIRBASE = { -- @field #CLEANUP_AIRBASE.__ CLEANUP_AIRBASE.__ = {} ---- @field #CLEANUP_AIRBASE.__.Airbases +-- @field #CLEANUP_AIRBASE.__.Airbases CLEANUP_AIRBASE.__.Airbases = {} --- Creates the main object which is handling the cleaning of the debris within the given Zone Names. @@ -240,7 +242,8 @@ function CLEANUP_AIRBASE.__:DestroyMissile( MissileObject ) end end ---- @param #CLEANUP_AIRBASE self +--- +-- @param #CLEANUP_AIRBASE self -- @param Core.Event#EVENTDATA EventData function CLEANUP_AIRBASE.__:OnEventBirth( EventData ) self:F( { EventData } ) diff --git a/Moose Development/Moose/Functional/DetectionZones.lua b/Moose Development/Moose/Functional/DetectionZones.lua index 20680559d..8a8984658 100644 --- a/Moose Development/Moose/Functional/DetectionZones.lua +++ b/Moose Development/Moose/Functional/DetectionZones.lua @@ -4,7 +4,7 @@ do -- DETECTION_ZONES - --- @type DETECTION_ZONES + -- @type DETECTION_ZONES -- @field DCS#Distance DetectionZoneRange The range till which targets are grouped upon the first detected target. -- @field #DETECTION_BASE.DetectedItems DetectedItems A list of areas containing the set of @{Wrapper.Unit}s, @{Core.Zone}s, the center @{Wrapper.Unit} within the zone, and ID of each area that was detected within a DetectionZoneRange. -- @extends Functional.Detection#DETECTION_BASE @@ -68,7 +68,7 @@ do -- DETECTION_ZONES return self end - --- @param #DETECTION_ZONES self + -- @param #DETECTION_ZONES self -- @param #number The amount of alive recce. function DETECTION_ZONES:CountAliveRecce() @@ -76,7 +76,7 @@ do -- DETECTION_ZONES end - --- @param #DETECTION_ZONES self + -- @param #DETECTION_ZONES self function DETECTION_ZONES:ForEachAliveRecce( IteratorFunction, ... ) self:F2( arg ) @@ -352,7 +352,7 @@ do -- DETECTION_ZONES --DetectedSet:Flush( self ) DetectedSet:ForEachUnit( - --- @param Wrapper.Unit#UNIT DetectedUnit + -- @param Wrapper.Unit#UNIT DetectedUnit function( DetectedUnit ) if DetectedUnit:IsAlive() then --self:T( "Detected Set #" .. DetectedItem.ID .. ":" .. DetectedUnit:GetName() ) @@ -380,7 +380,7 @@ do -- DETECTION_ZONES end - --- @param #DETECTION_ZONES self + -- @param #DETECTION_ZONES self -- @param #string From The From State string. -- @param #string Event The Event string. -- @param #string To The To State string. diff --git a/Moose Development/Moose/Functional/Fox.lua b/Moose Development/Moose/Functional/Fox.lua index 5ca6d4e51..bedbeeab6 100644 --- a/Moose Development/Moose/Functional/Fox.lua +++ b/Moose Development/Moose/Functional/Fox.lua @@ -141,7 +141,7 @@ FOX = { explosiondist = 200, explosiondist2 = 500, bigmissilemass = 50, - destroy = nil, + --destroy = nil, dt50 = 5, dt10 = 1, dt05 = 0.5, diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index a46e8a861..530d79053 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -1,4 +1,4 @@ ---- **Functional** - Create random airtraffic in your missions. +--- **Functional** - Create random air traffic in your missions. -- -- === -- @@ -179,8 +179,8 @@ -- * Climb rate is set to a moderate value of ~1500 ft/min. -- * The standard descent rate follows the 3:1 rule, i.e. 1000 ft decent per 3 miles of travel. Hence, angle of descent is ~3.6 degrees. -- * A holding point is randomly selected at a distance between 5 and 10 km away from destination airport. --- * The altitude of theholding point is ~1200 m AGL. Holding patterns might or might not happen with variable duration. --- * If an aircraft is spawned in air, the procedure omitts taxi and take-off and starts with the climb/cruising part. +-- * The altitude of the holding point is ~1200 m AGL. Holding patterns might or might not happen with variable duration. +-- * If an aircraft is spawned in air, the procedure omits taxi and take-off and starts with the climb/cruising part. -- * All values are randomized for each spawned aircraft. -- -- ## Mission Editor Setup @@ -196,13 +196,13 @@ -- Voilà, your already done! -- -- Optionally, you can set a specific livery for the aircraft or give it some weapons. --- However, the aircraft will by default not engage any enemies. Think of them as beeing on a peaceful or ferry mission. +-- However, the aircraft will by default not engage any enemies. Think of them as being on a peaceful or ferry mission. -- -- ## Basic Lua Script -- -- ![Process](..\Presentations\RAT\RAT_Basic_Lua_Script.png) -- --- The basic Lua script for one template group consits of two simple lines as shown in the picture above. +-- The basic Lua script for one template group consists of two simple lines as shown in the picture above. -- -- * **Line 2** creates a new RAT object "yak". The only required parameter for the constructor @{#RAT.New}() is the name of the group as defined in the mission editor. In this example it is "RAT_YAK". -- * **Line 5** trigger the command to spawn the aircraft. The (optional) parameter for the @{#RAT.Spawn}() function is the number of aircraft to be spawned of this object. @@ -216,9 +216,9 @@ -- ## Parking Problems -- -- One big issue in DCS is that not all aircraft can be spawned on every airport or airbase. In particular, bigger aircraft might not have a valid parking spot at smaller airports and --- airstripes. This can lead to multiple problems in DCS. +-- airstrips. This can lead to multiple problems in DCS. -- --- * Landing: When an aircraft tries to land at an airport where it does not have a valid parking spot, it is immidiately despawned the moment its wheels touch the runway, i.e. +-- * Landing: When an aircraft tries to land at an airport where it does not have a valid parking spot, it is immediately despawned the moment its wheels touch the runway, i.e. -- when a landing event is triggered. This leads to the loss of the RAT aircraft. On possible way to circumvent the this problem is to let another RAT aircraft spawn at landing -- and not when it shuts down its engines. See the @{#RAT.RespawnAfterLanding}() function. -- * Spawning: When a big aircraft is dynamically spawned on a small airbase a few things can go wrong. For example, it could be spawned at a parking spot with a shelter. @@ -246,9 +246,9 @@ -- c17:Spawn(5) -- -- This would randomly spawn five C-17s but only on airports which have big open air parking spots. Note that also only destination airports are allowed --- which do have this type of parking spot. This should ensure that the aircraft is able to land at the destination without beeing despawned immidiately. +-- which do have this type of parking spot. This should ensure that the aircraft is able to land at the destination without being despawned immediately. -- --- Also, the aircraft are spawned only on the requested parking spot types and not on any other type. If no parking spot of this type is availabe at the +-- Also, the aircraft are spawned only on the requested parking spot types and not on any other type. If no parking spot of this type is available at the -- moment of spawning, the group is automatically spawned in air above the selected airport. -- -- ## Examples @@ -274,7 +274,7 @@ -- -- It is also possible to make aircraft "commute" between two airports, i.e. flying from airport A to B and then back from B to A, etc. -- This can be done by the @{#RAT.Commute}() function. Note that if no departure or destination airports are specified, the first departure and destination are chosen randomly. --- Then the aircraft will fly back and forth between those two airports indefinetly. +-- Then the aircraft will fly back and forth between those two airports indefinitely. -- -- -- ### Spawn in Air @@ -302,7 +302,7 @@ -- * @{#RAT.SetTakeoff}("cold"), which means that all aircraft are spawned with their engines off, -- * @{#RAT.SetTakeoff}("hot"), which means that all aircraft are spawned with their engines on, -- * @{#RAT.SetTakeoff}("runway"), which means that all aircraft are spawned already at the runway ready to takeoff. --- Note that in this case the default spawn intervall is set to 180 seconds in order to avoid aircraft jamms on the runway. Generally, this takeoff at runways should be used with care and problems are to be expected. +-- Note that in this case the default spawn intervall is set to 180 seconds in order to avoid aircraft jams on the runway. Generally, this takeoff at runways should be used with care and problems are to be expected. -- -- -- The options @{#RAT.SetMinDistance}() and @{#RAT.SetMaxDistance}() can be used to restrict the range from departure to destination. For example @@ -325,7 +325,7 @@ -- -- * @{#RAT.SetFLcruise}(300) will cause most planes fly around FL300. -- * @{#RAT.SetFLmin}(100) restricts the cruising alt such that no plane will fly below FL100. Note that this automatically changes the minimum distance from departure to destination. --- That means that only destinations are possible for which the aircraft has had enought time to reach that flight level and descent again. +-- That means that only destinations are possible for which the aircraft has had enough time to reach that flight level and descent again. -- * @{#RAT.SetFLmax}(200) will restrict the cruise alt to maximum FL200, i.e. no aircraft will travel above this height. -- -- @@ -762,10 +762,10 @@ function RAT:Spawn(naircraft) -- Set the coalition table based on choice of self.coalition and self.friendly. self:_SetCoalitionTable() - -- Get all airports of this map beloning to friendly coalition(s). + -- Get all airports of this map belonging to friendly coalition(s). self:_GetAirportsOfCoalition() - -- Set submenuname if it has not been set by user. + -- Set sub-menu name if it has not been set by user. if not self.SubMenuName then self.SubMenuName=self.alias end @@ -1302,9 +1302,9 @@ end --- Set name of destination airports or zones for the AI aircraft. -- @param #RAT self --- @param #string destinationnames Name of the destination airport or table of destination airports. +-- @param #string destinationnames Name of the destination airport or #table of destination airports. -- @return #RAT RAT self object. --- @usage RAT:SetDestination("Krymsk") makes all aircraft of this RAT oject fly to Krymsk airport. +-- @usage RAT:SetDestination("Krymsk") makes all aircraft of this RAT object fly to Krymsk airport. function RAT:SetDestination(destinationnames) self:F2(destinationnames) @@ -1564,7 +1564,7 @@ function RAT:NoRespawn() return self end ---- Number of tries to respawn an aircraft in case it has accitentally been spawned on runway. +--- Number of tries to respawn an aircraft in case it has accidentally been spawned on runway. -- @param #RAT self -- @param #number n Number of retries. Default is 3. -- @return #RAT RAT self object. @@ -1621,7 +1621,7 @@ function RAT:RespawnInAirNotAllowed() return self end ---- Check if aircraft have accidentally been spawned on the runway. If so they will be removed immediatly. +--- Check if aircraft have accidentally been spawned on the runway. If so they will be removed immediately. -- @param #RAT self -- @param #boolean switch If true, check is performed. If false, this check is omitted. -- @param #number radius Distance in meters until a unit is considered to have spawned accidentally on the runway. Default is 75 m. diff --git a/Moose Development/Moose/Functional/Tactics.lua b/Moose Development/Moose/Functional/Tactics.lua new file mode 100644 index 000000000..7186905e2 --- /dev/null +++ b/Moose Development/Moose/Functional/Tactics.lua @@ -0,0 +1,3071 @@ +--- **Functional** - Improve the autonomous behaviour of ground AI. +-- +-- === +-- +-- ## Features: +-- +-- * Mechanized Infantry Tactics +-- * Move and attack +-- * etc +-- +-- === +-- +-- ## Missions: +-- +-- ## [MOOSE - ALL Demo Missions](https://github.com/FlightControl-Master/MOOSE_MISSIONS) +-- +-- === +-- +-- Short description +-- +-- ==== +-- +-- # YouTube Channel +-- +-- ### [MOOSE YouTube Channel](https://www.youtube.com/channel/UCjrA9j5LQoWsG4SpS8i79Qg) +-- +-- === +-- +-- ### Author: **Statua** +-- +-- ### Contributions: FlightControl +-- +-- === +-- +-- @module Functional.Tactics +-- @image Tactics.JPG + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- TACTICS class +-- @type TACTICS +-- @field #string ClassName Name of the class. +-- @field #boolean Debug Write Debug messages to DCS log file and send Debug messages to all players. +-- @field #string lid String for DCS log file. +-- @extends Core.Fsm#FSM +-- + +--- Improve the autonomous behaviour of ground AI. +-- +-- ## Title +-- +-- Body +-- +-- ### Subtitle +-- +-- Sub body +-- +-- ![Process](..\Presentations\TACTICS\image.png) +-- +-- Talking about this function/method @{#TACTICS.OnAfterTroopsDropped}() +-- +-- # Examples +-- +-- ## Mechanized Infantry +-- This example shows how to set up a basic mechanized infantry group which will respond to enemy contact by dispersing, deploying troops, and using the troops to fight back. +-- +-- ![Process](..\Presentations\TACTICS\Tactics_Example_01.png) +-- +-- +-- # Customization and Fine Tuning +-- The following user functions can be used to change the default values +-- +-- * @{#TACTICS.DefaultTroopAttackDist}() can be used to set the default maximum distance troops will move to attack a target after disembarking +-- +-- +-- @field #TACTICS +TACTICS = {} +TACTICS_UTILS = {} +TACTICS.ClassName = "TACTICS" +TACTICS.Debug = false +TACTICS.lid = nil +TACTICS_UTILS.GroupsRed = {} +TACTICS_UTILS.GroupsBlue = {} +TACTICS_UTILS.SetGroups = nil +TACTICS_UTILS.SetActive = false + +--- TACTICS version. +-- @field #number version +TACTICS.version="0.1.0" + + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--TODO list +--Check timer cutoffs in deadResponse +--Check nil for dead groups in all timers +--Check stuck in movement loop timers + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--[[Event Callbacks]] +--UnitLost(EventData) +--GroupDead(EventData) + +--StartTravel(StartPoint, EndPoint) +--Redirect(CurrentPoint, EndPoint) +--EndTravel(ActualPoint, Endpoint) + +--StartEngaging(WasHit, UnitName, WeaponName, EventData) +--EngageToIdle +--EngageToTravel +--EngageToRearming +--EngageToWinchester + +--IsWinchester +--StartRearming +--RearmedToIdle +--RearmedToTravel + +--StartAttacking +--AttackToIdle +--AttackToTravel + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Creates a new object to handle Tactics for a given Wrapper.Group#GROUP object. +-- @param #TACTICS self +-- @param Wrapper.Group#GROUP group The GROUP object for which tactics should be applied. +-- @return #TACTICS self +function TACTICS:New(group) + + ----------[INITIALIZATION]---------- + TACTICS_UTILS.SetGroups = SET_GROUP:new() + --Start Set + if not TACTICS_UTILS.SetActive then + TACTICS_UTILS.SetActive = true + TACTICS_UTILS.SetGroups:FilterStart() + end + + --Inherit from MOOSE + local self=BASE:Inherit(self, FSM:New()) -- #TACTICS + + + --Validate Wrapper.GROUP + if group:GetCoordinate() ~=nil then + self.lid=string.format("TACTICS %s | ", tostring(group:GetName())) + self:T("TACTICS version "..TACTICS.version..": Starting tactics handler for "..group:GetName()) + else + self:E("TACTICS: Requested group does not exist! (Has to be a MOOSE group that is also alive)") + return nil + end + + + --Warn on non-ground group + if group:IsGround() == false then + self:E("TACTICS: WARNING! "..group:GetName().." is not a ground group. Tactics are designed for ground units only and may result in errors or strange behaviour with this group.") + end + + + --Establish FSM Capabilities + self:SetStartState( "Stopped" ) + self:AddTransition( "Stopped", "Start", "Idle" ) + self:AddTransition( "*", "Stop", "Stopped" ) + self:AddTransition( "*", "GroupDead", "Dead" ) + self:AddTransition( "*", "UnitLost", "*" ) + self:AddTransition( "*", "Winchester", "*" ) + self:AddTransition( "*", "FullyRearmed", "*" ) + self:AddTransition( "*", "TargetSpotted", "*" ) + self:AddTransition( "*", "AttackManeuver", "*" ) + self:AddTransition( "*", "TroopsDropped", "*" ) + self:AddTransition( "*", "TroopsReturned", "*" ) + self:AddTransition( "*", "TroopsExtracted", "*" ) + self:AddTransition ("*", "SupportRequested", "*") + self:AddTransition ("*", "Supporting", "*") + self:AddTransition ("*", "Abandoned", "*") + self:AddTransition ("*", "CrewRecovered", "*") + + + + -- (Travel) + self:AddTransition( "Idle", "StartTravel", "Travelling" ) + self:AddTransition( "Travelling", "Redirect", "Travelling" ) + self:AddTransition( "Travelling", "EndTravel", "Idle" ) + + -- (Engage) + self:AddTransition( {"Idle", "Travelling","Attacking","Rearming"}, "StartEngaging", "Engaging" ) + self:AddTransition( "Engaging", "EngageToIdle", "Idle" ) + self:AddTransition( "Engaging", "EngageToTravel", "Travelling" ) + + -- (Rearming) + self:AddTransition( "*", "RequestRearming", "Rearming" ) + self:AddTransition( "Rearming", "RearmedToIdle", "Idle" ) + self:AddTransition( "Rearming", "RearmedToTravel", "Travelling" ) + + -- (Attacking) + self:AddTransition( {"Idle","Travelling"}, "StartAttack", "Attacking" ) + self:AddTransition( "Attacking", "AttackToIdle", "Idle" ) + self:AddTransition( "Attacking", "AttackToTravel", "Travelling" ) + self:AddTransition( {"Idle","Travelling"}, "StartHold", "Holding" ) + self:AddTransition( "Holding", "HoldToIdle", "Idle" ) + self:AddTransition( "Holding", "HoldToTravel", "Travelling" ) + self:AddTransition( {"Idle","Travelling"}, "StartAvoid", "Avoiding" ) + self:AddTransition( "Avoiding", "AvoidToIdle", "Idle" ) + self:AddTransition( "Avoiding", "AvoidToTravel", "Travelling" ) + + -- (Retreating) + self:AddTransition( "*", "StartRetreat", "Retreating" ) + self:AddTransition( "Retreating", "EndRetreat", "Idle" ) + + + --Initialize Group Data + self.TickRate = 1 + self.Group = group --The Wrapper.Group#GROUP object of the group. + self.Groupname = group:GetName() --The DCS GroupName of the Wrapper.Group#GROUP object + self.groupCoalition = self.Group:GetCoalition() + self.enemyCoalition = coalition.side.RED + self.groupCoalitionString = "blue" + self.enemyCoalitionString = "red" + if self.groupCoalition == coalition.side.RED then + self.enemyCoalition = coalition.side.BLUE + self.groupCoalitionString = "red" + self.enemyCoalitionString = "blue" + end + self.MessageOutput = false + self.MessageDuration = 10 + self.MessageSound = "squelch2.ogg" + self.MessageCallsign = "ANONYMOUS" + self.Sleeping = false + + + --(Group Units) + self.UnitTable = self.Group:GetUnits() --A table containing all of the Wrapper.Unit#UNIT objects in the group with nested data. + for i = 1, #self.UnitTable do + self.UnitTable[i].UnitName = self.UnitTable[i]:GetName() --Name of the Wrapper.Unit#UNIT object + self.UnitTable[i].TroopTransport = false --Is the unit a troop transport? + self.UnitTable[i].TroopsBoarded = false --Are any troops on board? + self.UnitTable[i].TroopGroup = nil --The Wrapper.Group#GROUP object of deployed troops when dropped + self.UnitTable[i].TroopsAlive = nil --Number of troops alive from the original template + end + + --(Ammunition/Rearming) + self.groupAmmo = {} + self.LowAmmoPercent = 0.25 + self.FullAmmoPercent = 0.95 + self.IsWinchester = false + self.IsRearming = false + self.RearmTemplate = nil + self.RearmSpawnCoord = nil + self.AllowRearming = false + self.DespawnRearmingGroup = false + self.AllowRearmRespawn = true + self.RearmGroup = nil + self.RearmGroupBase = nil + self.RearmGroupRTB = true + self.RearmGroupUseRoads = true + self.RearmGroupSpeed = 60 + self.RearmGroupFormation = "Cone" + self.RearmDrawing = false + self.DrawDataR = {} + + --(Troop Transport) + self.TroopTransport = false --Set to true to enable troop transport. Additional options required + self.TransportUnitPrefix = nil --Provide a #string to identify specific units that will carry troops. Leave as nil to enable troop transport for all units of the group + self.TroopTemplate = nil --A late activated Wrapper.Group#GROUP object to use as the template for troop deployment + self.TroopAttackDist = 1000 --How far troops deployed will move to attack the closest enemy (also affects when an attacking group stops to deploy troops) + self.TroopDismountDistMin = 100 -- If engaging beyond of TroopAttackDist, how far will troops move away from the carriers when disembarking (min random value) + self.TroopDismountDistMax = 300 -- If engaging beyond of TroopAttackDist, how far will troops move away from the carriers when disembarking (max random value) + self.TroopFormation = "Diamond" -- Formation the troops will move in when attacking + self.TroopMoveSpeed = 24 + self.TroopsAttacking = false + self.DeployedTroops = {} + self.AttackingTroops = {} + self.ExtractTimeLimit = 300 + + --(Travel) + self.Destination = nil --The last provided destination in the TravelTo call. + self.DestinationRate = 30 --How often in seconds to check up on the traveling group and see if its at its destination or is stuck + self.DestinationRadius = 100 --How close the group needs to be to its destination to consider it as arrived + self.FixStuck = true --Allow the group to make short movements in different directions if they've stopped before reaching their destination without switching states + self.UnstuckDist = 100 --How far to place a waypoint for the group to try and get it unstuck + self.MaxUnstuckAttempts = 10 --How many attempts to make to get unstuck before it stops trying. Returns state to Idle if DestroyStuck is false + self.DestroyStuck = false --Set to true to remove the group from the game if MaxUnstuckAttempts has been reached. + self.StuckHeadingIncrements = 60 + self.InclineLimit = 35 + + self.travelToStored = nil + self.stuckPosit = nil + self.lastStuckHeading = nil + self.countStuck = 0 + + --(Detection) + self.UseDetection = true + self.DetectionRate = 30 + self.TacticalROE = "Attack" --Options = "Attack", "Avoid", "Hold", "Ignore" + self.UseLOS = true + self.UseDetectionChance = true + self.MaxDetection = 6000 + self.FullDetection = 500 + self.FilterDetectionZones = nil + self.FilterEnemyType = nil --Options = "Helicopter", "Airplane", "Ground Unit", "Ship", "Train" + self.ManageAlarmState = true + self.DefaultAlarmState = "Auto" + self.ClosestEnemy = nil + self.DrawEnemySpots = true + self.EnemySpotStale = 120 + self.markSpot = nil + self.markSpotTimer = nil + self.zoneDetection = ZONE_RADIUS:New("DetZone_"..self.Groupname, self.Group:GetVec2(), self.MaxDetection, true) + + --(Attack) + self.CombatDistance = 2000 + self.AttackFarUsesRoads = false + self.AttackPositionDist = 200 + self.attackLastCoord = nil + self.AttackSpeed = 20 + self.AttackSpeedFar = 60 + self.AttackFormationFar = "Diamond" + self.AttackFormation = "Rank" + self.AttackTimeout = 300 + self.LastTargetThreshold = 25 + + self.HoldingTime = 120 + self.HoldDistance = 4000 + + self.AvoidDistance = 2000 + self.AvoidAzimuthMax = 30 + self.AvoidUseRoads = false + self.AvoidSpeed = 60 + self.AvoidFormation = 'Cone' + self.avoidDest = nil + self.AvoidRate = 30 + + --(Engagement) + self.ReactToHits = true + self.ReactAfterShooting = true + self.EvadeDistance = 25 + self.EngageCooldown = 120 + self.DisperseOnShoot = true + self.DisperseOnHit = true + self.DrawDataE = {} + self.EngageDrawing = false + self.EngageDrawingFresh = 120 + self.EngageDrawingStale = 300 + + --(Retreating) + self.RetreatAfterLosses = nil + self.RetreatZone = nil + self.RetreatSpeed = 60 + self.RetreatOnRoads = true + self.RetreatFormation = "Diamond" + self.DespawnAfterRetreat = false + self.retreatDestination = nil + + --(SUPPORT REQUEST) + self.AllowSupportRequests = true + self.SupportRadius = 4000 + self.SupportGroupLimit = 3 + self.RespondToSupport = true + self.SupportLevel = 3 --1 = On Spotted, 2 = On Engage, 3 = On Hit, 4 = On Unit Loss + self.supportTable = {} + self.SupportCooldown = 300 + + --(ABANDON VEHICLE) + self.AbandonEnabled = false + self.CrewTemplate = nil + self.AbandonHealth = 0.5 + self.AbandonDistance = 1000 + self.AllowSelfRecover = true + self.RecoveryVehicle = nil + self.RecoverySpawnZone = nil + self.RecoveryUseRoads = true + self.RecoverySpeed = 60 + self.RecoveryFormation = "Diamond" + self.SmokeAbandoned = false + self.StaticSmokeTimeout = 300 + + --Event Handling + self.Group:HandleEvent(EVENTS.Hit) + self.Group:HandleEvent(EVENTS.ShootingStart) + self.Group:HandleEvent(EVENTS.Shot) + self.Group:HandleEvent(EVENTS.Dead) + + local function handleContact(type, EventData) + if not self.Sleeping then + if not self:Is("Retreating") then + if type == "Hit" then + if self.ReactToHits then + if not self:Is("Engaging") then self:_InitEngagement(true,EventData) end + self.TimeEngageActive = true + self.TimeEngageStamp = timer.getAbsTime() + if self.SupportLevel <= 3 and not self.TimeSupportActive and self.AllowSupportRequests then + self:RequestSupport(EventData.IniUnit) + end + end + end + if type == "Shooting" then + if self.ReactAfterShooting then + if not self:Is("Engaging") then self:_InitEngagement(false,EventData) end + self.TimeEngageActive = true + self.TimeEngageStamp = timer.getAbsTime() + if self.SupportLevel <= 2 and not self.TimeSupportActive and self.AllowSupportRequests then + self:RequestSupport(EventData.TgtUnit) + end + end + end + if type == "Shot" then + if self.ReactAfterShooting then + if not self:Is("Engaging") then self:_InitEngagement(false,EventData) end + self.TimeEngageActive = true + self.TimeEngageStamp = timer.getAbsTime() + if self.SupportLevel <= 2 and not self.TimeSupportActive and self.AllowSupportRequests then + self:RequestSupport(EventData.TgtUnit) + end + end + end + end + end + if type == "Dead" then + self:_DeadResponse(EventData) + end + end + + function self.Group:OnEventHit(EventData) + handleContact("Hit", EventData) + end + + function self.Group:OnEventShot(EventData) + handleContact("Shot", EventData) + end + + function self.Group:OnEventShootingStart(EventData) + handleContact("Shooting", EventData) + end + + function self.Group:OnEventDead(EventData) + handleContact("Dead", EventData) + end + + + + --Build group ammunition table if able + for i = 1, #self.UnitTable do + local tableAmmo = self.UnitTable[i]:GetAmmo() + if tableAmmo then + for a = 1, #tableAmmo do + self:T( self.UnitTable[i].UnitName .. " has " .. tableAmmo[a]["count"] .. " " .. tableAmmo[a]["desc"]["typeName"]) + end + table.insert(self.groupAmmo, tableAmmo) + else + self:T( self.UnitTable[i].UnitName .. " does not use ammunition.") + table.insert(self.groupAmmo, nil) + end + end + + --Set Group Initialization + -- TIMER:New(function() + -- self.setEnemy = SET_UNIT:New():FilterCoalitions(self.enemyCoalitionString):FilterActive() + -- if self.FilterEnemyType then self.setEnemy:FilterCategories(self.FilterEnemyType) end + -- if self.FilterDetectionZones then self.setEnemy:FilterZones(self.FilterDetectionZones) end + -- self.setEnemy:FilterStart() + -- end):Start(1) + + + + + ----------[TIMER BASED FUNCTIONS]---------- + + + --Master Time Tracking + local initialTime = timer.getAbsTime() + self.TimeTravelActive = false + self.TimeTravelStamp = initialTime + self.TimeDetectionActive = false + self.TimeDetectionStamp = initialTime + self.TimeRearmActive = false + self.TimeRearmStamp = initialTime + self.TimeRetreatActive = false + self.TimeRetreatStamp = initialTime + self.TimeAvoidActive = false + self.TimeAvoidStamp = initialTime + + self.TimeEngageActive = false + self.TimeEngageStamp = initialTime + self.TimeHoldActive = false + self.TimeHoldStamp = initialTime + self.TimeAttackActive = false + self.TimeAttackStamp = initialTime + self.TimeSupportActive = false + self.TimeSupportStamp = initialTime + + + --Master Timer + self.MasterTime = TIMER:New(function() + local timeNow = timer.getAbsTime() + + ----{LOOPS}---- + --Travel Tracker + if self.TimeTravelActive then + if timeNow >= self.TimeTravelStamp + self.DestinationRate then + self.TimeTravelStamp = timer.getAbsTime() + self:_TravelCheck() + end + end + + --Detection + if self.TimeDetectionActive then + if timeNow >= self.TimeDetectionStamp + self.DetectionRate then + self.TimeDetectionStamp = timer.getAbsTime() + self:_DetectionCycle() + end + end + + --Avoid + if self.TimeAvoidActive then + if timeNow >= self.TimeAvoidStamp + self.AvoidRate then + self.TimeAvoidStamp = timer.getAbsTime() + self:_AvoidTimer() + end + end + + --Rearmed + if self.TimeRearmActive then + if timeNow >= self.TimeRearmStamp + 60 then + self.TimeRearmStamp = timer.getAbsTime() + self:_RearmCheckTimer() + end + end + + --Retreat + if self.TimeRetreatActive then + if timeNow >= self.TimeRetreatStamp + 60 then + self.TimeRetreatStamp = timer.getAbsTime() + self:_RetreatTimer() + end + end + + + ----{COOLDOWNS}---- + --Engagement + if self.TimeEngageActive then + if timeNow >= self.TimeEngageStamp + self.EngageCooldown then + self.TimeEngageActive = false + self:_EngageCooldown() + end + end + + --Hold + if self.TimeHoldActive then + if timeNow >= self.TimeHoldStamp + self.HoldingTime then + self.TimeHoldActive = false + self:_HoldTimer() + end + end + + --Attack + if self.TimeAttackActive then + if timeNow >= self.TimeAttackStamp + self.AttackTimeout then + self.TimeAttackActive = false + self:_AttackTimer() + end + end + + --Support + if self.TimeSupportActive then + if timeNow >= self.TimeSupportStamp + self.SupportCooldown then + self.TimeSupportActive = false + end + end + end) + + + ----------[USER FUNCTIONS]---------- + + + + + + + --Constructor related stuff + if self.groupCoalition == coalition.side.RED then + table.insert(TACTICS_UTILS.GroupsRed, self) + else + table.insert(TACTICS_UTILS.GroupsBlue, self) + end + + self:__Start(1) + return self +end + + + + +--------[INTERNAL FSM CALLBACKS]--------- + +--- [Internal] FSM Function onafterStart +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterStart(From,Event,To) + self:T({From, Event, To}) + self.MasterTime:Start(self.TickRate,self.TickRate) + if self.UseDetection == true then self.TimeDetectionActive = true end + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is now active and available for tasking.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end + return self +end + +--- [Internal] FSM Function onafterStop +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterStop(From,Event,To) + self:T({From, Event, To}) + self.MasterTime:Stop() + return self +end + +--- [Internal] FSM Function onafterStartTravel +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterStartTravel(From,Event,To,CoordGroup,CoordDest) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is initiating travel to our assigned destination.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterRedirect +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterRedirect(From,Event,To,CoordGroup,CoordDest) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." received. Redirecting to the new destination.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterEndTravel +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterEndTravel(From,Event,To,GroupCoord,DestCoord) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." has arrived at our destination. Ready for tasking.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterStartAvoid +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterStartAvoid(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is avoiding the target.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterAvoidToTravel +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterAvoidToTravel(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer avoiding the target. Resuming travel to destination.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterAvoidToIdle +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterAvoidToIdle(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer avoiding the target. Ready for tasking.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterEngageToTravel +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterEngageToTravel(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer engaged with the enemy. Resuming travel to destination.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterEngageToIdle +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterEngageToIdle(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer engaged with the enemy. Ready for tasking.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterHoldToTravel +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterHoldToTravel(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer holding from the enemy contact. Resuming travel to destination.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterHoldToIdle +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterHoldToIdle(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer holding from the enemy contact. Ready for tasking.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterStartAttack +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterStartAttack(From,Event,To,_enemy,distance,hdgEnemy) + if self.MessageOutput then + local tgtType = "enemy target" + if _enemy:GetClassName() and not _enemy:GetClassName() == "COORDINATE" then tgtType = _enemy:GetTypeName() end + MESSAGE:New(self.MessageCallsign.." is moving to attack a "..tostring(tgtType).." at "..math.floor(hdgEnemy).." for "..math.floor(distance).."m.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterAttackToTravel +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterAttackToTravel(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer attacking the enemy. Resuming travel to destination.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterAttackToIdle +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterAttackToIdle(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer attacking the enemy. Ready for tasking.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterStartEngaging +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterStartEngaging(From,Event,To,WasHit,UnitName,WeaponName,EventData) + if self.MessageOutput then + if WasHit then + if EventData.IniTypeName then + MESSAGE:New(self.MessageCallsign.." is engaged with and receiving fire from a "..tostring(EventData.IniTypeName).."!",self.MessageDuration):ToCoalition(self.groupCoalition) + else + MESSAGE:New(self.MessageCallsign.." is engaged with and receiving fire from the enemy!",self.MessageDuration):ToCoalition(self.groupCoalition) + end + else + if EventData.TgtTypeName then + MESSAGE:New(self.MessageCallsign.." is engaged with and attacking a "..tostring(EventData.TgtTypeName).."!",self.MessageDuration):ToCoalition(self.groupCoalition) + else + MESSAGE:New(self.MessageCallsign.." is engaged with and attacking the enemy!",self.MessageDuration):ToCoalition(self.groupCoalition) + end + end + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterRetreat +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterRetreat(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." has taken significant losses and is retreating!",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterEndRetreat +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterEndRetreat(From,Event,To,CoordGroup,CoordRetreat) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is no longer retreating.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterGroupDead +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterGroupDead(From,Event,To,EventData) + if self.MessageOutput and EventData then + MESSAGE:New(self.MessageCallsign.." is KIA!",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterWinchester +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterWinchester(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is winchester!",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterRequestRearming +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterRequestRearming(From,Event,To,GroupRearm) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." requesting rearming.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterFullyRearmed +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterFullyRearmed(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." is fully rearmed.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterTroopsDropped +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterTroopsDropped(From,Event,To,TargetCoord,IsAttacking) + if self.MessageOutput then + local attackMessage = " to attack a target" + if not IsAttacking then attackMessage = "" end + MESSAGE:New(self.MessageCallsign.."'s infantry are now disembarked"..attackMessage..".",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterTroopsReturned +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterTroopsReturned(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." has embarked all of our troops.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterTroopsExtracted +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterTroopsExtracted(From,Event,To) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." has extracted troops.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterSupportRequested +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterSupportRequested(From,Event,To,CoordTarget,UnitTarget) + if self.MessageOutput then + local addMessage = "" + if UnitTarget then addMessage = " Our target is a "..tostring(UnitTarget:GetTypeName()).."." end + MESSAGE:New(self.MessageCallsign.." requesting support!"..addMessage,self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterSupporting +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterSupporting(From,Event,To,Group,CoordTarget,Callsign) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." will provide support for "..tostring(Callsign)..".",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterAbandoned +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterAbandoned(From,Event,To,UnitCoord,UnitName,UnitType) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." has abandoned a "..UnitType.." due to excessive damage.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + +--- [Internal] FSM Function onafterCrewRecovered +-- @param #TACTICS self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #TACTICS self +function TACTICS:onafterCrewRecovered(From,Event,To,RecoveryUnit,RecoveryName) + if self.MessageOutput then + MESSAGE:New(self.MessageCallsign.." the abandoning crew has been recovered by another vehicle.",self.MessageDuration):ToCoalition(self.groupCoalition) + USERSOUND:New(self.MessageSound):ToCoalition(self.groupCoalition) + end +end + + + + +--------[TIMER METHODS]--------- + +---LOOP: Travel Tracker +--- [Internal] Travek Chek +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_TravelCheck() + if self:Is("Travelling") then + self:T2("TACTICS: "..self.Groupname.." travel check timer.") + local coordGroup = self.Group:GetAverageCoordinate() + if not coordGroup then coordGroup = self.Group:GetCoordinate() end + if not coordGroup then + if not self:Is("Dead") then + self:_DeadResponse() + end + elseif self.Destination then + local distGroup = coordGroup:Get3DDistance(self.Destination) + local speedGroup = self.Group:GetVelocityKMH() + + --Arrived at destination + if distGroup <= self.DestinationRadius then + self.Group:RouteStop() + self:T("TACTICS: "..self.Groupname.." arrived at their destination.") + self.TimeTravelActive = false + self.travelToStored = nil + self:EndTravel(self.Group:GetAverageCoordinate(), self.Destination) + self.Destination = nil + elseif speedGroup < 1 and self.FixStuck or self.countStuck > 0 then -- Attempt to get unstuck if it's stopped before arriving at the destination. + self.countStuck = self.countStuck + 1 + self:T("TACTICS: "..self.Groupname.." is stopped when it should be moving. Check #"..self.countStuck) + if self.countStuck == 1 then -- Initial unstuck check + self.stuckPosit = self.Group:GetAverageCoordinate() + elseif self.countStuck > 1 and self.countStuck < self.MaxUnstuckAttempts then + local distStuck = coordGroup:Get3DDistance(self.stuckPosit) + if distStuck <= self.UnstuckDist/4 then -- Attempt to get unstuck + if self.lastStuckHeading == nil then + self.lastStuckHeading = (self.stuckPosit:HeadingTo(self.Destination) + self.StuckHeadingIncrements) % 360 + else + self.lastStuckHeading = (self.lastStuckHeading + self.StuckHeadingIncrements) % 360 + end + local unstuckDest = coordGroup:Translate(self.UnstuckDist,self.lastStuckHeading,false,false) + self.Group:RouteGroundTo(unstuckDest, 10, 'Cone', 1) + self:T("TACTICS: "..self.Groupname.." is attempting to get unstuck by driving "..self.UnstuckDist .."m toward heading "..self.lastStuckHeading) + else -- Group has moved enough to resume the route + self:T("TACTICS: "..self.Groupname.." has gotten unstuck. Resuming on the path...") + self.countStuck = 0 + self.stuckPosit = nil + self.TimeTravelActive = false + self:_InitiateTravel() + end + elseif self.countStuck >= self.MaxUnstuckAttempts then -- Max stuck attempts exceeded + if self.DestroyStuck then --EITHER Destroy the group + self:E("TACTICS: "..self.Groupname.." has been stuck for too long and was removed from the game...") + self.Group:Destroy() + self:_DeadResponse(false) + else --OR Return the group to Idle + self:E("TACTICS: "..self.Groupname.." has been stuck for too long and was returned to the idle state...") + self.Group:RouteStop() + self.TimeTravelActive = false + self.travelToStored = nil + self:EndTravel(self.Group:GetAverageCoordinate(), self.Destination) + self.Destination = nil + end + end + else + self.countStuck = 0 + self.stuckPosit = nil + end + else + self:E("TACTCS ERROR: "..self.Groupname.." attempted to compare distance to travel destination but 'self.Destination' is a nil value!") + end + else + self.TimeTravelActive = false + self.stuckPosit = nil + self.lastStuckHeading = nil + self.countStuck = 0 + end + return self +end + + +--- [Internal] Detection Cycle +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_DetectionCycle() + if not self:Is("Engaging") then + self:T2("TACTICS: ---- Detection Cycle ---- - [GRP: "..self.Groupname.."]") + local coordGroup = self.Group:GetAverageCoordinate() + if not coordGroup then coordGroup = self.Group:GetCoordinate() end + if not coordGroup then + if not self:Is("Dead") then + self:_DeadResponse() + end + end + if coordGroup then + --Try to detect an enemy. + local distClosestEnemy = 9999999 + local newSpot = false + local hdgClosestEnemy = 0 + self.zoneDetection:SetVec2(coordGroup:GetVec2()) + + TACTICS_UTILS.SetGroups:ForEachGroupAnyInZone(self.zoneDetection, function(_setgroup) + local coordEnemy = _setgroup:GetCoordinate() + local validUnit = true + if not coordEnemy then + validUnit = false + elseif _setgroup:GetCoalition() == self.groupCoalition then + validUnit = false + elseif self.FilterEnemyType and not _setgroup:GetCategoryName() == self.FilterEnemyType then + validUnit = false + elseif self.FilterDetectionZones and type(self.FilterDetectionZones) == "table" then + local inZone = false + for i = 1, #self.FilterDetectionZones do + if _setgroup:IsAnyInZone(self.FilterDetectionZones[i]) then + inZone = true + break + end + end + validUnit = inZone + end + + if validUnit then + local tableEnemyUnits = _setgroup:GetUnits() + for i = 1,#tableEnemyUnits do + local _enemy = tableEnemyUnits[i] + if _enemy:IsInZone(self.zoneDetection) then + local speedEnemy = _enemy:GetVelocityKMH() + local distEnemy = coordGroup:Get3DDistance(coordEnemy) + self:T2("TACTICS: Checking "..tostring(_enemy:GetName()).." at a range of "..tostring(distEnemy).."m / "..tostring(self.MaxDetection).."m") + if distEnemy < self.MaxDetection then + local checkLOS = true + if self.UseLOS then checkLOS = coordGroup:IsLOS(coordEnemy) end + self:T2("TACTICS: "..tostring(_enemy:GetName()).." is LOS = "..tostring(checkLOS)) + if distEnemy < self.FullDetection and distEnemy < distClosestEnemy then + self:T2("TACTICS: "..tostring(_enemy:GetName()).." is the closest target and is within Full Detection range ("..tostring(self.FullDetection).."m)") + distClosestEnemy = distEnemy + hdgClosestEnemy = coordGroup:HeadingTo(coordEnemy) + self.ClosestEnemy = _enemy + newSpot = true + elseif checkLOS then + local distVarChance = 2 + if self.UseDetectionChance then distVarChance = (self.MaxDetection - distEnemy)/self.MaxDetection end + local checkChance = math.random(1,100) + if self.FilterEnemyType == "ground" then + if speedEnemy > 5 and speedEnemy < 60 then checkChance = checkChance / 2 end + end + if self.FilterEnemyType == "helicopter" and self.UseDetectionChance or self.FilterEnemyType == "airplane" and self.UseDetectionChance then + local altVarChance = 0.05 + local altHelo = _enemy:GetAltitude() + local altGroup = _grp:GetAltitude() + local altDiff = altHelo - altGroup + local degHelo = 0 + if altDiff > 0 then + local angHelo = math.asin(altDiff/distEnemy) + degHelo = math.deg(angHelo) + if degHelo > 15 then altVarChance = 1.0 elseif degHelo > 5 then altVarChance = (degHelo/15) end + end + distVarChance = distVarChance + altVarChance + end + + self:T2("TACTICS: Detection roll: Is "..tostring(checkChance).." <= "..tostring((distVarChance/2)*100).."?") + if checkChance <= (distVarChance/2)*100 and distEnemy < distClosestEnemy then + self:T2("TACTICS: "..tostring(_enemy:GetName()).." was detected by "..self.Groupname.." and is the closest target") + distClosestEnemy = distEnemy + hdgClosestEnemy = coordGroup:HeadingTo(coordEnemy) + self.ClosestEnemy = _enemy + newSpot = true + end + end + end + end + end + end + end) + if newSpot then + self:_SpotTarget(self.ClosestEnemy,distClosestEnemy) + self:TargetSpotted(self.ClosestEnemy,distClosestEnemy,hdgClosestEnemy) + if self.DrawEnemySpots then + self:_ContactMark(self.ClosestEnemy:GetCoordinate(),2) + end + end + end + end + return self +end + +--- [Internal] Avoid Timer Function +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_AvoidTimer() + self:T("TACTICS: >> AVOID TIMER << - [GRP: "..self.Groupname.."]") + if not self.Group:GetCoordinate() then + if not self:Is("Dead") then + self:_DeadResponse() + end + else + if self:Is("Engaging") then + self.TimeAvoidActive = false + else + local coordGroup = self.Group:GetAverageCoordinate() + if not coordGroup then coordGroup = self.Group:GetCoordinate() end + local distGroup = coordGroup:Get3DDistance(self.avoidDest) + if distGroup <= self.DestinationRadius then + self:I("TACTICS: "..self.Groupname.." is no longer avoiding the threat.") + if self.ManageAlarmState then + if self.DefaultAlarmState == "Auto" then + self.Group:OptionAlarmStateAuto() + elseif self.DefaultAlarmState == "Red" then + self.Group:OptionAlarmStateRed() + elseif self.DefaultAlarmState == "Green" then + self.Group:OptionAlarmStateGreen() + end + end + if self.travelToStored then + self:AvoidToTravel() + self:_InitiateTravel() + else + self.Group:RouteStop() + self:AvoidToIdle() + end + self.TimeAvoidActive = false + end + end + end + return self +end + +--- [Internal] Rearm check timer +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_RearmCheckTimer() + self:T("TACTICS: >> REARM CHECK TIMER << - [GRP: "..self.Groupname.."]") + if not self.Group:GetCoordinate() then + if not self:Is("Dead") then + self:_DeadResponse() + end + else + --Finish up if full + local isWinchester, isFull = self:CheckAmmo() + if isFull or self:Is("Retreating") then + if not self:Is("Retreating") then + self:I("TACTICS: "..self.Groupname.." is fully rearmed.") + else + self:I("TACTICS: "..self.Groupname.." interrupted rearming to retreat.") + end + self.TimeRearmActive = false + self.IsWinchester = false + self.IsRearming = false + self:FullyRearmed() + self:_RTBRearmGroup() + if self.DrawDataR.DrawText then + trigger.action.removeMark(self.DrawDataR.DrawText) + self.DrawDataR.DrawText = nil + end + if self.DrawDataR.DrawPoly then + trigger.action.removeMark(self.DrawDataR.DrawPoly) + self.DrawDataR.DrawPoly = nil + end + + --Return to activity + if self.Destination and not self:Is("Retreating") then + self:RearmedToTravel() + self:_InitiateTravel() + elseif not self:Is("Retreating") then + self:RearmedToIdle() + end + end + + --Dispatch another group if lost + if not self:Is("Retreating") then + if not self.RearmGroup and not self.RearmGroupBase then + self:T("TACTICS: "..self.Groupname.." does not have a rearm group or base. ") + elseif not self.RearmGroup:GetCoordinate() and self.AllowRearmRespawn then + self:_CallForRearm(true) + elseif not self.RearmGroup:GetCoordinate() and not self.AllowRearmRespawn then + self:I("TACTICS: "..self.Groupname.." can no longer be rearmed.") + self.TimeRearmActive = false + self.IsWinchester = false + self.IsRearming = false + self.AllowRearming = false + + --Return to activity + if self.Destination then + self:RearmedToTravel() + self:_InitiateTravel() + else + self:RearmedToIdle() + end + end + end + end + return self +end + +--- [Internal] Retreat check timer +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_RetreatTimer() + self:T("TACTICS: >> RETREAT CHECK TIMER << - [GRP: "..self.Groupname.."]") + if not self.Group:GetCoordinate() then + if not self:Is("Dead") then + self:_DeadResponse() + end + elseif self:Is("Retreating") then + local unitsRemain, selfRecover = self:CheckUnitLife() + if unitsRemain > 0 then + local coordGroup = self.Group:GetAverageCoordinate() + if not coordGroup then coordGroup = self.Group:GetCoordinate() end + local distGroup = coordGroup:Get3DDistance(self.retreatDestination) + local speedGroup = self.Group:GetVelocityKMH() + + --Arrived at destination + if distGroup <= self.DestinationRadius then + self.Group:RouteStop() + self:T("TACTICS: "..self.Groupname.." arrived at their destination.") + self.RetreatTimer:Stop() + self.travelToStored = nil + self:EndRetreat(self.Group:GetAverageCoordinate(), self.retreatDestination) + self.retreatDestination = nil + if self.DespawnAfterRetreat then + self.Group:Destroy() + self:_DeadResponse(false) + else + if self.UseDetection == true then + self.TimeDetectionActive = true + self.TimeDetectionStamp = timer.getAbsTime() + end + end + elseif speedGroup < 1 and self.FixStuck or self.countStuck > 0 then -- Attempt to get unstuck if it's stopped before arriving at the destination. + self.countStuck = self.countStuck + 1 + self:T("TACTICS: "..self.Groupname.." is stopped when it should be moving. Check #"..self.countStuck) + if self.countStuck == 1 then -- Initial unstuck check + self.stuckPosit = self.Group:GetAverageCoordinate() + elseif self.countStuck > 1 and self.countStuck < self.MaxUnstuckAttempts then + local distStuck = coordGroup:Get3DDistance(self.stuckPosit) + if distStuck <= self.UnstuckDist/4 then -- Attempt to get unstuck + if self.lastStuckHeading == nil then + self.lastStuckHeading = (self.stuckPosit:HeadingTo(self.retreatDestination) + self.StuckHeadingIncrements) % 360 + else + self.lastStuckHeading = (self.lastStuckHeading + self.StuckHeadingIncrements) % 360 + end + local unstuckDest = coordGroup:Translate(self.UnstuckDist,self.lastStuckHeading,false,false) + self.Group:RouteGroundTo(unstuckDest, 10, 'Cone', 1) + self:T("TACTICS: "..self.Groupname.." is attempting to get unstuck by driving "..self.UnstuckDist .."m toward heading "..self.lastStuckHeading) + else -- Group has moved enough to resume the route + self:T("TACTICS: "..self.Groupname.." has gotten unstuck. Resuming on the path...") + self.countStuck = 0 + self.stuckPosit = nil + if not self.TroopsAttacking then + if self.RetreatOnRoads then + self.Group:RouteGroundOnRoad(self.retreatDestination, self.RetreatSpeed, 1, self.RetreatFormation) + else + self.Group:RouteGroundTo(self.retreatDestination, self.a, self.RetreatFormation, 1) + end + end + end + elseif self.countStuck >= self.MaxUnstuckAttempts then -- Max stuck attempts exceeded + if self.DestroyStuck then --EITHER Destroy the group + self:E("TACTICS: "..self.Groupname.." has been stuck for too long and was removed from the game...") + self:EndRetreat(self.Group:GetAverageCoordinate(), self.retreatDestination) + self.Group:Destroy() + self:_DeadResponse(false) + else --OR Return the group to Idle + self:E("TACTICS: "..self.Groupname.." has been stuck for too long and was returned to the idle state...") + self.Group:RouteStop() + self.RetreatTimer:Stop() + self.travelToStored = nil + self:EndRetreat(self.Group:GetAverageCoordinate(), self.retreatDestination) + self.retreatDestination = nil + if self.DespawnAfterRetreat then + self.Group:Destroy() + self:_DeadResponse(false) + else + if self.UseDetection == true then + self.TimeDetectionActive = true + self.TimeDetectionStamp = timer.getAbsTime() + end + end + end + end + else + self.countStuck = 0 + self.stuckPosit = nil + end + end + else + self.TimeTravelActive = false + self.stuckPosit = nil + self.lastStuckHeading = nil + self.countStuck = 0 + end + return self +end + +--- [Internal] Cooldown engagement +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_EngageCooldown() + self:T("TACTICS: >> ENGAGE COOLDOWN TIMER << - [GRP: "..self.Groupname.."]") + if not self.Group:GetCoordinate() then + if not self:Is("Dead") then + self:_DeadResponse() + end + else + local unitsRemain, selfRecover = self:CheckUnitLife() + if unitsRemain > 0 then + local isWinchester, isFull = self:CheckAmmo() + if isWinchester and self.AllowRearming then + self:_CallForRearm() + if self.TroopsAttacking then self:_ReturnTroops() end + elseif not selfRecover then + if self.TroopsAttacking then + self:_ReturnTroops() + elseif self.Destination then + self:EngageToTravel() + self:_InitiateTravel() + else + self:EngageToIdle() + end + end + end + end + if self.DrawDataE.DrawText then + trigger.action.removeMark(self.DrawDataE.DrawText) + self.DrawDataE.DrawText = nil + end + if self.DrawDataE.DrawPoly then + trigger.action.removeMark(self.DrawDataE.DrawPoly) + self.DrawDataE.DrawPoly = nil + end + return self +end + +--- [Internal Hold timer +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_HoldTimer() + self:T("TACTICS: >> HOLD POSITION TIMER << - [GRP: "..self.Groupname.."]") + if not self.Group:GetCoordinate() then + if not self:Is("Dead") then + self:_DeadResponse() + end + else + if not self:Is("Engaging") then + self:I("TACTICS: "..self.Groupname.." is no longer holding after spotting a threat.") + if self.ManageAlarmState then + if self.DefaultAlarmState == "Auto" then + self.Group:OptionAlarmStateAuto() + elseif self.DefaultAlarmState == "Red" then + self.Group:OptionAlarmStateRed() + elseif self.DefaultAlarmState == "Green" then + self.Group:OptionAlarmStateGreen() + end + end + if self.TroopsAttacking then + self:_ReturnTroops() + elseif self.Destination then + self:HoldToTravel() + self:_InitiateTravel() + else + self:HoldToIdle() + end + end + end + return self +end + +--- [Internal Attacktimer +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_AttackTimer() + self:T("TACTICS: >> ATTACK TIMER << - [GRP: "..self.Groupname.."]") + self.attackLastCoord = nil + if not self.Group:GetCoordinate() then + if not self:Is("Dead") then + self:_DeadResponse() + end + else + if self:Is("Attacking") then + self:I("TACTICS: "..self.Groupname.." does not see their target anymore and will stop attacking.") + if self:Is("Attacking") then + if self.TroopsAttacking then + self:_ReturnTroops() + elseif self.Destination then + self:AttackToTravel() + self:_InitiateTravel() + else + self.Group:RouteStop() + self:AttackToIdle() + end + end + if self.ManageAlarmState then + if self.DefaultAlarmState == "Auto" then + self.Group:OptionAlarmStateAuto() + elseif self.DefaultAlarmState == "Red" then + self.Group:OptionAlarmStateRed() + elseif self.DefaultAlarmState == "Green" then + self.Group:OptionAlarmStateGreen() + end + end + end + end + return self +end + +--- [Internal EXTERNAL TIMER: Despawn Rearm Group +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_RearmingGroupDespawn() + self.RearmingGroupDespawnTimer = TIMER:New(function() + self:T({"TACTICS: >> REARM GROUP DESPAWN TIMER <<",GroupName = self.Groupname}) + if self.RearmGroup and self.RearmGroup:GetCoordinate() then + self:I("TACTICS: checking if "..self.RearmGroup:GetName().." can despawn.") + local speedGroup = self.RearmGroup:GetVelocityKMH() + if speedGroup < 1 then + self:I("TACTICS: removing "..self.RearmGroup:GetName().." from the simulation") + self.RearmGroup:Destroy() + self.RearmingGroupDespawnTimer:Stop() + self.RearmingGroupDespawnTimer = nil + end + else + self.RearmingGroupDespawnTimer:Stop() + self.RearmingGroupDespawnTimer = nil + end + end) + self.RearmingGroupDespawnTimer:Start(60,60) + return self +end + + + + +--------[INTERNAL METHODS]--------- + +--- [Internal Initiate Travel +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_InitiateTravel() + if self.Destination then + self:T({"TACTICS TRAVEL INITIATED:", Groupname = self.Groupname, UseRoads = self.travelToStored.UseRoads, ToCoordinate = self.travelToStored.ToCoordinate, Speed = self.travelToStored.Speed, Formation = self.travelToStored.Formation, DelaySeconds = self.travelToStored.DelaySeconds, WaypointFunction = self.travelToStored.WaypointFunction, WaypointFunctionArguments = self.travelToStored.WaypointFunctionArguments, CurrentState = self:GetState()}) + if self.travelToStored.UseRoads then + self.Group:RouteGroundOnRoad(self.travelToStored.ToCoordinate, self.travelToStored.Speed, self.travelToStored.DelaySeconds, self.travelToStored.Formation, self.travelToStored.WaypointFunction, self.travelToStored.WaypointFunctionArguments) + else + self.Group:RouteGroundTo(self.travelToStored.ToCoordinate, self.travelToStored.Speed, self.travelToStored.Formation, self.travelToStored.DelaySeconds, self.travelToStored.WaypointFunction, self.travelToStored.WaypointFunctionArguments) + end + if self:Is("Idle") then + self:StartTravel(self.Group:GetAverageCoordinate(), self.Destination) + elseif self:Is("Travelling") then + self:Redirect(self.Group:GetAverageCoordinate(), self.Destination) + end + self.TimeTravelActive = true + self.TimeTravelStamp = timer.getAbsTime() + else + self:E("TACTICS ERROR: "..self.Groupname.." attempted to travel somewhere but doesn't have a destination!") + end + return self +end + +--- [Internal Initiate Engagements +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_InitEngagement(WasHit,EventData) + self:T({"TACTICS: "..self.Groupname.." started engaging something.",WasHit,EventData}) + local UnitName = EventData.IniDCSUnitName + if not WasHit then UnitName = EventData.TgtDCSUnitName end + local WeaponName = EventData.WeaponName + local coordGroup = self.Group:GetAverageCoordinate() + if not coordGroup then coordGroup = self.Group:GetCoordinate() end + if coordGroup then + local unitEnemy = UNIT:FindByName(UnitName) + local coordEnemy = nil + if unitEnemy then coordEnemy = unitEnemy:GetCoordinate() end + local targetCoord = coordEnemy + if not targetCoord then targetCoord = coordGroup end + + --Deploy troops if able + if not self.TroopsAttacking and self.TroopTransport then + self:DropTroops(targetCoord,true) + end + + --Disperse if able + if self.DisperseOnShoot and not WasHit or self.DisperseOnHit and WasHit then + self:T("TACTICS: "..self.Groupname.." will attempt to disperse.") + local headingGroup = self.Group:GetHeading() + if headingGroup then + local roadside = math.random(2) + if roadside == 1 then headingGroup = headingGroup + 45 else headingGroup = headingGroup - 45 end + if headingGroup < 1 then headingGroup = headingGroup + 360 elseif headingGroup > 359 then headingGroup = headingGroup - 360 end + local coordEvade = coordGroup:Translate(headingGroup, self.EvadeDistance, false, false) + if not coordEvade:IsInFlatArea(25, self.InclineLimit) or coordEvade:IsSurfaceTypeWater() or coordEvade:IsSurfaceTypeShallowWater() then + if roadside == 2 then headingGroup = headingGroup + 45 else headingGroup = headingGroup - 45 end + if headingGroup < 1 then headingGroup = headingGroup + 360 elseif headingGroup > 359 then headingGroup = headingGroup - 360 end + coordEvade:Translate(headingGroup, self.EvadeDistance, false, true) + end + if coordEvade:IsInFlatArea(25, self.InclineLimit) and not coordEvade:IsSurfaceTypeWater() and not coordEvade:IsSurfaceTypeShallowWater() then + self:T({"TACTICS: "..self.Groupname.." is dispersing.",headingGroup,self.EvadeDistance}) + self.Group:RouteGroundTo(coordEvade, 20, 'Cone', 1) + TIMER:New(function() + if not self:Is("Retreating") then self.Group:RouteStop() end + end):Start(15) + else + self:T("TACTICS: "..self.Groupname.." could not disperse due to unsuitable terrain.") + self.Group:RouteStop() + end + end + elseif self.Is("Traveling") then + self.Group:RouteStop() + end + + --Interrupt rearming if required + if self.IsWinchester then + self.IsWinchester = false + if self.IsRearming then + self.IsRearming = false + self.TimeRearmActive = false + if self.RearmGroup and self.RearmGroup:GetCoordinate() then + self:_RTBRearmGroup() + end + if self.DrawDataR.DrawText then + trigger.action.removeMark(self.DrawDataR.DrawText) + self.DrawDataR.DrawText = nil + end + if self.DrawDataR.DrawPoly then + trigger.action.removeMark(self.DrawDataR.DrawPoly) + self.DrawDataR.DrawPoly = nil + end + end + end + + --Draw on map if able + if self.EngageDrawing then + if self.DrawDataE.DrawText then + trigger.action.removeMark(self.DrawDataE.DrawText) + end + if self.DrawDataE.DrawPoly then + trigger.action.removeMark(self.DrawDataE.DrawPoly) + end + + self.DrawDataE.DrawText = coordGroup:TextToAll(self.DrawDataE.Text,self.DrawDataE.Coalition,self.DrawDataE.Color1,self.DrawDataE.Alpha1,self.DrawDataE.Color2,self.DrawDataE.Alpha2,self.DrawDataE.Font,false) + self.DrawDataE.DrawPoly = coordGroup:CircleToAll(self.DrawDataE.Radius,self.DrawDataE.Coalition,self.DrawDataE.Color1,self.DrawDataE.Alpha1,self.DrawDataE.Color2,self.DrawDataE.Alpha2/2,self.DrawDataE.Linetype,false) + + if self.DrawDataE.MarkEnemy then + local tempType = 0 + if not coordEnemy then tempType = 1 end + self:_ContactMark(targetCoord,tempType) + end + end + + self:StartEngaging(WasHit, UnitName, WeaponName, EventData) + end + return self +end + +--- [Internal Dead unit response +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_DeadResponse(EventData) + if not self:Is("Dead") then + if EventData then + self:UnitLost(EventData) + self:T("TACTICS: "..self.Groupname.." lost a unit.") + if self.SupportLevel <= 4 and not self.TimeSupportActive and self.Group:GetCoordinate() and self.AllowSupportRequests then + self:RequestSupport() + end + end + if self.Group:GetUnits() == nil or #self.Group:GetUnits() <= 0 then + self:I("TACTICS: "..self.Groupname.." has died or was removed from the sim.") + if self.MasterTime and self.MasterTime:IsRunning() then self.MasterTime:Stop() end + + --Garbage Day + self.MasterTime = nil + self.UnitTable = nil + -- self.setEnemy:FilterStop() + -- self.setEnemy = nil + + if self.DrawDataR.DrawText then + trigger.action.removeMark(self.DrawDataR.DrawText) + self.DrawDataR.DrawText = nil + end + if self.DrawDataR.DrawPoly then + trigger.action.removeMark(self.DrawDataR.DrawPoly) + self.DrawDataR.DrawPoly = nil + end + if self.DrawDataE.DrawText then + trigger.action.removeMark(self.DrawDataE.DrawText) + self.DrawDataE.DrawText = nil + end + if self.DrawDataE.DrawPoly then + trigger.action.removeMark(self.DrawDataE.DrawPoly) + self.DrawDataE.DrawPoly = nil + end + + self:GroupDead(EventData) + elseif self.RetreatAfterLosses and #self.Group:GetUnits() <= (#self.UnitTable * self.RetreatAfterLosses) and not self:Is("Retreating") then + self:Retreat() + end + end + return self +end + +--- [Internal Ammo check +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:CheckAmmo() + self:T("TACTICS: Ammo check called for "..self.Groupname) + local checkUnits = self.Group:GetUnits() + local ammoLow = false + local ammoFull = true + for u = 1, #checkUnits do + for z = 1, #self.UnitTable do + if checkUnits[u]:GetName() == self.UnitTable[z].UnitName then + self:T("TACTICS: Checking "..self.UnitTable[z].UnitName) + local currentAmmo = checkUnits[u]:GetAmmo() + if self.groupAmmo[z] and #self.groupAmmo[z] > 0 then + for i = 1, #self.groupAmmo[z] do + local ammoCount = 0 + if currentAmmo and #currentAmmo > 0 then + for v = 1, #currentAmmo do + if currentAmmo[v]["desc"]["typeName"] == self.groupAmmo[z][i]["desc"]["typeName"] then + ammoCount = currentAmmo[v]["count"] + self:T( "TACTICS: "..self.groupAmmo[z][i]["desc"]["typeName"].." = "..currentAmmo[v]["count"].."/"..self.groupAmmo[z][i]["count"]) + end + end + else + ammoLow = true + end + if ammoCount < (self.groupAmmo[z][i]["count"] * self.LowAmmoPercent) then + ammoLow = true + end + if ammoCount < (self.groupAmmo[z][i]["count"] * self.FullAmmoPercent) or ammoLow then + ammoFull = false + end + end + else + self:T(self.UnitTable[z].UnitName.." does not use ammo.") + end + end + end + end + return ammoLow, ammoFull +end + +--- [Internal Call for rearm +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_CallForRearm(respawnCall) + if respawnCall then + self:I("TACTICS: "..self.Groupname.." requesting respawn of rearm group.") + else + self:I("TACTICS: "..self.Groupname.." is winchester.") + end + + self.IsWinchester = true + + --Manage rearming if able + if self.AllowRearming and not self:Is("Retreating") then + if self.RearmingGroupDespawnTimer and self.RearmingGroupDespawnTimer:IsRunning() then + self.RearmingGroupDespawnTimer:Stop() + self.RearmingGroupDespawnTimer = nil + end + --Dispatch ammo truck if available + local coordGroup = self.Group:GetAverageCoordinate() + if self.RearmGroup and self.RearmGroup:GetCoordinate() then + self:I("TACTICS: Dispatching "..self.RearmGroup:GetName().." to rearm "..self.Groupname) + if self.RearmGroupUseRoads then + self.RearmGroup:RouteGroundOnRoad(coordGroup, self.RearmGroupSpeed, 1, self.RearmGroupFormation) + else + self.RearmGroup:RouteGroundTo(coordGroup, self.RearmGroupSpeed, self.RearmGroupFormation, 1) + end + elseif self.RearmTemplate and self.RearmSpawnCoord then + --Spawn new if able and no truck is available + local spawnIndex = math.random(9999) + local rearmSpawn = SPAWN:NewWithAlias(self.RearmTemplate, self.RearmTemplate..spawnIndex) + rearmSpawn:OnSpawnGroup(function(_grp) + self.RearmGroup = _grp + if self.RearmGroupUseRoads then + _grp:RouteGroundOnRoad(coordGroup, self.RearmGroupSpeed, 1, self.RearmGroupFormation) + else + _grp:RouteGroundTo(coordGroup, self.RearmGroupSpeed, self.RearmGroupFormation, 1) + end + self:I("TACTICS: Spawned and dispatched ".._grp:GetName().." to rearm "..self.Groupname) + end) + rearmSpawn:SpawnFromCoordinate(self.RearmSpawnCoord) + else + self:I("TACTICS: "..self.Groupname.." does not have a rearming group assigned to it. They can mark but will remain stationary until rearmed.") + end + + --Draw on map if able + if self.RearmDrawing then + if self.DrawDataR.DrawText then + trigger.action.removeMark(self.DrawDataR.DrawText) + end + if self.DrawDataR.DrawPoly then + trigger.action.removeMark(self.DrawDataR.DrawPoly) + end + + self.DrawDataR.DrawText = coordGroup:TextToAll(self.DrawDataR.Text,self.DrawDataR.Coalition,self.DrawDataR.Color1,self.DrawDataR.Alpha1,self.DrawDataR.Color2,self.DrawDataR.Alpha2,self.DrawDataR.Font,false) + self.DrawDataR.DrawPoly = coordGroup:CircleToAll(self.DrawDataR.Radius,self.DrawDataR.Coalition,self.DrawDataR.Color1,self.DrawDataR.Alpha1,self.DrawDataR.Color2,self.DrawDataR.Alpha2/2,self.DrawDataR.Linetype,false) + end + + --Group units up if spread out + local unitList = self.Group:GetUnits() + for i = 1,#unitList do + local coordUnit = unitList[i]:GetCoordinate() + if coordUnit:Get3DDistance(coordGroup) >= 300 then + self.Group:RouteGroundTo(coordGroup) + break + end + end + + self.IsRearming = true + self:RequestRearming(self.RearmGroup) + self.TimeRearmActive = true + self.TimeRearmStamp = timer.getAbsTime() + end + self:Winchester() + return self +end + +--- [Internal RTB Rearm Group +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_RTBRearmGroup() + if self.RearmGroup and self.RearmGroup:GetCoordinate() and self.RearmGroupBase and self.RearmGroupRTB then + self:I("TACTICS: Sending "..self.RearmGroup:GetName().." back to base.") + if self.RearmGroupUseRoads then + self.RearmGroup:RouteGroundOnRoad(self.RearmGroupBase, self.RearmGroupSpeed, 1, self.RearmGroupFormation) + else + self.RearmGroup:RouteGroundTo(self.RearmGroupBase, self.RearmGroupSpeed, self.RearmGroupFormation, 1) + end + if self.DespawnRearmingGroup and not self.RearmingGroupDespawnTimer then + self:_RearmingGroupDespawn() + end + end + return self +end + +--- [Internal] Spot target +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_SpotTarget(_enemy,distance) + self:T("TACTICS: "..self.Groupname.." detected "..tostring(_enemy:GetName()).." at a range of "..distance.."m. Current Tactical ROE: "..self.TacticalROE) + if self.ManageAlarmState then self.Group:OptionAlarmStateRed() end + --Attack + if self.TacticalROE == "Attack" then + self:AttackTarget(_enemy,distance) + + --Hold + elseif self.TacticalROE == "Hold" then + if distance <= self.HoldDistance then + if self:Is("Travelling") or self:Is("Idle") then + self.Group:RouteStop() + self:StartHold() + end + --Deploy troops if able + if not self.TroopsAttacking and self.TroopTransport and _enemy:GetCoordinate() then + self:DropTroops(_enemy:GetCoordinate(),true) + end + self.TimeHoldActive = true + self.TimeHoldStamp = timer.getAbsTime() + end + + --Avoid + elseif self.TacticalROE == "Avoid" then + if distance <= self.AvoidDistance then + self:AvoidTarget(_enemy,distance) + end + + --Ignore + else + if self.ManageAlarmState then + TIMER:New(function() + if self.DefaultAlarmState == "Auto" then + self.Group:OptionAlarmStateAuto() + elseif self.DefaultAlarmState == "Red" then + self.Group:OptionAlarmStateRed() + elseif self.DefaultAlarmState == "Green" then + self.Group:OptionAlarmStateGreen() + end + end):Start(self.DetectionRate-1) + end + end + + if self.SupportLevel <= 1 and not self.TimeSupportActive and self.AllowSupportRequests then + self:RequestSupport(_enemy:GetCoordinate()) + end + return self +end + +--- [Internal Attack a target +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:AttackTarget(_enemy,distance) + local coordGroup = self.Group:GetAverageCoordinate() + local coordEnemy = nil + local hdgEnemy = 0 + local className = _enemy:GetClassName() + if className == "COORDINATE" then + self:T("TACTICS: "..self.Groupname.." is attacking a provided coordinate "..distance.."m away.") + coordEnemy = _enemy + elseif not className then + self:E("TACTICS ERROR: The provided enemy is not a valid Core.COORDINATE or Wrapper.POSITIONABLE object.") + else + self:T("TACTICS: "..self.Groupname.." is attacking "..tostring(_enemy:GetName()).." "..distance.."m away.") + coordEnemy = _enemy:GetCoordinate() + end + + if coordEnemy and coordGroup then + hdgEnemy = coordGroup:HeadingTo(coordEnemy) + local coordTargetDest = nil + local skipNewDest = false + if self.attackLastCoord and self.attackLastCoord:Get3DDistance(coordEnemy) <= self.LastTargetThreshold then + skipNewDest = true + local tempDist = self.attackLastCoord:Get3DDistance(coordEnemy) + self:T("TACTICS: "..self.Groupname.."'s target is only "..tempDist.."m away from where it was last. Threshold set to "..self.LastTargetThreshold) + end + + --Get attack move-to position + if distance > 25 then + local hdgTgt = coordGroup:HeadingTo(coordEnemy) + coordTargetDest = coordEnemy:Translate(-self.AttackPositionDist,hdgTgt,false,false) + if distance < self.AttackPositionDist+20 then + coordTargetDest = coordEnemy:Translate(-(distance/2),hdgTgt,false,false) + skipNewDest = false + end + local booIsFlat = false + local checkFlat = 0 + if not skipNewDest then + while not booIsFlat and checkFlat < 10 do + checkFlat = checkFlat + 1 + if coordTargetDest:IsInFlatArea(25, self.InclineLimit) and not coordTargetDest:IsSurfaceTypeWater() and not coordTargetDest:IsSurfaceTypeShallowWater() then + if distance < self.CombatDistance then + self.Group:RouteGroundTo(coordTargetDest, self.AttackSpeed, self.AttackFormation, 1) + else + if self.AttackFarUsesRoads then self.Group:RouteGroundOnRoad(coordTargetDest, self.AttackSpeedFar, 1, self.AttackFormationFar) + else self.Group:RouteGroundTo(coordTargetDest, self.AttackSpeedFar, self.AttackFormationFar, 1) end + end + booIsFlat = true + checkFlat = 10 + else + coordTargetDest:Translate(25,(hdgTgt+90) % 360 ,false,true) + end + end + if not booIsFlat then + coordTargetDest = coordEnemy:Translate(-self.AttackPositionDist,hdgTgt,false,false) + if distance < self.AttackPositionDist+20 then coordTargetDest = coordEnemy:Translate(-(distance/2),hdgTgt,false,false) end + if distance < self.CombatDistance then + self.Group:RouteGroundTo(coordTargetDest, self.AttackSpeed, self.AttackFormation, 1) + else + if self.AttackFarUsesRoads then self.Group:RouteGroundOnRoad(coordTargetDest, self.AttackSpeedFar, 1, self.AttackFormationFar) + else self.Group:RouteGroundTo(coordTargetDest, self.AttackSpeedFar, self.AttackFormationFar, 1) end + end + end + end + else + --Move both groups toward a convergence point + if className == "GROUP" or className == "UNIT" then + self:T("TACTICS: "..self.Groupname.." and "..tostring(_enemy:GetName()).." are too close without engaging (>25m). Attempting to move both groups.") + local coordTargetDest = coordEnemy:Translate(25,90,false,false) + if not coordTargetDest:IsInFlatArea(25, self.InclineLimit) or coordTargetDest:IsSurfaceTypeWater() or coordTargetDest:IsSurfaceTypeShallowWater() then + coordTargetDest = coordEnemy:Translate(25,-90 ,false,false) + end + if not coordTargetDest:IsInFlatArea(25, self.InclineLimit) or coordTargetDest:IsSurfaceTypeWater() or coordTargetDest:IsSurfaceTypeShallowWater() then + coordTargetDest = coordEnemy:Translate(25,0 ,false,false) + end + if not coordTargetDest:IsInFlatArea(25, self.InclineLimit) or coordTargetDest:IsSurfaceTypeWater() or coordTargetDest:IsSurfaceTypeShallowWater() then + coordTargetDest = coordEnemy:Translate(25,180 ,false,false) + end + self.Group:RouteGroundTo(coordTargetDest, self.AttackSpeed, self.AttackFormation, 1) + _enemy:RouteGroundTo(coordTargetDest, self.AttackSpeed, self.AttackFormation, 1) + end + end + + --Deploy Troops If Able + if not self.TroopsAttacking and self.TroopTransport and distance <= self.TroopAttackDist then + self:T("TACTICS: "..self.Groupname.." is deploying troops to attack "..tostring(_enemy:GetName())) + self.Group:RouteStop() + self:DropTroops(coordEnemy,true) + TIMER:New(function() + self.Group:RouteResume() + end):Start(5) + end + + self.attackLastCoord = coordEnemy + self.TimeAttackActive = true + self.TimeAttackStamp = timer.getAbsTime() + self:AttackManeuver(_enemy,distance,hdgEnemy) + if not self:Is("Attacking") then self:StartAttack(_enemy,distance,hdgEnemy) end + end + return self +end + +--- [Internal Avoid target +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:AvoidTarget(_enemy,distance) + local coordGroup = self.Group:GetAverageCoordinate() + local coordEnemy = nil + local className = _enemy:GetClassName() + if className == "COORDINATE" then + self:T("TACTICS: "..self.Groupname.." is avoiding a provided coordinate "..distance.."m away.") + coordEnemy = _enemy + elseif not className then + self:E("TACTICS ERROR: The provided enemy is not a valid Core.COORDINATE or Wrapper.POSITIONABLE object.") + else + self:T("TACTICS: "..self.Groupname.." is avoiding "..tostring(_enemy:GetName()).." "..distance.."m away.") + coordEnemy = _enemy:GetCoordinate() + end + local isAvoiding = false + + if coordGroup and coordEnemy then + self:T("TACTICS: "..self.Groupname.." will try to avoid "..tostring(_enemy:GetName())) + for i = 1,100 do + local hdgAvoid = coordEnemy:HeadingTo(coordGroup) + if self.AvoidAzimuthMax then + hdgAvoid = ((hdgAvoid - self.AvoidAzimuthMax) + (math.random(self.AvoidAzimuthMax*2))) % 360 + if hdgAvoid < 1 then hdgAvoid = hdgAvoid + 360 end + end + local avoidPoint = coordGroup:Translate(self.AvoidDistance, hdgAvoid, false, false) + if avoidPoint:IsInFlatArea(25, self.InclineLimit) and not avoidPoint:IsSurfaceTypeWater() and not avoidPoint:IsSurfaceTypeShallowWater() then + isAvoiding = true + if self.AvoidUseRoads then + self.Group:RouteGroundOnRoad(avoidPoint, self.AvoidSpeed, 1, self.AvoidFormation) + self.avoidDest = avoidPoint + self.TimeAvoidActive = true + self.TimeAvoidStamp = timer.getAbsTime() + else + self.Group:RouteGroundTo(avoidPoint, self.AvoidSpeed, self.AvoidFormation, 1) + self.avoidDest = avoidPoint + self.TimeAvoidActive = true + self.TimeAvoidStamp = timer.getAbsTime() + end + if self:Is("Travelling") or self:Is("Idle") then self:StartAvoid() end + break + end + end + end + if not isAvoiding then + self:E("TACTICS ERROR: "..self.Groupname.." tried to avoid ".._enemy:GetName().." but could not find a destination with suitable terrain after 100 attempts.") + end +end + +--- [Internal Drop troops +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:DropTroops(_targetCoord,_attacking,_limit) + self:T("TACTICS: "..self.Groupname.." called dropTroops. Attacking = "..tostring(_attacking)) + local coordGroup = self.Group:GetCoordinate() + local hdgGroup = self.Group:GetHeading() + + --Check if enemy is close enough to attack + local distTarget = _targetCoord:Get3DDistance(coordGroup) + local hdgTarget = nil + local coordAttack = nil + + if distTarget <= self.TroopAttackDist and _attacking then + self:T("TACTICS: "..self.Groupname.." dropped troops are in range and will attack the target.") + hdgTarget = coordGroup:HeadingTo(_targetCoord) + coordAttack = coordGroup:Translate(distTarget-20,hdgTarget,false,false) + elseif _attacking then + self:T("TACTICS: "..self.Groupname.." dropped troops are too far from the target and will disperse instead.") + else + coordAttack = _targetCoord + end + + --Get spawn parameters + local intSpawnIndex = math.random(1,9999) + local nameDroppedTroops = self.TroopTemplate.."_"..self.Groupname..intSpawnIndex + local troopsOffset = math.random(self.TroopDismountDistMin,self.TroopDismountDistMax) + local directionX = math.random(1,100) + if directionX > 50 then + troopsOffset = -troopsOffset + end + + --Set up troop spawn + local spawnDropTroops = SPAWN:NewWithAlias(self.TroopTemplate, nameDroppedTroops):InitGroupHeading(hdgGroup) + spawnDropTroops:OnSpawnGroup(function(_troops) + local coordMoveTo = nil + if coordAttack then coordMoveTo = coordAttack:GetCoordinate() end + if coordMoveTo and _attacking then + local headingFlank = 0 + local checkFlank = math.random(0,2) + if checkFlank == 0 then headingFlank = hdgTarget-90 elseif checkFlank == 2 then headingFlank = hdgTarget+90 end + if headingFlank < 0 then headingFlank = headingFlank+360 elseif headingFlank > 360 then headingFlank = headingFlank-360 end + if checkFlank ~= 1 then + coordMoveTo:Translate(100,headingFlank,false,true) + coordMoveTo:Translate(40,hdgTarget,false,true) + end + elseif _attacking then + coordMoveTo = _troops:GetUnit(1):GetOffsetCoordinate(0,0,troopsOffset) + elseif not _attacking then + coordMoveTo = _targetCoord + end + _troops:RouteGroundTo(coordMoveTo,self.TroopMoveSpeed,self.TroopFormation) + if _attacking then + table.insert(self.AttackingTroops,_troops) + self.TroopsAttacking = true + else + table.insert(self.DeployedTroops,_troops) + end + self:T("TACTICS: "..self.Groupname.." deployed ".._troops:GetName()) + end) + + --Timer to drop troops + local timerDropTroops = TIMER:New(function() + coordGroup = self.Group:GetCoordinate() + local unitTable = self.Group:GetUnits() + local dropAmount = #unitTable + if _limit then dropAmount = _limit end + for i = 1, dropAmount do + local coordDrop = unitTable[i]:GetOffsetCoordinate(-10,0,0) + spawnDropTroops:SpawnFromCoordinate(coordDrop) + end + self:TroopsDropped(_targetCoord,_attacking) + end) + timerDropTroops:Start(5) + return self +end + +--- [Internal Return troops +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_ReturnTroops() + self:I("TACTICS: "..self.Groupname.." attempting to recover deployed troops.") + self.Group:RouteStop() + + local homeCoord = self.Group:GetAverageCoordinate() + if not homeCoord then homeCoord = self.Group:GetCoordinate() end + local countTroops = 0 + + --Function to see if all troops have boarded + local function checkAllReturned() + if not self:Is("Dead") then + self:T("TACTICS: "..self.Groupname.."'s troops remaining to be extracted = "..tostring(countTroops)) + if countTroops == 0 then + self.AttackingTroops = {} + self.TroopsAttacking = false + self:I("TACTICS: "..self.Groupname.." picked up all deployed troops and will resume tasking.") + local isWinchester, isFull = self:CheckAmmo() + if isWinchester and self.AllowRearming and not self.IsRearming then + self:_CallForRearm() + end + if self:Is("Retreating") then + if self.RetreatOnRoads then + self.Group:RouteGroundOnRoad(self.retreatDestination, self.RetreatSpeed, 1, self.RetreatFormation) + self.TimeRetreatActive = true + self.TimeRetreatStamp = timer.getAbsTime() + else + self.Group:RouteGroundTo(self.retreatDestination, self.a, self.RetreatFormation, 1) + self.TimeRetreatActive = true + self.TimeRetreatStamp = timer.getAbsTime() + end + elseif not self.IsRearming then + if self.Destination then + if self:Is("Engaging") then self:EngageToTravel() + elseif self:Is("Attacking") then self:AttackToTravel() + elseif self:Is("Holding") then self:HoldToTravel() + elseif self:Is("Idle") then self:StartTravel() end + self:_InitiateTravel() + else + if self:Is("Engaging") then self:EngageToIdle() + elseif self:Is("Holding") then self:HoldToIdle() + elseif self:Is("Attacking") then self:AttackToIdle()end + end + end + self:TroopsReturned() + end + end + end + + --Send troops back to group position + if #self.AttackingTroops == 0 then + self:I("TACTICS: All of "..self.Groupname.."'s troops are KIA!") + checkAllReturned() + else + for i = #self.AttackingTroops,1,-1 do + local troopGroup = self.AttackingTroops[i] + if troopGroup:GetCoordinate() then + self:T("TACTICS: "..self.Groupname.." is recovering "..troopGroup:GetName()) + local despawn = {} + troopGroup:RouteGroundTo(homeCoord,self.TroopMoveSpeed,self.TroopFormation) + + --Check to despawn troops + local timerLimit = math.ceil(self.ExtractTimeLimit/20) + despawn.Timer = TIMER:New(function() + timerLimit = timerLimit - 1 + self:T("TACTICS: "..troopGroup:GetName().." recovery limit check = "..timerLimit.."/"..math.ceil(self.ExtractTimeLimit/20)) + local checkCoord = troopGroup:GetCoordinate() + local checkHome = self.Group:GetCoordinate() + if checkCoord and checkHome then + local distHome = checkCoord:Get3DDistance(homeCoord) + if distHome <= 25 then + despawn.Timer:Stop() + troopGroup:Destroy() + countTroops = countTroops - 1 + checkAllReturned() + end + else + despawn.Timer:Stop() + countTroops = countTroops - 1 + checkAllReturned() + end + if despawn.Timer:IsRunning() and timerLimit <= 0 then + despawn.Timer:Stop() + troopGroup:Destroy() + countTroops = countTroops - 1 + checkAllReturned() + end + end) + despawn.Timer:Start(20,20) + else + table.remove(self.AttackingTroops,i) + end + countTroops = #self.AttackingTroops + end + end + + --Backup in the event of a failure + TIMER:New(function() + if countTroops > 0 then + for i = 1, #self.AttackingTroops do + self.AttackingTroops[i]:Destroy() + end + countTroops = 0 + checkAllReturned() + end + end):Start(self.ExtractTimeLimit+5) + return self +end + +--- [Internal Exctract Troops +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:ExtractTroops() + if not self:Is("Retreating") then + self:I("TACTICS: "..self.Groupname.." attempting to extract troops from the field.") + self.Group:RouteStop() + + local homeCoord = self.Group:GetAverageCoordinate() + if not homeCoord then homeCoord = self.Group:GetCoordinate() end + local countTroops = 0 + + --Function to see if all troops have boarded + local function checkAllReturned() + self:T("TACTICS: "..self.Groupname.."'s troops remaining to be extracted = "..tostring(countTroops)) + if countTroops == 0 then + self.DeployedTroops = {} + self:I("TACTICS: "..self.Groupname.." picked up all deployed troops and will resume tasking.") + if self:Is("Retreating") then + if self.RetreatOnRoads then + self.Group:RouteGroundOnRoad(self.retreatDestination, self.RetreatSpeed, 1, self.RetreatFormation) + self.TimeRetreatActive = true + self.TimeRetreatStamp = timer.getAbsTime() + else + self.Group:RouteGroundTo(self.retreatDestination, self.a, self.RetreatFormation, 1) + self.TimeRetreatActive = true + self.TimeRetreatStamp = timer.getAbsTime() + end + elseif not self.IsRearming then + if self.Destination then + if self:Is("Engaging") then self:EngageToTravel() + elseif self:Is("Attacking") then self:AttackToTravel() + elseif self:Is("Idle") then self:StartTravel() end + self:_InitiateTravel() + else + if self:Is("Engaging") then self:EngageToIdle() + elseif self:Is("Attacking") then self:AttackToIdle()end + end + end + self:TroopsExtracted() + end + end + + --Send troops back to group position + if #self.DeployedTroops == 0 then + self:I("TACTICS: All of "..self.Groupname.."'s deployed troops are KIA!") + checkAllReturned() + else + for i = #self.DeployedTroops,1,-1 do + local troopGroup = self.DeployedTroops[i] + if troopGroup:GetCoordinate() then + local despawn = {} + troopGroup:RouteGroundTo(homeCoord,self.TroopMoveSpeed,self.TroopFormation) + + --Check to despawn troops + local timerLimit = math.ceil(self.ExtractTimeLimit/20) + despawn.Timer = TIMER:New(function() + timerLimit = timerLimit - 1 + local checkCoord = troopGroup:GetCoordinate() + local checkHome = self.Group:GetCoordinate() + if checkCoord and checkHome then + local distHome = checkCoord:Get3DDistance(homeCoord) + if distHome <= 25 then + despawn.Timer:Stop() + troopGroup:Destroy() + countTroops = countTroops - 1 + checkAllReturned() + end + else + despawn.Timer:Stop() + countTroops = countTroops - 1 + checkAllReturned() + end + if despawn.Timer:IsRunning() and timerLimit <= 0 then + despawn.Timer:Stop() + troopGroup:Destroy() + countTroops = countTroops - 1 + checkAllReturned() + end + end) + despawn.Timer:Start(20,20) + else + table.remove(self.DeployedTroops,i) + end + countTroops = #self.DeployedTroops + end + end + + --Backup in the event of a failure + TIMER:New(function() + if countTroops > 0 then + for i = 1, #self.DeployedTroops do + self.DeployedTroops[i]:Destroy() + end + countTroops = 0 + checkAllReturned() + end + end):Start(self.ExtractTimeLimit+5) + return self + else + self:E("TACTICS ERROR: "..self.Groupname.." cannot extract troops while retreating.") + end +end + +--- [Internal Contact marks +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:_ContactMark(_coord,_type) + + --Get coordinates for the correct shape + local coordQuad1 = _coord:Translate(200,359,false,false) + local coordQuad2 = _coord:Translate(200,1,false,false) + local coordQuad3 = _coord:Translate(200,120,false,false) + local coordQuad4 = _coord:Translate(200,240,false,false) + if _type == 1 then + coordQuad1 = _coord:Translate(200,179,false,false) + coordQuad2 = _coord:Translate(200,181,false,false) + coordQuad3 = _coord:Translate(200,300,false,false) + coordQuad4 = _coord:Translate(200,60,false,false) + end + if _type == 2 then + coordQuad1 = _coord:Translate(200,0,false,false) + coordQuad2 = _coord:Translate(200,90,false,false) + coordQuad3 = _coord:Translate(200,180,false,false) + coordQuad4 = _coord:Translate(200,270,false,false) + end + + --Get coalition params + local coalitionNum = 2 + local coalitionColorA = {1,0,0} + local coalitionColorB = {0.5,0,0} + if self.groupCoalition == coalition.side.RED then + coalitionColorA = {0,0,1} + coalitionColorB = {0,0,0.5} + coalitionNum = 1 + end + + --Get timeout values + local timeoutFresh = self.EngageDrawingFresh + local timeoutStale = self.EngageDrawingStale + if _type == 2 then + timeoutFresh = self.DetectionRate-1 + timeoutStale = self.EnemySpotStale + end + + --Draw marker + if self.markSpot then trigger.action.removeMark(self.markSpot) end + self.markSpot = coordQuad1:QuadToAll(coordQuad2, coordQuad3, coordQuad4, coalitionNum,coalitionColorA,1,coalitionColorA,0.15,1,true) + if self.markSpotTimer and self.markSpotTimer:IsRunning() then + self.markSpotTimer:Stop() + self.markSpotTimer = nil + end + self.markSpotTimer = TIMER:New(function() + trigger.action.removeMark(self.markSpot) + self.markSpot = coordQuad1:QuadToAll(coordQuad2, coordQuad3, coordQuad4, coalitionNum,coalitionColorB,1,coalitionColorB,0.15,3,true) + self.markSpotTimer = nil + self.markSpotTimer = TIMER:New(function() + trigger.action.removeMark(self.markSpot) + self.markSpot = nil + self.markSpotTimer = nil + end):Start(timeoutStale) + end):Start(timeoutFresh) + return self +end + +--- [Internal Request Support +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:RequestSupport(target) + local targetName = "nil target" + local coordGroup = self.Group:GetCoordinate() + local coordTarget = coordGroup + local unitTarget = nil + if target and target:GetClassName() == "COORDINATE" then + coordTarget = target + elseif target and target:GetClassName() == "UNIT" then + coordTarget = target:GetCoordinate() + unitTarget = target + targetName = target:GetName() + end + self:T({"TACTICS: "..self.Groupname.." requested support.","Target = "..tostring(targetName)}) + if coordGroup then + self:T2("TACTICS: "..self.Groupname.." will search for nearby friendlies.") + local countGroups = 0 + local friendlyTable = TACTICS_UTILS.GroupsRed + if self.groupCoalition == coalition.side.BLUE then friendlyTable = TACTICS_UTILS.GroupsBlue end + for i = 1,#friendlyTable do + self:T2("TACTICS: Group table index "..i.." for coalition "..tostring(self.groupCoalition)) + local coordFriendly = friendlyTable[i].Group:GetCoordinate() + if coordFriendly then + self:T({"TACTICS: "..self.Groupname.." is checking if "..friendlyTable[i].Groupname.." can provide support.",RespondToSupport = friendlyTable[i].RespondToSupport, State = friendlyTable[i]:GetState()}) + if friendlyTable[i].Groupname ~= self.Groupname and friendlyTable[i].RespondToSupport then + if friendlyTable[i]:Is("Idle") or friendlyTable[i]:Is("Travelling") then + local distFriendly = coordFriendly:Get3DDistance(coordGroup) + self:T("TACTICS: "..friendlyTable[i].Groupname.." is "..distFriendly.."m / "..self.SupportRadius.."m from "..self.Groupname) + if distFriendly <= self.SupportRadius then + local distTarget = coordFriendly:Get3DDistance(coordTarget) + friendlyTable[i]:AttackTarget(coordTarget,distTarget) + table.insert(self.supportTable,friendlyTable[i]) + countGroups = countGroups + 1 + self:I("TACTICS: "..friendlyTable[i].Groupname.." is moving to support "..self.Groupname) + friendlyTable[i]:Supporting(self.Group,coordTarget,self.MessageCallsign) + if self.SupportGroupLimit and countGroups >= self.SupportGroupLimit then + self:I("TACTICS: "..self.Groupname.." reached the support group limit: "..self.SupportGroupLimit) + break + end + end + end + end + end + end + self.TimeSupportActive = true + self.TimeSupportStamp = timer.getAbsTime() + self:SupportRequested(coordTarget,unitTarget) + end + return self +end + +--- [Internal Check Unit Health +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:CheckUnitLife() + local unitsRemain = 0 + local willRecover = false + local unitList = self.Group:GetUnits() + if unitList and #unitList > 0 then + self:T({"TACTICS: Checking health of all units in "..self.Groupname}) + for i = 1,#unitList do + unitsRemain = unitsRemain + 1 + local unitLife = unitList[i]:GetLifeRelative() + self:T({"TACTICS: "..unitList[i]:GetName(),"RelativeLife = "..unitLife.."/"..self.AbandonHealth,GroupUnitCount = unitsRemain}) + if unitLife < self.AbandonHealth then + unitsRemain = unitsRemain - 1 + if self.AllowSelfRecover then willRecover = true end + self:T({"TACTICS: "..unitList[i]:GetName().." is below the life threshold. Crew will abandon vehicle.",GroupUnitCount = unitsRemain,SelfRecover = willRecover}) + if self:Is("Retreating") then + self.Group:RouteStop() + TIMER:New(function() + self:AbandonVehicle(unitList[i]) + end):Start(5) + else + self:AbandonVehicle(unitList[i]) + end + end + end + end + return unitsRemain,willRecover +end + +--- [Internal Abandon vehicle +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:AbandonVehicle(Unit) + local coordUnit = Unit:GetCoordinate() + local headingUnit = Unit:GetHeading() + local healthUnit = Unit:GetLife() + local nameUnit = Unit:GetName() + local countryUnit = Unit:GetCountry() + local typeUnit = Unit:GetTypeName() + local crewPosition = coordUnit:Translate(5,(headingUnit + 90)%360,false,false) + Unit:Destroy() + self:T({"TACTICS: "..nameUnit.." is being abandoned."}) + self:_DeadResponse(false) + + --Crew spawning logic + local spawnCrew = SPAWN:NewWithAlias(self.CrewTemplate,"Crew_"..nameUnit) + spawnCrew:OnSpawnGroup(function(_grp) + self:T({"TACTICS: ".._grp:GetName().." spawned. Checking next step.", CanRecover = self.AllowSelfRecover}) + local canRecover = false + local crewName = _grp:GetName() + + --Check if group can self recover + if self.Group:GetCoordinate() and self.AllowSelfRecover then + local groupUnits = self.Group:GetUnits() + local closestDist = 99999999 + local closestCoord = nil + local closestUnit = nil + local closestUnitName = "invalid" + for i = 1,#groupUnits do + local coordNearby = groupUnits[i]:GetCoordinate() + local distNearby = coordNearby:Get3DDistance(crewPosition) + if distNearby < closestDist then + closestDist = distNearby + closestCoord = coordNearby + closestUnit = groupUnits[i] + canRecover = true + end + end + if canRecover then + self:T({"TACTICS: "..crewName.." will move to "..closestUnitName.." for recovery."}) + _grp:RouteGroundTo(closestCoord,20,"Diamond",1) + local tbl = {} + tbl.recoverTime = TIMER:New(function() + local coordGrp = _grp:GetCoordinate() + local coordRecoverUnit = closestUnit:GetCoordinate() + if coordGrp and coordRecoverUnit then + local distGrp = coordGrp:Get3DDistance(closestCoord) + self:T2({"TACTICS: "..crewName.." is "..distGrp.."/25m from "..closestUnitName}) + if distGrp <= 25 then + self:T({"TACTICS: "..crewName.." is within 25m of "..closestUnitName.." and will board the vehicle.",Distance = distGrp}) + _grp:Destroy() + self:CrewRecovered(closestUnit,nameUnit) + tbl.recoverTime:Stop() + if self.TroopsAttacking then + self:_ReturnTroops() + elseif self.Destination and not self:Is("Retreating") then + self:EngageToTravel() + self:_InitiateTravel() + elseif self:Is("Retreating") then + self.Group:RouteResume() + else + self:EngageToIdle() + end + end + else + self:T({"TACTICS: "..crewName.." was destroyed."}) + tbl.recoverTime:Stop() + if self.TroopsAttacking then + self:_ReturnTroops() + elseif self.Destination and not self:Is("Retreating") then + self:EngageToTravel() + self:_InitiateTravel() + elseif self:Is("Retreating") then + self.Group:RouteResume() + else + self:EngageToIdle() + end + end + end) + tbl.recoverTime:Start(20,20) + end + return self + end + + --Run away and dispatch recovery vehicle if avail + if not canRecover then + local hdgEscape = math.random(90,270) + if self:Is("Retreating") then hdgEscape = math.random(270,450) end + hdgEscape = (hdgEscape + headingUnit)%360 + self:T({"TACTICS: "..crewName.." will run "..self.AbandonDistance.."m away at a heading of "..hdgEscape}) + local coordEscape = coordUnit:Translate(hdgEscape,self.AbandonDistance) + _grp:RouteGroundTo(coordEscape,20,"Diamond",1) + if self.RecoveryVehicle and self.RecoverySpawnZone then + self:T({"TACTICS: "..crewName.." will request a recovery vehicle pickup from their destination."}) + local spawnRecovery = SPAWN:NewWithAlias(self.RecoveryVehicle,"Recovery_"..nameUnit) + spawnRecovery:OnSpawnGroup(function(_veh) + local nameRecovery = _veh:GetName() + local isRTB = false + if self.RecoveryUseRoads then + _veh:RouteGroundOnRoad(coordEscape, self.RecoverySpeed, 1, self.RecoveryFormation) + else + _veh:RouteGroundTo(coordEscape,self.RecoverySpeed,self.RecoveryFormation,1) + end + local tbl = {} + tbl.recoverTimer = TIMER:New(function() + local coordVeh = _veh:GetCoordinate() + local coordGrp = _grp:GetCoordinate() + if coordVeh then + if not isRTB then + if coordGrp then + local distRecover = coordVeh:Get3DDistance(coordGrp) + self:T2({"TACTICS: "..nameRecovery.." is "..distRecover.."/25m from "..crewName}) + if distRecover < 25 then + self:T({"TACTICS: "..crewName.." is within 25m of "..nameRecovery.." and will board the vehicle.",Distance = distRecover}) + _grp:Destroy() + self:CrewRecovered(_veh,nameUnit) + isRTB = true + if self.RecoveryUseRoads then + _veh:RouteGroundOnRoad(self.RecoverySpawnZone:GetCoordinate(), self.RecoverySpeed, 1, self.RecoveryFormation) + else + _veh:RouteGroundTo(self.RecoverySpawnZone:GetCoordinate(),self.RecoverySpeed,self.RecoveryFormation,1) + end + end + else + self:T({"TACTICS: "..crewName.." was destroyed. "..nameRecovery.." is RTB."}) + isRTB = true + if self.RecoveryUseRoads then + _veh:RouteGroundOnRoad(self.RecoverySpawnZone:GetCoordinate(), self.RecoverySpeed, 1, self.RecoveryFormation) + else + _veh:RouteGroundTo(self.RecoverySpawnZone:GetCoordinate(),self.RecoverySpeed,self.RecoveryFormation,1) + end + end + else + if _veh:IsAnyInZone(self.RecoverySpawnZone) then + self:T({"TACTICS: "..nameRecovery.." returned to base and will despawn."}) + _veh:Destroy() + tbl.recoverTimer:Stop() + end + end + else + tbl.recoverTimer:Stop() + end + end) + tbl.recoverTimer:Start(10,10) + self:T({"TACTICS: "..nameRecovery.." spawned and is moving to recover "..crewName,UseRoads = self.RecoveryUseRoads,Speed = self.RecoverySpeed,Formation = self.RecoveryFormation}) + end) + spawnRecovery:SpawnInZone(self.RecoverySpawnZone,true) + end + end + end) + spawnCrew:SpawnFromCoordinate(crewPosition) + + --New static spawn + self:T({"TACTICS: Replacing "..nameUnit.." with a static object."}) + local vec2Unit = coordUnit:GetVec2() + local staticInfo = { + ["heading"] = headingUnit * (math.pi*2) / 360, + ["Country"] = countryUnit, + ["y"] = vec2Unit.y, + ["x"] = vec2Unit.x, + ["name"] = nameUnit.."_Abandoned", + ["category"] = "Ground Identifiable", + ["type"] = typeUnit, + ["dead"] = false, + --["livery_id"] = SaveStatics[k]["livery_id"] + } + coalition.addStaticObject(countryUnit, staticInfo) + if self.SmokeAbandoned then + coordUnit:BigSmokeSmall(0.01) + TIMER:New(function() + coordUnit:StopBigSmokeAndFire() + end):Start(self.StaticSmokeTimeout) + end + self:Abandoned(coordUnit,nameUnit,typeUnit) +end + + +--------[USER METHODS]--------- + +--- [User] Find a group by name +-- @param #TACTICS self +-- @param #string Groupname Name to find +-- @return Wrapper.Group#GROUP Group found +function TACTICS:FindByName(Groupname) + for i = 1,#TACTICS_UTILS.GroupsRed do + if TACTICS_UTILS.GroupsRed[i].Groupname == Groupname then + return TACTICS_UTILS.GroupsRed[i] + end + end + for i = 1,#TACTICS_UTILS.GroupsBlue do + if TACTICS_UTILS.GroupsBlue[i].Groupname == Groupname then + return TACTICS_UTILS.GroupsBlue[i] + end + end + BASE:E("TACTICS ERROR: Could not find a group named "..Groupname.." with Tactics capabilities enabled.") + return nil +end + +--- [User] Get Group Name +-- @param #TACTICS self +-- @return #string Name Name of the group +function TACTICS:GetName() + return self.Groupname +end + + +--- [User] Travel To: Assigns a destination for the group to make its way to +-- @param #TACTICS self +-- @param #boolean UseRoads Set to true to use road connections +-- @param Core.Point#COORDINATE ToCoordinate Coordinate to go to +-- @param #number Speed Speed to set on the group +-- @param #string Formation Formation to be used +-- @param #number DelaySeconds Delay in seconds +-- @param #function WaypointFunction Function to execute at a waypoint +-- @param #table WaypointFunctionArguments Arguments to be passed to the prior function +-- @return #TACTICS self +function TACTICS:TravelTo(UseRoads, ToCoordinate, Speed, Formation, DelaySeconds, WaypointFunction, WaypointFunctionArguments) + if not self:Is("Dead") then + self.Destination = ToCoordinate + self.travelToStored = {UseRoads = UseRoads, ToCoordinate = ToCoordinate, Speed = Speed, Formation = Formation, DelaySeconds = DelaySeconds, WaypointFunction = WaypointFunction, WaypointFunctionArguments = WaypointFunctionArguments} + if self:Is("Idle") or self:Is("Travelling") then + self:_InitiateTravel() + end + end + return self +end + + +--- [User] Stop Travel +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:StopTravel() + if not self:Is("Dead") then + if self:Is("Travelling") then + self.Group:RouteStop() + self:T("TACTICS: "..self.Groupname.." was forced to stop travelling.") + self:EndTravel(self.Group:GetAverageCoordinate(), self.Destination) + self.TimeTravelActive = false + self.Destination = nil + self.travelToStored = nil + else + self.Destination = nil + self.travelToStored = nil + self:T("TACTICS: Removing travel to from "..self.Groupname.."'s queue.") + end + end + return self +end + +--- [User] Set tactical ROE +-- @param #TACTICS self +-- @param #string rtype Type or ROE, can be "Ignore" or "Attack" or "Hold" or "Avoid" +-- @return #TACTICS self +function TACTICS:SetTacticalROE(rtype) + if rtype == "Ignore" or rtype == "Attack" or rtype == "Hold" or rtype == "Avoid" then + self.TacticalROE = rtype + else + self:E("TACTICS ERROR: "..tostring(rtype).." is not a valid TacticalROE! Please enter one of the following: 'Attack' | 'Hold' | 'Avoid' | 'Ignore'") + end + return self +end + +--- [User] Enable/Disable Detection +-- @param #TACTICS self +-- @param #boolean OnOff +-- @param Core.Zone#ZONE FilterZone +-- @param #string FilterType +-- @return #TACTICS self +function TACTICS:DetectionEnabled(OnOff,FilterZone,FilterType) + if OnOff == true then + self.UseDetection = true + self.TimeDetectionActive = true + else + self.UseDetection = false + self.TimeDetectionActive = false + end + if FilterZone then self.FilterDetectionZones = FilterZone end + if FilterType then self.FilterEnemyType = FilterType end + return self +end + +--- [User] Enable/Disable Rearming +-- @param #TACTICS self +-- @param #boolean OnOff +-- @param #number LowPercent +-- @param #string FullPercent +-- @param #boolean RearmGroup +-- @param Core.Point#COORDINATE BaseCoord +-- @param #boolean AllowRTB +-- @param #string SpawnTemplate +-- @param Core.Point#COORDINATE SpawnCoord +-- @param #boolean UseRoads +-- @param #number Speed +-- @param #string Formation +-- @return #TACTICS self +function TACTICS:EnableRearming(OnOff,LowPercent,FullPercent,RearmGroup,BaseCoord,AllowRTB,SpawnTemplate,SpawnCoord,UseRoads,Speed,Formation) + self.AllowRearming = OnOff + self.LowAmmoPercent = LowPercent or 0.25 + self.FullAmmoPercent = FullPercent or 0.95 + self.RearmGroup = GroupAlive + self.RearmTemplate = SpawnTemplate + self.RearmSpawnCoord = SpawnCoord or BaseCoord + self.DespawnRearmingGroup = false + self.RearmGroupBase = BaseCoord + self.RearmGroupRTB = AllowRTB or false + self.RearmGroupUseRoads = UseRoads or false + self.RearmGroupSpeed = Speed or 60 + self.RearmGroupFormation = Formation or "Diamond" + return self +end + +--- [User] Enable Troop Transport +-- @param #TACTICS self +-- @param #string template +-- @param #number attackdist +-- @param #number attackreturn +-- @param string unitprefix +-- @return #TACTICS self +function TACTICS:EnableTroopTransport(template,attackdist,attackreturn,unitprefix) + self.TroopTransport = true + self.TroopTemplate = template + if attackdist then self.TroopAttackDist = attackdist end + if attackreturn then self.TroopReturnTime = attackreturn end + if unitprefix then self.TransportUnitPrefix = unitprefix end + return self +end + +--- [User] Enable drawing rearming requests +-- @param #TACTICS self +-- @param #string Text +-- @param #number FontSize +-- @param #number Radius +-- @param #table BorderTextColor +-- @param #number BorderTextAlpha +-- @param #table FillColor +-- @param #number FillAlpha +-- @param #number LineType +-- @return #TACTICS self +function TACTICS:EnableRearmDrawings(Text,FontSize,Radius,BorderTextColor,BorderTextAlpha,FillColor,FillAlpha,LineType) + self.RearmDrawing = true + self.DrawDataR.DrawText = nil + self.DrawDataR.DrawPoly = nil + self.DrawDataR.Text = Text + self.DrawDataR.Font = FontSize + self.DrawDataR.Radius = Radius + self.DrawDataR.Color1 = BorderTextColor + self.DrawDataR.Color2 = FillColor + self.DrawDataR.Alpha1 = BorderTextAlpha + self.DrawDataR.Alpha2 = FillAlpha + self.DrawDataR.Linetype = LineType + self.DrawDataR.Coalition = 2 + if self.groupCoalition == coalition.side.RED then self.DrawDataR.Coalition = 1 end + return self +end + +--- [User] Enable drawing rgroups that are engaged with enemy forces +-- @param #TACTICS self +-- @param #string Text +-- @param #number FontSize +-- @param #number Radius +-- @param #table BorderTextColor +-- @param #number BorderTextAlpha +-- @param #table FillColor +-- @param #number FillAlpha +-- @param #number LineType +-- @param #boolean MarkEnemy +-- @param #number MarkFreshTime +-- @param #number MarkStaleTime +-- @return #TACTICS self +function TACTICS:EnableEngageDrawings(Text,FontSize,Radius,BorderTextColor,BorderTextAlpha,FillColor,FillAlpha,LineType,MarkEnemy,MarkFreshTime,MarkStaleTime) + self.EngageDrawing = true + self.DrawDataE.DrawText = nil + self.DrawDataE.DrawPoly = nil + self.DrawDataE.Text = Text + self.DrawDataE.Font = FontSize + self.DrawDataE.Radius = Radius + self.DrawDataE.Color1 = BorderTextColor + self.DrawDataE.Color2 = FillColor + self.DrawDataE.Alpha1 = BorderTextAlpha + self.DrawDataE.Alpha2 = FillAlpha + self.DrawDataE.Linetype = LineType + if MarkEnemy then self.DrawDataE.MarkEnemy = MarkEnemy end + if MarkFreshTime then self.EngageDrawingFresh = MarkFreshTime end + if MarkStaleTime then self.EngageDrawingStale = MarkStaleTime end + self.DrawDataE.Coalition = 2 + if self.groupCoalition == coalition.side.RED then self.DrawDataE.Coalition = 1 end + return self +end + +--- [User] Enable drawing rgroups that are engaged with enemy forces +-- @param #TACTICS self +-- @param #number StaleTimeout +-- @return #TACTICS self +function TACTICS:EnableSpotDrawings(StaleTimeout) + self.DrawEnemySpots = true + if StaleTimeout then self.EnemySpotStale = StaleTimeout end + return self +end + +--- [User] Retreat to the retreat zone +-- @param #TACTICS self +-- @param Core.Point#COORDINATE Destination +-- @param #boolean Despawn +-- @param #number Speed +-- @param #string Formation +-- @param #boolean UseRoads +-- @return #TACTICS self +function TACTICS:Retreat(Destination,Despawn,Speed,Formation,UseRoads) + if not self:Is("Retreating") then + if not Destination and self.RetreatZone then + self:I("RETREAT: "..self.Groupname.." will attempt to retreat to the defined retreat zone.") + Destination = self.RetreatZone:GetRandomCoordinate() + if not Speed then Speed = self.RetreatSpeed else self.RetreatSpeed = Speed end + if not Formation then Formation = self.RetreatFormation else self.RetreatFormation = Formation end + if not UseRoads then UseRoads = false end + if not Despawn then Despawn = false end + self.retreatDestination = Destination + self.TimeTravelActive = false + self.TimeEngageActive = false + self.TimeHoldActive = false + self.TimeAvoidActive = false + self.TimeAttackActive = false + self.TimeDetectionActive = false + + if self.DrawDataR.DrawText then + trigger.action.removeMark(self.DrawDataR.DrawText) + self.DrawDataR.DrawText = nil + end + if self.DrawDataR.DrawPoly then + trigger.action.removeMark(self.DrawDataR.DrawPoly) + self.DrawDataR.DrawPoly = nil + end + if self.DrawDataE.DrawText then + trigger.action.removeMark(self.DrawDataE.DrawText) + self.DrawDataE.DrawText = nil + end + if self.DrawDataE.DrawPoly then + trigger.action.removeMark(self.DrawDataE.DrawPoly) + self.DrawDataE.DrawPoly = nil + end + + if not self.TroopsAttacking then + if self.RetreatOnRoads then + self.Group:RouteGroundOnRoad(self.retreatDestination, self.RetreatSpeed, 1, self.RetreatFormation) + self.TimeRetreatActive = true + self.TimeRetreatStamp = timer.getAbsTime() + else + self.Group:RouteGroundTo(self.retreatDestination, self.a, self.RetreatFormation, 1) + self.TimeRetreatActive = true + self.TimeRetreatStamp = timer.getAbsTime() + end + else + self:_ReturnTroops() + end + self:StartRetreat(self.retreatDestination) + else + self:E("TACICS ERROR: "..self.Groupname.." attempted to retreat but no retreat zone was declared and no destination was provided.") + end + end + return self +end + +--- [User] Enable retreating +-- @param #TACTICS self +-- @param Core.Zone#ZONE RetreatZone +-- @param #number LossPercentage +-- @param #boolean DespawnAfterRetreat +-- @param #number RetreatSpeed +-- @param #string RetreatFormation +-- @param #boolean UseRoads +-- @return #TACTICS self +function TACTICS:EnableRetreating(RetreatZone,LossPercentage,DespawnAfterRetreat,RetreatSpeed,RetreatFormation,UseRoads) + if RetreatZone then + self.RetreatZone = RetreatZone + else + self:E("TACTICS WARNING: No retreat zone declared when retreating was enabled for "..self.Groupname..". Retreating can only be conducted if executed manually.") + end + if LossPercentage then self.RetreatAfterLosses = LossPercentage end + if RetreatSpeed then self.RetreatSpeed = RetreatSpeed end + if RetreatFormation then self.RetreatFormation = RetreatFormation end + if UseRoads or UseRoads == false then self.RetreatOnRoads = UseRoads end + if DespawnAfterRetreat or DespawnAfterRetreat == false then self.DespawnAfterRetreat = DespawnAfterRetreat end + self:T({"TACTCS: Retreating enabled for "..self.Groupname,RetreatZone = RetreatZone,LossPercentage = LossPercentage,RetreatSpeed = RetreatSpeed,RetreatFormation = RetreatFormation,UseRoads = UseRoads,DespawnAfterRetreat = DespawnAfterRetreat}) + return self +end + +--- [User] Enable Abandoning +-- @param #TACTICS self +-- @param #string CrewTemplate +-- @param #boolean AllowSelfRecover +-- @param #string RecoveryVehicle +-- @param Core.Zone#ZONE RecoverySpawnZone +-- @param #boolean SmokeAbandoned +-- @param #number AbandonHealth +-- @param #number AbandonDistance +-- @param #boolean RecoveryUseRoads +-- @param #number RecoverySpeed +-- @param #string RecoveryFormation +-- @return #TACTICS self +function TACTICS:EnableAbandon(CrewTemplate,AllowSelfRecover,RecoveryVehicle,RecoverySpawnZone,SmokeAbandoned,AbandonHealth,AbandonDistance,RecoveryUseRoads,RecoverySpeed,RecoveryFormation) + if CrewTemplate then + self.AbandonEnabled = true + self.CrewTemplate = CrewTemplate + if AllowSelfRecover then self.AllowSelfRecover = AllowSelfRecover end + if RecoveryVehicle then self.RecoveryVehicle = RecoveryVehicle end + if RecoverySpawnZone then self.RecoverySpawnZone = RecoverySpawnZone end + if SmokeAbandoned then self.SmokeAbandoned = true else self.SmokeAbandoned = false end + if AbandonHealth then self.AbandonHealth = AbandonHealth end + if AbandonDistance then self.AbandonDistance = AbandonDistance end + if RecoveryUseRoads then self.RecoveryUseRoads = true else self.RecoveryUseRoads = false end + if RecoverySpeed then self.RecoverySpeed = RecoverySpeed end + if RecoveryFormation then self.RecoveryFormation = RecoveryFormation end + else + self:E("TACTICS ERROR: A crew template is required for vehicle abandoning!") + end + return self +end + +--- [User] Set Detection Range +-- @param #TACTICS self +-- @param #number val +-- @return #TACTICS self +function TACTICS:SetDetectionMax(val) + self.zoneDetection:SetRadius(val) + self.MaxDetection = val + return self +end + +--- [User] Enable Message Output +-- @param #TACTICS self +-- @param #boolean OnOff +-- @param #string Callsign +-- @param #string sound +-- @param #number duration +-- @return #TACTICS self +function TACTICS:EnableMessageOutput(OnOff,Callsign,Sound,Duration) + self.MessageOutput = OnOff or true + if Callsign then self.MessageCallsign = Callsign end + if Sound then self.MessageSound = Sound end + if Duration then self.MessageDuration = Duration end + return self +end + +--- [User] Enable Support Requests +-- @param #TACTICS self +-- @param #boolean OnOff +-- @param #number Radius +-- @param #number GroupLimit +-- @return #TACTICS self +function TACTICS:EnableSupportRequest(OnOff,Radius,GroupLimit) + self.AllowSupportRequests = OnOff or true + if Radius then self.SupportRadius = Radius end + if GroupLimit then self.SupportGroupLimit = GroupLimit end + return self +end + +--- [User] Enable Support Response +-- @param #TACTICS self +-- @param #boolean OnOff +-- @return #TACTICS self +function TACTICS:EnableSupportRespond(OnOff) + self.RespondToSupport = OnOff or true + return self +end + +--- [User] Pause timers, halt group, and disable AI +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:Sleep() + if not self.Sleeping then + if self.MasterTime then + self.MasterTime:Stop() + self.Group:RouteStop() + self.Group:SetAIOff() + self.Sleeping = true + else + self.E("Failed attempt to sleep "..self.Groupname.." as it is no longer active!") + end + end + return self +end + +--- [User] Resume timers after 5 seconds and enable AI immediately +-- @param #TACTICS self +-- @return #TACTICS self +function TACTICS:Wake() + if self.Sleeping then + if self.MasterTime then + self.MasterTime:Start(5,self.TickRate) + self.Group:SetAIOn() + self.Sleeping = false + else + self.E("Failed attempt to wake "..self.Groupname.." as it is no longer active!") + end + end + return self +end diff --git a/Moose Development/Moose/Functional/Tiresias.lua b/Moose Development/Moose/Functional/Tiresias.lua index 078bfda56..83cc02bba 100644 --- a/Moose Development/Moose/Functional/Tiresias.lua +++ b/Moose Development/Moose/Functional/Tiresias.lua @@ -97,7 +97,7 @@ TIRESIAS = { ClassName = "TIRESIAS", debug = false, - version = "0.0.4", + version = "0.0.5", Interval = 20, GroundSet = nil, VehicleSet = nil, @@ -187,7 +187,7 @@ function TIRESIAS:SetAAARanges(FiringRange,SwitchAAA) return self end ---- [USER] Add a SET_GROUP of GROUP objects as exceptions. Can be done multiple times. +--- [USER] Add a SET_GROUP of GROUP objects as exceptions. Can be done multiple times. Does **not** work work for GROUP objects spawned into the SET after start, i.e. the groups need to exist in the game already. -- @param #TIRESIAS self -- @param Core.Set#SET_GROUP Set to add to the exception list. -- @return #TIRESIAS self @@ -203,7 +203,7 @@ function TIRESIAS:AddExceptionSet(Set) } exceptions:AddGroup(grp,true) end - BASE:I("TIRESIAS: Added exception group: "..grp:GetName()) + BASE:T("TIRESIAS: Added exception group: "..grp:GetName()) end ) return self @@ -391,6 +391,7 @@ function TIRESIAS:_SwitchOnGroups(group,radius) if ground:CountAlive() > 0 then ground:ForEachGroupAlive( function(grp) + local name = grp:GetName() if grp.Tiresias and grp.Tiresias.type and (not grp.Tiresias.exception == true ) then if grp.Tiresias.invisible == true then grp:SetCommandInvisible(false) @@ -407,7 +408,7 @@ function TIRESIAS:_SwitchOnGroups(group,radius) end --BASE:I(string.format("TIRESIAS - Switch on %s %s (Exception %s)",tostring(grp.Tiresias.type),grp:GetName(),tostring(grp.Tiresias.exception))) else - BASE:E("TIRESIAS - This group has not been initialized or is an exception!") + BASE:T("TIRESIAS - This group "..tostring(name).. " has not been initialized or is an exception!") end end ) diff --git a/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua b/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua index d20732f20..b6f392426 100644 --- a/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua +++ b/Moose Development/Moose/Functional/ZoneCaptureCoalition.lua @@ -48,7 +48,7 @@ do -- ZONE_CAPTURE_COALITION - --- @type ZONE_CAPTURE_COALITION + -- @type ZONE_CAPTURE_COALITION -- @field #string ClassName Name of the class. -- @field #number MarkBlue ID of blue F10 mark. -- @field #number MarkRed ID of red F10 mark. @@ -161,7 +161,7 @@ do -- ZONE_CAPTURE_COALITION -- The mission designer can use these values to alter the logic. -- For example: -- - -- --- @param Functional.ZoneCaptureCoalition#ZONE_CAPTURE_COALITION self + -- -- @param Functional.ZoneCaptureCoalition#ZONE_CAPTURE_COALITION self -- function ZoneCaptureCoalition:OnEnterGuarded( From, Event, To ) -- if From ~= "Empty" then -- -- Display a message @@ -172,7 +172,7 @@ do -- ZONE_CAPTURE_COALITION -- -- ## Example Event Handler. -- - -- --- @param Functional.ZoneCaptureCoalition#ZONE_CAPTURE_COALITION self + -- -- @param Functional.ZoneCaptureCoalition#ZONE_CAPTURE_COALITION self -- function ZoneCaptureCoalition:OnEnterGuarded( From, Event, To ) -- if From ~= To then -- local Coalition = self:GetCoalition() @@ -273,7 +273,7 @@ do -- ZONE_CAPTURE_COALITION -- Depending on the zone ownership, different messages are sent. -- Note the methods `ZoneCaptureCoalition:GetZoneName()`. -- - -- --- @param Functional.ZoneCaptureCoalition#ZONE_CAPTURE_COALITION self + -- -- @param Functional.ZoneCaptureCoalition#ZONE_CAPTURE_COALITION self -- function ZoneCaptureCoalition:OnEnterGuarded( From, Event, To ) -- if From ~= To then -- local Coalition = self:GetCoalition() @@ -294,7 +294,7 @@ do -- ZONE_CAPTURE_COALITION -- Next is the Event Handler when the **Empty** state transition is triggered. -- Now we smoke the ZoneCaptureCoalition with a green color, using `self:Smoke( SMOKECOLOR.Green )`. -- - -- --- @param Functional.Protect#ZONE_CAPTURE_COALITION self + -- -- @param Functional.Protect#ZONE_CAPTURE_COALITION self -- function ZoneCaptureCoalition:OnEnterEmpty() -- self:Smoke( SMOKECOLOR.Green ) -- US_CC:MessageTypeToCoalition( string.format( "%s is unprotected, and can be captured!", ZoneCaptureCoalition:GetZoneName() ), MESSAGE.Type.Information ) @@ -304,7 +304,7 @@ do -- ZONE_CAPTURE_COALITION -- The next Event Handlers speak for itself. -- When the zone is Attacked, we smoke the zone white and send some messages to each coalition. -- - -- --- @param Functional.Protect#ZONE_CAPTURE_COALITION self + -- -- @param Functional.Protect#ZONE_CAPTURE_COALITION self -- function ZoneCaptureCoalition:OnEnterAttacked() -- ZoneCaptureCoalition:Smoke( SMOKECOLOR.White ) -- local Coalition = self:GetCoalition() @@ -321,7 +321,7 @@ do -- ZONE_CAPTURE_COALITION -- When the zone is Captured, we send some victory or loss messages to the correct coalition. -- And we add some score. -- - -- --- @param Functional.Protect#ZONE_CAPTURE_COALITION self + -- -- @param Functional.Protect#ZONE_CAPTURE_COALITION self -- function ZoneCaptureCoalition:OnEnterCaptured() -- local Coalition = self:GetCoalition() -- self:E({Coalition = Coalition}) @@ -641,7 +641,7 @@ do -- ZONE_CAPTURE_COALITION -- -- @usage -- -- For example, one could stop the monitoring when the zone was captured! - -- --- @param Functional.Protect#ZONE_CAPTURE_COALITION self + -- -- @param Functional.Protect#ZONE_CAPTURE_COALITION self -- function ZoneCaptureCoalition:OnEnterCaptured() -- local Coalition = self:GetCoalition() -- self:E({Coalition = Coalition}) diff --git a/Moose Development/Moose/Functional/ZoneGoal.lua b/Moose Development/Moose/Functional/ZoneGoal.lua index 1044e7920..2d0b5a4b3 100644 --- a/Moose Development/Moose/Functional/ZoneGoal.lua +++ b/Moose Development/Moose/Functional/ZoneGoal.lua @@ -17,7 +17,7 @@ do -- Zone - --- @type ZONE_GOAL + -- @type ZONE_GOAL -- @field #string ClassName Name of the class. -- @field Core.Goal#GOAL Goal The goal object. -- @field #number SmokeTime Time stamp in seconds when the last smoke of the zone was triggered. @@ -178,7 +178,7 @@ do -- Zone end - --- @param #ZONE_GOAL self + -- @param #ZONE_GOAL self -- @param Core.Event#EVENTDATA EventData Event data table. function ZONE_GOAL:__Destroyed( EventData ) self:F( { "EventDead", EventData } ) diff --git a/Moose Development/Moose/Functional/ZoneGoalCargo.lua b/Moose Development/Moose/Functional/ZoneGoalCargo.lua index 7a19ed02a..4397f621c 100644 --- a/Moose Development/Moose/Functional/ZoneGoalCargo.lua +++ b/Moose Development/Moose/Functional/ZoneGoalCargo.lua @@ -21,7 +21,7 @@ do -- ZoneGoal - --- @type ZONE_GOAL_CARGO + -- @type ZONE_GOAL_CARGO -- @extends Functional.ZoneGoal#ZONE_GOAL @@ -55,7 +55,7 @@ do -- ZoneGoal ClassName = "ZONE_GOAL_CARGO", } - --- @field #table ZONE_GOAL_CARGO.States + -- @field #table ZONE_GOAL_CARGO.States ZONE_GOAL_CARGO.States = {} --- ZONE_GOAL_CARGO Constructor. diff --git a/Moose Development/Moose/Functional/ZoneGoalCoalition.lua b/Moose Development/Moose/Functional/ZoneGoalCoalition.lua index 622843b10..82da20706 100644 --- a/Moose Development/Moose/Functional/ZoneGoalCoalition.lua +++ b/Moose Development/Moose/Functional/ZoneGoalCoalition.lua @@ -16,7 +16,7 @@ do -- ZoneGoal - --- @type ZONE_GOAL_COALITION + -- @type ZONE_GOAL_COALITION -- @field #string ClassName Name of the Class. -- @field #number Coalition The current coalition ID of the zone owner. -- @field #number PreviousCoalition The previous owner of the zone. @@ -48,7 +48,7 @@ do -- ZoneGoal ObjectCategories = nil, } - --- @field #table ZONE_GOAL_COALITION.States + -- @field #table ZONE_GOAL_COALITION.States ZONE_GOAL_COALITION.States = {} --- ZONE_GOAL_COALITION Constructor. diff --git a/Moose Development/Moose/Modules.lua b/Moose Development/Moose/Modules.lua index f8a543793..831f807ef 100644 --- a/Moose Development/Moose/Modules.lua +++ b/Moose Development/Moose/Modules.lua @@ -2,7 +2,7 @@ __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Enums.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Utils.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Profiler.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Templates.lua' ) -__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/STTS.lua' ) +--__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/STTS.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/FiFo.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Utilities/Socket.lua' ) @@ -84,7 +84,6 @@ __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Autolase.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ZoneGoalCargo.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Tiresias.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/Stratego.lua' ) -__Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Functional/ClientWatch.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/Airboss.lua' ) __Moose.Include( MOOSE_DEVELOPMENT_FOLDER..'/Moose/Ops/RecoveryTanker.lua' ) diff --git a/Moose Development/Moose/Modules_local.lua b/Moose Development/Moose/Modules_local.lua index b3816dbf1..ecb494af1 100644 --- a/Moose Development/Moose/Modules_local.lua +++ b/Moose Development/Moose/Modules_local.lua @@ -1,9 +1,7 @@ __Moose.Include( 'Utilities\\Enums.lua' ) -__Moose.Include( 'Utilities\\Routines.lua' ) __Moose.Include( 'Utilities\\Utils.lua' ) __Moose.Include( 'Utilities\\Profiler.lua' ) -__Moose.Include( 'Utilities\\Templates.lua' ) -__Moose.Include( 'Utilities\\STTS.lua' ) +--__Moose.Include( 'Utilities\\STTS.lua' ) __Moose.Include( 'Utilities\\FiFo.lua' ) __Moose.Include( 'Utilities\\Socket.lua' ) @@ -17,11 +15,11 @@ __Moose.Include( 'Core\\Event.lua' ) __Moose.Include( 'Core\\Settings.lua' ) __Moose.Include( 'Core\\Menu.lua' ) __Moose.Include( 'Core\\Zone.lua' ) -__Moose.Include( 'Core\\Zone_Detection.lua' ) +__Moose.Include( 'Core\\Velocity.lua' ) __Moose.Include( 'Core\\Database.lua' ) __Moose.Include( 'Core\\Set.lua' ) __Moose.Include( 'Core\\Point.lua' ) -__Moose.Include( 'Core\\Velocity.lua' ) +__Moose.Include( 'Core\\Pathline.lua' ) __Moose.Include( 'Core\\Message.lua' ) __Moose.Include( 'Core\\Fsm.lua' ) __Moose.Include( 'Core\\Spawn.lua' ) @@ -46,6 +44,9 @@ __Moose.Include( 'Wrapper\\Static.lua' ) __Moose.Include( 'Wrapper\\Airbase.lua' ) __Moose.Include( 'Wrapper\\Scenery.lua' ) __Moose.Include( 'Wrapper\\Marker.lua' ) +__Moose.Include( 'Wrapper\\Net.lua' ) +__Moose.Include( 'Wrapper\\Weapon.lua' ) +__Moose.Include( 'Wrapper\\Storage.lua' ) __Moose.Include( 'Cargo\\Cargo.lua' ) __Moose.Include( 'Cargo\\CargoUnit.lua' ) @@ -77,7 +78,9 @@ __Moose.Include( 'Functional\\Mantis.lua' ) __Moose.Include( 'Functional\\Shorad.lua' ) __Moose.Include( 'Functional\\Autolase.lua' ) __Moose.Include( 'Functional\\AICSAR.lua' ) -__Moose.Include( 'Functional\\ClientWatch.lua' ) +__Moose.Include( 'Functional\\AmmoTruck.lua' ) +__Moose.Include( 'Functional\\Tiresias.lua' ) +__Moose.Include( 'Functional\\Stratego.lua' ) __Moose.Include( 'Ops\\Airboss.lua' ) __Moose.Include( 'Ops\\RecoveryTanker.lua' ) @@ -108,6 +111,9 @@ __Moose.Include( 'Ops\\Awacs.lua' ) __Moose.Include( 'Ops\\PlayerTask.lua' ) __Moose.Include( 'Ops\\Operation.lua' ) __Moose.Include( 'Ops\\FlightControl.lua' ) +__Moose.Include( 'Ops\\PlayerRecce.lua' ) +__Moose.Include( 'Ops\\EasyGCICAP.lua' ) +__Moose.Include( 'Ops\\EasyA2G.lua' ) __Moose.Include( 'AI\\AI_Balancer.lua' ) __Moose.Include( 'AI\\AI_Air.lua' ) diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index 244e252ed..31116dde9 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -3623,6 +3623,7 @@ function AIRBOSS:onafterStart( From, Event, To ) self:HandleEvent( EVENTS.PlayerLeaveUnit, self._PlayerLeft ) self:HandleEvent( EVENTS.MissionEnd ) self:HandleEvent( EVENTS.RemoveUnit ) + self:HandleEvent( EVENTS.UnitLost, self.OnEventRemoveUnit ) -- self.StatusScheduler=SCHEDULER:New(self) -- self.StatusScheduler:Schedule(self, self._Status, {}, 1, 0.5) diff --git a/Moose Development/Moose/Ops/ArmyGroup.lua b/Moose Development/Moose/Ops/ArmyGroup.lua index 62f3dfec4..40f04de61 100644 --- a/Moose Development/Moose/Ops/ArmyGroup.lua +++ b/Moose Development/Moose/Ops/ArmyGroup.lua @@ -403,6 +403,7 @@ function ARMYGROUP:New(group) self:HandleEvent(EVENTS.Birth, self.OnEventBirth) self:HandleEvent(EVENTS.Dead, self.OnEventDead) self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit) + self:HandleEvent(EVENTS.UnitLost, self.OnEventRemoveUnit) self:HandleEvent(EVENTS.Hit, self.OnEventHit) -- Start the status monitoring. diff --git a/Moose Development/Moose/Ops/Awacs.lua b/Moose Development/Moose/Ops/Awacs.lua index 0f4bef1f5..3b048ada3 100644 --- a/Moose Development/Moose/Ops/Awacs.lua +++ b/Moose Development/Moose/Ops/Awacs.lua @@ -17,7 +17,7 @@ -- === -- -- ### Author: **applevangelist** --- @date Last Update Jan 2024 +-- @date Last Update July 2024 -- @module Ops.AWACS -- @image OPS_AWACS.jpg @@ -935,7 +935,7 @@ AWACS.TaskStatus = { --@field #boolean FromAI ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --- TODO-List 0.2.53 +-- TODO-List 0.2.54 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- -- DONE - WIP - Player tasking, VID diff --git a/Moose Development/Moose/Ops/Chief.lua b/Moose Development/Moose/Ops/Chief.lua index 0592046df..99c9d05d4 100644 --- a/Moose Development/Moose/Ops/Chief.lua +++ b/Moose Development/Moose/Ops/Chief.lua @@ -163,7 +163,7 @@ -- -- Will at a strategic zone with importance 2. -- --- If the zone is currently owned by another coalition and enemy ground troops are present in the zone, a CAS and an ARTY mission are lauchned: +-- If the zone is currently owned by another coalition and enemy ground troops are present in the zone, a CAS and an ARTY mission are launched: -- -- * A mission of type `AUFTRAG.Type.CASENHANCED` is started if assets are available that can carry out this mission type. -- * A mission of type `AUFTRAG.Type.ARTY` is started provided assets are available. diff --git a/Moose Development/Moose/Ops/Cohort.lua b/Moose Development/Moose/Ops/Cohort.lua index b77f8978c..5488c99cd 100644 --- a/Moose Development/Moose/Ops/Cohort.lua +++ b/Moose Development/Moose/Ops/Cohort.lua @@ -1009,6 +1009,7 @@ function COHORT:CanMission(Mission) if Mission.refuelSystem and Mission.refuelSystem==self.tankerSystem then -- Correct refueling system. + self:T(self.lid..string.format("INFO: Correct refueling system requested=%s != %s=available", tostring(Mission.refuelSystem), tostring(self.tankerSystem))) else self:T(self.lid..string.format("INFO: Wrong refueling system requested=%s != %s=available", tostring(Mission.refuelSystem), tostring(self.tankerSystem))) return false diff --git a/Moose Development/Moose/Ops/EasyA2G.lua b/Moose Development/Moose/Ops/EasyA2G.lua new file mode 100644 index 000000000..8082ca350 --- /dev/null +++ b/Moose Development/Moose/Ops/EasyA2G.lua @@ -0,0 +1,1510 @@ +------------------------------------------------------------------------- +-- Easy A2G Class, based on OPS classes +------------------------------------------------------------------------- +-- Documentation +-- +-- https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Ops.EasyA2G.html +-- +------------------------------------------------------------------------- +-- Date: December 2023 +------------------------------------------------------------------------- +-- +--- **Ops** - Easy A2G Manager +-- +-- === +-- +-- **Main Features:** +-- +-- * Automatically create and manage A2G CAS/BAI/SEAD defenses using an AirWing and Squadrons for one coalition +-- * Easy set-up +-- * Add additional AirWings on other airbases +-- * Each wing can have more than one Squadron - tasking to Squadrons is done on a random basis per AirWing +-- * Create borders and zones of engagement +-- * Detection can be ground based and/or via AWACS +-- +-- === +-- +-- ### AUTHOR: **applevangelist** +-- +-- @module Ops.EasyA2G +-- @image AI_Air_To_Ground_Dispatching.JPG + + +--- EASYA2G Class +-- @type EASYA2G +-- @field #string ClassName +-- @field #number overhead +-- @field #number engagerange +-- @field #number casgrouping +-- @field #string airbasename +-- @field Wrapper.Airbase#AIRBASE airbase +-- @field #number coalition +-- @field #string alias +-- @field #table wings +-- @field Ops.Intelligence#INTEL Intel +-- @field #number resurrection +-- @field #number casspeed +-- @field #number casalt +-- @field #number casdir +-- @field #number casleg +-- @field #number maxinterceptsize +-- @field #number missionrange +-- @field #number noaltert5 +-- @field #table ManagedAW +-- @field #table ManagedSQ +-- @field #table ManagedCP +-- @field #table ManagedTK +-- @field #table ManagedEWR +-- @field #table ManagedREC +-- @field #number MaxAliveMissions +-- @field #boolean debug +-- @field #number repeatsonfailure +-- @field Core.Set#SET_ZONE GoZoneSet +-- @field Core.Set#SET_ZONE NoGoZoneSet +-- @field #boolean Monitor +-- @field #boolean TankerInvisible +-- @field #number CasFormation +-- @extends Core.Fsm#FSM + +--- *“Airspeed, altitude, and brains. Two are always needed to successfully complete the flight.”* -- Unknown. +-- +-- === +-- +-- # The EASYA2G Concept +-- +-- The idea of this class is partially to make the OPS classes easier operational for an A2G defense network, and to replace the legacy AI_A2G_Dispatcher system - not to it's +-- full extent, but make a basic system work very quickly. +-- +-- # Setup +-- +-- ## Basic understanding +-- +-- The basics are, there is **one** and only **one** AirWing per airbase. Each AirWing has **at least** one Squadron, who will do CAS, SEAS and BAI tasks. Squadrons will be randomly chosen for the task at hand. +-- Each AirWing has **at least** one Recon Point that it manages. Recon Points will be covered by the AirWing automatically as long as airframes are available. Detected intruders will be assigned to **one** +-- AirWing based on proximity (that is, if you have more than one). +-- +-- ## Assignment of tasks for intruders +-- +-- Either a A2G Plane or a newly spawned plane will take care of the intruders. Standard overhead is 0.20, i.e. a group of 5 intrudes will +-- be managed by 1 plane from the assigned AirWing. There is an maximum missions limitation per AirWing, so we do not spam the skies. +-- +-- ## Basic set-up code +-- +-- ### Prerequisites +-- +-- You have to put a STATIC object on the airbase with the UNIT name according to the name of the airbase. E.g. for Kuitaisi this has to have the name Kutaisi. This object symbolizes the AirWing HQ. +-- Next put a late activated template group for your A2G Squadron on the map. Last, put a zone on the map for the CAP operations, let's name it "Blue Zone 1". Size of the zone plays no role. +-- Put an EW radar system on the map and name it aptly, like "Blue EWR". +-- +-- ### Code it +-- +-- -- Set up a basic system for the blue side, we'll reside on Kutaisi, and use GROUP objects with "Blue EWR" in the name as EW Radar Systems. +-- local mywing = EASYA2G:New("Blue A2G Operations",AIRBASE.Caucasus.Kutaisi,"blue","Blue EWR") +-- +-- -- Add a Recon patrol point belonging to our airbase, we'll be at 30k ft doing 400 kn, initial direction 90 degrees (East), leg 20NM +-- mywing:AddPatrolPointCAP(AIRBASE.Caucasus.Kutaisi,ZONE:FindByName("Blue Zone 1"):GetCoordinate(),30000,400,90,20) +-- +-- -- Add a Squadron with template "Blue Sq1 M2000c", 20 airframes, skill good, Modex starting with 102 and skin "Vendee Jeanne" +-- mywing:AddSquadron("Blue Sq1 M2000c","CAP Kutaisi",AIRBASE.Caucasus.Kutaisi,20,AI.Skill.GOOD,102,"ec1.5_Vendee_Jeanne_clean") +-- +-- -- Add a couple of zones +-- -- We'll defend our border +-- mywing:AddAcceptZone(ZONE_POLYGON:New( "Blue Border", GROUP:FindByName( "Blue Border" ) )) +-- -- We'll attack intruders also here +-- mywing:AddAcceptZone(ZONE_POLYGON:New("Red Defense Zone", GROUP:FindByName( "Red Defense Zone" ))) +-- -- We'll leave the reds alone on their turf +-- mywing:AddRejectZone(ZONE_POLYGON:New( "Red Border", GROUP:FindByName( "Red Border" ) )) +-- +-- -- Optional - Draw the borders on the map so we see what's going on +-- -- Set up borders on map +-- local BlueBorder = ZONE_POLYGON:New( "Blue Border", GROUP:FindByName( "Blue Border" ) ) +-- BlueBorder:DrawZone(-1,{0,0,1},1,FillColor,FillAlpha,1,true) +-- local BlueNoGoZone = ZONE_POLYGON:New("Red Defense Zone", GROUP:FindByName( "Red Defense Zone" )) +-- BlueNoGoZone:DrawZone(-1,{1,1,0},1,FillColor,FillAlpha,2,true) +-- local BlueNoGoZone2 = ZONE_POLYGON:New( "Red Border", GROUP:FindByName( "Red Border" ) ) +-- BlueNoGoZone2:DrawZone(-1,{1,0,0},1,FillColor,FillAlpha,4,true) +-- +-- ### Add a second airwing with squads and own CAP point (optional) +-- +-- -- Set this up at Sukhumi +-- mywing:AddAirwing(AIRBASE.Caucasus.Sukhumi_Babushara,"Blue A2G Sukhumi") +-- -- Recon Point "Blue Zone 2" +-- mywing:AddPatrolPointCAP(AIRBASE.Caucasus.Sukhumi_Babushara,ZONE:FindByName("Blue Zone 2"):GetCoordinate(),30000,400,90,20) +-- +-- -- This one has two squadrons to choose from +-- mywing:AddSquadron("Blue Sq3 F16","CAP Sukhumi II",AIRBASE.Caucasus.Sukhumi_Babushara,20,AI.Skill.GOOD,402,"JASDF 6th TFS 43-8526 Skull Riders") +-- mywing:AddSquadron("Blue Sq2 F15","CAP Sukhumi I",AIRBASE.Caucasus.Sukhumi_Babushara,20,AI.Skill.GOOD,202,"390th Fighter SQN") +-- +-- ### Add a tanker (optional) +-- +-- -- **Note** If you need different tanker types, i.e. Boom and Drogue, set them up at different AirWings! +-- -- Add a tanker point +-- mywing:AddPatrolPointTanker(AIRBASE.Caucasus.Kutaisi,ZONE:FindByName("Blue Zone Tanker"):GetCoordinate(),20000,280,270,50) +-- -- Add an AWACS squad - Radio 251 AM, TACAN 51Y +-- mywing:AddTankerSquadron("Blue Tanker","Tanker Ops Kutaisi",AIRBASE.Caucasus.Kutaisi,20,AI.Skill.EXCELLENT,602,nil,251,radio.modulation.AM,51) +-- +-- ### Add an AWACS (optional) +-- +-- -- Add an AWACS point +-- mywing:AddPatrolPointAwacs(AIRBASE.Caucasus.Kutaisi,ZONE:FindByName("Blue Zone AWACS"):GetCoordinate(),25000,300,270,50) +-- -- Add a tanker squad - Radio 251 AM, TACAN 51Y +-- mywing:AddAWACSSquadron("Blue AWACS","AWACS Ops Kutaisi",AIRBASE.Caucasus.Kutaisi,20,AI.Skill.AVERAGE,702,nil,271,radio.modulation.AM) +-- +-- # Fine-Tuning +-- +-- ## Change Defaults +-- +-- * @{#EASYA2G.SetDefaultResurrection}: Set how many seconds the AirWing stays inoperable after the AirWing STATIC HQ ist destroyed, default 900 secs. +-- * @{#EASYA2G.SetDefaultCAPSpeed}: Set how many knots the CAP flights should do (will be altitude corrected), default 300 kn. +-- * @{#EASYA2G.SetDefaultCAPAlt}: Set at which altitude (ASL) the CAP planes will fly, default 25,000 ft. +-- * @{#EASYA2G.SetDefaultCAPDirection}: Set the initial direction from the CAP point the planes will fly in degrees, default is 90°. +-- * @{#EASYA2G.SetDefaultCAPLeg}: Set the length of the CAP leg, default is 15 NM. +-- * @{#EASYA2G.SetDefaultCAPGrouping}: Set how many planes will be spawned per mission (CVAP/GCI), defaults to 2. +-- * @{#EASYA2G.SetDefaultMissionRange}: Set how many NM the planes can go from the home base, defaults to 100. +-- * @{#EASYA2G.SetDefaultNumberAlter5Standby}: Set how many planes will be spawned on cold standby (Alert5), default 2. +-- * @{#EASYA2G.SetDefaultEngageRange}: Set max engage range for CAP flights if they detect intruders, defaults to 50. +-- * @{#EASYA2G.SetMaxAliveMissions}: Set max parallel missions can be done (CAP+GCI+Alert5+Tanker+AWACS), defaults to 8. +-- * @{#EASYA2G.SetDefaultRepeatOnFailure}: Set max repeats on failure for intercepting/killing intruders, defaults to 3. +-- * @{#EASYA2G.SetTankerAndAWACSInvisible}: Set Tanker and AWACS to be invisible to enemy AI eyes. Is set to `true` by default. +-- +-- ## Debug and Monitor +-- +-- mywing.debug = true -- log information +-- mywing.Monitor = true -- show some statistics on screen +-- +-- +-- @field #EASYA2G +EASYA2G = { + ClassName = "EASYA2G", + overhead = 0.2, + casgrouping = 2, + airbasename = nil, + airbase = nil, + coalition = "blue", + alias = nil, + wings = {}, + Intel = nil, + resurrection = 900, + casspeed = 250, + casalt = 10000, + casdir = 45, + casleg = 15, + maxinterceptsize = 2, + missionrange = 100, + noaltert5 = 0, + ManagedAW = {}, + ManagedSQ = {}, + ManagedCP = {}, + ManagedTK = {}, + ManagedEWR = {}, + ManagedREC = {}, + MaxAliveMissions = 10, + debug = true, + engagerange = 50, + repeatsonfailure = 10, + GoZoneSet = nil, + NoGoZoneSet = nil, + Monitor = true, + TankerInvisible = true, + CasFormation = nil, +} + +--- Internal Squadron data type +-- @type EASYA2G.Squad +-- @field #string TemplateName +-- @field #string SquadName +-- @field #string AirbaseName +-- @field #number AirFrames +-- @field #string Skill +-- @field #string Modex +-- @field #string Livery +-- @field #boolean Tanker +-- @field #boolean AWACS +-- @field #boolean RECON +-- @field #number Frequency +-- @field #number Modulation +-- @field #number TACAN + +--- Internal Wing data type +-- @type EASYA2G.Wing +-- @field #string AirbaseName +-- @field #string Alias +-- @field #string CapZoneName + +--- Internal CasPoint data type +-- @type EASYA2G.CasPoint +-- @field #string AirbaseName +-- @field Core.Point#COORDINATE Coordinate +-- @field #number Altitude +-- @field #number Speed +-- @field #number Heading +-- @field #number LegLength + +--- EASYA2G class version. +-- @field #string version +EASYA2G.version="0.0.9" + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- TODO list +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +-- TODO: TBD + +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- Constructor +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + +--- Create a new GCICAP Manager +-- @param #EASYA2G self +-- @param #string Alias +-- @param #string AirbaseName +-- @param #string Coalition +-- @param #string EWRName +-- @return #EASYA2G self +function EASYA2G:New(Alias, AirbaseName, Coalition, EWRName) + -- Inherit everything from FSM class. + local self=BASE:Inherit(self, FSM:New()) -- #EASYA2G + + -- defaults + self.alias = Alias or AirbaseName.." A2G Wing" + self.coalitionname = string.lower(Coalition) or "blue" + self.coalition = self.coaltitionname == "blue" and coalition.side.BLUE or coalition.side.RED + self.wings = {} + self.EWRName = EWRName or self.coalitionname.." EWR" + --self.CapZoneName = CapZoneName + self.airbasename = AirbaseName + self.airbase = AIRBASE:FindByName(self.airbasename) + self.GoZoneSet = SET_ZONE:New() + self.NoGoZoneSet = SET_ZONE:New() + self.resurrection = 900 + self.casspeed = 250 + self.casalt = 10000 + self.casdir = 90 + self.casleg = 15 + self.casgrouping = 2 + self.missionrange = 100 + self.noaltert5 = 2 + self.MaxAliveMissions = 8 + self.engagerange = 50 + self.repeatsonfailure = 3 + self.Monitor = false + self.TankerInvisible = true + self.CasFormation = ENUMS.Formation.FixedWing.BomberElement.Group + + -- Set some string id for output to DCS.log file. + self.lid=string.format("EASYA2G %s | ", self.alias) + + -- Add FSM transitions. + -- From State --> Event --> To State + self:SetStartState("Stopped") + self:AddTransition("Stopped", "Start", "Running") + self:AddTransition("Running", "Stop", "Stopped") + self:AddTransition("*", "Status", "*") + + self:AddAirwing(self.airbasename,self.alias,self.CapZoneName) + + self:I(self.lid.."Created new instance (v"..self.version..")") + + self:__Start(math.random(6,12)) + + return self +end + +------------------------------------------------------------------------- +-- Functions +------------------------------------------------------------------------- + +--- Set CAP formation. +-- @param #EASYA2G self +-- @param #number Formation Formation to fly, defaults to ENUMS.Formation.FixedWing.FingerFour.Group +-- @return #EASYA2G self +function EASYA2G:SetA2GFormation(Formation) + self.CasFormation = Formation + return self +end + +--- Set Tanker and AWACS to be invisible to enemy AI eyes +-- @param #EASYA2G self +-- @param #boolean Switch Set to true or false, by default this is set to true already +-- @return #EASYA2G self +function EASYA2G:SetTankerAndAWACSInvisible(Switch) + self:T(self.lid.."SetTankerAndAWACSInvisible") + self.TankerInvisible = Switch + return self +end + +--- Set Maximum of alive missions to stop airplanes spamming the map +-- @param #EASYA2G self +-- @param #number Maxiumum Maxmimum number of parallel missions allowed. Count is Cap-Missions + Intercept-Missions + Alert5-Missionsm default is 6 +-- @return #EASYA2G self +function EASYA2G:SetMaxAliveMissions(Maxiumum) + self:T(self.lid.."SetDefaultResurrection") + self.MaxAliveMissions = Maxiumum or 8 + return self +end + +--- Add default time to resurrect Airwing building if destroyed +-- @param #EASYA2G self +-- @param #number Seconds Seconds, defaults to 900 +-- @return #EASYA2G self +function EASYA2G:SetDefaultResurrection(Seconds) + self:T(self.lid.."SetDefaultResurrection") + self.resurrection = Seconds or 900 + return self +end + +--- Add default repeat attempts if an Intruder intercepts fails. +-- @param #EASYA2G self +-- @param #number Retries Retries, defaults to 3 +-- @return #EASYA2G self +function EASYA2G:SetDefaultRepeatOnFailure(Retries) + self:T(self.lid.."SetDefaultRepeatOnFailure") + self.repeatsonfailure = Retries or 3 + return self +end + +--- Set default A2G Speed in knots +-- @param #EASYA2G self +-- @param #number Speed Speed defaults to 250 +-- @return #EASYA2G self +function EASYA2G:SetDefaultA2GSpeed(Speed) + self:T(self.lid.."SetDefaultSpeed") + self.casspeed = Speed or 250 + return self +end + +--- Set default A2G Altitude in feet +-- @param #EASYA2G self +-- @param #number Altitude Altitude defaults to 25000 +-- @return #EASYA2G self +function EASYA2G:SetDefaultA2GAlt(Altitude) + self:T(self.lid.."SetDefaultAltitude") + self.casalt = Altitude or 25000 + return self +end + +--- Set default A2G leg initial direction in degrees +-- @param #EASYA2G self +-- @param #number Direction Direction defaults to 90 (East) +-- @return #EASYA2G self +function EASYA2G:SetDefaultA2GDirection(Direction) + self:T(self.lid.."SetDefaultDirection") + self.casdir = Direction or 90 + return self +end + +--- Set default leg length in NM +-- @param #EASYA2G self +-- @param #number Leg Leg defaults to 15 +-- @return #EASYA2G self +function EASYA2G:SetDefaultA2GLeg(Leg) + self:T(self.lid.."SetDefaultLeg") + self.casleg = Leg or 15 + return self +end + +--- Set default grouping, i.e. how many airplanes per A2G point +-- @param #EASYA2G self +-- @param #number Grouping Grouping defaults to 2 +-- @return #EASYA2G self +function EASYA2G:SetDefaultA2GGrouping(Grouping) + self:T(self.lid.."SetDefaultA2GGrouping") + self.casgrouping = Grouping or 2 + return self +end + +--- Set default range planes can fly from their homebase in NM +-- @param #EASYA2G self +-- @param #number Range Range defaults to 100 NM +-- @return #EASYA2G self +function EASYA2G:SetDefaultMissionRange(Range) + self:T(self.lid.."SetDefaultMissionRange") + self.missionrange = Range or 100 + return self +end + +--- Set default number of airframes standing by for intercept tasks (visible on the airfield) +-- @param #EASYA2G self +-- @param #number Airframes defaults to 2 +-- @return #EASYA2G selfAirframes +function EASYA2G:SetDefaultNumberAlter5Standby(Airframes) + self:T(self.lid.."SetDefaultNumberAlter5Standby") + self.noaltert5 = math.abs(Airframes) or 2 + return self +end + +--- Set default engage range for intruders detected by A2G flights in NM. +-- @param #EASYA2G self +-- @param #number Range defaults to 50NM +-- @return #EASYA2G selfAirframes +function EASYA2G:SetDefaultEngageRange(Range) + self:T(self.lid.."SetDefaultNumberAlter5Standby") + self.engagerange = Range or 50 + return self +end + +--- Add an AirWing to the manager +-- @param #EASYA2G self +-- @param #string Airbasename +-- @param #string Alias +-- @return #EASYA2G self +function EASYA2G:AddAirwing(Airbasename, Alias) + self:T(self.lid.."AddAirwing "..Airbasename) + + -- Create Airwing data entry + local AWEntry = {} -- #EASYA2G.Wing + AWEntry.AirbaseName = Airbasename + AWEntry.Alias = Alias + --AWEntry.CapZoneName = CapZoneName + + self.ManagedAW[Airbasename] = AWEntry + + return self +end + +--- (Internal) Create actual AirWings from the list +-- @param #EASYA2G self +-- @return #EASYA2G self +function EASYA2G:_CreateAirwings() + self:T(self.lid.."_CreateAirwings") + for airbase,data in pairs(self.ManagedAW) do + local wing = data -- #EASYA2G.Wing + local afb = wing.AirbaseName + local alias = wing.Alias + --local cz = wing.CapZoneName + self:_AddAirwing(airbase,alias) + end + return self +end + +--- (internal) Create and add another AirWing to the manager +-- @param #EASYA2G self +-- @param #string Airbasename +-- @param #string Alias +-- @return #EASYA2G self +function EASYA2G:_AddAirwing(Airbasename, Alias) + self:T(self.lid.."_AddAirwing "..Airbasename) + + local CasFormation = self.CasFormation + + -- Create Airwing + local CAP_Wing = AIRWING:New(Airbasename,Alias) + CAP_Wing:SetVerbosityLevel(0) + CAP_Wing:SetReportOff() + CAP_Wing:SetMarker(true) + CAP_Wing:SetAirbase(AIRBASE:FindByName(Airbasename)) + CAP_Wing:SetRespawnAfterDestroyed() + CAP_Wing:SetNumberCAS(self.casgrouping) + --CAP_Wing:SetCapCloseRaceTrack(true) + if CasFormation then + CAP_Wing:SetCASFormation(CasFormation) + end + if #self.ManagedTK > 0 then + CAP_Wing:SetNumberTankerBoom(1) + CAP_Wing:SetNumberTankerProbe(1) + end + if #self.ManagedEWR > 0 then + CAP_Wing:SetNumberAWACS(1) + end + if #self.ManagedREC > 0 then + CAP_Wing:SetNumberRecon(1) + end + --local PatrolCoordinateKutaisi = ZONE:New(CapZoneName):GetCoordinate() + --CAP_Wing:AddPatrolPointCAP(PatrolCoordinateKutaisi,self.casalt,UTILS.KnotsToAltKIAS(self.casspeed,self.casalt),self.casdir,self.casleg) + CAP_Wing:SetTakeoffHot() + CAP_Wing:SetLowFuelThreshold(0.3) + CAP_Wing.RandomAssetScore = math.random(50,100) + CAP_Wing:Start() + + local Intel = self.Intel + + local TankerInvisible = self.TankerInvisible + + function CAP_Wing:OnAfterFlightOnMission(From, Event, To, Flightgroup, Mission) + local flightgroup = Flightgroup -- Ops.FlightGroup#FLIGHTGROUP + --flightgroup:SetDespawnAfterLanding() + flightgroup:SetDespawnAfterHolding() + flightgroup:SetDestinationbase(AIRBASE:FindByName(Airbasename)) + flightgroup:GetGroup():CommandEPLRS(true,5) + if Mission.type ~= AUFTRAG.Type.TANKER and Mission.type ~= AUFTRAG.Type.AWACS and Mission.type ~= AUFTRAG.Type.RECON then + flightgroup:SetDetection(true) + flightgroup:SetEngageDetectedOn(self.engagerange,nil,self.GoZoneSet,self.NoGoZoneSet) + flightgroup:SetOutOfAGMRTB(switch) + if CasFormation then + flightgroup:GetGroup():SetOption(AI.Option.Air.id.FORMATION,CasFormation) + end + end + if Mission.type == AUFTRAG.Type.TANKER or Mission.type == AUFTRAG.Type.AWACS or Mission.type == AUFTRAG.Type.RECON then + if TankerInvisible then + flightgroup:GetGroup():SetCommandInvisible(true) + end + if Mission.type == AUFTRAG.Type.RECON then + flightgroup:SetDetection(true) + end + end + flightgroup:GetGroup():OptionROTEvadeFire() + flightgroup:SetFuelLowRTB(true) + Intel:AddAgent(flightgroup) + function flightgroup:OnAfterHolding(From,Event,To) + self:ClearToLand(5) + end + + end + + if self.noaltert5 > 0 then + local alert = AUFTRAG:NewALERT5(AUFTRAG.Type.CASENHANCED) + alert:SetRequiredAssets(self.noaltert5) + alert:SetRepeat(99) + CAP_Wing:AddMission(alert) + end + + self.wings[Airbasename] = { CAP_Wing, AIRBASE:FindByName(Airbasename):GetZone(), Airbasename } + + return self +end + +--- Add a A2G patrol point to a Wing +-- @param #EASYA2G self +-- @param #string AirbaseName Name of the Wing's airbase +-- @param Core.Point#COORDINATE Coordinate. +-- @param #number Altitude Defaults to 25000 feet ASL. +-- @param #number Speed Defaults to 300 knots TAS. +-- @param #number Heading Defaults to 90 degrees (East). +-- @param #number LegLength Defaults to 15 NM. +-- @return #EASYA2G self +function EASYA2G:AddPatrolPointA2G(AirbaseName,Coordinate,Altitude,Speed,Heading,LegLength) + self:T(self.lid.."AddPatrolPointA2G "..Coordinate:ToStringLLDDM()) + local EntryCAP = {} -- #EASYA2G.CasPoint + EntryCAP.AirbaseName = AirbaseName + EntryCAP.Coordinate = Coordinate + EntryCAP.Altitude = Altitude or 25000 + EntryCAP.Speed = Speed or 300 + EntryCAP.Heading = Heading or 90 + EntryCAP.LegLength = LegLength or 15 + self.ManagedCP[#self.ManagedCP+1] = EntryCAP + if self.debug then + local mark = MARKER:New(Coordinate,self.lid.."Patrol Point"):ToAll() + end + return self +end + +--- Add a RECON patrol point to a Wing +-- @param #EASYA2G self +-- @param #string AirbaseName Name of the Wing's airbase +-- @param Core.Point#COORDINATE Coordinate. +-- @param #number Altitude Defaults to 25000 feet. +-- @param #number Speed Defaults to 300 knots. +-- @param #number Heading Defaults to 90 degrees (East). +-- @param #number LegLength Defaults to 15 NM. +-- @return #EASYA2G self +function EASYA2G:AddPatrolPointRecon(AirbaseName,Coordinate,Altitude,Speed,Heading,LegLength) + self:T(self.lid.."AddPatrolPointRecon "..Coordinate:ToStringLLDDM()) + local EntryCAP = {} -- #EASYA2G.CasPoint + EntryCAP.AirbaseName = AirbaseName + EntryCAP.Coordinate = Coordinate + EntryCAP.Altitude = Altitude or 25000 + EntryCAP.Speed = Speed or 300 + EntryCAP.Heading = Heading or 90 + EntryCAP.LegLength = LegLength or 15 + self.ManagedREC[#self.ManagedREC+1] = EntryCAP + if self.debug then + local mark = MARKER:New(Coordinate,self.lid.."Patrol Point Recon"):ToAll() + end + return self +end + +--- Add a TANKER patrol point to a Wing +-- @param #EASYA2G self +-- @param #string AirbaseName Name of the Wing's airbase +-- @param Core.Point#COORDINATE Coordinate. +-- @param #number Altitude Defaults to 25000 feet. +-- @param #number Speed Defaults to 300 knots. +-- @param #number Heading Defaults to 90 degrees (East). +-- @param #number LegLength Defaults to 15 NM. +-- @return #EASYA2G self +function EASYA2G:AddPatrolPointTanker(AirbaseName,Coordinate,Altitude,Speed,Heading,LegLength) + self:T(self.lid.."AddPatrolPointTanker "..Coordinate:ToStringLLDDM()) + local EntryCAP = {} -- #EASYA2G.CasPoint + EntryCAP.AirbaseName = AirbaseName + EntryCAP.Coordinate = Coordinate + EntryCAP.Altitude = Altitude or 25000 + EntryCAP.Speed = Speed or 300 + EntryCAP.Heading = Heading or 90 + EntryCAP.LegLength = LegLength or 15 + self.ManagedTK[#self.ManagedTK+1] = EntryCAP + if self.debug then + local mark = MARKER:New(Coordinate,self.lid.."Patrol Point Tanker"):ToAll() + end + return self +end + +--- Add an AWACS patrol point to a Wing +-- @param #EASYA2G self +-- @param #string AirbaseName Name of the Wing's airbase +-- @param Core.Point#COORDINATE Coordinate. +-- @param #number Altitude Defaults to 25000 feet. +-- @param #number Speed Defaults to 300 knots. +-- @param #number Heading Defaults to 90 degrees (East). +-- @param #number LegLength Defaults to 15 NM. +-- @return #EASYA2G self +function EASYA2G:AddPatrolPointAwacs(AirbaseName,Coordinate,Altitude,Speed,Heading,LegLength) + self:T(self.lid.."AddPatrolPointAwacs "..Coordinate:ToStringLLDDM()) + local EntryCAP = {} -- #EASYA2G.CasPoint + EntryCAP.AirbaseName = AirbaseName + EntryCAP.Coordinate = Coordinate + EntryCAP.Altitude = Altitude or 25000 + EntryCAP.Speed = Speed or 300 + EntryCAP.Heading = Heading or 90 + EntryCAP.LegLength = LegLength or 15 + self.ManagedEWR[#self.ManagedEWR+1] = EntryCAP + if self.debug then + local mark = MARKER:New(Coordinate,self.lid.."Patrol Point AWACS"):ToAll() + end + return self +end + +--- (Internal) Set actual Tanker Points from the list +-- @param #EASYA2G self +-- @return #EASYA2G self +function EASYA2G:_SetTankerPatrolPoints() + self:T(self.lid.."_SetTankerPatrolPoints") + for _,_data in pairs(self.ManagedTK) do + local data = _data --#EASYA2G.CasPoint + local Wing = self.wings[data.AirbaseName][1] -- Ops.AirWing#AIRWING + local Coordinate = data.Coordinate + local Altitude = data.Altitude + local Speed = data.Speed + local Heading = data.Heading + local LegLength = data.LegLength + Wing:AddPatrolPointTANKER(Coordinate,Altitude,Speed,Heading,LegLength) + end + + return self +end + +--- (Internal) Set actual Awacs Points from the list +-- @param #EASYA2G self +-- @return #EASYA2G self +function EASYA2G:_SetAwacsPatrolPoints() + self:T(self.lid.."_SetAwacsPatrolPoints") + for _,_data in pairs(self.ManagedEWR) do + local data = _data --#EASYA2G.CasPoint + local Wing = self.wings[data.AirbaseName][1] -- Ops.AirWing#AIRWING + local Coordinate = data.Coordinate + local Altitude = data.Altitude + local Speed = data.Speed + local Heading = data.Heading + local LegLength = data.LegLength + Wing:AddPatrolPointAWACS(Coordinate,Altitude,Speed,Heading,LegLength) + end + + return self +end + +--- (Internal) Set actual PatrolPoints from the list +-- @param #EASYA2G self +-- @return #EASYA2G self +function EASYA2G:_SetA2GPatrolPoints() + self:T(self.lid.."_SetA2GPatrolPoints") + for _,_data in pairs(self.ManagedCP) do + local data = _data --#EASYA2G.CasPoint + local Wing = self.wings[data.AirbaseName][1] -- Ops.AirWing#AIRWING + local Coordinate = data.Coordinate + local Altitude = data.Altitude + local Speed = data.Speed + local Heading = data.Heading + local LegLength = data.LegLength + local caszone = ZONE_RADIUS:New("EasyA2G-"..math.random(1,100000),Coordinate:GetVec2(),5000,false) + Wing:AddPatrolPointCAS(caszone,Altitude,Speed,100,self.NoGoZoneSet) + end + + return self +end + +--- (Internal) Set actual PatrolPoints from the list +-- @param #EASYA2G self +-- @return #EASYA2G self +function EASYA2G:_SetReconPatrolPoints() + self:T(self.lid.."_SetReconPatrolPoints") + for _,_data in pairs(self.ManagedREC) do + local data = _data --#EASYA2G.CasPoint + local Wing = self.wings[data.AirbaseName][1] -- Ops.AirWing#AIRWING + local Coordinate = data.Coordinate + local Altitude = data.Altitude + local Speed = data.Speed + local Heading = data.Heading + local LegLength = data.LegLength + Wing:AddPatrolPointRecon(Coordinate,Altitude,Speed,Heading,LegLength) + end + + return self +end + +--- (Internal) Create actual Squadrons from the list +-- @param #EASYA2G self +-- @return #EASYA2G self +function EASYA2G:_CreateSquads() + self:T(self.lid.."_CreateSquads") + for name,data in pairs(self.ManagedSQ) do + local squad = data -- #EASYA2G.Squad + local SquadName = name + local TemplateName = squad.TemplateName + local AirbaseName = squad.AirbaseName + local AirFrames = squad.AirFrames + local Skill = squad.Skill + local Modex = squad.Modex + local Livery = squad.Livery + local Frequency = squad.Frequency + local Modulation = squad.Modulation + local TACAN = squad.TACAN + if squad.Tanker then + self:_AddTankerSquadron(TemplateName,SquadName,AirbaseName,AirFrames,Skill,Modex,Livery,Frequency,Modulation,TACAN) + elseif squad.AWACS then + self:_AddAWACSSquadron(TemplateName,SquadName,AirbaseName,AirFrames,Skill,Modex,Livery,Frequency,Modulation) + elseif squad.RECON then + self:_AddReconSquadron(TemplateName,SquadName,AirbaseName,AirFrames,Skill,Modex,Livery) + elseif squad.BOMBING then + self:_AddSquadronBOMBING(TemplateName,SquadName,AirbaseName,AirFrames,Skill,Modex,Livery,Frequency,Modulation) + elseif squad.SEAD then + self:_AddSquadronSEAD(TemplateName,SquadName,AirbaseName,AirFrames,Skill,Modex,Livery,Frequency,Modulation) + elseif squad.ANTISHIP then + self:_AddSquadronANTISHIP(TemplateName,SquadName,AirbaseName,AirFrames,Skill,Modex,Livery,Frequency,Modulation) + else + self:_AddSquadron(TemplateName,SquadName,AirbaseName,AirFrames,Skill,Modex,Livery) + end + end + return self +end + +--- Add a CAS Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @return #EASYA2G self +function EASYA2G:AddSquadronCAS(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery) + self:T(self.lid.."AddSquadronCAS "..SquadName) + -- Add Squadron Data + local EntrySQ = {} -- #EASYA2G.Squad + EntrySQ.TemplateName = TemplateName + EntrySQ.SquadName = SquadName + EntrySQ.AirbaseName = AirbaseName + EntrySQ.AirFrames = AirFrames or 20 + EntrySQ.Skill = Skill or AI.Skill.AVERAGE + EntrySQ.Modex = Modex or 402 + EntrySQ.Livery = Livery + + self.ManagedSQ[SquadName] = EntrySQ + + return self +end + +--- Add a SEAD Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @return #EASYA2G self +function EASYA2G:AddSquadronSEAD(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery) + self:T(self.lid.."AddSquadronSEAD "..SquadName) + -- Add Squadron Data + local EntrySQ = {} -- #EASYA2G.Squad + EntrySQ.TemplateName = TemplateName + EntrySQ.SquadName = SquadName + EntrySQ.AirbaseName = AirbaseName + EntrySQ.AirFrames = AirFrames or 20 + EntrySQ.Skill = Skill or AI.Skill.AVERAGE + EntrySQ.Modex = Modex or 402 + EntrySQ.Livery = Livery + EntrySQ.SEAD= true + self.CanSEAD = true + + self.ManagedSQ[SquadName] = EntrySQ + + return self +end + +--- Add an ANTISHIP Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @return #EASYA2G self +function EASYA2G:AddSquadronANTISHIP(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery) + self:T(self.lid.."AddSquadronANTISHIP "..SquadName) + -- Add Squadron Data + local EntrySQ = {} -- #EASYA2G.Squad + EntrySQ.TemplateName = TemplateName + EntrySQ.SquadName = SquadName + EntrySQ.AirbaseName = AirbaseName + EntrySQ.AirFrames = AirFrames or 20 + EntrySQ.Skill = Skill or AI.Skill.AVERAGE + EntrySQ.Modex = Modex or 402 + EntrySQ.Livery = Livery + EntrySQ.ANTISHIP = true + self.CanAntiShip = true + + self.ManagedSQ[SquadName] = EntrySQ + + return self +end + +--- Add a BOMBING Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @return #EASYA2G self +function EASYA2G:AddSquadronBOMBING(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery) + self:T(self.lid.."AddSquadronBOMBING "..SquadName) + -- Add Squadron Data + local EntrySQ = {} -- #EASYA2G.Squad + EntrySQ.TemplateName = TemplateName + EntrySQ.SquadName = SquadName + EntrySQ.AirbaseName = AirbaseName + EntrySQ.AirFrames = AirFrames or 20 + EntrySQ.Skill = Skill or AI.Skill.AVERAGE + EntrySQ.Modex = Modex or 402 + EntrySQ.Livery = Livery + EntrySQ.BOMBING = true + self.CanBombing = true + + self.ManagedSQ[SquadName] = EntrySQ + + return self +end + +--- Add a Recon Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @return #EASYA2G self +function EASYA2G:AddReconSquadron(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery) + self:T(self.lid.."AddReconSquadron "..SquadName) + -- Add Squadron Data + local EntrySQ = {} -- #EASYA2G.Squad + EntrySQ.TemplateName = TemplateName + EntrySQ.SquadName = SquadName + EntrySQ.AirbaseName = AirbaseName + EntrySQ.AirFrames = AirFrames or 20 + EntrySQ.Skill = Skill or AI.Skill.AVERAGE + EntrySQ.Modex = Modex or 402 + EntrySQ.Livery = Livery + EntrySQ.RECON = true + + self.ManagedSQ[SquadName] = EntrySQ + + return self +end + +--- Add a Tanker Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @param #number Frequency (optional) Radio Frequency to be used. +-- @param #number Modulation (optional) Radio Modulation to be used, e.g. radio.modulation.AM or radio.modulation.FM +-- @param #number TACAN (optional) TACAN channel, e.g. 71, resulting in Channel 71Y +-- @return #EASYA2G self +function EASYA2G:AddTankerSquadron(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery, Frequency, Modulation, TACAN) + self:T(self.lid.."AddTankerSquadron "..SquadName) + -- Add Squadron Data + local EntrySQ = {} -- #EASYA2G.Squad + EntrySQ.TemplateName = TemplateName + EntrySQ.SquadName = SquadName + EntrySQ.AirbaseName = AirbaseName + EntrySQ.AirFrames = AirFrames or 20 + EntrySQ.Skill = Skill or AI.Skill.AVERAGE + EntrySQ.Modex = Modex or 602 + EntrySQ.Livery = Livery + EntrySQ.Frequency = Frequency + EntrySQ.Modulation = Livery + EntrySQ.TACAN = TACAN + EntrySQ.Tanker = true + + self.ManagedSQ[SquadName] = EntrySQ + + return self +end + +--- Add an AWACS Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @param #number Frequency (optional) Radio Frequency to be used. +-- @param #number Modulation (optional) Radio Modulation to be used, e.g. radio.modulation.AM or radio.modulation.FM +-- @return #EASYA2G self +function EASYA2G:AddAWACSSquadron(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery, Frequency, Modulation) + self:T(self.lid.."AddAWACSSquadron "..SquadName) + -- Add Squadron Data + local EntrySQ = {} -- #EASYA2G.Squad + EntrySQ.TemplateName = TemplateName + EntrySQ.SquadName = SquadName + EntrySQ.AirbaseName = AirbaseName + EntrySQ.AirFrames = AirFrames or 20 + EntrySQ.Skill = Skill or AI.Skill.AVERAGE + EntrySQ.Modex = Modex or 702 + EntrySQ.Livery = Livery + EntrySQ.Frequency = Frequency + EntrySQ.Modulation = Livery + EntrySQ.AWACS = true + + self.ManagedSQ[SquadName] = EntrySQ + + return self +end + +--- (Internal) Add a Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @param #number Frequency (optional) Radio Frequency to be used. +-- @param #number Modulation (optional) Radio Modulation to be used, e.g. radio.modulation.AM or radio.modulation.FM +-- @return #EASYA2G self +function EASYA2G:_AddSquadron(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery, Frequency, Modulation) + self:T(self.lid.."_AddSquadron "..SquadName) + -- Add Squadrons + local Squadron_One = SQUADRON:New(TemplateName,AirFrames,SquadName) + Squadron_One:AddMissionCapability({AUFTRAG.Type.CASENHANCED, AUFTRAG.Type.BAI, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5}) + --Squadron_One:SetFuelLowRefuel(true) + Squadron_One:SetFuelLowThreshold(0.3) + Squadron_One:SetTurnoverTime(10,20) + Squadron_One:SetModex(Modex) + Squadron_One:SetLivery(Livery) + Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE) + Squadron_One:SetMissionRange(self.missionrange) + + local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING + + wing:AddSquadron(Squadron_One) + wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.CASENHANCED, AUFTRAG.Type.BAI, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5},75) + + return self +end + +--- (Internal) Add a SEAD Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @param #number Frequency (optional) Radio Frequency to be used. +-- @param #number Modulation (optional) Radio Modulation to be used, e.g. radio.modulation.AM or radio.modulation.FM +-- @return #EASYA2G self +function EASYA2G:_AddSquadronSEAD(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery, Frequency, Modulation) + self:T(self.lid.."_AddSquadronSEAD "..SquadName) + -- Add Squadrons + local Squadron_One = SQUADRON:New(TemplateName,AirFrames,SquadName) + Squadron_One:AddMissionCapability({AUFTRAG.Type.SEAD, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5}) + --Squadron_One:SetFuelLowRefuel(true) + Squadron_One:SetFuelLowThreshold(0.3) + Squadron_One:SetTurnoverTime(10,20) + Squadron_One:SetModex(Modex) + Squadron_One:SetLivery(Livery) + Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE) + Squadron_One:SetMissionRange(self.missionrange) + + local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING + + wing:AddSquadron(Squadron_One) + wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.SEAD, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5},75) + + return self +end + +--- (Internal) Add an ANTISHIP Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @param #number Frequency (optional) Radio Frequency to be used. +-- @param #number Modulation (optional) Radio Modulation to be used, e.g. radio.modulation.AM or radio.modulation.FM +-- @return #EASYA2G self +function EASYA2G:_AddSquadronANTISHIP(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery, Frequency, Modulation) + self:T(self.lid.."_AddSquadronANTISHIP "..SquadName) + -- Add Squadrons + local Squadron_One = SQUADRON:New(TemplateName,AirFrames,SquadName) + Squadron_One:AddMissionCapability({AUFTRAG.Type.ANTISHIP, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5}) + --Squadron_One:SetFuelLowRefuel(true) + Squadron_One:SetFuelLowThreshold(0.3) + Squadron_One:SetTurnoverTime(10,20) + Squadron_One:SetModex(Modex) + Squadron_One:SetLivery(Livery) + Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE) + Squadron_One:SetMissionRange(self.missionrange) + + local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING + + wing:AddSquadron(Squadron_One) + wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.ANTISHIP, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5},75) + + return self +end + +--- (Internal) Add an BOMBING Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @param #number Frequency (optional) Radio Frequency to be used. +-- @param #number Modulation (optional) Radio Modulation to be used, e.g. radio.modulation.AM or radio.modulation.FM +-- @return #EASYA2G self +function EASYA2G:_AddSquadronBOMBING(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery, Frequency, Modulation) + self:T(self.lid.."_AddSquadronBOMBING "..SquadName) + -- Add Squadrons + local Squadron_One = SQUADRON:New(TemplateName,AirFrames,SquadName) + Squadron_One:AddMissionCapability({AUFTRAG.Type.BOMBING, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5}) + --Squadron_One:SetFuelLowRefuel(true) + Squadron_One:SetFuelLowThreshold(0.3) + Squadron_One:SetTurnoverTime(10,20) + Squadron_One:SetModex(Modex) + Squadron_One:SetLivery(Livery) + Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE) + Squadron_One:SetMissionRange(self.missionrange) + + local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING + + wing:AddSquadron(Squadron_One) + wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.BOMBING, AUFTRAG.Type.PATROLRACETRACK, AUFTRAG.Type.ALERT5},75) + + return self +end + +--- (Internal) Add a Recon Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @return #EASYA2G self +function EASYA2G:_AddReconSquadron(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery) + self:T(self.lid.."_AddReconSquadron "..SquadName) + -- Add Squadrons + local Squadron_One = SQUADRON:New(TemplateName,AirFrames,SquadName) + Squadron_One:AddMissionCapability({AUFTRAG.Type.RECON}) + --Squadron_One:SetFuelLowRefuel(true) + Squadron_One:SetFuelLowThreshold(0.3) + Squadron_One:SetTurnoverTime(10,20) + Squadron_One:SetModex(Modex) + Squadron_One:SetLivery(Livery) + Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE) + Squadron_One:SetMissionRange(self.missionrange) + + local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING + + wing:AddSquadron(Squadron_One) + wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.RECON},75) + + return self +end + +--- (Internal) Add a Tanker Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @param #number Frequency (optional) Radio frequency of the Tanker +-- @param #number Modulation (Optional) Radio modulation of the Tanker +-- @param #number TACAN (Optional) TACAN Channel to be used, will always be an "Y" channel +-- @return #EASYA2G self +function EASYA2G:_AddTankerSquadron(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery, Frequency, Modulation, TACAN) + self:T(self.lid.."_AddTankerSquadron "..SquadName) + -- Add Squadrons + local Squadron_One = SQUADRON:New(TemplateName,AirFrames,SquadName) + Squadron_One:AddMissionCapability({AUFTRAG.Type.TANKER}) + --Squadron_One:SetFuelLowRefuel(true) + Squadron_One:SetFuelLowThreshold(0.3) + Squadron_One:SetTurnoverTime(10,20) + Squadron_One:SetModex(Modex) + Squadron_One:SetLivery(Livery) + Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE) + Squadron_One:SetMissionRange(self.missionrange) + Squadron_One:SetRadio(Frequency,Modulation) + Squadron_One:AddTacanChannel(TACAN,TACAN) + + local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING + + wing:AddSquadron(Squadron_One) + wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.TANKER},75) + + return self +end + +--- (Internal) Add a AWACS Squadron to an Airwing of the manager +-- @param #EASYA2G self +-- @param #string TemplateName Name of the group template. +-- @param #string SquadName Squadron name - must be unique! +-- @param #string AirbaseName Name of the airbase the airwing resides on, e.g. AIRBASE.Caucasus.Kutaisi +-- @param #number AirFrames Number of available airframes, e.g. 20. +-- @param #string Skill(optional) Skill level, e.g. AI.Skill.AVERAGE +-- @param #string Modex (optional) Modex to be used,e.g. 402. +-- @param #string Livery (optional) Livery name to be used. +-- @param #number Frequency (optional) Radio frequency of the AWACS +-- @param #number Modulation (Optional) Radio modulation of the AWACS +-- @return #EASYA2G self +function EASYA2G:_AddAWACSSquadron(TemplateName, SquadName, AirbaseName, AirFrames, Skill, Modex, Livery, Frequency, Modulation) + self:T(self.lid.."_AddAWACSSquadron "..SquadName) + -- Add Squadrons + local Squadron_One = SQUADRON:New(TemplateName,AirFrames,SquadName) + Squadron_One:AddMissionCapability({AUFTRAG.Type.AWACS}) + --Squadron_One:SetFuelLowRefuel(true) + Squadron_One:SetFuelLowThreshold(0.3) + Squadron_One:SetTurnoverTime(10,20) + Squadron_One:SetModex(Modex) + Squadron_One:SetLivery(Livery) + Squadron_One:SetSkill(Skill or AI.Skill.AVERAGE) + Squadron_One:SetMissionRange(self.missionrange) + Squadron_One:SetRadio(Frequency,Modulation) + local wing = self.wings[AirbaseName][1] -- Ops.AirWing#AIRWING + + wing:AddSquadron(Squadron_One) + wing:NewPayload(TemplateName,-1,{AUFTRAG.Type.AWACS},75) + + return self +end + +--- Add a zone to the accepted zones set. +-- @param #EASYA2G self +-- @param Core.Zone#ZONE_BASE Zone +-- @return #EASYA2G self +function EASYA2G:AddAcceptZone(Zone) + self:T(self.lid.."AddAcceptZone0") + self.GoZoneSet:AddZone(Zone) + return self +end + +--- Add a zone to the rejected zones set. +-- @param #EASYA2G self +-- @param Core.Zone#ZONE_BASE Zone +-- @return #EASYA2G self +function EASYA2G:AddRejectZone(Zone) + self:T(self.lid.."AddRejectZone") + self.NoGoZoneSet:AddZone(Zone) + return self +end + +--- (Internal) Start detection. +-- @param #EASYA2G self +-- @return #EASYA2G self +function EASYA2G:_StartIntel() + self:T(self.lid.."_StartIntel") + -- Border GCI Detection + local BlueAir_DetectionSetGroup = SET_GROUP:New() + BlueAir_DetectionSetGroup:FilterPrefixes( { self.EWRName } ) + BlueAir_DetectionSetGroup:FilterStart() + + -- Intel type detection + local BlueIntel = INTEL:New(BlueAir_DetectionSetGroup,self.coalitionname, self.EWRName) + BlueIntel:SetClusterAnalysis(false,false,false) + BlueIntel:SetForgetTime(300) + BlueIntel:SetAcceptZones(self.GoZoneSet) + BlueIntel:SetRejectZones(self.NoGoZoneSet) + BlueIntel:SetVerbosity(0) + BlueIntel:SetDetectStatics(true) + BlueIntel:SetFilterCategory({Unit.Category.GROUND_UNIT, Unit.Category.SHIP, Unit.Category.STRUCTURE}) + --BlueIntel:SetDetectionTypes(false,true,true,true,false,true) + BlueIntel:Start() + + if self.debug then + BlueIntel.debug = true + end + + -- Here, we'll decide if we need to launch an A2G flight, and from where + + local overhead = self.overhead + local casspeed = self.casspeed + 100 + local casalt = self.casalt + local maxsize = self.maxinterceptsize + local repeatsonfailure = self.repeatsonfailure + + local wings = self.wings + local ctlpts = self.ManagedCP + local MaxAliveMissions = self.MaxAliveMissions * self.casgrouping + local nogozoneset = self.NoGoZoneSet + + function BlueIntel:OnAfterNewContact(From,Event,To,Contact) + -- Aircraft? + if Contact.ctype == INTEL.Ctype.AIRCRAFT then return end + -- Threatlevel 0..10 + --local contact = self:GetHighestThreatContact(Cluster) + local contact = Contact -- Ops.Intelligence#INTEL.Contact + local name = contact.groupname --#string + local threat = contact.threatlevel --#number + --local position = self:CalcClusterFuturePosition(Cluster,300) + local position = Contact.position + -- calculate closest zone + local bestdistance = 2000*1000 -- 2000km + local targetairwing = nil -- Ops.AirWing#AIRWING + local targetawname = "" -- #string + local clustersize = contact.group.ClassName == "GROUP" and contact.group:CountAliveUnits() or 1 + local wingsize = math.abs(overhead * (clustersize+1)) + if wingsize > maxsize then wingsize = maxsize end + -- existing mission, and if so - done? + local retrymission = true + if Contact.mission and (not Contact.mission:IsOver()) then + retrymission = false + end + if (retrymission) and (wingsize >= 1) then + MESSAGE:New(string.format("**** %s A2G need wingsize %d", UTILS.GetCoalitionName(self.coalition), wingsize),15,"A2G"):ToAllIf(self.debug):ToLog() + for _,_data in pairs (wings) do + local airwing = _data[1] -- Ops.AirWing#AIRWING + local zone = _data[2] -- Core.Zone#ZONE + local zonecoord = zone:GetCoordinate() + local name = _data[3] -- #string + local distance = position:DistanceFromPointVec2(zonecoord) + local airframes = airwing:CountAssets(true) + if distance < bestdistance and airframes >= wingsize then + bestdistance = distance + targetairwing = airwing + targetawname = name + end + end + for _,_data in pairs (ctlpts) do + --local airwing = _data[1] -- Ops.AirWing#AIRWING + --local zone = _data[2] -- Core.Zone#ZONE + --local zonecoord = zone:GetCoordinate() + --local name = _data[3] -- #string + + local data = _data -- #EASYA2G.CasPoint + local name = data.AirbaseName + local zonecoord = data.Coordinate + local airwing = wings[name][1] + + local distance = position:DistanceFromPointVec2(zonecoord) + local airframes = airwing:CountAssets(true) + if distance < bestdistance and airframes >= wingsize then + bestdistance = distance + targetairwing = airwing -- Ops.AirWing#AIRWING + targetawname = name + end + end + local text = string.format("Closest Airwing is %s", targetawname) + local m = MESSAGE:New(text,10,"A2G"):ToAllIf(self.debug):ToLog() + -- Do we have a matching airwing? + if targetairwing then + local AssetCount = targetairwing:CountAssetsOnMission(MissionTypes,Cohort) + -- Enough airframes on mission already? + self:T(self.lid.." Assets on Mission "..AssetCount) + if AssetCount <= MaxAliveMissions then + local repeats = repeatsonfailure + local caszone = ZONE_RADIUS:New("EasyA2G-"..math.random(1,100000),contact.position:GetVec2(),5000,false) + --local InterceptAuftrag = AUFTRAG:NewCASENHANCED(caszone,casalt,casspeed,100,nogozoneset) + local prio = 30 + local urgent = false + local InterceptAuftrag = AUFTRAG:NewBAI(contact.group,casalt) + if contact.isStatic and self.CanBombing then + InterceptAuftrag = AUFTRAG:NewBOMBING(contact.group,casalt) + prio = 50 + elseif contact.isship and self.CanAntiShip then + InterceptAuftrag = AUFTRAG:NewANTISHIP(contact.group,casalt) + urgent = true + elseif self.CanSEAD and (contact.group:HasAttribute("RADAR_BAND1_FOR_ARM") or contact.group:HasAttribute("RADAR_BAND2_FOR_ARM") or contact.group:HasAttribute("Optical Tracker")) then + InterceptAuftrag = AUFTRAG:NewSEAD(contact.group,casalt) + prio = 1 + urgent = true + end + --local InterceptAuftrag = AUFTRAG:NewBAI(contact,casalt) + InterceptAuftrag:SetMissionRange(100) + InterceptAuftrag:SetPriority(prio,urgent) + InterceptAuftrag:SetRequiredAssets(wingsize) + InterceptAuftrag:SetRepeatOnFailure(repeats) + InterceptAuftrag:SetMissionSpeed(UTILS.KnotsToAltKIAS(casspeed,casalt)) + InterceptAuftrag:SetMissionAltitude(casalt) + + if nogozoneset:Count() > 0 then + InterceptAuftrag:AddConditionSuccess( + function(group,zoneset) + local success = false + if group and group:IsAlive() then + local coord = group:GetCoordinate() + if coord and zoneset:IsCoordinateInZone(coord) then + success = true + end + end + return success + end, + contact.group, + nogozoneset + ) + end + + targetairwing:AddMission(InterceptAuftrag) + Contact.mission = InterceptAuftrag + end + else + MESSAGE:New("**** Not enough airframes available or max mission limit reached!",15,"A2G"):ToAllIf(self.debug):ToLog() + end + end + end +self.Intel = BlueIntel +return self +end + +------------------------------------------------------------------------- +-- FSM Functions +------------------------------------------------------------------------- + +--- (Internal) FSM Function onafterStart +-- @param #EASYA2G self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #EASYA2G self +function EASYA2G:onafterStart(From,Event,To) + self:T({From,Event,To}) + self:_StartIntel() + self:_CreateAirwings() + self:_CreateSquads() + self:_SetA2GPatrolPoints() + self:_SetTankerPatrolPoints() + self:_SetAwacsPatrolPoints() + self:_SetReconPatrolPoints() + self:__Status(-10) + return self +end + +--- (Internal) FSM Function onbeforeStatus +-- @param #EASYA2G self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #EASYA2G self +function EASYA2G:onbeforeStatus(From,Event,To) + self:T({From,Event,To}) + if self:GetState() == "Stopped" then return false end + return self +end + +--- (Internal) FSM Function onafterStatus +-- @param #EASYA2G self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #EASYA2G self +function EASYA2G:onafterStatus(From,Event,To) + self:T({From,Event,To}) + -- Gather Some Stats + local function counttable(tbl) + local count = 0 + for _,_data in pairs(tbl) do + count = count + 1 + end + return count + end + local wings = counttable(self.ManagedAW) + local squads = counttable(self.ManagedSQ) + local caps = counttable(self.ManagedCP) + local assets = 0 + local instock = 0 + local capmission = 0 + --local interceptmission = 0 + local reconmission = 0 + --local awacsmission = 0 + --local tankermission = 0 + local seadmission = 0 + local bombmission = 0 + local shipmission = 0 + for _,_wing in pairs(self.wings) do + local count = _wing[1]:CountAssetsOnMission(MissionTypes,Cohort) + local count2 = _wing[1]:CountAssets(true,MissionTypes,Attributes) + capmission = capmission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.CASENHANCED,AUFTRAG.Type.BAI}) + --interceptmission = interceptmission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.INTERCEPT}) + reconmission = reconmission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.RECON}) + --awacsmission = awacsmission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.AWACS}) + --tankermission = tankermission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.TANKER}) + seadmission = seadmission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.SEAD}) + bombmission = bombmission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.BOMBING}) + shipmission = shipmission + _wing[1]:CountMissionsInQueue({AUFTRAG.Type.ANTISHIP}) + assets = assets + count + instock = instock + count2 + end + if self.Monitor then + local threatcount = #self.Intel.Contacts or 0 + local text = "GCICAP "..self.alias + text = text.."\nWings: "..wings.."\nSquads: "..squads.."\nCasPoints: "..caps.."\nAssets on Mission: "..assets.."\nAssets in Stock: "..instock + text = text.."\nThreats: "..threatcount + text = text.."\nMissions: "..capmission+reconmission+seadmission+bombmission+shipmission + --text = text.."\n - Intercept: "..interceptmission + --text = text.."\n - AWACS: "..awacsmission + --text = text.."\n - TANKER: "..tankermission + text = text.."\n - Recon: "..reconmission + text = text.."\n - CAS/BAI: "..capmission + if self.CanSEAD then + text = text.."\n - SEAD: "..seadmission + end + if self.CanBombing then + text = text.."\n - Bombing: "..bombmission + end + if self.CanAntiShip then + text = text.."\n - Anti-Ship: "..shipmission + end + MESSAGE:New(text,15,"GCICAP"):ToAll():ToLogIf(self.debug) + end + self:__Status(30) + return self +end + +--- (Internal) FSM Function onafterStop +-- @param #EASYA2G self +-- @param #string From +-- @param #string Event +-- @param #string To +-- @return #EASYA2G self +function EASYA2G:onafterStop(From,Event,To) + self:T({From,Event,To}) + self.Intel:Stop() + return self +end diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 45c7d753a..499ca6b12 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -394,7 +394,8 @@ function NAVYGROUP:New(group) -- Handle events: self:HandleEvent(EVENTS.Birth, self.OnEventBirth) self:HandleEvent(EVENTS.Dead, self.OnEventDead) - self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit) + self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit) + self:HandleEvent(EVENTS.UnitLost, self.OnEventRemoveUnit) -- Start the status monitoring. self.timerStatus=TIMER:New(self.Status, self):Start(1, 30) diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index b27564a62..853d17520 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -1238,7 +1238,7 @@ function MSRS:PlayTextExt(Text, Delay, Frequencies, Modulations, Gender, Culture self:T({Text, Delay, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate} ) if Delay and Delay>0 then - self:ScheduleOnce(Delay, MSRS.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate) + self:ScheduleOnce(Delay, self.PlayTextExt, self, Text, 0, Frequencies, Modulations, Gender, Culture, Voice, Volume, Label, Coordinate) else Frequencies = Frequencies or self:GetFrequencies() @@ -1560,8 +1560,8 @@ end function MSRS:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate) -- Debug info. - self:F("MSRS_BACKEND_DCSGRPC:_DCSgRPCtts()") - self:F({Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate}) + self:T("MSRS_BACKEND_DCSGRPC:_DCSgRPCtts()") + self:T({Text, Frequencies, Gender, Culture, Voice, Volume, Label, Coordinate}) local options = {} -- #MSRS.GRPCOptions @@ -1587,7 +1587,6 @@ function MSRS:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Lab -- Provider (win, gcloud, ...) local provider = self.provider or MSRS.Provider.WINDOWS - self:F({provider=provider}) -- Provider options: voice, credentials options.provider = {} @@ -1595,7 +1594,7 @@ function MSRS:_DCSgRPCtts(Text, Frequencies, Gender, Culture, Voice, Volume, Lab -- Voice Voice=Voice or self:GetVoice(self.provider) or self.voice - + if Voice then -- We use a specific voice options.provider[provider].voice = Voice diff --git a/Moose Development/Moose/Sound/SoundOutput.lua b/Moose Development/Moose/Sound/SoundOutput.lua index 466d0fa22..552689fc8 100644 --- a/Moose Development/Moose/Sound/SoundOutput.lua +++ b/Moose Development/Moose/Sound/SoundOutput.lua @@ -24,7 +24,7 @@ do -- Sound Base - --- @type SOUNDBASE + -- @type SOUNDBASE -- @field #string ClassName Name of the class. -- @extends Core.Base#BASE @@ -100,7 +100,7 @@ end do -- Sound File - --- @type SOUNDFILE + -- @type SOUNDFILE -- @field #string ClassName Name of the class -- @field #string filename Name of the flag. -- @field #string path Directory path, where the sound file is located. This includes the final slash "/". @@ -292,7 +292,7 @@ end do -- Text-To-Speech - --- @type SOUNDTEXT + -- @type SOUNDTEXT -- @field #string ClassName Name of the class -- @field #string text Text to speak. -- @field #number duration Duration in seconds. diff --git a/Moose Development/Moose/Sound/UserSound.lua b/Moose Development/Moose/Sound/UserSound.lua index ceaeeb6e2..f78c42e78 100644 --- a/Moose Development/Moose/Sound/UserSound.lua +++ b/Moose Development/Moose/Sound/UserSound.lua @@ -21,7 +21,7 @@ do -- UserSound - --- @type USERSOUND + -- @type USERSOUND -- @extends Core.Base#BASE diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index 873279e4a..59ab36a3c 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -181,7 +181,8 @@ COMMANDCENTER = { } ---- @type COMMANDCENTER.AutoAssignMethods +--- +-- @type COMMANDCENTER.AutoAssignMethods COMMANDCENTER.AutoAssignMethods = { ["Random"] = 1, ["Distance"] = 2, @@ -210,7 +211,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) self:SetMessageDuration(10) self:HandleEvent( EVENTS.Birth, - --- @param #COMMANDCENTER self + -- @param #COMMANDCENTER self -- @param Core.Event#EVENTDATA EventData function( self, EventData ) if EventData.IniObjectCategory == 1 then @@ -241,7 +242,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) -- -- - Assign the PlayerUnit to the Task if required. -- -- - Send a message to the other players in the group that this player has joined. -- self:HandleEvent( EVENTS.PlayerEnterUnit, --- --- @param #COMMANDCENTER self +-- -- @param #COMMANDCENTER self -- -- @param Core.Event#EVENTDATA EventData -- function( self, EventData ) -- local PlayerUnit = EventData.IniUnit @@ -258,7 +259,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) -- The PlayerUnit will be UnAssigned from the Task. -- When there is no Unit left running the Task, the Task goes into Abort... self:HandleEvent( EVENTS.MissionEnd, - --- @param #TASK self + -- @param #TASK self -- @param Core.Event#EVENTDATA EventData function( self, EventData ) local PlayerUnit = EventData.IniUnit @@ -273,7 +274,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) -- The PlayerUnit will be UnAssigned from the Task. -- When there is no Unit left running the Task, the Task goes into Abort... self:HandleEvent( EVENTS.PlayerLeaveUnit, - --- @param #TASK self + -- @param #TASK self -- @param Core.Event#EVENTDATA EventData function( self, EventData ) local PlayerUnit = EventData.IniUnit @@ -290,7 +291,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) -- The PlayerUnit will be UnAssigned from the Task. -- When there is no Unit left running the Task, the Task goes into Abort... self:HandleEvent( EVENTS.Crash, - --- @param #TASK self + -- @param #TASK self -- @param Core.Event#EVENTDATA EventData function( self, EventData ) local PlayerUnit = EventData.IniUnit diff --git a/Moose Development/Moose/Tasking/DetectionManager.lua b/Moose Development/Moose/Tasking/DetectionManager.lua index da560e5d0..81dd1f882 100644 --- a/Moose Development/Moose/Tasking/DetectionManager.lua +++ b/Moose Development/Moose/Tasking/DetectionManager.lua @@ -48,7 +48,7 @@ do -- DETECTION MANAGER - --- @type DETECTION_MANAGER + -- @type DETECTION_MANAGER -- @field Core.Set#SET_GROUP SetGroup The groups to which the FAC will report to. -- @field Functional.Detection#DETECTION_BASE Detection The DETECTION_BASE object that is used to report the detected objects. -- @field Tasking.CommandCenter#COMMANDCENTER CC The command center that is used to communicate with the players. @@ -62,7 +62,7 @@ do -- DETECTION MANAGER Detection = nil, } - --- @field Tasking.CommandCenter#COMMANDCENTER + -- @field Tasking.CommandCenter#COMMANDCENTER DETECTION_MANAGER.CC = nil --- FAC constructor. diff --git a/Moose Development/Moose/Tasking/Mission.lua b/Moose Development/Moose/Tasking/Mission.lua index 1c65725d2..6fa3da747 100644 --- a/Moose Development/Moose/Tasking/Mission.lua +++ b/Moose Development/Moose/Tasking/Mission.lua @@ -19,7 +19,8 @@ -- @module Tasking.Mission -- @image Task_Mission.JPG ---- @type MISSION +--- +-- @type MISSION -- @field #MISSION.Clients _Clients -- @field Core.Menu#MENU_COALITION MissionMenu -- @field #string MissionBriefing @@ -790,7 +791,7 @@ function MISSION:HasGroup( TaskGroup ) return Has end ---- @param #MISSION self +-- @param #MISSION self -- @return #number function MISSION:GetTasksRemaining() -- Determine how many tasks are remaining. @@ -805,7 +806,7 @@ function MISSION:GetTasksRemaining() return TasksRemaining end ---- @param #MISSION self +-- @param #MISSION self -- @return #number function MISSION:GetTaskTypes() -- Determine how many tasks are remaining. @@ -865,7 +866,7 @@ end ---- - Aborted Tasks (xp) ---- - Failed Tasks (xp) ---- ----- @param #MISSION self +-- @param #MISSION self ---- @return #string --function MISSION:ReportSummary() -- @@ -1175,7 +1176,7 @@ end ---- @param #MISSION self +-- @param #MISSION self -- @param #string TaskStatus The status -- @param Wrapper.Group#GROUP ReportGroup function MISSION:MenuReportTasksPerStatus( ReportGroup, TaskStatus ) @@ -1186,7 +1187,7 @@ function MISSION:MenuReportTasksPerStatus( ReportGroup, TaskStatus ) end ---- @param #MISSION self +-- @param #MISSION self -- @param Wrapper.Group#GROUP ReportGroup function MISSION:MenuReportPlayersPerTask( ReportGroup ) @@ -1195,7 +1196,7 @@ function MISSION:MenuReportPlayersPerTask( ReportGroup ) self:GetCommandCenter():MessageTypeToGroup( Report, ReportGroup, MESSAGE.Type.Overview ) end ---- @param #MISSION self +-- @param #MISSION self -- @param Wrapper.Group#GROUP ReportGroup function MISSION:MenuReportPlayersProgress( ReportGroup ) diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 21be7dfd8..452f88242 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -220,7 +220,8 @@ -- @module Tasking.Task -- @image MOOSE.JPG ---- @type TASK +--- +-- @type TASK -- @field Core.Scheduler#SCHEDULER TaskScheduler -- @field Tasking.Mission#MISSION Mission -- @field Core.Set#SET_GROUP SetGroup The Set of Groups assigned to the Task @@ -726,7 +727,7 @@ function TASK:AddGroups( GroupSet ) GroupSet = GroupSet or SET_GROUP:New() self.SetGroup:ForEachGroup( - --- @param Wrapper.Group#GROUP GroupSet + -- @param Wrapper.Group#GROUP GroupSet function( GroupItem ) GroupSet:Add( GroupItem:GetName(), GroupItem) end @@ -819,7 +820,7 @@ end do -- Group Assignment - --- @param #TASK self + -- @param #TASK self -- @param Actions.Act_Assign#ACT_ASSIGN AcceptClass function TASK:SetAssignMethod( AcceptClass ) @@ -1199,7 +1200,7 @@ function TASK:RemoveAssignedMenuForGroup( TaskGroup ) end ---- @param #TASK self +-- @param #TASK self -- @param Wrapper.Group#GROUP TaskGroup function TASK:MenuAssignToGroup( TaskGroup ) @@ -1208,7 +1209,7 @@ function TASK:MenuAssignToGroup( TaskGroup ) self:AssignToGroup( TaskGroup ) end ---- @param #TASK self +-- @param #TASK self -- @param Wrapper.Group#GROUP TaskGroup function TASK:MenuMarkToGroup( TaskGroup ) self:F() diff --git a/Moose Development/Moose/Tasking/TaskInfo.lua b/Moose Development/Moose/Tasking/TaskInfo.lua index 4007230dc..428e629c9 100644 --- a/Moose Development/Moose/Tasking/TaskInfo.lua +++ b/Moose Development/Moose/Tasking/TaskInfo.lua @@ -11,7 +11,8 @@ -- @module Tasking.TaskInfo -- @image MOOSE.JPG ---- @type TASKINFO +--- +-- @type TASKINFO -- @extends Core.Base#BASE --- @@ -29,7 +30,8 @@ TASKINFO = { ClassName = "TASKINFO", } ---- @type TASKINFO.Detail #string A string that flags to document which level of detail needs to be shown in the report. +--- +-- @type TASKINFO.Detail #string A string that flags to document which level of detail needs to be shown in the report. -- -- - "M" for Markings on the Map (F10). -- - "S" for Summary Reports. @@ -279,7 +281,7 @@ function TASKINFO:AddCargoSet( SetCargo, Order, Detail, Keep ) local CargoReport = REPORT:New() CargoReport:Add( "" ) SetCargo:ForEachCargo( - --- @param Cargo.Cargo#CARGO Cargo + -- @param Cargo.Cargo#CARGO Cargo function( Cargo ) CargoReport:Add( string.format( ' - %s (%s) %s - status %s ', Cargo:GetName(), Cargo:GetType(), Cargo:GetTransportationMethod(), Cargo:GetCurrentState() ) ) end diff --git a/Moose Development/Moose/Tasking/Task_A2A.lua b/Moose Development/Moose/Tasking/Task_A2A.lua index a43c79c9f..9309526bb 100644 --- a/Moose Development/Moose/Tasking/Task_A2A.lua +++ b/Moose Development/Moose/Tasking/Task_A2A.lua @@ -173,19 +173,19 @@ do -- TASK_A2A end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Core.Set#SET_UNIT TargetSetUnit The set of targets. function TASK_A2A:SetTargetSetUnit( TargetSetUnit ) self.TargetSetUnit = TargetSetUnit end - --- @param #TASK_A2A self + -- @param #TASK_A2A self function TASK_A2A:GetPlannedMenuText() return self:GetStateString() .. " - " .. self:GetTaskName() .. " ( " .. self.TargetSetUnit:GetUnitTypesText() .. " )" end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Core.Point#COORDINATE RendezVousCoordinate The Coordinate object referencing to the 2D point where the RendezVous point is located on the map. -- @param #number RendezVousRange The RendezVousRange that defines when the player is considered to have arrived at the RendezVous point. -- @param Wrapper.Unit#UNIT TaskUnit @@ -198,7 +198,7 @@ do -- TASK_A2A ActRouteRendezVous:SetRange( RendezVousRange ) end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Wrapper.Unit#UNIT TaskUnit -- @return Core.Point#COORDINATE The Coordinate object referencing to the 2D point where the RendezVous point is located on the map. -- @return #number The RendezVousRange that defines when the player is considered to have arrived at the RendezVous point. @@ -210,7 +210,7 @@ do -- TASK_A2A return ActRouteRendezVous:GetCoordinate(), ActRouteRendezVous:GetRange() end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Core.Zone#ZONE_BASE RendezVousZone The Zone object where the RendezVous is located on the map. -- @param Wrapper.Unit#UNIT TaskUnit function TASK_A2A:SetRendezVousZone( RendezVousZone, TaskUnit ) @@ -221,7 +221,7 @@ do -- TASK_A2A ActRouteRendezVous:SetZone( RendezVousZone ) end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Wrapper.Unit#UNIT TaskUnit -- @return Core.Zone#ZONE_BASE The Zone object where the RendezVous is located on the map. function TASK_A2A:GetRendezVousZone( TaskUnit ) @@ -232,7 +232,7 @@ do -- TASK_A2A return ActRouteRendezVous:GetZone() end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Core.Point#COORDINATE TargetCoordinate The Coordinate object where the Target is located on the map. -- @param Wrapper.Unit#UNIT TaskUnit function TASK_A2A:SetTargetCoordinate( TargetCoordinate, TaskUnit ) @@ -243,7 +243,7 @@ do -- TASK_A2A ActRouteTarget:SetCoordinate( TargetCoordinate ) end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Wrapper.Unit#UNIT TaskUnit -- @return Core.Point#COORDINATE The Coordinate object where the Target is located on the map. function TASK_A2A:GetTargetCoordinate( TaskUnit ) @@ -254,7 +254,7 @@ do -- TASK_A2A return ActRouteTarget:GetCoordinate() end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Core.Zone#ZONE_BASE TargetZone The Zone object where the Target is located on the map. -- @param Wrapper.Unit#UNIT TaskUnit function TASK_A2A:SetTargetZone( TargetZone, Altitude, Heading, TaskUnit ) @@ -265,7 +265,7 @@ do -- TASK_A2A ActRouteTarget:SetZone( TargetZone, Altitude, Heading ) end - --- @param #TASK_A2A self + -- @param #TASK_A2A self -- @param Wrapper.Unit#UNIT TaskUnit -- @return Core.Zone#ZONE_BASE The Zone object where the Target is located on the map. function TASK_A2A:GetTargetZone( TaskUnit ) @@ -309,7 +309,7 @@ do -- TASK_A2A self:__Goal( -10 ) end - --- @param #TASK_A2A self + -- @param #TASK_A2A self function TASK_A2A:UpdateTaskInfo( DetectedItem ) if self:IsStatePlanned() or self:IsStateAssigned() then @@ -501,7 +501,7 @@ do -- TASK_A2A_SWEEP return self end - --- @param #TASK_A2A_SWEEP self + -- @param #TASK_A2A_SWEEP self function TASK_A2A_SWEEP:onafterGoal( TaskUnit, From, Event, To ) local TargetSetUnit = self.TargetSetUnit -- Core.Set#SET_UNIT diff --git a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua index 9b0f8f5b5..d592ad4a6 100644 --- a/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_A2A_Dispatcher.lua @@ -148,7 +148,7 @@ do -- TASK_A2A_DISPATCHER -- -- TaskDispatcher = TASK_A2A_DISPATCHER:New( ... ) -- - -- --- @param #TaskDispatcher self + -- -- @param #TaskDispatcher self -- -- @param #string From Contains the name of the state from where the Event was triggered. -- -- @param #string Event Contains the name of the event that was triggered. In this case Assign. -- -- @param #string To Contains the name of the state that will be transitioned to. diff --git a/Moose Development/Moose/Tasking/Task_CARGO.lua b/Moose Development/Moose/Tasking/Task_CARGO.lua index e2839d64e..be894d805 100644 --- a/Moose Development/Moose/Tasking/Task_CARGO.lua +++ b/Moose Development/Moose/Tasking/Task_CARGO.lua @@ -409,7 +409,7 @@ do -- TASK_CARGO - --- @type TASK_CARGO + -- @type TASK_CARGO -- @extends Tasking.Task#TASK --- Model tasks for players to transport Cargo. @@ -620,7 +620,7 @@ do -- TASK_CARGO Fsm:AddTransition( "Rejected", "Reject", "Aborted" ) Fsm:AddTransition( "Failed", "Fail", "Failed" ) - ---- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param #TASK_CARGO Task function Fsm:OnAfterAssigned( TaskUnit, Task ) @@ -643,7 +643,7 @@ do -- TASK_CARGO Task.SetCargo:ForEachCargo( - --- @param Cargo.Cargo#CARGO Cargo + -- @param Cargo.Cargo#CARGO Cargo function( Cargo ) if Cargo:IsAlive() then @@ -837,7 +837,7 @@ do -- TASK_CARGO --#Wrapper.Unit#UNIT - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task -- @param From @@ -857,7 +857,7 @@ do -- TASK_CARGO - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterArriveAtPickup( TaskUnit, Task ) @@ -873,7 +873,7 @@ do -- TASK_CARGO end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterCancelRouteToPickup( TaskUnit, Task ) @@ -884,7 +884,7 @@ do -- TASK_CARGO end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit function Fsm:onafterRouteToDeploy( TaskUnit, Task, From, Event, To, DeployZone ) self:F( { TaskUnit = TaskUnit, Task = Task and Task:GetClassNameAndID() } ) @@ -896,7 +896,7 @@ do -- TASK_CARGO end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterArriveAtDeploy( TaskUnit, Task ) @@ -911,7 +911,7 @@ do -- TASK_CARGO end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterCancelRouteToDeploy( TaskUnit, Task ) @@ -923,7 +923,7 @@ do -- TASK_CARGO - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterLand( TaskUnit, Task, From, Event, To, Action ) @@ -958,7 +958,7 @@ do -- TASK_CARGO end end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterLanded( TaskUnit, Task, From, Event, To, Action ) @@ -991,7 +991,7 @@ do -- TASK_CARGO end end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterPrepareBoarding( TaskUnit, Task, From, Event, To, Cargo ) @@ -1003,7 +1003,7 @@ do -- TASK_CARGO end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterBoard( TaskUnit, Task, From, Event, To, Cargo ) @@ -1031,7 +1031,7 @@ do -- TASK_CARGO end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterBoarded( TaskUnit, Task, From, Event, To, Cargo ) @@ -1046,7 +1046,7 @@ do -- TASK_CARGO end - --- @param #FSM_PROCESS self + -- @param #FSM_PROCESS self -- @param Wrapper.Unit#UNIT TaskUnit -- @param Tasking.Task_Cargo#TASK_CARGO Task function Fsm:onafterLoad( TaskUnit, Task, From, Event, To, Cargo ) @@ -1195,26 +1195,26 @@ do -- TASK_CARGO return self.SmokeColor end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self function TASK_CARGO:GetPlannedMenuText() return self:GetStateString() .. " - " .. self:GetTaskName() .. " ( " .. self.TargetSetUnit:GetUnitTypesText() .. " )" end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self -- @return Core.Set#SET_CARGO The Cargo Set. function TASK_CARGO:GetCargoSet() return self.SetCargo end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self -- @return #list The Deployment Zones. function TASK_CARGO:GetDeployZones() return self.DeployZones end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self -- @param AI.AI_Cargo#AI_CARGO Cargo The cargo. -- @param Wrapper.Unit#UNIT TaskUnit -- @return #TASK_CARGO @@ -1237,7 +1237,7 @@ do -- TASK_CARGO end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self -- @param Core.Zone#ZONE DeployZone -- @param Wrapper.Unit#UNIT TaskUnit -- @return #TASK_CARGO @@ -1258,7 +1258,7 @@ do -- TASK_CARGO end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self -- @param Core.Zone#ZONE DeployZone -- @param Wrapper.Unit#UNIT TaskUnit -- @return #TASK_CARGO @@ -1269,7 +1269,7 @@ do -- TASK_CARGO return self end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self -- @param Core.Zone#ZONE DeployZone -- @param Wrapper.Unit#UNIT TaskUnit -- @return #TASK_CARGO @@ -1280,7 +1280,7 @@ do -- TASK_CARGO return self end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self -- @param #list DeployZones -- @param Wrapper.Unit#UNIT TaskUnit -- @return #TASK_CARGO @@ -1295,7 +1295,7 @@ do -- TASK_CARGO - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self -- @param Wrapper.Unit#UNIT TaskUnit -- @return Core.Zone#ZONE_BASE The Zone object where the Target is located on the map. function TASK_CARGO:GetTargetZone( TaskUnit ) @@ -1364,7 +1364,7 @@ do -- TASK_CARGO return self.GoalTotal end - --- @param #TASK_CARGO self + -- @param #TASK_CARGO self function TASK_CARGO:UpdateTaskInfo() if self:IsStatePlanned() or self:IsStateAssigned() then diff --git a/Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua index be2086a2f..c9c476efa 100644 --- a/Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_Capture_Dispatcher.lua @@ -69,7 +69,7 @@ do -- TASK_CAPTURE_DISPATCHER -- @extends Tasking.Task_Manager#TASK_MANAGER -- @field TASK_CAPTURE_DISPATCHER.ZONE ZONE - --- @type TASK_CAPTURE_DISPATCHER.CSAR + -- @type TASK_CAPTURE_DISPATCHER.CSAR -- @field Wrapper.Unit#UNIT PilotUnit -- @field Tasking.Task#TASK Task diff --git a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua index bd0637a9d..33b464a35 100644 --- a/Moose Development/Moose/Tasking/Task_Capture_Zone.lua +++ b/Moose Development/Moose/Tasking/Task_Capture_Zone.lua @@ -119,7 +119,7 @@ do -- TASK_ZONE_GOAL end - --- @param #TASK_ZONE_GOAL self + -- @param #TASK_ZONE_GOAL self -- @param Functional.ZoneGoal#ZONE_GOAL ZoneGoal The ZoneGoal Engine. function TASK_ZONE_GOAL:SetProtect( ZoneGoal ) @@ -128,13 +128,13 @@ do -- TASK_ZONE_GOAL - --- @param #TASK_ZONE_GOAL self + -- @param #TASK_ZONE_GOAL self function TASK_ZONE_GOAL:GetPlannedMenuText() return self:GetStateString() .. " - " .. self:GetTaskName() .. " ( " .. self.ZoneGoal:GetZoneName() .. " )" end - --- @param #TASK_ZONE_GOAL self + -- @param #TASK_ZONE_GOAL self -- @param Core.Zone#ZONE_BASE TargetZone The Zone object where the Target is located on the map. -- @param Wrapper.Unit#UNIT TaskUnit function TASK_ZONE_GOAL:SetTargetZone( TargetZone, TaskUnit ) @@ -146,7 +146,7 @@ do -- TASK_ZONE_GOAL end - --- @param #TASK_ZONE_GOAL self + -- @param #TASK_ZONE_GOAL self -- @param Wrapper.Unit#UNIT TaskUnit -- @return Core.Zone#ZONE_BASE The Zone object where the Target is located on the map. function TASK_ZONE_GOAL:GetTargetZone( TaskUnit ) @@ -286,7 +286,7 @@ do -- TASK_CAPTURE_ZONE end - --- @param #TASK_CAPTURE_ZONE self + -- @param #TASK_CAPTURE_ZONE self -- @param Wrapper.Unit#UNIT TaskUnit function TASK_CAPTURE_ZONE:OnAfterGoal( From, Event, To, PlayerUnit, PlayerName ) diff --git a/Moose Development/Moose/Tasking/Task_Cargo_CSAR.lua b/Moose Development/Moose/Tasking/Task_Cargo_CSAR.lua index f0c14b227..e27a225c0 100644 --- a/Moose Development/Moose/Tasking/Task_Cargo_CSAR.lua +++ b/Moose Development/Moose/Tasking/Task_Cargo_CSAR.lua @@ -72,8 +72,8 @@ do -- TASK_CARGO_CSAR - --- @type TASK_CARGO_CSAR - -- @extends Tasking.Task_CARGO#TASK_CARGO + -- @type TASK_CARGO_CSAR + -- @extends Tasking.Task_Cargo#TASK_CARGO --- Orchestrates the task for players to execute CSAR for downed pilots. -- diff --git a/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua b/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua index d60318573..f78b2d5cd 100644 --- a/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua +++ b/Moose Development/Moose/Tasking/Task_Cargo_Dispatcher.lua @@ -77,7 +77,7 @@ do -- TASK_CARGO_DISPATCHER -- @field TASK_CARGO_DISPATCHER.CSAR CSAR -- @field Core.Set#SET_ZONE SetZonesCSAR - --- @type TASK_CARGO_DISPATCHER.CSAR + -- @type TASK_CARGO_DISPATCHER.CSAR -- @field Wrapper.Unit#UNIT PilotUnit -- @field Tasking.Task#TASK Task diff --git a/Moose Development/Moose/Tasking/Task_Cargo_Transport.lua b/Moose Development/Moose/Tasking/Task_Cargo_Transport.lua index 6f8137c6a..6293f03fa 100644 --- a/Moose Development/Moose/Tasking/Task_Cargo_Transport.lua +++ b/Moose Development/Moose/Tasking/Task_Cargo_Transport.lua @@ -285,7 +285,7 @@ do -- TASK_CARGO_TRANSPORT local CargoReport = REPORT:New( "Transport Cargo. The following cargo needs to be transported including initial positions:") SetCargo:ForEachCargo( - --- @param Core.Cargo#CARGO Cargo + -- @param Core.Cargo#CARGO Cargo function( Cargo ) local CargoType = Cargo:GetType() local CargoName = Cargo:GetName() @@ -348,7 +348,7 @@ do -- TASK_CARGO_TRANSPORT return CargoDeployed end - --- @param #TASK_CARGO_TRANSPORT self + -- @param #TASK_CARGO_TRANSPORT self function TASK_CARGO_TRANSPORT:onafterGoal( TaskUnit, From, Event, To ) local CargoSet = self.CargoSet diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index f181cbd23..fb552427d 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -671,7 +671,7 @@ function POSITIONABLE:GetBoundingRadius( MinDist ) return math.max( math.max( CX, CZ ), boxmin ) end - BASE:E( { "Cannot GetBoundingRadius", Positionable = self, Alive = self:IsAlive() } ) + BASE:T( { "Cannot GetBoundingRadius", Positionable = self, Alive = self:IsAlive() } ) return nil end diff --git a/Moose Setup/Moose.files b/Moose Setup/Moose.files index 855c0c4f2..81a99772a 100644 --- a/Moose Setup/Moose.files +++ b/Moose Setup/Moose.files @@ -2,7 +2,6 @@ Utilities/Enums.lua Utilities/Utils.lua Utilities/Enums.lua Utilities/Profiler.lua -Utilities/Templates.lua Utilities/STTS.lua Utilities/FiFo.lua Utilities/Socket.lua @@ -17,19 +16,17 @@ Core/Event.lua Core/Settings.lua Core/Menu.lua Core/Zone.lua -Core/Zone_Detection.lua Core/Database.lua Core/Set.lua Core/Point.lua -Core/Velocity.lua Core/Message.lua Core/Fsm.lua Core/Spawn.lua Core/SpawnStatic.lua Core/Timer.lua -Core/Goal.lua Core/Spot.lua -Core/TextAndSound.lua +Core/MarkerOps_Base.lua +Core/Astar.lua Core/Condition.lua Core/Pathline.lua Core/ClientMenu.lua @@ -51,26 +48,17 @@ Wrapper/Weapon.lua Wrapper/Net.lua Wrapper/Storage.lua -Cargo/Cargo.lua -Cargo/CargoUnit.lua -Cargo/CargoSlingload.lua -Cargo/CargoCrate.lua -Cargo/CargoGroup.lua - Functional/Scoring.lua Functional/CleanUp.lua Functional/Movement.lua Functional/Sead.lua Functional/Escort.lua -Functional/MissileTrainer.lua Functional/ATC_Ground.lua Functional/Detection.lua Functional/DetectionZones.lua Functional/Designate.lua Functional/RAT.lua Functional/Range.lua -Functional/ZoneGoal.lua -Functional/ZoneGoalCoalition.lua Functional/ZoneCaptureCoalition.lua Functional/Artillery.lua Functional/Suppression.lua @@ -85,7 +73,6 @@ Functional/AmmoTruck.lua Functional/ZoneGoalCargo.lua Functional/Tiresias.lua Functional/Stratego.lua -Functional/ClientWatch.lua Ops/Airboss.lua Ops/RecoveryTanker.lua @@ -119,43 +106,6 @@ Ops/ArmyGroup.lua Ops/OpsTransport.lua Ops/Target.lua -AI/AI_Balancer.lua -AI/AI_Air.lua -AI/AI_Air_Patrol.lua -AI/AI_Air_Engage.lua -AI/AI_A2A_Patrol.lua -AI/AI_A2A_Cap.lua -AI/AI_A2A_Gci.lua -AI/AI_A2A_Dispatcher.lua -AI/AI_A2G_BAI.lua -AI/AI_A2G_CAS.lua -AI/AI_A2G_SEAD.lua -AI/AI_A2G_Dispatcher.lua -AI/AI_Patrol.lua -AI/AI_CAP.lua -AI/AI_CAS.lua -AI/AI_BAI.lua -AI/AI_Formation.lua -AI/AI_Escort.lua -AI/AI_Escort_Request.lua -AI/AI_Escort_Dispatcher.lua -AI/AI_Escort_Dispatcher_Request.lua -AI/AI_Cargo.lua -AI/AI_Cargo_APC.lua -AI/AI_Cargo_Helicopter.lua -AI/AI_Cargo_Airplane.lua -AI/AI_Cargo_Ship.lua -AI/AI_Cargo_Dispatcher.lua -AI/AI_Cargo_Dispatcher_APC.lua -AI/AI_Cargo_Dispatcher_Helicopter.lua -AI/AI_Cargo_Dispatcher_Airplane.lua -AI/AI_Cargo_Dispatcher_Ship.lua - -Actions/Act_Assign.lua -Actions/Act_Route.lua -Actions/Act_Account.lua -Actions/Act_Assist.lua - Sound/UserSound.lua Sound/SoundOutput.lua Sound/Radio.lua @@ -163,21 +113,4 @@ Sound/RadioQueue.lua Sound/RadioSpeech.lua Sound/SRS.lua -Tasking/CommandCenter.lua -Tasking/Mission.lua -Tasking/Task.lua -Tasking/TaskInfo.lua -Tasking/Task_Manager.lua -Tasking/DetectionManager.lua -Tasking/Task_A2G_Dispatcher.lua -Tasking/Task_A2G.lua -Tasking/Task_A2A_Dispatcher.lua -Tasking/Task_A2A.lua -Tasking/Task_CARGO.lua -Tasking/Task_Cargo_Transport.lua -Tasking/Task_Cargo_CSAR.lua -Tasking/Task_Cargo_Dispatcher.lua -Tasking/Task_Capture_Zone.lua -Tasking/Task_Capture_Dispatcher.lua - Globals.lua diff --git a/Moose Setup/Moose_Create.lua b/Moose Setup/Moose_Create.lua index a69a34a18..e060d8238 100644 --- a/Moose Setup/Moose_Create.lua +++ b/Moose Setup/Moose_Create.lua @@ -1,4 +1,4 @@ --- This routine is called from the LDT environment to create the Moose.lua file stub for use in .miz files. +--- This routine is called from the LDT environment to create the Moose.lua file stub for use in .miz files. local MooseDynamicStatic = arg[1] local MooseCommitHash = arg[2]