From a34e4c68d070538b8df997f7b9ae097313218608 Mon Sep 17 00:00:00 2001 From: FlightControl Date: Thu, 2 Jun 2016 14:49:10 +0200 Subject: [PATCH] Added lots of functions in GROUP --- Moose Development/Moose/Airbase.lua | 290 +++ Moose Development/Moose/Group.lua | 1737 +++++++++++----- .../l10n/DEFAULT/Moose.lua | 1739 ++++++++++++----- Moose Mission Setup/Moose.lua | 1739 ++++++++++++----- Moose Training/Documentation/Airbase.html | 662 +++++++ Moose Training/Documentation/Base.html | 1 + Moose Training/Documentation/CARGO.html | 1 + Moose Training/Documentation/CleanUp.html | 1 + Moose Training/Documentation/Client.html | 1 + Moose Training/Documentation/DCSAirbase.html | 1 + .../Documentation/DCSCoalitionObject.html | 1 + Moose Training/Documentation/DCSCommand.html | 1 + .../Documentation/DCSController.html | 1 + Moose Training/Documentation/DCSGroup.html | 1 + Moose Training/Documentation/DCSObject.html | 1 + Moose Training/Documentation/DCSTask.html | 1 + Moose Training/Documentation/DCSTypes.html | 1 + Moose Training/Documentation/DCSUnit.html | 1 + Moose Training/Documentation/DCSWorld.html | 1 + Moose Training/Documentation/DCStimer.html | 1 + Moose Training/Documentation/DEPLOYTASK.html | 1 + .../Documentation/DESTROYBASETASK.html | 1 + .../Documentation/DESTROYGROUPSTASK.html | 1 + .../Documentation/DESTROYRADARSTASK.html | 1 + .../Documentation/DESTROYUNITTYPESTASK.html | 1 + Moose Training/Documentation/Database.html | 1 + Moose Training/Documentation/Escort.html | 1 + Moose Training/Documentation/Event.html | 1 + Moose Training/Documentation/GOHOMETASK.html | 1 + Moose Training/Documentation/Group.html | 952 ++++++++- Moose Training/Documentation/GroupSet.html | 1 + Moose Training/Documentation/MISSION.html | 1 + Moose Training/Documentation/MOVEMENT.html | 1 + Moose Training/Documentation/Menu.html | 1 + Moose Training/Documentation/Message.html | 1 + .../Documentation/MissileTrainer.html | 1 + Moose Training/Documentation/NOTASK.html | 1 + Moose Training/Documentation/PICKUPTASK.html | 1 + Moose Training/Documentation/ROUTETASK.html | 1 + Moose Training/Documentation/STAGE.html | 1 + Moose Training/Documentation/Scheduler.html | 1 + Moose Training/Documentation/Scoring.html | 1 + Moose Training/Documentation/Sead.html | 1 + Moose Training/Documentation/Set.html | 1 + Moose Training/Documentation/Spawn.html | 1 + .../Documentation/StaticObject.html | 1 + Moose Training/Documentation/TASK.html | 1 + Moose Training/Documentation/Unit.html | 1 + Moose Training/Documentation/UnitSet.html | 1 + Moose Training/Documentation/Zone.html | 1 + Moose Training/Documentation/env.html | 1 + Moose Training/Documentation/index.html | 14 + Moose Training/Documentation/land.html | 1 + Moose Training/Documentation/routines.html | 1 + 54 files changed, 5548 insertions(+), 1632 deletions(-) create mode 100644 Moose Development/Moose/Airbase.lua create mode 100644 Moose Training/Documentation/Airbase.html diff --git a/Moose Development/Moose/Airbase.lua b/Moose Development/Moose/Airbase.lua new file mode 100644 index 000000000..970e8ddfa --- /dev/null +++ b/Moose Development/Moose/Airbase.lua @@ -0,0 +1,290 @@ +--- AIRBASE Class +-- +-- @{AIRBASE} class +-- ============== +-- The @{AIRBASE} class is a wrapper class to handle the DCS Airbase objects: +-- +-- * Support all DCS Airbase APIs. +-- * Enhance with Airbase specific APIs not in the DCS Airbase API set. +-- +-- +-- AIRBASE reference methods +-- ====================== +-- For each DCS Airbase object alive within a running mission, a AIRBASE wrapper object (instance) will be created within the _@{DATABASE} object. +-- This is done at the beginning of the mission (when the mission starts). +-- +-- The AIRBASE class **does not contain a :New()** method, rather it provides **:Find()** methods to retrieve the object reference +-- using the DCS Airbase or the DCS AirbaseName. +-- +-- Another thing to know is that AIRBASE objects do not "contain" the DCS Airbase object. +-- The AIRBASE methods will reference the DCS Airbase object by name when it is needed during API execution. +-- If the DCS Airbase object does not exist or is nil, the AIRBASE methods will return nil and log an exception in the DCS.log file. +-- +-- The AIRBASE class provides the following functions to retrieve quickly the relevant AIRBASE instance: +-- +-- * @{#AIRBASE.Find}(): Find a AIRBASE instance from the _DATABASE object using a DCS Airbase object. +-- * @{#AIRBASE.FindByName}(): Find a AIRBASE instance from the _DATABASE object using a DCS Airbase name. +-- +-- IMPORTANT: ONE SHOULD NEVER SANATIZE these AIRBASE OBJECT REFERENCES! (make the AIRBASE object references nil). +-- +-- DCS AIRBASE APIs +-- ============= +-- The DCS Airbase APIs are used extensively within MOOSE. The AIRBASE class has for each DCS Airbase API a corresponding method. +-- To be able to distinguish easily in your code the difference between a AIRBASE API call and a DCS Airbase API call, +-- the first letter of the method is also capitalized. So, by example, the DCS Airbase method @{DCSAirbase#Airbase.getName}() +-- is implemented in the AIRBASE class as @{#AIRBASE.GetName}(). +-- +-- More functions will be added +-- ---------------------------- +-- During the MOOSE development, more functions will be added. +-- +-- @module Airbase +-- @author FlightControl + +Include.File( "Routines" ) +Include.File( "Base" ) +Include.File( "Message" ) + +--- The AIRBASE class +-- @type AIRBASE +-- @extends Base#BASE +AIRBASE = { + ClassName="AIRBASE", + CategoryName = { + [Airbase.Category.AIRDROME] = "Airdrome", + [Airbase.Category.HELIPAD] = "Helipad", + [Airbase.Category.SHIP] = "Ship", + }, + } + +-- Registration. + +--- Create a new AIRBASE from DCSAirbase. +-- @param #AIRBASE self +-- @param DCSAirbase#Airbase DCSAirbase +-- @param Database#DATABASE Database +-- @return Airbase#AIRBASE +function AIRBASE:Register( AirbaseName ) + + local self = BASE:Inherit( self, BASE:New() ) + self:F2( AirbaseName ) + self.AirbaseName = AirbaseName + return self +end + +-- Reference methods. + +--- Finds a AIRBASE from the _DATABASE using a DCSAirbase object. +-- @param #AIRBASE self +-- @param DCSAirbase#Airbase DCSAirbase An existing DCS Airbase object reference. +-- @return Airbase#AIRBASE self +function AIRBASE:Find( DCSAirbase ) + + local AirbaseName = DCSAirbase:getName() + local AirbaseFound = _DATABASE:FindAirbase( AirbaseName ) + return AirbaseFound +end + +--- Find a AIRBASE in the _DATABASE using the name of an existing DCS Airbase. +-- @param #AIRBASE self +-- @param #string AirbaseName The Airbase Name. +-- @return Airbase#AIRBASE self +function AIRBASE:FindByName( AirbaseName ) + + local AirbaseFound = _DATABASE:FindAirbase( AirbaseName ) + return AirbaseFound +end + +function AIRBASE:GetDCSAirbase() + local DCSAirbase = Airbase.getByName( self.AirbaseName ) + + if DCSAirbase then + return DCSAirbase + end + + return nil +end + +--- Returns coalition of the Airbase. +-- @param Airbase#AIRBASE self +-- @return DCSCoalitionObject#coalition.side The side of the coalition. +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:GetCoalition() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseCoalition = DCSAirbase:getCoalition() + self:T3( AirbaseCoalition ) + return AirbaseCoalition + end + + return nil +end + +--- Returns country of the Airbase. +-- @param Airbase#AIRBASE self +-- @return DCScountry#country.id The country identifier. +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:GetCountry() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseCountry = DCSAirbase:getCountry() + self:T3( AirbaseCountry ) + return AirbaseCountry + end + + return nil +end + + +--- Returns DCS Airbase object name. +-- The function provides access to non-activated units too. +-- @param Airbase#AIRBASE self +-- @return #string The name of the DCS Airbase. +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:GetName() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseName = self.AirbaseName + return AirbaseName + end + + return nil +end + + +--- Returns if the airbase is alive. +-- @param Airbase#AIRBASE self +-- @return #boolean true if Airbase is alive. +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:IsAlive() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseIsAlive = DCSAirbase:isExist() + return AirbaseIsAlive + end + + return false +end + +--- Returns the unit's unique identifier. +-- @param Airbase#AIRBASE self +-- @return DCSAirbase#Airbase.ID Airbase ID +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:GetID() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseID = DCSAirbase:getID() + return AirbaseID + end + + return nil +end + +--- Returns the Airbase's callsign - the localized string. +-- @param Airbase#AIRBASE self +-- @return #string The Callsign of the Airbase. +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:GetCallSign() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseCallSign = DCSAirbase:getCallsign() + return AirbaseCallSign + end + + return nil +end + + + +--- Returns unit descriptor. Descriptor type depends on unit category. +-- @param Airbase#AIRBASE self +-- @return DCSAirbase#Airbase.Desc The Airbase descriptor. +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:GetDesc() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseDesc = DCSAirbase:getDesc() + return AirbaseDesc + end + + return nil +end + + +--- Returns the type name of the DCS Airbase. +-- @param Airbase#AIRBASE self +-- @return #string The type name of the DCS Airbase. +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:GetTypeName() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseTypeName = DCSAirbase:getTypeName() + self:T3( AirbaseTypeName ) + return AirbaseTypeName + end + + return nil +end + + +--- Returns the @{DCSTypes#Vec2} vector indicating the point in 2D of the DCS Airbase within the mission. +-- @param Airbase#AIRBASE self +-- @return DCSTypes#Vec2 The 2D point vector of the DCS Airbase. +-- @return #nil The DCS Airbase is not existing or alive. +function AIRBASE:GetPointVec2() + self:F2( self.AirbaseName ) + + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbasePointVec3 = DCSAirbase:getPosition().p + + local AirbasePointVec2 = {} + AirbasePointVec2.x = AirbasePointVec3.x + AirbasePointVec2.y = AirbasePointVec3.z + + self:T3( AirbasePointVec2 ) + return AirbasePointVec2 + end + + return nil +end + +--- Returns the DCS Airbase category name as defined within the DCS Airbase Descriptor. +-- @param Airbase#AIRBASE self +-- @return #string The DCS Airbase Category Name +function AIRBASE:GetCategoryName() + local DCSAirbase = self:GetDCSAirbase() + + if DCSAirbase then + local AirbaseCategoryName = self.CategoryName[ self:GetDesc().category ] + return AirbaseCategoryName + end + + return nil +end + diff --git a/Moose Development/Moose/Group.lua b/Moose Development/Moose/Group.lua index 27e972843..818d21eb9 100644 --- a/Moose Development/Moose/Group.lua +++ b/Moose Development/Moose/Group.lua @@ -1,32 +1,32 @@ ---- GROUP class. --- +--- GROUP class. +-- -- @{GROUP} class -- ============== -- The @{GROUP} class is a wrapper class to handle the DCS Group objects: --- +-- -- * Support all DCS Group APIs. -- * Enhance with Group specific APIs not in the DCS Group API set. -- * Handle local Group Controller. -- * Manage the "state" of the DCS Group. --- --- +-- +-- -- GROUP reference methods --- ======================= +-- ======================= -- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object. -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class). --- +-- -- The GROUP class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference -- using the DCS Group or the DCS GroupName. --- --- Another thing to know is that GROUP objects do not "contain" the DCS Group object. +-- +-- Another thing to know is that GROUP objects do not "contain" the DCS Group object. -- The GROUP methods will reference the DCS Group object by name when it is needed during API execution. -- If the DCS Group object does not exist or is nil, the GROUP methods will return nil and log an exception in the DCS.log file. --- +-- -- The GROUP class provides the following functions to retrieve quickly the relevant GROUP instance: --- +-- -- * @{#GROUP.Find}(): Find a GROUP instance from the _DATABASE object using a DCS Group object. -- * @{#GROUP.FindByName}(): Find a GROUP instance from the _DATABASE object using a DCS Group name. --- +-- -- IMPORTANT: ONE SHOULD NEVER SANATIZE these GROUP OBJECT REFERENCES! (make the GROUP object references nil). -- @module Group -- @author FlightControl @@ -42,14 +42,14 @@ Include.File( "Unit" ) -- @field DCSGroup#Group DCSGroup The DCS group class. -- @field #string GroupName The name of the group. GROUP = { - ClassName = "GROUP", - GroupName = "", - GroupID = 0, - Controller = nil, - DCSGroup = nil, - WayPointFunctions = {}, - } - + ClassName = "GROUP", + GroupName = "", + GroupID = 0, + Controller = nil, + DCSGroup = nil, + WayPointFunctions = {}, +} + --- A DCSGroup -- @type DCSGroup -- @field id_ The ID of the group in DCS @@ -59,10 +59,10 @@ GROUP = { -- @param DCSGroup#Group GroupName The DCS Group name -- @return #GROUP self function GROUP:Register( GroupName ) - local self = BASE:Inherit( self, BASE:New() ) - self:F2( GroupName ) - self.GroupName = GroupName - return self + local self = BASE:Inherit( self, BASE:New() ) + self:F2( GroupName ) + self.GroupName = GroupName + return self end -- Reference methods. @@ -95,11 +95,11 @@ end -- @return DCSGroup#Group The DCS Group. function GROUP:GetDCSGroup() local DCSGroup = Group.getByName( self.GroupName ) - + if DCSGroup then return DCSGroup end - + return nil end @@ -110,27 +110,27 @@ end -- @return #boolean true if the DCS Group is alive. function GROUP:IsAlive() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupIsAlive = DCSGroup:isExist() self:T3( GroupIsAlive ) return GroupIsAlive end - + return nil end ---- Destroys the DCS Group and all of its DCS Units. +--- Destroys the DCS Group and all of its DCS Units. -- Note that this destroy method also raises a destroy event at run-time. -- So all event listeners will catch the destroy event of this DCS Group. -- @param #GROUP self function GROUP:Destroy() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then for Index, UnitData in pairs( DCSGroup:getUnits() ) do self:CreateEventCrash( timer.getTime(), UnitData ) @@ -138,11 +138,11 @@ function GROUP:Destroy() DCSGroup:destroy() DCSGroup = nil end - + return nil end ---- Returns category of the DCS Group. +--- Returns category of the DCS Group. -- @param #GROUP self -- @return DCSGroup#Group.Category The category ID function GROUP:GetCategory() @@ -154,7 +154,7 @@ function GROUP:GetCategory() self:T3( GroupCategory ) return GroupCategory end - + return nil end @@ -170,14 +170,14 @@ function GROUP:GetCategoryName() [Group.Category.AIRPLANE] = "Airplane", [Group.Category.HELICOPTER] = "Helicopter", [Group.Category.GROUND] = "Ground Unit", - [Group.Category.SHIP] = "Ship", + [Group.Category.SHIP] = "Ship", } local GroupCategory = DCSGroup:getCategory() self:T3( GroupCategory ) - + return CategoryNames[GroupCategory] end - + return nil end @@ -194,14 +194,14 @@ function GROUP:GetCoalition() self:T3( GroupCoalition ) return GroupCoalition end - + return nil end --- Returns the country of the DCS Group. -- @param #GROUP self -- @return DCScountry#country.id The country identifier. --- @return #nil The DCS Group is not existing or alive. +-- @return #nil The DCS Group is not existing or alive. function GROUP:GetCountry() self:F2( self.GroupName ) @@ -211,7 +211,7 @@ function GROUP:GetCountry() self:T3( GroupCountry ) return GroupCountry end - + return nil end @@ -222,13 +222,13 @@ function GROUP:GetName() self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupName = DCSGroup:getName() self:T3( GroupName ) return GroupName end - + return nil end @@ -237,19 +237,19 @@ end -- @return #number The identifier of the DCS Group. function GROUP:GetID() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupID = DCSGroup:getID() self:T3( GroupID ) return GroupID end - + return nil end ---- Returns the UNIT wrapper class with number UnitNumber. +--- Returns the UNIT wrapper class with number UnitNumber. -- If the underlying DCS Unit does not exist, the method will return nil. . -- @param #GROUP self -- @param #number UnitNumber The number of the UNIT wrapper class to be returned. @@ -258,7 +258,7 @@ function GROUP:GetUnit( UnitNumber ) self:F2( { self.GroupName, UnitNumber } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local UnitFound = UNIT:Find( DCSGroup:getUnit( UnitNumber ) ) self:T3( UnitFound.UnitName ) @@ -269,7 +269,7 @@ function GROUP:GetUnit( UnitNumber ) return nil end ---- Returns the DCS Unit with number UnitNumber. +--- Returns the DCS Unit with number UnitNumber. -- If the underlying DCS Unit does not exist, the method will return nil. . -- @param #GROUP self -- @param #number UnitNumber The number of the DCS Unit to be returned. @@ -278,7 +278,7 @@ function GROUP:GetDCSUnit( UnitNumber ) self:F2( { self.GroupName, UnitNumber } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnitFound = DCSGroup:getUnit( UnitNumber ) self:T3( DCSUnitFound ) @@ -288,14 +288,14 @@ function GROUP:GetDCSUnit( UnitNumber ) return nil end ---- Returns current size of the DCS Group. --- If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed. +--- Returns current size of the DCS Group. +-- If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed. -- @param #GROUP self -- @return #number The DCS Group size. function GROUP:GetSize() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupSize = DCSGroup:getSize() self:T3( GroupSize ) @@ -305,15 +305,15 @@ function GROUP:GetSize() return nil end ---- ---- Returns the initial size of the DCS Group. --- If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged. +--- +--- Returns the initial size of the DCS Group. +-- If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged. -- @param #GROUP self -- @return #number The DCS Group initial size. function GROUP:GetInitialSize() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupInitialSize = DCSGroup:getInitialSize() self:T3( GroupInitialSize ) @@ -329,7 +329,7 @@ end function GROUP:GetUnits() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnits = DCSGroup:getUnits() local Units = {} @@ -350,7 +350,7 @@ end function GROUP:GetDCSUnits() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnits = DCSGroup:getUnits() self:T3( DCSUnits ) @@ -366,7 +366,7 @@ end function GROUP:_GetController() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupController = DCSGroup:getController() self:T3( GroupController ) @@ -386,7 +386,7 @@ end function GROUP:WayPointInitialize() self.WayPoints = self:GetTaskRoute() - + return self end @@ -399,7 +399,7 @@ end -- @return #GROUP function GROUP:WayPointFunction( WayPoint, WayPointIndex, WayPointFunction, ... ) self:F2( { WayPoint, WayPointIndex, WayPointFunction } ) - + table.insert( self.WayPoints[WayPoint].task.params.tasks, WayPointIndex ) self.WayPoints[WayPoint].task.params.tasks[WayPointIndex] = self:TaskFunction( WayPoint, WayPointIndex, WayPointFunction, arg ) return self @@ -409,7 +409,7 @@ end function GROUP:TaskFunction( WayPoint, WayPointIndex, FunctionString, FunctionArguments ) local DCSTask - + local DCSScript = {} DCSScript[#DCSScript+1] = "local MissionGroup = GROUP:Find( ... ) " @@ -417,16 +417,16 @@ function GROUP:TaskFunction( WayPoint, WayPointIndex, FunctionString, FunctionAr DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup, " .. table.concat( FunctionArguments, "," ) .. ")" else DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup )" - end - - DCSTask = self:TaskWrappedAction( + end + + DCSTask = self:TaskWrappedAction( self:CommandDoScript( table.concat( DCSScript ) ), WayPointIndex ) - + self:T3( DCSTask ) - + return DCSTask end @@ -445,14 +445,14 @@ function GROUP:WayPointExecute( WayPoint, WaitTime ) if not WayPoint then WayPoint = 1 end - + -- When starting the mission from a certain point, the TaskPoints need to be deleted before the given WayPoint. for TaskPointID = 1, WayPoint - 1 do table.remove( self.WayPoints, 1 ) end self:T3( self.WayPoints ) - + self:SetTask( self:TaskRoute( self.WayPoints ), WaitTime ) return self @@ -462,9 +462,9 @@ end --- Activates a GROUP. -- @param #GROUP self function GROUP:Activate() - self:F2( { self.GroupName } ) - trigger.action.activateGroup( self:GetDCSGroup() ) - return self:GetDCSGroup() + self:F2( { self.GroupName } ) + trigger.action.activateGroup( self:GetDCSGroup() ) + return self:GetDCSGroup() end @@ -475,13 +475,13 @@ function GROUP:GetTypeName() self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupTypeName = DCSGroup:getUnit(1):getTypeName() self:T3( GroupTypeName ) return( GroupTypeName ) end - + return nil end @@ -490,33 +490,33 @@ end -- @return #string The CallSign of the first DCS Unit of the DCS Group. function GROUP:GetCallsign() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCallSign = DCSGroup:getUnit(1):getCallsign() self:T3( GroupCallSign ) return GroupCallSign end - + return nil end --- Returns the current point (Vec2 vector) of the first DCS Unit in the DCS Group. -- @return DCSTypes#Vec2 Current Vec2 point of the first DCS Unit of the DCS Group. function GROUP:GetPointVec2() - self:F2( self.GroupName ) - - local GroupPointVec2 = self:GetUnit(1):GetPointVec2() - self:T3( GroupPointVec2 ) - return GroupPointVec2 + self:F2( self.GroupName ) + + local GroupPointVec2 = self:GetUnit(1):GetPointVec2() + self:T3( GroupPointVec2 ) + return GroupPointVec2 end --- Returns the current point (Vec3 vector) of the first DCS Unit in the DCS Group. -- @return DCSTypes#Vec3 Current Vec3 point of the first DCS Unit of the DCS Group. function GROUP:GetPointVec3() - self:F2( self.GroupName ) - + self:F2( self.GroupName ) + local GroupPointVec3 = self:GetUnit(1):GetPointVec3() self:T3( GroupPointVec3 ) return GroupPointVec3 @@ -531,16 +531,16 @@ end -- @param #GROUP self -- @return #boolean Air category evaluation result. function GROUP:IsAir() - self:F2( self.GroupName ) + self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local IsAirResult = DCSGroup:getCategory() == Group.Category.AIRPLANE or DCSGroup:getCategory() == Group.Category.HELICOPTER - self:T3( IsAirResult ) - return IsAirResult + local IsAirResult = DCSGroup:getCategory() == Group.Category.AIRPLANE or DCSGroup:getCategory() == Group.Category.HELICOPTER + self:T3( IsAirResult ) + return IsAirResult end - + return nil end @@ -549,15 +549,15 @@ end -- @return #boolean true if DCS Group contains Helicopters. function GROUP:IsHelicopter() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.HELICOPTER end - + return nil end @@ -566,15 +566,15 @@ end -- @return #boolean true if DCS Group contains AirPlanes. function GROUP:IsAirPlane() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.AIRPLANE end - + return nil end @@ -583,15 +583,15 @@ end -- @return #boolean true if DCS Group contains Ground troops. function GROUP:IsGround() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.GROUND end - + return nil end @@ -600,15 +600,15 @@ end -- @return #boolean true if DCS Group contains Ships. function GROUP:IsShip() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.SHIP end - + return nil end @@ -617,23 +617,23 @@ end -- @param #GROUP self -- @return #boolean All units on the ground result. function GROUP:AllOnGround() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local AllOnGroundResult = true - - for Index, UnitData in pairs( DCSGroup:getUnits() ) do - if UnitData:inAir() then - AllOnGroundResult = false - end - end - - self:T3( AllOnGroundResult ) - return AllOnGroundResult + local AllOnGroundResult = true + + for Index, UnitData in pairs( DCSGroup:getUnits() ) do + if UnitData:inAir() then + AllOnGroundResult = false + end + end + + self:T3( AllOnGroundResult ) + return AllOnGroundResult end - + return nil end @@ -642,26 +642,26 @@ end -- @param #GROUP self -- @return #number Maximum velocity found. function GROUP:GetMaxVelocity() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local MaxVelocity = 0 - - for Index, UnitData in pairs( DCSGroup:getUnits() ) do - - local Velocity = UnitData:getVelocity() - local VelocityTotal = math.abs( Velocity.x ) + math.abs( Velocity.y ) + math.abs( Velocity.z ) - - if VelocityTotal < MaxVelocity then - MaxVelocity = VelocityTotal - end - end - - return MaxVelocity + local MaxVelocity = 0 + + for Index, UnitData in pairs( DCSGroup:getUnits() ) do + + local Velocity = UnitData:getVelocity() + local VelocityTotal = math.abs( Velocity.x ) + math.abs( Velocity.y ) + math.abs( Velocity.z ) + + if VelocityTotal < MaxVelocity then + MaxVelocity = VelocityTotal + end + end + + return MaxVelocity end - + return nil end @@ -670,7 +670,7 @@ end -- @param #GROUP self -- @return #number Minimum height found. function GROUP:GetMinHeight() - self:F2() + self:F2() end @@ -679,7 +679,7 @@ end -- @param #GROUP self -- @return #number Maximum height found. function GROUP:GetMaxHeight() - self:F2() + self:F2() end @@ -689,16 +689,16 @@ end -- @param #GROUP self -- @return Group#GROUP self function GROUP:PopCurrentTask() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() Controller:popTask() return self end - + return nil end @@ -706,27 +706,27 @@ end -- @param #GROUP self -- @return Group#GROUP self function GROUP:PushTask( DCSTask, WaitTime ) - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() - + -- When a group SPAWNs, it takes about a second to get the group in the simulator. Setting tasks to unspawned groups provides unexpected results. -- Therefore we schedule the functions to set the mission and options for the Group. -- Controller:pushTask( DCSTask ) - + if WaitTime then --routines.scheduleFunction( Controller.pushTask, { Controller, DCSTask }, timer.getTime() + WaitTime ) SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime ) else Controller:pushTask( DCSTask ) end - + return self end - + return nil end @@ -737,24 +737,24 @@ function GROUP:SetTask( DCSTask, WaitTime ) self:F2( { DCSTask } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - + local Controller = self:_GetController() - + -- When a group SPAWNs, it takes about a second to get the group in the simulator. Setting tasks to unspawned groups provides unexpected results. -- Therefore we schedule the functions to set the mission and options for the Group. -- Controller.setTask( Controller, DCSTask ) - + if not WaitTime then WaitTime = 1 end --routines.scheduleFunction( Controller.setTask, { Controller, DCSTask }, timer.getTime() + WaitTime ) SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime ) - + return self end - + return nil end @@ -762,15 +762,15 @@ end --- Return a condition section for a controlled task -- @param #GROUP self -- @param DCSTime#Time time --- @param #string userFlag --- @param #boolean userFlagValue +-- @param #string userFlag +-- @param #boolean userFlagValue -- @param #string condition --- @param DCSTime#Time duration --- @param #number lastWayPoint +-- @param DCSTime#Time duration +-- @param #number lastWayPoint -- return DCSTask#Task function GROUP:TaskCondition( time, userFlag, userFlagValue, condition, duration, lastWayPoint ) - self:F2( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } ) - + self:F2( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } ) + local DCSStopCondition = {} DCSStopCondition.time = time DCSStopCondition.userFlag = userFlag @@ -778,9 +778,9 @@ function GROUP:TaskCondition( time, userFlag, userFlagValue, condition, duration DCSStopCondition.condition = condition DCSStopCondition.duration = duration DCSStopCondition.lastWayPoint = lastWayPoint - + self:T3( { DCSStopCondition } ) - return DCSStopCondition + return DCSStopCondition end --- Return a Controlled Task taking a Task and a TaskCondition @@ -789,18 +789,18 @@ end -- @param #DCSStopCondition DCSStopCondition -- @return DCSTask#Task function GROUP:TaskControlled( DCSTask, DCSStopCondition ) - self:F2( { DCSTask, DCSStopCondition } ) + self:F2( { DCSTask, DCSStopCondition } ) local DCSTaskControlled - - DCSTaskControlled = { - id = 'ControlledTask', - params = { - task = DCSTask, - stopCondition = DCSStopCondition - } + + DCSTaskControlled = { + id = 'ControlledTask', + params = { + task = DCSTask, + stopCondition = DCSStopCondition + } } - + self:T3( { DCSTaskControlled } ) return DCSTaskControlled end @@ -813,19 +813,19 @@ function GROUP:TaskCombo( DCSTasks ) self:F2( { DCSTasks } ) local DCSTaskCombo - - DCSTaskCombo = { - id = 'ComboTask', - params = { + + DCSTaskCombo = { + id = 'ComboTask', + params = { tasks = DCSTasks - } + } } - + self:T3( { DCSTaskCombo } ) return DCSTaskCombo end ---- Return a WrappedAction Task taking a Command +--- Return a WrappedAction Task taking a Command -- @param #GROUP self -- @param DCSCommand#Command DCSCommand -- @return DCSTask#Task @@ -833,8 +833,8 @@ function GROUP:TaskWrappedAction( DCSCommand, Index ) self:F2( { DCSCommand } ) local DCSTaskWrappedAction - - DCSTaskWrappedAction = { + + DCSTaskWrappedAction = { id = "WrappedAction", enabled = true, number = Index, @@ -854,15 +854,15 @@ end -- @return #GROUP self function GROUP:SetCommand( DCSCommand ) self:F2( DCSCommand ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() Controller:setCommand( DCSCommand ) return self end - + return nil end @@ -873,117 +873,387 @@ end -- @return DCSTask#Task function GROUP:CommandSwitchWayPoint( FromWayPoint, ToWayPoint, Index ) self:F2( { FromWayPoint, ToWayPoint, Index } ) - + local CommandSwitchWayPoint = { - id = 'SwitchWaypoint', - params = { - fromWaypointIndex = FromWayPoint, - goToWaypointIndex = ToWayPoint, + id = 'SwitchWaypoint', + params = { + fromWaypointIndex = FromWayPoint, + goToWaypointIndex = ToWayPoint, }, } - + self:T3( { CommandSwitchWayPoint } ) return CommandSwitchWayPoint end - ---- Orbit at a specified position at a specified alititude during a specified duration with a specified speed. + +-- TASKS FOR AIR GROUPS + + +--- (AIR) Attack a Group. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param DCSTypes#Distance Altitude (optional) Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit ) + self:F2( { self.GroupName, AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } ) + + -- AttackGroup = { + -- id = 'AttackGroup', + -- params = { + -- groupId = Group.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend, + -- attackQty = number, + -- directionEnabled = boolean, + -- direction = Azimuth, + -- altitudeEnabled = boolean, + -- altitude = Distance, + -- attackQtyLimit = boolean, + -- } + -- } + + local DirectionEnabled = nil + if Direction then + DirectionEnabled = true + end + + local AltitudeEnabled = nil + if Altitude then + AltitudeEnabled = true + end + + local DCSTask + DCSTask = { id = 'AttackGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + directionEnabled = DirectionEnabled, + direction = Direction, + altitudeEnabled = AltitudeEnabled, + altitude = Altitude, + attackQtyLimit = AttackQtyLimit, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Attack the Unit. +-- @param #GROUP self +-- @param Unit#UNIT AttackUnit The unit. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackUnit( AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack ) + self:F2( { self.GroupName, AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack } ) + + -- AttackUnit = { + -- id = 'AttackUnit', + -- params = { + -- unitId = Unit.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend + -- attackQty = number, + -- direction = Azimuth, + -- attackQtyLimit = boolean, + -- groupAttack = boolean, + -- } + -- } + + local DCSTask + DCSTask = { id = 'AttackUnit', + params = { + unitId = AttackUnit:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + attackQtyLimit = AttackQtyLimit, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Delivering weapon at the point on the ground. +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the point to deliver weapon at. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) Desired quantity of passes. The parameter is not the same in AttackGroup and AttackUnit tasks. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskBombing( PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- Bombing = { +-- id = 'Bombing', +-- params = { +-- point = Vec2, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'Bombing', + params = { + point = PointVec2, + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + +--- (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed. -- @param #GROUP self -- @param DCSTypes#Vec2 Point The point to hold the position. -- @param #number Altitude The altitude to hold the position. -- @param #number Speed The speed flying when holding the position. -- @return #GROUP self function GROUP:TaskOrbitCircleAtVec2( Point, Altitude, Speed ) - self:F2( { self.GroupName, Point, Altitude, Speed } ) + self:F2( { self.GroupName, Point, Altitude, Speed } ) + + -- pattern = enum AI.Task.OribtPattern, + -- point = Vec2, + -- point2 = Vec2, + -- speed = Distance, + -- altitude = Distance --- pattern = enum AI.Task.OribtPattern, --- point = Vec2, --- point2 = Vec2, --- speed = Distance, --- altitude = Distance - local LandHeight = land.getHeight( Point ) - + self:T3( { LandHeight } ) - local DCSTask = { id = 'Orbit', - params = { pattern = AI.Task.OrbitPattern.CIRCLE, - point = Point, - speed = Speed, - altitude = Altitude + LandHeight - } - } + local DCSTask = { id = 'Orbit', + params = { pattern = AI.Task.OrbitPattern.CIRCLE, + point = Point, + speed = Speed, + altitude = Altitude + LandHeight + } + } + + + -- local AITask = { id = 'ControlledTask', + -- params = { task = { id = 'Orbit', + -- params = { pattern = AI.Task.OrbitPattern.CIRCLE, + -- point = Point, + -- speed = Speed, + -- altitude = Altitude + LandHeight + -- } + -- }, + -- stopCondition = { duration = Duration + -- } + -- } + -- } + -- ) - --- local AITask = { id = 'ControlledTask', --- params = { task = { id = 'Orbit', --- params = { pattern = AI.Task.OrbitPattern.CIRCLE, --- point = Point, --- speed = Speed, --- altitude = Altitude + LandHeight --- } --- }, --- stopCondition = { duration = Duration --- } --- } --- } --- ) - return DCSTask end ---- Orbit at the current position of the first unit of the group at a specified alititude +--- (AIR) Orbit at the current position of the first unit of the group at a specified alititude -- @param #GROUP self -- @param #number Altitude The altitude to hold the position. -- @param #number Speed The speed flying when holding the position. -- @return #GROUP self function GROUP:TaskOrbitCircle( Altitude, Speed ) - self:F2( { self.GroupName, Altitude, Speed } ) + self:F2( { self.GroupName, Altitude, Speed } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupPoint = self:GetPointVec2() return self:TaskOrbitCircleAtVec2( GroupPoint, Altitude, Speed ) end - + return nil end ---- Hold position at the current position of the first unit of the group. +--- (AIR) Hold position at the current position of the first unit of the group. -- @param #GROUP self -- @param #number Duration The maximum duration in seconds to hold the position. -- @return #GROUP self function GROUP:TaskHoldPosition() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) return self:TaskOrbitCircle( 30, 10 ) end ---- Land the group at a Vec2Point. + + +--- (AIR) Attacking the map object (building, structure, e.t.c). +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the point the map object is closest to. The distance between the point and the map object must not be greater than 2000 meters. Object id is not used here because Mission Editor doesn't support map object identificators. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackMapObject( PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- AttackMapObject = { +-- id = 'AttackMapObject', +-- params = { +-- point = Vec2, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'AttackMapObject', + params = { + point = PointVec2, + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Delivering weapon on the runway. +-- @param #GROUP self +-- @param Airbase#AIRBASE Airbase Airbase to attack. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskBombingRunway( Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- BombingRunway = { +-- id = 'BombingRunway', +-- params = { +-- runwayId = AirdromeId, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'BombingRunway', + params = { + point = Airbase:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Refueling from the nearest tanker. No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskRefueling() + self:F2( { self.GroupName } ) + +-- Refueling = { +-- id = 'Refueling', +-- params = {} +-- } + + local DCSTask + DCSTask = { id = 'Refueling', + params = { + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR HELICOPTER) Landing at the ground. For helicopters only. -- @param #GROUP self -- @param DCSTypes#Vec2 Point The point where to land. -- @param #number Duration The duration in seconds to stay on the ground. -- @return #GROUP self function GROUP:TaskLandAtVec2( Point, Duration ) - self:F2( { self.GroupName, Point, Duration } ) + self:F2( { self.GroupName, Point, Duration } ) +-- Land = { +-- id= 'Land', +-- params = { +-- point = Vec2, +-- durationFlag = boolean, +-- duration = Time +-- } +-- } + local DCSTask - - if Duration and Duration > 0 then - DCSTask = { id = 'Land', params = { point = Point, durationFlag = true, duration = Duration } } - else - DCSTask = { id = 'Land', params = { point = Point, durationFlag = false } } - end + if Duration and Duration > 0 then + DCSTask = { id = 'Land', + params = { + point = Point, + durationFlag = true, + duration = Duration, + }, + } + else + DCSTask = { id = 'Land', + params = { + point = Point, + durationFlag = false, + }, + } + end self:T3( DCSTask ) - return DCSTask + return DCSTask end ---- Land the group at a @{Zone#ZONE). +--- (AIR) Land the group at a @{Zone#ZONE). -- @param #GROUP self -- @param Zone#ZONE Zone The zone where to land. -- @param #number Duration The duration in seconds to stay on the ground. @@ -997,80 +1267,104 @@ function GROUP:TaskLandAtZone( Zone, Duration, RandomPoint ) else Point = Zone:GetPointVec2() end - + local DCSTask = self:TaskLandAtVec2( Point, Duration ) self:T3( DCSTask ) return DCSTask end - ---- Attack the Unit. +--- (AIR) Following another airborne group. +-- The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. +-- If another group is on land the unit / group will orbit around. -- @param #GROUP self --- @param Unit#UNIT The unit. +-- @param Group#GROUP FollowGroup The group to be followed. +-- @param DCSTypes#Vec3 PointVec3 Position of the unit / lead unit of the group relative lead unit of another group in frame reference oriented by course of lead unit of another group. If another group is on land the unit / group will orbit around. +-- @param #number LastWaypointIndex Detach waypoint of another group. Once reached the unit / group Follow task is finished. -- @return DCSTask#Task The DCS task structure. -function GROUP:TaskAttackUnit( AttackUnit ) - self:F2( { self.GroupName, AttackUnit } ) +function GROUP:TaskFollow( FollowGroup, PointVec3, LastWaypointIndex ) + self:F2( { self.GroupName, FollowGroup, PointVec3, LastWaypointIndex } ) --- AttackUnit = { --- id = 'AttackUnit', --- params = { --- unitId = Unit.ID, --- weaponType = number, --- expend = enum AI.Task.WeaponExpend --- attackQty = number, --- direction = Azimuth, --- attackQtyLimit = boolean, --- groupAttack = boolean, --- } +-- Follow = { +-- id = 'Follow', +-- params = { +-- groupId = Group.ID, +-- pos = Vec3, +-- lastWptIndexFlag = boolean, +-- lastWptIndex = number +-- } -- } + + local LastWaypointIndexFlag = nil + if LastWaypointIndex then + LastWaypointIndexFlag = true + end - local DCSTask - DCSTask = { id = 'AttackUnit', - params = { unitId = AttackUnit:GetID(), - expend = AI.Task.WeaponExpend.TWO, - groupAttack = true, - }, - }, - + local DCSTask + DCSTask = { id = 'Follow', + params = { + groupId = FollowGroup:GetID(), + pos = PointVec3, + lastWptIndexFlag = LastWaypointIndexFlag, + lastWptIndex = LastWaypointIndex, + }, + }, + self:T3( { DCSTask } ) return DCSTask end ---- Attack a Group. + +--- (AIR) Escort another airborne group. +-- The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. +-- The unit / group will also protect that group from threats of specified types. -- @param #GROUP self --- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param Group#GROUP EscortGroup The group to be escorted. +-- @param DCSTypes#Vec3 PointVec3 Position of the unit / lead unit of the group relative lead unit of another group in frame reference oriented by course of lead unit of another group. If another group is on land the unit / group will orbit around. +-- @param #number LastWaypointIndex Detach waypoint of another group. Once reached the unit / group Follow task is finished. +-- @param #number EngagementDistanceMax Maximal distance from escorted group to threat. If the threat is already engaged by escort escort will disengage if the distance becomes greater than 1.5 * engagementDistMax. +-- @param #list TargetTypes Array of AttributeName that is contains threat categories allowed to engage. -- @return DCSTask#Task The DCS task structure. -function GROUP:TaskAttackGroup( AttackGroup ) - self:F2( { self.GroupName, AttackGroup } ) +function GROUP:TaskEscort( FollowGroup, PointVec3, LastWaypointIndex, EngagementDistance, TargetTypes ) + self:F2( { self.GroupName, FollowGroup, PointVec3, LastWaypointIndex, EngagementDistance, TargetTypes } ) --- AttackGroup = { --- id = 'AttackGroup', --- params = { --- groupId = Group.ID, --- weaponType = number, --- expend = enum AI.Task.WeaponExpend, --- attackQty = number, --- directionEnabled = boolean, --- direction = Azimuth, --- altitudeEnabled = boolean, --- altitude = Distance, --- attackQtyLimit = boolean, --- } --- } +-- Escort = { +-- id = 'Escort', +-- params = { +-- groupId = Group.ID, +-- pos = Vec3, +-- lastWptIndexFlag = boolean, +-- lastWptIndex = number, +-- engagementDistMax = Distance, +-- targetTypes = array of AttributeName, +-- } +-- } - local DCSTask - DCSTask = { id = 'AttackGroup', - params = { groupId = AttackGroup:GetID(), - expend = AI.Task.WeaponExpend.TWO, - }, - }, + local LastWaypointIndexFlag = nil + if LastWaypointIndex then + LastWaypointIndexFlag = true + end + local DCSTask + DCSTask = { id = 'Follow', + params = { + groupId = FollowGroup:GetID(), + pos = PointVec3, + lastWptIndexFlag = LastWaypointIndexFlag, + lastWptIndex = LastWaypointIndex, + engagementDistMax = EngagementDistance, + targetTypes = TargetTypes, + }, + }, + self:T3( { DCSTask } ) return DCSTask end ---- Fires at a VEC2 point. + +-- GROUND TASKS + +--- (GROUND) Fire at a VEC2 point until ammunition is finished. -- @param #GROUP self -- @param DCSTypes#Vec2 The point to fire at. -- @param DCSTypes#Distance Radius The radius of the zone to deploy the fire at. @@ -1078,25 +1372,406 @@ end function GROUP:TaskFireAtPoint( PointVec2, Radius ) self:F2( { self.GroupName, PointVec2, Radius } ) --- FireAtPoint = { --- id = 'FireAtPoint', --- params = { --- point = Vec2, --- radius = Distance, --- } --- } - - local DCSTask - DCSTask = { id = 'FireAtPoint', - params = { point = PointVec2, - radius = Radius, - } - } - + -- FireAtPoint = { + -- id = 'FireAtPoint', + -- params = { + -- point = Vec2, + -- radius = Distance, + -- } + -- } + + local DCSTask + DCSTask = { id = 'FireAtPoint', + params = { + point = PointVec2, + radius = Radius, + } + } + self:T3( { DCSTask } ) return DCSTask end +--- (GROUND) Hold ground group from moving. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskHold() + self:F2( { self.GroupName } ) + +-- Hold = { +-- id = 'Hold', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'Hold', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +-- TASKS FOR AIRBORNE AND GROUND UNITS/GROUPS + +--- (AIR + GROUND) The task makes the group/unit a FAC and orders the FAC to control the target (enemy ground group) destruction. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup Target GROUP. +-- @param #number WeaponType Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.Designation Designation (optional) Designation type. +-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink ) + self:F2( { self.GroupName, AttackGroup, WeaponType, Designation, Datalink } ) + +-- FAC_AttackGroup = { +-- id = 'FAC_AttackGroup', +-- params = { +-- groupId = Group.ID, +-- weaponType = number, +-- designation = enum AI.Task.Designation, +-- datalink = boolean +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC_AttackGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + designation = Designation, + datalink = Datalink, + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +-- EN-ROUTE TASKS FOR AIRBORNE GROUPS + +--- (AIR) Engaging targets of defined types. +-- @param #GROUP self +-- @param DCSTypes#Distance Distance Maximal distance from the target to a route leg. If the target is on a greater distance it will be ignored. +-- @param #list<#DCSTypes#AttributeName> TargetTypes Array of target categories allowed to engage. +-- @param #number Priority All enroute tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority ) + self:F2( { self.GroupName, Distance, TargetTypes, Priority } ) + +-- EngageTargets ={ +-- id = 'EngageTargets', +-- params = { +-- maxDist = Distance, +-- targetTypes = array of AttributeName, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'EngageTargets', + params = { + maxDist = Distance, + targetTypes = TargetTypes, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Engaging a targets of defined types at circle-shaped zone. +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the zone. +-- @param DCSTypes#Distance Radius Radius of the zone. +-- @param #list<#DCSTypes#AttributeName> TargetTypes Array of target categories allowed to engage. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageTargets( PointVec2, Radius, TargetTypes, Priority ) + self:F2( { self.GroupName, PointVec2, Radius, TargetTypes, Priority } ) + +-- EngageTargetsInZone = { +-- id = 'EngageTargetsInZone', +-- params = { +-- point = Vec2, +-- zoneRadius = Distance, +-- targetTypes = array of AttributeName, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'EngageTargetsInZone', + params = { + point = PointVec2, + zoneRadius = Radius, + targetTypes = TargetTypes, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +--- (AIR) Engaging a group. The task does not assign the target group to the unit/group to attack now; it just allows the unit/group to engage the target group as well as other assigned targets. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param DCSTypes#Distance Altitude (optional) Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit ) + self:F2( { self.GroupName, AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } ) + + -- EngageGroup = { + -- id = 'EngageGroup ', + -- params = { + -- groupId = Group.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend, + -- attackQty = number, + -- directionEnabled = boolean, + -- direction = Azimuth, + -- altitudeEnabled = boolean, + -- altitude = Distance, + -- attackQtyLimit = boolean, + -- priority = number, + -- } + -- } + + local DirectionEnabled = nil + if Direction then + DirectionEnabled = true + end + + local AltitudeEnabled = nil + if Altitude then + AltitudeEnabled = true + end + + local DCSTask + DCSTask = { id = 'EngageGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + directionEnabled = DirectionEnabled, + direction = Direction, + altitudeEnabled = AltitudeEnabled, + altitude = Altitude, + attackQtyLimit = AttackQtyLimit, + priority = Priority, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Attack the Unit. +-- @param #GROUP self +-- @param Unit#UNIT AttackUnit The UNIT. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageUnit( AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack ) + self:F2( { self.GroupName, AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack } ) + + -- EngageUnit = { + -- id = 'EngageUnit', + -- params = { + -- unitId = Unit.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend + -- attackQty = number, + -- direction = Azimuth, + -- attackQtyLimit = boolean, + -- groupAttack = boolean, + -- priority = number, + -- } + -- } + + local DCSTask + DCSTask = { id = 'EngageUnit', + params = { + unitId = AttackUnit:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + attackQtyLimit = AttackQtyLimit, + groupAttack = GroupAttack, + priority = Priority, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Aircraft will act as an AWACS for friendly units (will provide them with information about contacts). No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskAWACS( ) + self:F2( { self.GroupName } ) + +-- AWACS = { +-- id = 'AWACS', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'AWACS', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Aircraft will act as a tanker for friendly units. No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskTanker( ) + self:F2( { self.GroupName } ) + +-- Tanker = { +-- id = 'Tanker', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'Tanker', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +-- En-route tasks for ground units/groups + +--- (GROUND) Ground unit (EW-radar) will act as an EWR for friendly units (will provide them with information about contacts). No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEWR( ) + self:F2( { self.GroupName } ) + +-- EWR = { +-- id = 'EWR', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'EWR', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +-- En-route tasks for airborne and ground units/groups + +--- (AIR + GROUND) The task makes the group/unit a FAC and lets the FAC to choose the target (enemy ground group) as well as other assigned targets. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup Target GROUP. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.Designation Designation (optional) Designation type. +-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponType, Designation, Datalink ) + self:F2( { self.GroupName, AttackGroup, WeaponType, Priority, Designation, Datalink } ) + +-- FAC_EngageGroup = { +-- id = 'FAC_EngageGroup', +-- params = { +-- groupId = Group.ID, +-- weaponType = number, +-- designation = enum AI.Task.Designation, +-- datalink = boolean, +-- priority = number, +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC_EngageGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + designation = Designation, + datalink = Datalink, + priority = Priority, + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR + GROUND) The task makes the group/unit a FAC and lets the FAC to choose a targets (enemy ground group) around as well as other assigned targets. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param DCSTypes#Distance Radius The maximal distance from the FAC to a target. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskFAC( Radius, Priority ) + self:F2( { self.GroupName, Radius, Priority } ) + +-- FAC = { +-- id = 'FAC', +-- params = { +-- radius = Distance, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC', + params = { + radius = Radius, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + --- Move the group to a Vec2 Point, wait for a defined duration and embark a group. @@ -1106,22 +1781,22 @@ end -- @param #GROUP EmbarkingGroup The group to be embarked. -- @return DCSTask#Task The DCS task structure function GROUP:TaskEmbarkingAtVec2( Point, Duration, EmbarkingGroup ) - self:F2( { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } ) + self:F2( { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } ) - local DCSTask - DCSTask = { id = 'Embarking', - params = { x = Point.x, - y = Point.y, - duration = Duration, - groupsForEmbarking = { EmbarkingGroup.GroupID }, - durationFlag = true, - distributionFlag = false, - distribution = {}, - } - } - - self:T3( { DCSTask } ) - return DCSTask + local DCSTask + DCSTask = { id = 'Embarking', + params = { x = Point.x, + y = Point.y, + duration = Duration, + groupsForEmbarking = { EmbarkingGroup.GroupID }, + durationFlag = true, + distributionFlag = false, + distribution = {}, + } + } + + self:T3( { DCSTask } ) + return DCSTask end --- Move to a defined Vec2 Point, and embark to a group when arrived within a defined Radius. @@ -1130,30 +1805,30 @@ end -- @param #number Radius The radius of the embarking zone around the Point. -- @return DCSTask#Task The DCS task structure. function GROUP:TaskEmbarkToTransportAtVec2( Point, Radius ) - self:F2( { self.GroupName, Point, Radius } ) + self:F2( { self.GroupName, Point, Radius } ) local DCSTask --DCSTask#Task - DCSTask = { id = 'EmbarkToTransport', - params = { x = Point.x, - y = Point.y, - zoneRadius = Radius, - } - } + DCSTask = { id = 'EmbarkToTransport', + params = { x = Point.x, + y = Point.y, + zoneRadius = Radius, + } + } self:T3( { DCSTask } ) - return DCSTask + return DCSTask end --- Return a Misson task from a mission template. -- @param #GROUP self -- @param #table TaskMission A table containing the mission task. --- @return DCSTask#Task +-- @return DCSTask#Task function GROUP:TaskMission( TaskMission ) - self:F2( Points ) - + self:F2( Points ) + local DCSTask DCSTask = { id = 'Mission', params = { TaskMission, }, } - + self:T3( { DCSTask } ) return DCSTask end @@ -1161,13 +1836,13 @@ end --- Return a Misson task to follow a given route defined by Points. -- @param #GROUP self -- @param #table Points A table of route points. --- @return DCSTask#Task +-- @return DCSTask#Task function GROUP:TaskRoute( Points ) self:F2( Points ) - + local DCSTask DCSTask = { id = 'Mission', params = { route = { points = Points, }, }, } - + self:T3( { DCSTask } ) return DCSTask end @@ -1181,22 +1856,22 @@ function GROUP:TaskRouteToVec2( Point, Speed ) self:F2( { Point, Speed } ) local GroupPoint = self:GetUnit( 1 ):GetPointVec2() - + local PointFrom = {} PointFrom.x = GroupPoint.x PointFrom.y = GroupPoint.y PointFrom.type = "Turning Point" PointFrom.action = "Turning Point" - PointFrom.speed = Speed + PointFrom.speed = Speed PointFrom.speed_locked = true PointFrom.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local PointTo = {} PointTo.x = Point.x @@ -1206,18 +1881,18 @@ function GROUP:TaskRouteToVec2( Point, Speed ) PointTo.speed = Speed PointTo.speed_locked = true PointTo.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local Points = { PointFrom, PointTo } - + self:T3( Points ) - + self:Route( Points ) return self @@ -1232,7 +1907,7 @@ function GROUP:TaskRouteToVec3( Point, Speed ) self:F2( { Point, Speed } ) local GroupPoint = self:GetUnit( 1 ):GetPointVec3() - + local PointFrom = {} PointFrom.x = GroupPoint.x PointFrom.y = GroupPoint.z @@ -1240,39 +1915,39 @@ function GROUP:TaskRouteToVec3( Point, Speed ) PointFrom.alt_type = "BARO" PointFrom.type = "Turning Point" PointFrom.action = "Turning Point" - PointFrom.speed = Speed + PointFrom.speed = Speed PointFrom.speed_locked = true PointFrom.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local PointTo = {} PointTo.x = Point.x PointTo.y = Point.z - PointTo.alt = Point.y + PointTo.alt = Point.y PointTo.alt_type = "BARO" PointTo.type = "Turning Point" PointTo.action = "Fly Over Point" PointTo.speed = Speed PointTo.speed_locked = true PointTo.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local Points = { PointFrom, PointTo } - + self:T3( Points ) - + self:Route( Points ) return self @@ -1283,22 +1958,22 @@ end --- Make the group to follow a given route. -- @param #GROUP self -- @param #table GoPoints A table of Route Points. --- @return #GROUP self +-- @return #GROUP self function GROUP:Route( GoPoints ) - self:F2( GoPoints ) + self:F2( GoPoints ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local Points = routines.utils.deepCopy( GoPoints ) - local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, } - local Controller = self:_GetController() + local Points = routines.utils.deepCopy( GoPoints ) + local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, } + local Controller = self:_GetController() --Controller.setTask( Controller, MissionTask ) - --routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 ) + --routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 ) SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 ) - return self + return self end - + return nil end @@ -1314,56 +1989,56 @@ end -- @param #number Speed The speed. -- @param Base#FORMATION Formation The formation string. function GROUP:TaskRouteToZone( Zone, Randomize, Speed, Formation ) - self:F2( Zone ) + self:F2( Zone ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - - local GroupPoint = self:GetPointVec2() - - local PointFrom = {} - PointFrom.x = GroupPoint.x - PointFrom.y = GroupPoint.y - PointFrom.type = "Turning Point" - PointFrom.action = "Cone" - PointFrom.speed = 20 / 1.6 - - - local PointTo = {} - local ZonePoint - - if Randomize then - ZonePoint = Zone:GetRandomPointVec2() - else - ZonePoint = Zone:GetPointVec2() - end - - PointTo.x = ZonePoint.x - PointTo.y = ZonePoint.y - PointTo.type = "Turning Point" - - if Formation then - PointTo.action = Formation - else - PointTo.action = "Cone" - end - - if Speed then - PointTo.speed = Speed - else - PointTo.speed = 20 / 1.6 - end - - local Points = { PointFrom, PointTo } - - self:T3( Points ) - - self:Route( Points ) - - return self + + local GroupPoint = self:GetPointVec2() + + local PointFrom = {} + PointFrom.x = GroupPoint.x + PointFrom.y = GroupPoint.y + PointFrom.type = "Turning Point" + PointFrom.action = "Cone" + PointFrom.speed = 20 / 1.6 + + + local PointTo = {} + local ZonePoint + + if Randomize then + ZonePoint = Zone:GetRandomPointVec2() + else + ZonePoint = Zone:GetPointVec2() + end + + PointTo.x = ZonePoint.x + PointTo.y = ZonePoint.y + PointTo.type = "Turning Point" + + if Formation then + PointTo.action = Formation + else + PointTo.action = "Cone" + end + + if Speed then + PointTo.speed = Speed + else + PointTo.speed = 20 / 1.6 + end + + local Points = { PointFrom, PointTo } + + self:T3( Points ) + + self:Route( Points ) + + return self end - + return nil end @@ -1410,48 +2085,48 @@ end -- @param #number Begin The route point from where the copy will start. The base route point is 0. -- @param #number End The route point where the copy will end. The End point is the last point - the End point. The last point has base 0. -- @param #boolean Randomize Randomization of the route, when true. --- @param #number Radius When randomization is on, the randomization is within the radius. +-- @param #number Radius When randomization is on, the randomization is within the radius. function GROUP:CopyRoute( Begin, End, Randomize, Radius ) - self:F2( { Begin, End } ) + self:F2( { Begin, End } ) - local Points = {} - - -- Could be a Spawned Group - local GroupName = string.match( self:GetName(), ".*#" ) - if GroupName then - GroupName = GroupName:sub( 1, -2 ) - else - GroupName = self:GetName() - end - - self:T3( { GroupName } ) - - local Template = _DATABASE.Templates.Groups[GroupName].Template - - if Template then - if not Begin then - Begin = 0 - end - if not End then - End = 0 - end - - for TPointID = Begin + 1, #Template.route.points - End do - if Template.route.points[TPointID] then - Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] ) - if Randomize then - if not Radius then - Radius = 500 - end - Points[#Points].x = Points[#Points].x + math.random( Radius * -1, Radius ) - Points[#Points].y = Points[#Points].y + math.random( Radius * -1, Radius ) - end - end - end - return Points - end - - return nil + local Points = {} + + -- Could be a Spawned Group + local GroupName = string.match( self:GetName(), ".*#" ) + if GroupName then + GroupName = GroupName:sub( 1, -2 ) + else + GroupName = self:GetName() + end + + self:T3( { GroupName } ) + + local Template = _DATABASE.Templates.Groups[GroupName].Template + + if Template then + if not Begin then + Begin = 0 + end + if not End then + End = 0 + end + + for TPointID = Begin + 1, #Template.route.points - End do + if Template.route.points[TPointID] then + Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] ) + if Randomize then + if not Radius then + Radius = 500 + end + Points[#Points].x = Points[#Points].x + math.random( Radius * -1, Radius ) + Points[#Points].y = Points[#Points].y + math.random( Radius * -1, Radius ) + end + end + end + return Points + end + + return nil end @@ -1462,28 +2137,28 @@ function GROUP:GetDetectedTargets() if DCSGroup then return self:_GetController():getDetectedTargets() end - + return nil end function GROUP:IsTargetDetected( DCSObject ) self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then - + local TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity - = self:_GetController().isTargetDetected( self:_GetController(), DCSObject, - Controller.Detection.VISUAL, - Controller.Detection.OPTIC, - Controller.Detection.RADAR, - Controller.Detection.IRST, - Controller.Detection.RWR, - Controller.Detection.DLINK - ) + = self:_GetController().isTargetDetected( self:_GetController(), DCSObject, + Controller.Detection.VISUAL, + Controller.Detection.OPTIC, + Controller.Detection.RADAR, + Controller.Detection.IRST, + Controller.Detection.RWR, + Controller.Detection.DLINK + ) return TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity end - + return nil end @@ -1494,16 +2169,16 @@ end -- @return #boolean function GROUP:OptionROEHoldFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -1511,12 +2186,12 @@ end -- @param Group#GROUP self -- @return Group#GROUP self function GROUP:OptionROEHoldFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD ) elseif self:IsGround() then @@ -1524,10 +2199,10 @@ function GROUP:OptionROEHoldFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.WEAPON_HOLD ) end - + return self end - + return nil end @@ -1536,16 +2211,16 @@ end -- @return #boolean function GROUP:OptionROEReturnFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -1553,12 +2228,12 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEReturnFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.RETURN_FIRE ) elseif self:IsGround() then @@ -1566,10 +2241,10 @@ function GROUP:OptionROEReturnFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.RETURN_FIRE ) end - + return self end - + return nil end @@ -1584,10 +2259,10 @@ function GROUP:OptionROEOpenFirePossible() if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -1595,12 +2270,12 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEOpenFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE ) elseif self:IsGround() then @@ -1608,10 +2283,10 @@ function GROUP:OptionROEOpenFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.OPEN_FIRE ) end - + return self end - + return nil end @@ -1620,16 +2295,16 @@ end -- @return #boolean function GROUP:OptionROEWeaponFreePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -1637,19 +2312,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEWeaponFree() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_FREE ) end - + return self end - + return nil end @@ -1658,16 +2333,16 @@ end -- @return #boolean function GROUP:OptionROTNoReactionPossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -1676,19 +2351,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTNoReaction() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.NO_REACTION ) end - + return self end - + return nil end @@ -1703,10 +2378,10 @@ function GROUP:OptionROTPassiveDefensePossible() if self:IsAir() then return true end - + return false end - + return nil end @@ -1714,19 +2389,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTPassiveDefense() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENCE ) end - + return self end - + return nil end @@ -1735,16 +2410,16 @@ end -- @return #boolean function GROUP:OptionROTEvadeFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -1753,19 +2428,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTEvadeFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE ) end - + return self end - + return nil end @@ -1774,16 +2449,16 @@ end -- @return #boolean function GROUP:OptionROTVerticalPossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -1792,19 +2467,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTVertical() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.BYPASS_AND_ESCAPE ) end - + return self end - + return nil end @@ -1817,12 +2492,12 @@ end -- @return Message#MESSAGE function GROUP:Message( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then return MESSAGE:New( Message, self:GetCallsign() .. " (" .. self:GetTypeName() .. ")", Duration, self:GetClassNameAndID() ) end - + return nil end @@ -1833,12 +2508,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToAll( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToAll() end - + return nil end @@ -1849,12 +2524,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToRed( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToRed() end - + return nil end @@ -1865,12 +2540,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToBlue( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToBlue() end - + return nil end @@ -1882,11 +2557,11 @@ end -- @param Client#CLIENT Client The client object receiving the message. function GROUP:MessageToClient( Message, Duration, Client ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToClient( Client ) end - + return nil end diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index 9b72a9419..07c019def 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20160527_1422' ) +env.info( 'Moose Generation Timestamp: 20160602_1448' ) local base = _G env.info("Loading MOOSE " .. base.timer.getAbsTime() ) @@ -4071,35 +4071,35 @@ function MENU_COALITION_COMMAND:Remove() self.ParentMenu.Menus[self.MenuPath] = nil return nil end ---- GROUP class. --- +--- GROUP class. +-- -- @{GROUP} class -- ============== -- The @{GROUP} class is a wrapper class to handle the DCS Group objects: --- +-- -- * Support all DCS Group APIs. -- * Enhance with Group specific APIs not in the DCS Group API set. -- * Handle local Group Controller. -- * Manage the "state" of the DCS Group. --- --- +-- +-- -- GROUP reference methods --- ======================= +-- ======================= -- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object. -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class). --- +-- -- The GROUP class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference -- using the DCS Group or the DCS GroupName. --- --- Another thing to know is that GROUP objects do not "contain" the DCS Group object. +-- +-- Another thing to know is that GROUP objects do not "contain" the DCS Group object. -- The GROUP methods will reference the DCS Group object by name when it is needed during API execution. -- If the DCS Group object does not exist or is nil, the GROUP methods will return nil and log an exception in the DCS.log file. --- +-- -- The GROUP class provides the following functions to retrieve quickly the relevant GROUP instance: --- +-- -- * @{#GROUP.Find}(): Find a GROUP instance from the _DATABASE object using a DCS Group object. -- * @{#GROUP.FindByName}(): Find a GROUP instance from the _DATABASE object using a DCS Group name. --- +-- -- IMPORTANT: ONE SHOULD NEVER SANATIZE these GROUP OBJECT REFERENCES! (make the GROUP object references nil). -- @module Group -- @author FlightControl @@ -4115,14 +4115,14 @@ Include.File( "Unit" ) -- @field DCSGroup#Group DCSGroup The DCS group class. -- @field #string GroupName The name of the group. GROUP = { - ClassName = "GROUP", - GroupName = "", - GroupID = 0, - Controller = nil, - DCSGroup = nil, - WayPointFunctions = {}, - } - + ClassName = "GROUP", + GroupName = "", + GroupID = 0, + Controller = nil, + DCSGroup = nil, + WayPointFunctions = {}, +} + --- A DCSGroup -- @type DCSGroup -- @field id_ The ID of the group in DCS @@ -4132,10 +4132,10 @@ GROUP = { -- @param DCSGroup#Group GroupName The DCS Group name -- @return #GROUP self function GROUP:Register( GroupName ) - local self = BASE:Inherit( self, BASE:New() ) - self:F2( GroupName ) - self.GroupName = GroupName - return self + local self = BASE:Inherit( self, BASE:New() ) + self:F2( GroupName ) + self.GroupName = GroupName + return self end -- Reference methods. @@ -4168,11 +4168,11 @@ end -- @return DCSGroup#Group The DCS Group. function GROUP:GetDCSGroup() local DCSGroup = Group.getByName( self.GroupName ) - + if DCSGroup then return DCSGroup end - + return nil end @@ -4183,27 +4183,27 @@ end -- @return #boolean true if the DCS Group is alive. function GROUP:IsAlive() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupIsAlive = DCSGroup:isExist() self:T3( GroupIsAlive ) return GroupIsAlive end - + return nil end ---- Destroys the DCS Group and all of its DCS Units. +--- Destroys the DCS Group and all of its DCS Units. -- Note that this destroy method also raises a destroy event at run-time. -- So all event listeners will catch the destroy event of this DCS Group. -- @param #GROUP self function GROUP:Destroy() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then for Index, UnitData in pairs( DCSGroup:getUnits() ) do self:CreateEventCrash( timer.getTime(), UnitData ) @@ -4211,11 +4211,11 @@ function GROUP:Destroy() DCSGroup:destroy() DCSGroup = nil end - + return nil end ---- Returns category of the DCS Group. +--- Returns category of the DCS Group. -- @param #GROUP self -- @return DCSGroup#Group.Category The category ID function GROUP:GetCategory() @@ -4227,7 +4227,7 @@ function GROUP:GetCategory() self:T3( GroupCategory ) return GroupCategory end - + return nil end @@ -4243,14 +4243,14 @@ function GROUP:GetCategoryName() [Group.Category.AIRPLANE] = "Airplane", [Group.Category.HELICOPTER] = "Helicopter", [Group.Category.GROUND] = "Ground Unit", - [Group.Category.SHIP] = "Ship", + [Group.Category.SHIP] = "Ship", } local GroupCategory = DCSGroup:getCategory() self:T3( GroupCategory ) - + return CategoryNames[GroupCategory] end - + return nil end @@ -4267,14 +4267,14 @@ function GROUP:GetCoalition() self:T3( GroupCoalition ) return GroupCoalition end - + return nil end --- Returns the country of the DCS Group. -- @param #GROUP self -- @return DCScountry#country.id The country identifier. --- @return #nil The DCS Group is not existing or alive. +-- @return #nil The DCS Group is not existing or alive. function GROUP:GetCountry() self:F2( self.GroupName ) @@ -4284,7 +4284,7 @@ function GROUP:GetCountry() self:T3( GroupCountry ) return GroupCountry end - + return nil end @@ -4295,13 +4295,13 @@ function GROUP:GetName() self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupName = DCSGroup:getName() self:T3( GroupName ) return GroupName end - + return nil end @@ -4310,19 +4310,19 @@ end -- @return #number The identifier of the DCS Group. function GROUP:GetID() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupID = DCSGroup:getID() self:T3( GroupID ) return GroupID end - + return nil end ---- Returns the UNIT wrapper class with number UnitNumber. +--- Returns the UNIT wrapper class with number UnitNumber. -- If the underlying DCS Unit does not exist, the method will return nil. . -- @param #GROUP self -- @param #number UnitNumber The number of the UNIT wrapper class to be returned. @@ -4331,7 +4331,7 @@ function GROUP:GetUnit( UnitNumber ) self:F2( { self.GroupName, UnitNumber } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local UnitFound = UNIT:Find( DCSGroup:getUnit( UnitNumber ) ) self:T3( UnitFound.UnitName ) @@ -4342,7 +4342,7 @@ function GROUP:GetUnit( UnitNumber ) return nil end ---- Returns the DCS Unit with number UnitNumber. +--- Returns the DCS Unit with number UnitNumber. -- If the underlying DCS Unit does not exist, the method will return nil. . -- @param #GROUP self -- @param #number UnitNumber The number of the DCS Unit to be returned. @@ -4351,7 +4351,7 @@ function GROUP:GetDCSUnit( UnitNumber ) self:F2( { self.GroupName, UnitNumber } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnitFound = DCSGroup:getUnit( UnitNumber ) self:T3( DCSUnitFound ) @@ -4361,14 +4361,14 @@ function GROUP:GetDCSUnit( UnitNumber ) return nil end ---- Returns current size of the DCS Group. --- If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed. +--- Returns current size of the DCS Group. +-- If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed. -- @param #GROUP self -- @return #number The DCS Group size. function GROUP:GetSize() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupSize = DCSGroup:getSize() self:T3( GroupSize ) @@ -4378,15 +4378,15 @@ function GROUP:GetSize() return nil end ---- ---- Returns the initial size of the DCS Group. --- If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged. +--- +--- Returns the initial size of the DCS Group. +-- If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged. -- @param #GROUP self -- @return #number The DCS Group initial size. function GROUP:GetInitialSize() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupInitialSize = DCSGroup:getInitialSize() self:T3( GroupInitialSize ) @@ -4402,7 +4402,7 @@ end function GROUP:GetUnits() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnits = DCSGroup:getUnits() local Units = {} @@ -4423,7 +4423,7 @@ end function GROUP:GetDCSUnits() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnits = DCSGroup:getUnits() self:T3( DCSUnits ) @@ -4439,7 +4439,7 @@ end function GROUP:_GetController() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupController = DCSGroup:getController() self:T3( GroupController ) @@ -4459,7 +4459,7 @@ end function GROUP:WayPointInitialize() self.WayPoints = self:GetTaskRoute() - + return self end @@ -4472,7 +4472,7 @@ end -- @return #GROUP function GROUP:WayPointFunction( WayPoint, WayPointIndex, WayPointFunction, ... ) self:F2( { WayPoint, WayPointIndex, WayPointFunction } ) - + table.insert( self.WayPoints[WayPoint].task.params.tasks, WayPointIndex ) self.WayPoints[WayPoint].task.params.tasks[WayPointIndex] = self:TaskFunction( WayPoint, WayPointIndex, WayPointFunction, arg ) return self @@ -4482,7 +4482,7 @@ end function GROUP:TaskFunction( WayPoint, WayPointIndex, FunctionString, FunctionArguments ) local DCSTask - + local DCSScript = {} DCSScript[#DCSScript+1] = "local MissionGroup = GROUP:Find( ... ) " @@ -4490,16 +4490,16 @@ function GROUP:TaskFunction( WayPoint, WayPointIndex, FunctionString, FunctionAr DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup, " .. table.concat( FunctionArguments, "," ) .. ")" else DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup )" - end - - DCSTask = self:TaskWrappedAction( + end + + DCSTask = self:TaskWrappedAction( self:CommandDoScript( table.concat( DCSScript ) ), WayPointIndex ) - + self:T3( DCSTask ) - + return DCSTask end @@ -4518,14 +4518,14 @@ function GROUP:WayPointExecute( WayPoint, WaitTime ) if not WayPoint then WayPoint = 1 end - + -- When starting the mission from a certain point, the TaskPoints need to be deleted before the given WayPoint. for TaskPointID = 1, WayPoint - 1 do table.remove( self.WayPoints, 1 ) end self:T3( self.WayPoints ) - + self:SetTask( self:TaskRoute( self.WayPoints ), WaitTime ) return self @@ -4535,9 +4535,9 @@ end --- Activates a GROUP. -- @param #GROUP self function GROUP:Activate() - self:F2( { self.GroupName } ) - trigger.action.activateGroup( self:GetDCSGroup() ) - return self:GetDCSGroup() + self:F2( { self.GroupName } ) + trigger.action.activateGroup( self:GetDCSGroup() ) + return self:GetDCSGroup() end @@ -4548,13 +4548,13 @@ function GROUP:GetTypeName() self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupTypeName = DCSGroup:getUnit(1):getTypeName() self:T3( GroupTypeName ) return( GroupTypeName ) end - + return nil end @@ -4563,33 +4563,33 @@ end -- @return #string The CallSign of the first DCS Unit of the DCS Group. function GROUP:GetCallsign() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCallSign = DCSGroup:getUnit(1):getCallsign() self:T3( GroupCallSign ) return GroupCallSign end - + return nil end --- Returns the current point (Vec2 vector) of the first DCS Unit in the DCS Group. -- @return DCSTypes#Vec2 Current Vec2 point of the first DCS Unit of the DCS Group. function GROUP:GetPointVec2() - self:F2( self.GroupName ) - - local GroupPointVec2 = self:GetUnit(1):GetPointVec2() - self:T3( GroupPointVec2 ) - return GroupPointVec2 + self:F2( self.GroupName ) + + local GroupPointVec2 = self:GetUnit(1):GetPointVec2() + self:T3( GroupPointVec2 ) + return GroupPointVec2 end --- Returns the current point (Vec3 vector) of the first DCS Unit in the DCS Group. -- @return DCSTypes#Vec3 Current Vec3 point of the first DCS Unit of the DCS Group. function GROUP:GetPointVec3() - self:F2( self.GroupName ) - + self:F2( self.GroupName ) + local GroupPointVec3 = self:GetUnit(1):GetPointVec3() self:T3( GroupPointVec3 ) return GroupPointVec3 @@ -4604,16 +4604,16 @@ end -- @param #GROUP self -- @return #boolean Air category evaluation result. function GROUP:IsAir() - self:F2( self.GroupName ) + self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local IsAirResult = DCSGroup:getCategory() == Group.Category.AIRPLANE or DCSGroup:getCategory() == Group.Category.HELICOPTER - self:T3( IsAirResult ) - return IsAirResult + local IsAirResult = DCSGroup:getCategory() == Group.Category.AIRPLANE or DCSGroup:getCategory() == Group.Category.HELICOPTER + self:T3( IsAirResult ) + return IsAirResult end - + return nil end @@ -4622,15 +4622,15 @@ end -- @return #boolean true if DCS Group contains Helicopters. function GROUP:IsHelicopter() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.HELICOPTER end - + return nil end @@ -4639,15 +4639,15 @@ end -- @return #boolean true if DCS Group contains AirPlanes. function GROUP:IsAirPlane() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.AIRPLANE end - + return nil end @@ -4656,15 +4656,15 @@ end -- @return #boolean true if DCS Group contains Ground troops. function GROUP:IsGround() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.GROUND end - + return nil end @@ -4673,15 +4673,15 @@ end -- @return #boolean true if DCS Group contains Ships. function GROUP:IsShip() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.SHIP end - + return nil end @@ -4690,23 +4690,23 @@ end -- @param #GROUP self -- @return #boolean All units on the ground result. function GROUP:AllOnGround() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local AllOnGroundResult = true - - for Index, UnitData in pairs( DCSGroup:getUnits() ) do - if UnitData:inAir() then - AllOnGroundResult = false - end - end - - self:T3( AllOnGroundResult ) - return AllOnGroundResult + local AllOnGroundResult = true + + for Index, UnitData in pairs( DCSGroup:getUnits() ) do + if UnitData:inAir() then + AllOnGroundResult = false + end + end + + self:T3( AllOnGroundResult ) + return AllOnGroundResult end - + return nil end @@ -4715,26 +4715,26 @@ end -- @param #GROUP self -- @return #number Maximum velocity found. function GROUP:GetMaxVelocity() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local MaxVelocity = 0 - - for Index, UnitData in pairs( DCSGroup:getUnits() ) do - - local Velocity = UnitData:getVelocity() - local VelocityTotal = math.abs( Velocity.x ) + math.abs( Velocity.y ) + math.abs( Velocity.z ) - - if VelocityTotal < MaxVelocity then - MaxVelocity = VelocityTotal - end - end - - return MaxVelocity + local MaxVelocity = 0 + + for Index, UnitData in pairs( DCSGroup:getUnits() ) do + + local Velocity = UnitData:getVelocity() + local VelocityTotal = math.abs( Velocity.x ) + math.abs( Velocity.y ) + math.abs( Velocity.z ) + + if VelocityTotal < MaxVelocity then + MaxVelocity = VelocityTotal + end + end + + return MaxVelocity end - + return nil end @@ -4743,7 +4743,7 @@ end -- @param #GROUP self -- @return #number Minimum height found. function GROUP:GetMinHeight() - self:F2() + self:F2() end @@ -4752,7 +4752,7 @@ end -- @param #GROUP self -- @return #number Maximum height found. function GROUP:GetMaxHeight() - self:F2() + self:F2() end @@ -4762,16 +4762,16 @@ end -- @param #GROUP self -- @return Group#GROUP self function GROUP:PopCurrentTask() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() Controller:popTask() return self end - + return nil end @@ -4779,27 +4779,27 @@ end -- @param #GROUP self -- @return Group#GROUP self function GROUP:PushTask( DCSTask, WaitTime ) - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() - + -- When a group SPAWNs, it takes about a second to get the group in the simulator. Setting tasks to unspawned groups provides unexpected results. -- Therefore we schedule the functions to set the mission and options for the Group. -- Controller:pushTask( DCSTask ) - + if WaitTime then --routines.scheduleFunction( Controller.pushTask, { Controller, DCSTask }, timer.getTime() + WaitTime ) SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime ) else Controller:pushTask( DCSTask ) end - + return self end - + return nil end @@ -4810,24 +4810,24 @@ function GROUP:SetTask( DCSTask, WaitTime ) self:F2( { DCSTask } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - + local Controller = self:_GetController() - + -- When a group SPAWNs, it takes about a second to get the group in the simulator. Setting tasks to unspawned groups provides unexpected results. -- Therefore we schedule the functions to set the mission and options for the Group. -- Controller.setTask( Controller, DCSTask ) - + if not WaitTime then WaitTime = 1 end --routines.scheduleFunction( Controller.setTask, { Controller, DCSTask }, timer.getTime() + WaitTime ) SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime ) - + return self end - + return nil end @@ -4835,15 +4835,15 @@ end --- Return a condition section for a controlled task -- @param #GROUP self -- @param DCSTime#Time time --- @param #string userFlag --- @param #boolean userFlagValue +-- @param #string userFlag +-- @param #boolean userFlagValue -- @param #string condition --- @param DCSTime#Time duration --- @param #number lastWayPoint +-- @param DCSTime#Time duration +-- @param #number lastWayPoint -- return DCSTask#Task function GROUP:TaskCondition( time, userFlag, userFlagValue, condition, duration, lastWayPoint ) - self:F2( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } ) - + self:F2( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } ) + local DCSStopCondition = {} DCSStopCondition.time = time DCSStopCondition.userFlag = userFlag @@ -4851,9 +4851,9 @@ function GROUP:TaskCondition( time, userFlag, userFlagValue, condition, duration DCSStopCondition.condition = condition DCSStopCondition.duration = duration DCSStopCondition.lastWayPoint = lastWayPoint - + self:T3( { DCSStopCondition } ) - return DCSStopCondition + return DCSStopCondition end --- Return a Controlled Task taking a Task and a TaskCondition @@ -4862,18 +4862,18 @@ end -- @param #DCSStopCondition DCSStopCondition -- @return DCSTask#Task function GROUP:TaskControlled( DCSTask, DCSStopCondition ) - self:F2( { DCSTask, DCSStopCondition } ) + self:F2( { DCSTask, DCSStopCondition } ) local DCSTaskControlled - - DCSTaskControlled = { - id = 'ControlledTask', - params = { - task = DCSTask, - stopCondition = DCSStopCondition - } + + DCSTaskControlled = { + id = 'ControlledTask', + params = { + task = DCSTask, + stopCondition = DCSStopCondition + } } - + self:T3( { DCSTaskControlled } ) return DCSTaskControlled end @@ -4886,19 +4886,19 @@ function GROUP:TaskCombo( DCSTasks ) self:F2( { DCSTasks } ) local DCSTaskCombo - - DCSTaskCombo = { - id = 'ComboTask', - params = { + + DCSTaskCombo = { + id = 'ComboTask', + params = { tasks = DCSTasks - } + } } - + self:T3( { DCSTaskCombo } ) return DCSTaskCombo end ---- Return a WrappedAction Task taking a Command +--- Return a WrappedAction Task taking a Command -- @param #GROUP self -- @param DCSCommand#Command DCSCommand -- @return DCSTask#Task @@ -4906,8 +4906,8 @@ function GROUP:TaskWrappedAction( DCSCommand, Index ) self:F2( { DCSCommand } ) local DCSTaskWrappedAction - - DCSTaskWrappedAction = { + + DCSTaskWrappedAction = { id = "WrappedAction", enabled = true, number = Index, @@ -4927,15 +4927,15 @@ end -- @return #GROUP self function GROUP:SetCommand( DCSCommand ) self:F2( DCSCommand ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() Controller:setCommand( DCSCommand ) return self end - + return nil end @@ -4946,117 +4946,387 @@ end -- @return DCSTask#Task function GROUP:CommandSwitchWayPoint( FromWayPoint, ToWayPoint, Index ) self:F2( { FromWayPoint, ToWayPoint, Index } ) - + local CommandSwitchWayPoint = { - id = 'SwitchWaypoint', - params = { - fromWaypointIndex = FromWayPoint, - goToWaypointIndex = ToWayPoint, + id = 'SwitchWaypoint', + params = { + fromWaypointIndex = FromWayPoint, + goToWaypointIndex = ToWayPoint, }, } - + self:T3( { CommandSwitchWayPoint } ) return CommandSwitchWayPoint end - ---- Orbit at a specified position at a specified alititude during a specified duration with a specified speed. + +-- TASKS FOR AIR GROUPS + + +--- (AIR) Attack a Group. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param DCSTypes#Distance Altitude (optional) Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit ) + self:F2( { self.GroupName, AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } ) + + -- AttackGroup = { + -- id = 'AttackGroup', + -- params = { + -- groupId = Group.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend, + -- attackQty = number, + -- directionEnabled = boolean, + -- direction = Azimuth, + -- altitudeEnabled = boolean, + -- altitude = Distance, + -- attackQtyLimit = boolean, + -- } + -- } + + local DirectionEnabled = nil + if Direction then + DirectionEnabled = true + end + + local AltitudeEnabled = nil + if Altitude then + AltitudeEnabled = true + end + + local DCSTask + DCSTask = { id = 'AttackGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + directionEnabled = DirectionEnabled, + direction = Direction, + altitudeEnabled = AltitudeEnabled, + altitude = Altitude, + attackQtyLimit = AttackQtyLimit, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Attack the Unit. +-- @param #GROUP self +-- @param Unit#UNIT AttackUnit The unit. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackUnit( AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack ) + self:F2( { self.GroupName, AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack } ) + + -- AttackUnit = { + -- id = 'AttackUnit', + -- params = { + -- unitId = Unit.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend + -- attackQty = number, + -- direction = Azimuth, + -- attackQtyLimit = boolean, + -- groupAttack = boolean, + -- } + -- } + + local DCSTask + DCSTask = { id = 'AttackUnit', + params = { + unitId = AttackUnit:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + attackQtyLimit = AttackQtyLimit, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Delivering weapon at the point on the ground. +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the point to deliver weapon at. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) Desired quantity of passes. The parameter is not the same in AttackGroup and AttackUnit tasks. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskBombing( PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- Bombing = { +-- id = 'Bombing', +-- params = { +-- point = Vec2, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'Bombing', + params = { + point = PointVec2, + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + +--- (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed. -- @param #GROUP self -- @param DCSTypes#Vec2 Point The point to hold the position. -- @param #number Altitude The altitude to hold the position. -- @param #number Speed The speed flying when holding the position. -- @return #GROUP self function GROUP:TaskOrbitCircleAtVec2( Point, Altitude, Speed ) - self:F2( { self.GroupName, Point, Altitude, Speed } ) + self:F2( { self.GroupName, Point, Altitude, Speed } ) + + -- pattern = enum AI.Task.OribtPattern, + -- point = Vec2, + -- point2 = Vec2, + -- speed = Distance, + -- altitude = Distance --- pattern = enum AI.Task.OribtPattern, --- point = Vec2, --- point2 = Vec2, --- speed = Distance, --- altitude = Distance - local LandHeight = land.getHeight( Point ) - + self:T3( { LandHeight } ) - local DCSTask = { id = 'Orbit', - params = { pattern = AI.Task.OrbitPattern.CIRCLE, - point = Point, - speed = Speed, - altitude = Altitude + LandHeight - } - } + local DCSTask = { id = 'Orbit', + params = { pattern = AI.Task.OrbitPattern.CIRCLE, + point = Point, + speed = Speed, + altitude = Altitude + LandHeight + } + } + + + -- local AITask = { id = 'ControlledTask', + -- params = { task = { id = 'Orbit', + -- params = { pattern = AI.Task.OrbitPattern.CIRCLE, + -- point = Point, + -- speed = Speed, + -- altitude = Altitude + LandHeight + -- } + -- }, + -- stopCondition = { duration = Duration + -- } + -- } + -- } + -- ) - --- local AITask = { id = 'ControlledTask', --- params = { task = { id = 'Orbit', --- params = { pattern = AI.Task.OrbitPattern.CIRCLE, --- point = Point, --- speed = Speed, --- altitude = Altitude + LandHeight --- } --- }, --- stopCondition = { duration = Duration --- } --- } --- } --- ) - return DCSTask end ---- Orbit at the current position of the first unit of the group at a specified alititude +--- (AIR) Orbit at the current position of the first unit of the group at a specified alititude -- @param #GROUP self -- @param #number Altitude The altitude to hold the position. -- @param #number Speed The speed flying when holding the position. -- @return #GROUP self function GROUP:TaskOrbitCircle( Altitude, Speed ) - self:F2( { self.GroupName, Altitude, Speed } ) + self:F2( { self.GroupName, Altitude, Speed } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupPoint = self:GetPointVec2() return self:TaskOrbitCircleAtVec2( GroupPoint, Altitude, Speed ) end - + return nil end ---- Hold position at the current position of the first unit of the group. +--- (AIR) Hold position at the current position of the first unit of the group. -- @param #GROUP self -- @param #number Duration The maximum duration in seconds to hold the position. -- @return #GROUP self function GROUP:TaskHoldPosition() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) return self:TaskOrbitCircle( 30, 10 ) end ---- Land the group at a Vec2Point. + + +--- (AIR) Attacking the map object (building, structure, e.t.c). +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the point the map object is closest to. The distance between the point and the map object must not be greater than 2000 meters. Object id is not used here because Mission Editor doesn't support map object identificators. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackMapObject( PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- AttackMapObject = { +-- id = 'AttackMapObject', +-- params = { +-- point = Vec2, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'AttackMapObject', + params = { + point = PointVec2, + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Delivering weapon on the runway. +-- @param #GROUP self +-- @param Airbase#AIRBASE Airbase Airbase to attack. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskBombingRunway( Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- BombingRunway = { +-- id = 'BombingRunway', +-- params = { +-- runwayId = AirdromeId, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'BombingRunway', + params = { + point = Airbase:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Refueling from the nearest tanker. No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskRefueling() + self:F2( { self.GroupName } ) + +-- Refueling = { +-- id = 'Refueling', +-- params = {} +-- } + + local DCSTask + DCSTask = { id = 'Refueling', + params = { + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR HELICOPTER) Landing at the ground. For helicopters only. -- @param #GROUP self -- @param DCSTypes#Vec2 Point The point where to land. -- @param #number Duration The duration in seconds to stay on the ground. -- @return #GROUP self function GROUP:TaskLandAtVec2( Point, Duration ) - self:F2( { self.GroupName, Point, Duration } ) + self:F2( { self.GroupName, Point, Duration } ) +-- Land = { +-- id= 'Land', +-- params = { +-- point = Vec2, +-- durationFlag = boolean, +-- duration = Time +-- } +-- } + local DCSTask - - if Duration and Duration > 0 then - DCSTask = { id = 'Land', params = { point = Point, durationFlag = true, duration = Duration } } - else - DCSTask = { id = 'Land', params = { point = Point, durationFlag = false } } - end + if Duration and Duration > 0 then + DCSTask = { id = 'Land', + params = { + point = Point, + durationFlag = true, + duration = Duration, + }, + } + else + DCSTask = { id = 'Land', + params = { + point = Point, + durationFlag = false, + }, + } + end self:T3( DCSTask ) - return DCSTask + return DCSTask end ---- Land the group at a @{Zone#ZONE). +--- (AIR) Land the group at a @{Zone#ZONE). -- @param #GROUP self -- @param Zone#ZONE Zone The zone where to land. -- @param #number Duration The duration in seconds to stay on the ground. @@ -5070,80 +5340,104 @@ function GROUP:TaskLandAtZone( Zone, Duration, RandomPoint ) else Point = Zone:GetPointVec2() end - + local DCSTask = self:TaskLandAtVec2( Point, Duration ) self:T3( DCSTask ) return DCSTask end - ---- Attack the Unit. +--- (AIR) Following another airborne group. +-- The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. +-- If another group is on land the unit / group will orbit around. -- @param #GROUP self --- @param Unit#UNIT The unit. +-- @param Group#GROUP FollowGroup The group to be followed. +-- @param DCSTypes#Vec3 PointVec3 Position of the unit / lead unit of the group relative lead unit of another group in frame reference oriented by course of lead unit of another group. If another group is on land the unit / group will orbit around. +-- @param #number LastWaypointIndex Detach waypoint of another group. Once reached the unit / group Follow task is finished. -- @return DCSTask#Task The DCS task structure. -function GROUP:TaskAttackUnit( AttackUnit ) - self:F2( { self.GroupName, AttackUnit } ) +function GROUP:TaskFollow( FollowGroup, PointVec3, LastWaypointIndex ) + self:F2( { self.GroupName, FollowGroup, PointVec3, LastWaypointIndex } ) --- AttackUnit = { --- id = 'AttackUnit', --- params = { --- unitId = Unit.ID, --- weaponType = number, --- expend = enum AI.Task.WeaponExpend --- attackQty = number, --- direction = Azimuth, --- attackQtyLimit = boolean, --- groupAttack = boolean, --- } +-- Follow = { +-- id = 'Follow', +-- params = { +-- groupId = Group.ID, +-- pos = Vec3, +-- lastWptIndexFlag = boolean, +-- lastWptIndex = number +-- } -- } + + local LastWaypointIndexFlag = nil + if LastWaypointIndex then + LastWaypointIndexFlag = true + end - local DCSTask - DCSTask = { id = 'AttackUnit', - params = { unitId = AttackUnit:GetID(), - expend = AI.Task.WeaponExpend.TWO, - groupAttack = true, - }, - }, - + local DCSTask + DCSTask = { id = 'Follow', + params = { + groupId = FollowGroup:GetID(), + pos = PointVec3, + lastWptIndexFlag = LastWaypointIndexFlag, + lastWptIndex = LastWaypointIndex, + }, + }, + self:T3( { DCSTask } ) return DCSTask end ---- Attack a Group. + +--- (AIR) Escort another airborne group. +-- The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. +-- The unit / group will also protect that group from threats of specified types. -- @param #GROUP self --- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param Group#GROUP EscortGroup The group to be escorted. +-- @param DCSTypes#Vec3 PointVec3 Position of the unit / lead unit of the group relative lead unit of another group in frame reference oriented by course of lead unit of another group. If another group is on land the unit / group will orbit around. +-- @param #number LastWaypointIndex Detach waypoint of another group. Once reached the unit / group Follow task is finished. +-- @param #number EngagementDistanceMax Maximal distance from escorted group to threat. If the threat is already engaged by escort escort will disengage if the distance becomes greater than 1.5 * engagementDistMax. +-- @param #list TargetTypes Array of AttributeName that is contains threat categories allowed to engage. -- @return DCSTask#Task The DCS task structure. -function GROUP:TaskAttackGroup( AttackGroup ) - self:F2( { self.GroupName, AttackGroup } ) +function GROUP:TaskEscort( FollowGroup, PointVec3, LastWaypointIndex, EngagementDistance, TargetTypes ) + self:F2( { self.GroupName, FollowGroup, PointVec3, LastWaypointIndex, EngagementDistance, TargetTypes } ) --- AttackGroup = { --- id = 'AttackGroup', --- params = { --- groupId = Group.ID, --- weaponType = number, --- expend = enum AI.Task.WeaponExpend, --- attackQty = number, --- directionEnabled = boolean, --- direction = Azimuth, --- altitudeEnabled = boolean, --- altitude = Distance, --- attackQtyLimit = boolean, --- } --- } +-- Escort = { +-- id = 'Escort', +-- params = { +-- groupId = Group.ID, +-- pos = Vec3, +-- lastWptIndexFlag = boolean, +-- lastWptIndex = number, +-- engagementDistMax = Distance, +-- targetTypes = array of AttributeName, +-- } +-- } - local DCSTask - DCSTask = { id = 'AttackGroup', - params = { groupId = AttackGroup:GetID(), - expend = AI.Task.WeaponExpend.TWO, - }, - }, + local LastWaypointIndexFlag = nil + if LastWaypointIndex then + LastWaypointIndexFlag = true + end + local DCSTask + DCSTask = { id = 'Follow', + params = { + groupId = FollowGroup:GetID(), + pos = PointVec3, + lastWptIndexFlag = LastWaypointIndexFlag, + lastWptIndex = LastWaypointIndex, + engagementDistMax = EngagementDistance, + targetTypes = TargetTypes, + }, + }, + self:T3( { DCSTask } ) return DCSTask end ---- Fires at a VEC2 point. + +-- GROUND TASKS + +--- (GROUND) Fire at a VEC2 point until ammunition is finished. -- @param #GROUP self -- @param DCSTypes#Vec2 The point to fire at. -- @param DCSTypes#Distance Radius The radius of the zone to deploy the fire at. @@ -5151,25 +5445,406 @@ end function GROUP:TaskFireAtPoint( PointVec2, Radius ) self:F2( { self.GroupName, PointVec2, Radius } ) --- FireAtPoint = { --- id = 'FireAtPoint', --- params = { --- point = Vec2, --- radius = Distance, --- } --- } - - local DCSTask - DCSTask = { id = 'FireAtPoint', - params = { point = PointVec2, - radius = Radius, - } - } - + -- FireAtPoint = { + -- id = 'FireAtPoint', + -- params = { + -- point = Vec2, + -- radius = Distance, + -- } + -- } + + local DCSTask + DCSTask = { id = 'FireAtPoint', + params = { + point = PointVec2, + radius = Radius, + } + } + self:T3( { DCSTask } ) return DCSTask end +--- (GROUND) Hold ground group from moving. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskHold() + self:F2( { self.GroupName } ) + +-- Hold = { +-- id = 'Hold', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'Hold', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +-- TASKS FOR AIRBORNE AND GROUND UNITS/GROUPS + +--- (AIR + GROUND) The task makes the group/unit a FAC and orders the FAC to control the target (enemy ground group) destruction. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup Target GROUP. +-- @param #number WeaponType Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.Designation Designation (optional) Designation type. +-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink ) + self:F2( { self.GroupName, AttackGroup, WeaponType, Designation, Datalink } ) + +-- FAC_AttackGroup = { +-- id = 'FAC_AttackGroup', +-- params = { +-- groupId = Group.ID, +-- weaponType = number, +-- designation = enum AI.Task.Designation, +-- datalink = boolean +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC_AttackGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + designation = Designation, + datalink = Datalink, + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +-- EN-ROUTE TASKS FOR AIRBORNE GROUPS + +--- (AIR) Engaging targets of defined types. +-- @param #GROUP self +-- @param DCSTypes#Distance Distance Maximal distance from the target to a route leg. If the target is on a greater distance it will be ignored. +-- @param #list<#DCSTypes#AttributeName> TargetTypes Array of target categories allowed to engage. +-- @param #number Priority All enroute tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority ) + self:F2( { self.GroupName, Distance, TargetTypes, Priority } ) + +-- EngageTargets ={ +-- id = 'EngageTargets', +-- params = { +-- maxDist = Distance, +-- targetTypes = array of AttributeName, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'EngageTargets', + params = { + maxDist = Distance, + targetTypes = TargetTypes, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Engaging a targets of defined types at circle-shaped zone. +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the zone. +-- @param DCSTypes#Distance Radius Radius of the zone. +-- @param #list<#DCSTypes#AttributeName> TargetTypes Array of target categories allowed to engage. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageTargets( PointVec2, Radius, TargetTypes, Priority ) + self:F2( { self.GroupName, PointVec2, Radius, TargetTypes, Priority } ) + +-- EngageTargetsInZone = { +-- id = 'EngageTargetsInZone', +-- params = { +-- point = Vec2, +-- zoneRadius = Distance, +-- targetTypes = array of AttributeName, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'EngageTargetsInZone', + params = { + point = PointVec2, + zoneRadius = Radius, + targetTypes = TargetTypes, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +--- (AIR) Engaging a group. The task does not assign the target group to the unit/group to attack now; it just allows the unit/group to engage the target group as well as other assigned targets. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param DCSTypes#Distance Altitude (optional) Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit ) + self:F2( { self.GroupName, AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } ) + + -- EngageGroup = { + -- id = 'EngageGroup ', + -- params = { + -- groupId = Group.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend, + -- attackQty = number, + -- directionEnabled = boolean, + -- direction = Azimuth, + -- altitudeEnabled = boolean, + -- altitude = Distance, + -- attackQtyLimit = boolean, + -- priority = number, + -- } + -- } + + local DirectionEnabled = nil + if Direction then + DirectionEnabled = true + end + + local AltitudeEnabled = nil + if Altitude then + AltitudeEnabled = true + end + + local DCSTask + DCSTask = { id = 'EngageGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + directionEnabled = DirectionEnabled, + direction = Direction, + altitudeEnabled = AltitudeEnabled, + altitude = Altitude, + attackQtyLimit = AttackQtyLimit, + priority = Priority, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Attack the Unit. +-- @param #GROUP self +-- @param Unit#UNIT AttackUnit The UNIT. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageUnit( AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack ) + self:F2( { self.GroupName, AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack } ) + + -- EngageUnit = { + -- id = 'EngageUnit', + -- params = { + -- unitId = Unit.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend + -- attackQty = number, + -- direction = Azimuth, + -- attackQtyLimit = boolean, + -- groupAttack = boolean, + -- priority = number, + -- } + -- } + + local DCSTask + DCSTask = { id = 'EngageUnit', + params = { + unitId = AttackUnit:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + attackQtyLimit = AttackQtyLimit, + groupAttack = GroupAttack, + priority = Priority, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Aircraft will act as an AWACS for friendly units (will provide them with information about contacts). No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskAWACS( ) + self:F2( { self.GroupName } ) + +-- AWACS = { +-- id = 'AWACS', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'AWACS', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Aircraft will act as a tanker for friendly units. No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskTanker( ) + self:F2( { self.GroupName } ) + +-- Tanker = { +-- id = 'Tanker', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'Tanker', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +-- En-route tasks for ground units/groups + +--- (GROUND) Ground unit (EW-radar) will act as an EWR for friendly units (will provide them with information about contacts). No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEWR( ) + self:F2( { self.GroupName } ) + +-- EWR = { +-- id = 'EWR', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'EWR', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +-- En-route tasks for airborne and ground units/groups + +--- (AIR + GROUND) The task makes the group/unit a FAC and lets the FAC to choose the target (enemy ground group) as well as other assigned targets. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup Target GROUP. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.Designation Designation (optional) Designation type. +-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponType, Designation, Datalink ) + self:F2( { self.GroupName, AttackGroup, WeaponType, Priority, Designation, Datalink } ) + +-- FAC_EngageGroup = { +-- id = 'FAC_EngageGroup', +-- params = { +-- groupId = Group.ID, +-- weaponType = number, +-- designation = enum AI.Task.Designation, +-- datalink = boolean, +-- priority = number, +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC_EngageGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + designation = Designation, + datalink = Datalink, + priority = Priority, + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR + GROUND) The task makes the group/unit a FAC and lets the FAC to choose a targets (enemy ground group) around as well as other assigned targets. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param DCSTypes#Distance Radius The maximal distance from the FAC to a target. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskFAC( Radius, Priority ) + self:F2( { self.GroupName, Radius, Priority } ) + +-- FAC = { +-- id = 'FAC', +-- params = { +-- radius = Distance, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC', + params = { + radius = Radius, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + --- Move the group to a Vec2 Point, wait for a defined duration and embark a group. @@ -5179,22 +5854,22 @@ end -- @param #GROUP EmbarkingGroup The group to be embarked. -- @return DCSTask#Task The DCS task structure function GROUP:TaskEmbarkingAtVec2( Point, Duration, EmbarkingGroup ) - self:F2( { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } ) + self:F2( { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } ) - local DCSTask - DCSTask = { id = 'Embarking', - params = { x = Point.x, - y = Point.y, - duration = Duration, - groupsForEmbarking = { EmbarkingGroup.GroupID }, - durationFlag = true, - distributionFlag = false, - distribution = {}, - } - } - - self:T3( { DCSTask } ) - return DCSTask + local DCSTask + DCSTask = { id = 'Embarking', + params = { x = Point.x, + y = Point.y, + duration = Duration, + groupsForEmbarking = { EmbarkingGroup.GroupID }, + durationFlag = true, + distributionFlag = false, + distribution = {}, + } + } + + self:T3( { DCSTask } ) + return DCSTask end --- Move to a defined Vec2 Point, and embark to a group when arrived within a defined Radius. @@ -5203,30 +5878,30 @@ end -- @param #number Radius The radius of the embarking zone around the Point. -- @return DCSTask#Task The DCS task structure. function GROUP:TaskEmbarkToTransportAtVec2( Point, Radius ) - self:F2( { self.GroupName, Point, Radius } ) + self:F2( { self.GroupName, Point, Radius } ) local DCSTask --DCSTask#Task - DCSTask = { id = 'EmbarkToTransport', - params = { x = Point.x, - y = Point.y, - zoneRadius = Radius, - } - } + DCSTask = { id = 'EmbarkToTransport', + params = { x = Point.x, + y = Point.y, + zoneRadius = Radius, + } + } self:T3( { DCSTask } ) - return DCSTask + return DCSTask end --- Return a Misson task from a mission template. -- @param #GROUP self -- @param #table TaskMission A table containing the mission task. --- @return DCSTask#Task +-- @return DCSTask#Task function GROUP:TaskMission( TaskMission ) - self:F2( Points ) - + self:F2( Points ) + local DCSTask DCSTask = { id = 'Mission', params = { TaskMission, }, } - + self:T3( { DCSTask } ) return DCSTask end @@ -5234,13 +5909,13 @@ end --- Return a Misson task to follow a given route defined by Points. -- @param #GROUP self -- @param #table Points A table of route points. --- @return DCSTask#Task +-- @return DCSTask#Task function GROUP:TaskRoute( Points ) self:F2( Points ) - + local DCSTask DCSTask = { id = 'Mission', params = { route = { points = Points, }, }, } - + self:T3( { DCSTask } ) return DCSTask end @@ -5254,22 +5929,22 @@ function GROUP:TaskRouteToVec2( Point, Speed ) self:F2( { Point, Speed } ) local GroupPoint = self:GetUnit( 1 ):GetPointVec2() - + local PointFrom = {} PointFrom.x = GroupPoint.x PointFrom.y = GroupPoint.y PointFrom.type = "Turning Point" PointFrom.action = "Turning Point" - PointFrom.speed = Speed + PointFrom.speed = Speed PointFrom.speed_locked = true PointFrom.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local PointTo = {} PointTo.x = Point.x @@ -5279,18 +5954,18 @@ function GROUP:TaskRouteToVec2( Point, Speed ) PointTo.speed = Speed PointTo.speed_locked = true PointTo.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local Points = { PointFrom, PointTo } - + self:T3( Points ) - + self:Route( Points ) return self @@ -5305,7 +5980,7 @@ function GROUP:TaskRouteToVec3( Point, Speed ) self:F2( { Point, Speed } ) local GroupPoint = self:GetUnit( 1 ):GetPointVec3() - + local PointFrom = {} PointFrom.x = GroupPoint.x PointFrom.y = GroupPoint.z @@ -5313,39 +5988,39 @@ function GROUP:TaskRouteToVec3( Point, Speed ) PointFrom.alt_type = "BARO" PointFrom.type = "Turning Point" PointFrom.action = "Turning Point" - PointFrom.speed = Speed + PointFrom.speed = Speed PointFrom.speed_locked = true PointFrom.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local PointTo = {} PointTo.x = Point.x PointTo.y = Point.z - PointTo.alt = Point.y + PointTo.alt = Point.y PointTo.alt_type = "BARO" PointTo.type = "Turning Point" PointTo.action = "Fly Over Point" PointTo.speed = Speed PointTo.speed_locked = true PointTo.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local Points = { PointFrom, PointTo } - + self:T3( Points ) - + self:Route( Points ) return self @@ -5356,22 +6031,22 @@ end --- Make the group to follow a given route. -- @param #GROUP self -- @param #table GoPoints A table of Route Points. --- @return #GROUP self +-- @return #GROUP self function GROUP:Route( GoPoints ) - self:F2( GoPoints ) + self:F2( GoPoints ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local Points = routines.utils.deepCopy( GoPoints ) - local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, } - local Controller = self:_GetController() + local Points = routines.utils.deepCopy( GoPoints ) + local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, } + local Controller = self:_GetController() --Controller.setTask( Controller, MissionTask ) - --routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 ) + --routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 ) SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 ) - return self + return self end - + return nil end @@ -5387,56 +6062,56 @@ end -- @param #number Speed The speed. -- @param Base#FORMATION Formation The formation string. function GROUP:TaskRouteToZone( Zone, Randomize, Speed, Formation ) - self:F2( Zone ) + self:F2( Zone ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - - local GroupPoint = self:GetPointVec2() - - local PointFrom = {} - PointFrom.x = GroupPoint.x - PointFrom.y = GroupPoint.y - PointFrom.type = "Turning Point" - PointFrom.action = "Cone" - PointFrom.speed = 20 / 1.6 - - - local PointTo = {} - local ZonePoint - - if Randomize then - ZonePoint = Zone:GetRandomPointVec2() - else - ZonePoint = Zone:GetPointVec2() - end - - PointTo.x = ZonePoint.x - PointTo.y = ZonePoint.y - PointTo.type = "Turning Point" - - if Formation then - PointTo.action = Formation - else - PointTo.action = "Cone" - end - - if Speed then - PointTo.speed = Speed - else - PointTo.speed = 20 / 1.6 - end - - local Points = { PointFrom, PointTo } - - self:T3( Points ) - - self:Route( Points ) - - return self + + local GroupPoint = self:GetPointVec2() + + local PointFrom = {} + PointFrom.x = GroupPoint.x + PointFrom.y = GroupPoint.y + PointFrom.type = "Turning Point" + PointFrom.action = "Cone" + PointFrom.speed = 20 / 1.6 + + + local PointTo = {} + local ZonePoint + + if Randomize then + ZonePoint = Zone:GetRandomPointVec2() + else + ZonePoint = Zone:GetPointVec2() + end + + PointTo.x = ZonePoint.x + PointTo.y = ZonePoint.y + PointTo.type = "Turning Point" + + if Formation then + PointTo.action = Formation + else + PointTo.action = "Cone" + end + + if Speed then + PointTo.speed = Speed + else + PointTo.speed = 20 / 1.6 + end + + local Points = { PointFrom, PointTo } + + self:T3( Points ) + + self:Route( Points ) + + return self end - + return nil end @@ -5483,48 +6158,48 @@ end -- @param #number Begin The route point from where the copy will start. The base route point is 0. -- @param #number End The route point where the copy will end. The End point is the last point - the End point. The last point has base 0. -- @param #boolean Randomize Randomization of the route, when true. --- @param #number Radius When randomization is on, the randomization is within the radius. +-- @param #number Radius When randomization is on, the randomization is within the radius. function GROUP:CopyRoute( Begin, End, Randomize, Radius ) - self:F2( { Begin, End } ) + self:F2( { Begin, End } ) - local Points = {} - - -- Could be a Spawned Group - local GroupName = string.match( self:GetName(), ".*#" ) - if GroupName then - GroupName = GroupName:sub( 1, -2 ) - else - GroupName = self:GetName() - end - - self:T3( { GroupName } ) - - local Template = _DATABASE.Templates.Groups[GroupName].Template - - if Template then - if not Begin then - Begin = 0 - end - if not End then - End = 0 - end - - for TPointID = Begin + 1, #Template.route.points - End do - if Template.route.points[TPointID] then - Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] ) - if Randomize then - if not Radius then - Radius = 500 - end - Points[#Points].x = Points[#Points].x + math.random( Radius * -1, Radius ) - Points[#Points].y = Points[#Points].y + math.random( Radius * -1, Radius ) - end - end - end - return Points - end - - return nil + local Points = {} + + -- Could be a Spawned Group + local GroupName = string.match( self:GetName(), ".*#" ) + if GroupName then + GroupName = GroupName:sub( 1, -2 ) + else + GroupName = self:GetName() + end + + self:T3( { GroupName } ) + + local Template = _DATABASE.Templates.Groups[GroupName].Template + + if Template then + if not Begin then + Begin = 0 + end + if not End then + End = 0 + end + + for TPointID = Begin + 1, #Template.route.points - End do + if Template.route.points[TPointID] then + Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] ) + if Randomize then + if not Radius then + Radius = 500 + end + Points[#Points].x = Points[#Points].x + math.random( Radius * -1, Radius ) + Points[#Points].y = Points[#Points].y + math.random( Radius * -1, Radius ) + end + end + end + return Points + end + + return nil end @@ -5535,28 +6210,28 @@ function GROUP:GetDetectedTargets() if DCSGroup then return self:_GetController():getDetectedTargets() end - + return nil end function GROUP:IsTargetDetected( DCSObject ) self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then - + local TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity - = self:_GetController().isTargetDetected( self:_GetController(), DCSObject, - Controller.Detection.VISUAL, - Controller.Detection.OPTIC, - Controller.Detection.RADAR, - Controller.Detection.IRST, - Controller.Detection.RWR, - Controller.Detection.DLINK - ) + = self:_GetController().isTargetDetected( self:_GetController(), DCSObject, + Controller.Detection.VISUAL, + Controller.Detection.OPTIC, + Controller.Detection.RADAR, + Controller.Detection.IRST, + Controller.Detection.RWR, + Controller.Detection.DLINK + ) return TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity end - + return nil end @@ -5567,16 +6242,16 @@ end -- @return #boolean function GROUP:OptionROEHoldFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -5584,12 +6259,12 @@ end -- @param Group#GROUP self -- @return Group#GROUP self function GROUP:OptionROEHoldFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD ) elseif self:IsGround() then @@ -5597,10 +6272,10 @@ function GROUP:OptionROEHoldFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.WEAPON_HOLD ) end - + return self end - + return nil end @@ -5609,16 +6284,16 @@ end -- @return #boolean function GROUP:OptionROEReturnFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -5626,12 +6301,12 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEReturnFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.RETURN_FIRE ) elseif self:IsGround() then @@ -5639,10 +6314,10 @@ function GROUP:OptionROEReturnFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.RETURN_FIRE ) end - + return self end - + return nil end @@ -5657,10 +6332,10 @@ function GROUP:OptionROEOpenFirePossible() if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -5668,12 +6343,12 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEOpenFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE ) elseif self:IsGround() then @@ -5681,10 +6356,10 @@ function GROUP:OptionROEOpenFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.OPEN_FIRE ) end - + return self end - + return nil end @@ -5693,16 +6368,16 @@ end -- @return #boolean function GROUP:OptionROEWeaponFreePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -5710,19 +6385,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEWeaponFree() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_FREE ) end - + return self end - + return nil end @@ -5731,16 +6406,16 @@ end -- @return #boolean function GROUP:OptionROTNoReactionPossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -5749,19 +6424,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTNoReaction() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.NO_REACTION ) end - + return self end - + return nil end @@ -5776,10 +6451,10 @@ function GROUP:OptionROTPassiveDefensePossible() if self:IsAir() then return true end - + return false end - + return nil end @@ -5787,19 +6462,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTPassiveDefense() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENCE ) end - + return self end - + return nil end @@ -5808,16 +6483,16 @@ end -- @return #boolean function GROUP:OptionROTEvadeFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -5826,19 +6501,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTEvadeFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE ) end - + return self end - + return nil end @@ -5847,16 +6522,16 @@ end -- @return #boolean function GROUP:OptionROTVerticalPossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -5865,19 +6540,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTVertical() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.BYPASS_AND_ESCAPE ) end - + return self end - + return nil end @@ -5890,12 +6565,12 @@ end -- @return Message#MESSAGE function GROUP:Message( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then return MESSAGE:New( Message, self:GetCallsign() .. " (" .. self:GetTypeName() .. ")", Duration, self:GetClassNameAndID() ) end - + return nil end @@ -5906,12 +6581,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToAll( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToAll() end - + return nil end @@ -5922,12 +6597,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToRed( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToRed() end - + return nil end @@ -5938,12 +6613,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToBlue( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToBlue() end - + return nil end @@ -5955,12 +6630,12 @@ end -- @param Client#CLIENT Client The client object receiving the message. function GROUP:MessageToClient( Message, Duration, Client ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToClient( Client ) end - + return nil end --- UNIT Class diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index 9b72a9419..07c019def 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20160527_1422' ) +env.info( 'Moose Generation Timestamp: 20160602_1448' ) local base = _G env.info("Loading MOOSE " .. base.timer.getAbsTime() ) @@ -4071,35 +4071,35 @@ function MENU_COALITION_COMMAND:Remove() self.ParentMenu.Menus[self.MenuPath] = nil return nil end ---- GROUP class. --- +--- GROUP class. +-- -- @{GROUP} class -- ============== -- The @{GROUP} class is a wrapper class to handle the DCS Group objects: --- +-- -- * Support all DCS Group APIs. -- * Enhance with Group specific APIs not in the DCS Group API set. -- * Handle local Group Controller. -- * Manage the "state" of the DCS Group. --- --- +-- +-- -- GROUP reference methods --- ======================= +-- ======================= -- For each DCS Group object alive within a running mission, a GROUP wrapper object (instance) will be created within the _@{DATABASE} object. -- This is done at the beginning of the mission (when the mission starts), and dynamically when new DCS Group objects are spawned (using the @{SPAWN} class). --- +-- -- The GROUP class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference -- using the DCS Group or the DCS GroupName. --- --- Another thing to know is that GROUP objects do not "contain" the DCS Group object. +-- +-- Another thing to know is that GROUP objects do not "contain" the DCS Group object. -- The GROUP methods will reference the DCS Group object by name when it is needed during API execution. -- If the DCS Group object does not exist or is nil, the GROUP methods will return nil and log an exception in the DCS.log file. --- +-- -- The GROUP class provides the following functions to retrieve quickly the relevant GROUP instance: --- +-- -- * @{#GROUP.Find}(): Find a GROUP instance from the _DATABASE object using a DCS Group object. -- * @{#GROUP.FindByName}(): Find a GROUP instance from the _DATABASE object using a DCS Group name. --- +-- -- IMPORTANT: ONE SHOULD NEVER SANATIZE these GROUP OBJECT REFERENCES! (make the GROUP object references nil). -- @module Group -- @author FlightControl @@ -4115,14 +4115,14 @@ Include.File( "Unit" ) -- @field DCSGroup#Group DCSGroup The DCS group class. -- @field #string GroupName The name of the group. GROUP = { - ClassName = "GROUP", - GroupName = "", - GroupID = 0, - Controller = nil, - DCSGroup = nil, - WayPointFunctions = {}, - } - + ClassName = "GROUP", + GroupName = "", + GroupID = 0, + Controller = nil, + DCSGroup = nil, + WayPointFunctions = {}, +} + --- A DCSGroup -- @type DCSGroup -- @field id_ The ID of the group in DCS @@ -4132,10 +4132,10 @@ GROUP = { -- @param DCSGroup#Group GroupName The DCS Group name -- @return #GROUP self function GROUP:Register( GroupName ) - local self = BASE:Inherit( self, BASE:New() ) - self:F2( GroupName ) - self.GroupName = GroupName - return self + local self = BASE:Inherit( self, BASE:New() ) + self:F2( GroupName ) + self.GroupName = GroupName + return self end -- Reference methods. @@ -4168,11 +4168,11 @@ end -- @return DCSGroup#Group The DCS Group. function GROUP:GetDCSGroup() local DCSGroup = Group.getByName( self.GroupName ) - + if DCSGroup then return DCSGroup end - + return nil end @@ -4183,27 +4183,27 @@ end -- @return #boolean true if the DCS Group is alive. function GROUP:IsAlive() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupIsAlive = DCSGroup:isExist() self:T3( GroupIsAlive ) return GroupIsAlive end - + return nil end ---- Destroys the DCS Group and all of its DCS Units. +--- Destroys the DCS Group and all of its DCS Units. -- Note that this destroy method also raises a destroy event at run-time. -- So all event listeners will catch the destroy event of this DCS Group. -- @param #GROUP self function GROUP:Destroy() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then for Index, UnitData in pairs( DCSGroup:getUnits() ) do self:CreateEventCrash( timer.getTime(), UnitData ) @@ -4211,11 +4211,11 @@ function GROUP:Destroy() DCSGroup:destroy() DCSGroup = nil end - + return nil end ---- Returns category of the DCS Group. +--- Returns category of the DCS Group. -- @param #GROUP self -- @return DCSGroup#Group.Category The category ID function GROUP:GetCategory() @@ -4227,7 +4227,7 @@ function GROUP:GetCategory() self:T3( GroupCategory ) return GroupCategory end - + return nil end @@ -4243,14 +4243,14 @@ function GROUP:GetCategoryName() [Group.Category.AIRPLANE] = "Airplane", [Group.Category.HELICOPTER] = "Helicopter", [Group.Category.GROUND] = "Ground Unit", - [Group.Category.SHIP] = "Ship", + [Group.Category.SHIP] = "Ship", } local GroupCategory = DCSGroup:getCategory() self:T3( GroupCategory ) - + return CategoryNames[GroupCategory] end - + return nil end @@ -4267,14 +4267,14 @@ function GROUP:GetCoalition() self:T3( GroupCoalition ) return GroupCoalition end - + return nil end --- Returns the country of the DCS Group. -- @param #GROUP self -- @return DCScountry#country.id The country identifier. --- @return #nil The DCS Group is not existing or alive. +-- @return #nil The DCS Group is not existing or alive. function GROUP:GetCountry() self:F2( self.GroupName ) @@ -4284,7 +4284,7 @@ function GROUP:GetCountry() self:T3( GroupCountry ) return GroupCountry end - + return nil end @@ -4295,13 +4295,13 @@ function GROUP:GetName() self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupName = DCSGroup:getName() self:T3( GroupName ) return GroupName end - + return nil end @@ -4310,19 +4310,19 @@ end -- @return #number The identifier of the DCS Group. function GROUP:GetID() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupID = DCSGroup:getID() self:T3( GroupID ) return GroupID end - + return nil end ---- Returns the UNIT wrapper class with number UnitNumber. +--- Returns the UNIT wrapper class with number UnitNumber. -- If the underlying DCS Unit does not exist, the method will return nil. . -- @param #GROUP self -- @param #number UnitNumber The number of the UNIT wrapper class to be returned. @@ -4331,7 +4331,7 @@ function GROUP:GetUnit( UnitNumber ) self:F2( { self.GroupName, UnitNumber } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local UnitFound = UNIT:Find( DCSGroup:getUnit( UnitNumber ) ) self:T3( UnitFound.UnitName ) @@ -4342,7 +4342,7 @@ function GROUP:GetUnit( UnitNumber ) return nil end ---- Returns the DCS Unit with number UnitNumber. +--- Returns the DCS Unit with number UnitNumber. -- If the underlying DCS Unit does not exist, the method will return nil. . -- @param #GROUP self -- @param #number UnitNumber The number of the DCS Unit to be returned. @@ -4351,7 +4351,7 @@ function GROUP:GetDCSUnit( UnitNumber ) self:F2( { self.GroupName, UnitNumber } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnitFound = DCSGroup:getUnit( UnitNumber ) self:T3( DCSUnitFound ) @@ -4361,14 +4361,14 @@ function GROUP:GetDCSUnit( UnitNumber ) return nil end ---- Returns current size of the DCS Group. --- If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed. +--- Returns current size of the DCS Group. +-- If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed. -- @param #GROUP self -- @return #number The DCS Group size. function GROUP:GetSize() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupSize = DCSGroup:getSize() self:T3( GroupSize ) @@ -4378,15 +4378,15 @@ function GROUP:GetSize() return nil end ---- ---- Returns the initial size of the DCS Group. --- If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged. +--- +--- Returns the initial size of the DCS Group. +-- If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged. -- @param #GROUP self -- @return #number The DCS Group initial size. function GROUP:GetInitialSize() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupInitialSize = DCSGroup:getInitialSize() self:T3( GroupInitialSize ) @@ -4402,7 +4402,7 @@ end function GROUP:GetUnits() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnits = DCSGroup:getUnits() local Units = {} @@ -4423,7 +4423,7 @@ end function GROUP:GetDCSUnits() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local DCSUnits = DCSGroup:getUnits() self:T3( DCSUnits ) @@ -4439,7 +4439,7 @@ end function GROUP:_GetController() self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupController = DCSGroup:getController() self:T3( GroupController ) @@ -4459,7 +4459,7 @@ end function GROUP:WayPointInitialize() self.WayPoints = self:GetTaskRoute() - + return self end @@ -4472,7 +4472,7 @@ end -- @return #GROUP function GROUP:WayPointFunction( WayPoint, WayPointIndex, WayPointFunction, ... ) self:F2( { WayPoint, WayPointIndex, WayPointFunction } ) - + table.insert( self.WayPoints[WayPoint].task.params.tasks, WayPointIndex ) self.WayPoints[WayPoint].task.params.tasks[WayPointIndex] = self:TaskFunction( WayPoint, WayPointIndex, WayPointFunction, arg ) return self @@ -4482,7 +4482,7 @@ end function GROUP:TaskFunction( WayPoint, WayPointIndex, FunctionString, FunctionArguments ) local DCSTask - + local DCSScript = {} DCSScript[#DCSScript+1] = "local MissionGroup = GROUP:Find( ... ) " @@ -4490,16 +4490,16 @@ function GROUP:TaskFunction( WayPoint, WayPointIndex, FunctionString, FunctionAr DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup, " .. table.concat( FunctionArguments, "," ) .. ")" else DCSScript[#DCSScript+1] = FunctionString .. "( MissionGroup )" - end - - DCSTask = self:TaskWrappedAction( + end + + DCSTask = self:TaskWrappedAction( self:CommandDoScript( table.concat( DCSScript ) ), WayPointIndex ) - + self:T3( DCSTask ) - + return DCSTask end @@ -4518,14 +4518,14 @@ function GROUP:WayPointExecute( WayPoint, WaitTime ) if not WayPoint then WayPoint = 1 end - + -- When starting the mission from a certain point, the TaskPoints need to be deleted before the given WayPoint. for TaskPointID = 1, WayPoint - 1 do table.remove( self.WayPoints, 1 ) end self:T3( self.WayPoints ) - + self:SetTask( self:TaskRoute( self.WayPoints ), WaitTime ) return self @@ -4535,9 +4535,9 @@ end --- Activates a GROUP. -- @param #GROUP self function GROUP:Activate() - self:F2( { self.GroupName } ) - trigger.action.activateGroup( self:GetDCSGroup() ) - return self:GetDCSGroup() + self:F2( { self.GroupName } ) + trigger.action.activateGroup( self:GetDCSGroup() ) + return self:GetDCSGroup() end @@ -4548,13 +4548,13 @@ function GROUP:GetTypeName() self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupTypeName = DCSGroup:getUnit(1):getTypeName() self:T3( GroupTypeName ) return( GroupTypeName ) end - + return nil end @@ -4563,33 +4563,33 @@ end -- @return #string The CallSign of the first DCS Unit of the DCS Group. function GROUP:GetCallsign() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCallSign = DCSGroup:getUnit(1):getCallsign() self:T3( GroupCallSign ) return GroupCallSign end - + return nil end --- Returns the current point (Vec2 vector) of the first DCS Unit in the DCS Group. -- @return DCSTypes#Vec2 Current Vec2 point of the first DCS Unit of the DCS Group. function GROUP:GetPointVec2() - self:F2( self.GroupName ) - - local GroupPointVec2 = self:GetUnit(1):GetPointVec2() - self:T3( GroupPointVec2 ) - return GroupPointVec2 + self:F2( self.GroupName ) + + local GroupPointVec2 = self:GetUnit(1):GetPointVec2() + self:T3( GroupPointVec2 ) + return GroupPointVec2 end --- Returns the current point (Vec3 vector) of the first DCS Unit in the DCS Group. -- @return DCSTypes#Vec3 Current Vec3 point of the first DCS Unit of the DCS Group. function GROUP:GetPointVec3() - self:F2( self.GroupName ) - + self:F2( self.GroupName ) + local GroupPointVec3 = self:GetUnit(1):GetPointVec3() self:T3( GroupPointVec3 ) return GroupPointVec3 @@ -4604,16 +4604,16 @@ end -- @param #GROUP self -- @return #boolean Air category evaluation result. function GROUP:IsAir() - self:F2( self.GroupName ) + self:F2( self.GroupName ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local IsAirResult = DCSGroup:getCategory() == Group.Category.AIRPLANE or DCSGroup:getCategory() == Group.Category.HELICOPTER - self:T3( IsAirResult ) - return IsAirResult + local IsAirResult = DCSGroup:getCategory() == Group.Category.AIRPLANE or DCSGroup:getCategory() == Group.Category.HELICOPTER + self:T3( IsAirResult ) + return IsAirResult end - + return nil end @@ -4622,15 +4622,15 @@ end -- @return #boolean true if DCS Group contains Helicopters. function GROUP:IsHelicopter() self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.HELICOPTER end - + return nil end @@ -4639,15 +4639,15 @@ end -- @return #boolean true if DCS Group contains AirPlanes. function GROUP:IsAirPlane() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.AIRPLANE end - + return nil end @@ -4656,15 +4656,15 @@ end -- @return #boolean true if DCS Group contains Ground troops. function GROUP:IsGround() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.GROUND end - + return nil end @@ -4673,15 +4673,15 @@ end -- @return #boolean true if DCS Group contains Ships. function GROUP:IsShip() self:F2() - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupCategory = DCSGroup:getCategory() self:T2( GroupCategory ) return GroupCategory == Group.Category.SHIP end - + return nil end @@ -4690,23 +4690,23 @@ end -- @param #GROUP self -- @return #boolean All units on the ground result. function GROUP:AllOnGround() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local AllOnGroundResult = true - - for Index, UnitData in pairs( DCSGroup:getUnits() ) do - if UnitData:inAir() then - AllOnGroundResult = false - end - end - - self:T3( AllOnGroundResult ) - return AllOnGroundResult + local AllOnGroundResult = true + + for Index, UnitData in pairs( DCSGroup:getUnits() ) do + if UnitData:inAir() then + AllOnGroundResult = false + end + end + + self:T3( AllOnGroundResult ) + return AllOnGroundResult end - + return nil end @@ -4715,26 +4715,26 @@ end -- @param #GROUP self -- @return #number Maximum velocity found. function GROUP:GetMaxVelocity() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local MaxVelocity = 0 - - for Index, UnitData in pairs( DCSGroup:getUnits() ) do - - local Velocity = UnitData:getVelocity() - local VelocityTotal = math.abs( Velocity.x ) + math.abs( Velocity.y ) + math.abs( Velocity.z ) - - if VelocityTotal < MaxVelocity then - MaxVelocity = VelocityTotal - end - end - - return MaxVelocity + local MaxVelocity = 0 + + for Index, UnitData in pairs( DCSGroup:getUnits() ) do + + local Velocity = UnitData:getVelocity() + local VelocityTotal = math.abs( Velocity.x ) + math.abs( Velocity.y ) + math.abs( Velocity.z ) + + if VelocityTotal < MaxVelocity then + MaxVelocity = VelocityTotal + end + end + + return MaxVelocity end - + return nil end @@ -4743,7 +4743,7 @@ end -- @param #GROUP self -- @return #number Minimum height found. function GROUP:GetMinHeight() - self:F2() + self:F2() end @@ -4752,7 +4752,7 @@ end -- @param #GROUP self -- @return #number Maximum height found. function GROUP:GetMaxHeight() - self:F2() + self:F2() end @@ -4762,16 +4762,16 @@ end -- @param #GROUP self -- @return Group#GROUP self function GROUP:PopCurrentTask() - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() Controller:popTask() return self end - + return nil end @@ -4779,27 +4779,27 @@ end -- @param #GROUP self -- @return Group#GROUP self function GROUP:PushTask( DCSTask, WaitTime ) - self:F2() + self:F2() local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() - + -- When a group SPAWNs, it takes about a second to get the group in the simulator. Setting tasks to unspawned groups provides unexpected results. -- Therefore we schedule the functions to set the mission and options for the Group. -- Controller:pushTask( DCSTask ) - + if WaitTime then --routines.scheduleFunction( Controller.pushTask, { Controller, DCSTask }, timer.getTime() + WaitTime ) SCHEDULER:New( Controller, Controller.pushTask, { DCSTask }, WaitTime ) else Controller:pushTask( DCSTask ) end - + return self end - + return nil end @@ -4810,24 +4810,24 @@ function GROUP:SetTask( DCSTask, WaitTime ) self:F2( { DCSTask } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - + local Controller = self:_GetController() - + -- When a group SPAWNs, it takes about a second to get the group in the simulator. Setting tasks to unspawned groups provides unexpected results. -- Therefore we schedule the functions to set the mission and options for the Group. -- Controller.setTask( Controller, DCSTask ) - + if not WaitTime then WaitTime = 1 end --routines.scheduleFunction( Controller.setTask, { Controller, DCSTask }, timer.getTime() + WaitTime ) SCHEDULER:New( Controller, Controller.setTask, { DCSTask }, WaitTime ) - + return self end - + return nil end @@ -4835,15 +4835,15 @@ end --- Return a condition section for a controlled task -- @param #GROUP self -- @param DCSTime#Time time --- @param #string userFlag --- @param #boolean userFlagValue +-- @param #string userFlag +-- @param #boolean userFlagValue -- @param #string condition --- @param DCSTime#Time duration --- @param #number lastWayPoint +-- @param DCSTime#Time duration +-- @param #number lastWayPoint -- return DCSTask#Task function GROUP:TaskCondition( time, userFlag, userFlagValue, condition, duration, lastWayPoint ) - self:F2( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } ) - + self:F2( { time, userFlag, userFlagValue, condition, duration, lastWayPoint } ) + local DCSStopCondition = {} DCSStopCondition.time = time DCSStopCondition.userFlag = userFlag @@ -4851,9 +4851,9 @@ function GROUP:TaskCondition( time, userFlag, userFlagValue, condition, duration DCSStopCondition.condition = condition DCSStopCondition.duration = duration DCSStopCondition.lastWayPoint = lastWayPoint - + self:T3( { DCSStopCondition } ) - return DCSStopCondition + return DCSStopCondition end --- Return a Controlled Task taking a Task and a TaskCondition @@ -4862,18 +4862,18 @@ end -- @param #DCSStopCondition DCSStopCondition -- @return DCSTask#Task function GROUP:TaskControlled( DCSTask, DCSStopCondition ) - self:F2( { DCSTask, DCSStopCondition } ) + self:F2( { DCSTask, DCSStopCondition } ) local DCSTaskControlled - - DCSTaskControlled = { - id = 'ControlledTask', - params = { - task = DCSTask, - stopCondition = DCSStopCondition - } + + DCSTaskControlled = { + id = 'ControlledTask', + params = { + task = DCSTask, + stopCondition = DCSStopCondition + } } - + self:T3( { DCSTaskControlled } ) return DCSTaskControlled end @@ -4886,19 +4886,19 @@ function GROUP:TaskCombo( DCSTasks ) self:F2( { DCSTasks } ) local DCSTaskCombo - - DCSTaskCombo = { - id = 'ComboTask', - params = { + + DCSTaskCombo = { + id = 'ComboTask', + params = { tasks = DCSTasks - } + } } - + self:T3( { DCSTaskCombo } ) return DCSTaskCombo end ---- Return a WrappedAction Task taking a Command +--- Return a WrappedAction Task taking a Command -- @param #GROUP self -- @param DCSCommand#Command DCSCommand -- @return DCSTask#Task @@ -4906,8 +4906,8 @@ function GROUP:TaskWrappedAction( DCSCommand, Index ) self:F2( { DCSCommand } ) local DCSTaskWrappedAction - - DCSTaskWrappedAction = { + + DCSTaskWrappedAction = { id = "WrappedAction", enabled = true, number = Index, @@ -4927,15 +4927,15 @@ end -- @return #GROUP self function GROUP:SetCommand( DCSCommand ) self:F2( DCSCommand ) - + local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local Controller = self:_GetController() Controller:setCommand( DCSCommand ) return self end - + return nil end @@ -4946,117 +4946,387 @@ end -- @return DCSTask#Task function GROUP:CommandSwitchWayPoint( FromWayPoint, ToWayPoint, Index ) self:F2( { FromWayPoint, ToWayPoint, Index } ) - + local CommandSwitchWayPoint = { - id = 'SwitchWaypoint', - params = { - fromWaypointIndex = FromWayPoint, - goToWaypointIndex = ToWayPoint, + id = 'SwitchWaypoint', + params = { + fromWaypointIndex = FromWayPoint, + goToWaypointIndex = ToWayPoint, }, } - + self:T3( { CommandSwitchWayPoint } ) return CommandSwitchWayPoint end - ---- Orbit at a specified position at a specified alititude during a specified duration with a specified speed. + +-- TASKS FOR AIR GROUPS + + +--- (AIR) Attack a Group. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param DCSTypes#Distance Altitude (optional) Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackGroup( AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit ) + self:F2( { self.GroupName, AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } ) + + -- AttackGroup = { + -- id = 'AttackGroup', + -- params = { + -- groupId = Group.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend, + -- attackQty = number, + -- directionEnabled = boolean, + -- direction = Azimuth, + -- altitudeEnabled = boolean, + -- altitude = Distance, + -- attackQtyLimit = boolean, + -- } + -- } + + local DirectionEnabled = nil + if Direction then + DirectionEnabled = true + end + + local AltitudeEnabled = nil + if Altitude then + AltitudeEnabled = true + end + + local DCSTask + DCSTask = { id = 'AttackGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + directionEnabled = DirectionEnabled, + direction = Direction, + altitudeEnabled = AltitudeEnabled, + altitude = Altitude, + attackQtyLimit = AttackQtyLimit, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Attack the Unit. +-- @param #GROUP self +-- @param Unit#UNIT AttackUnit The unit. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackUnit( AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack ) + self:F2( { self.GroupName, AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack } ) + + -- AttackUnit = { + -- id = 'AttackUnit', + -- params = { + -- unitId = Unit.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend + -- attackQty = number, + -- direction = Azimuth, + -- attackQtyLimit = boolean, + -- groupAttack = boolean, + -- } + -- } + + local DCSTask + DCSTask = { id = 'AttackUnit', + params = { + unitId = AttackUnit:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + attackQtyLimit = AttackQtyLimit, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Delivering weapon at the point on the ground. +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the point to deliver weapon at. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) Desired quantity of passes. The parameter is not the same in AttackGroup and AttackUnit tasks. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskBombing( PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- Bombing = { +-- id = 'Bombing', +-- params = { +-- point = Vec2, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'Bombing', + params = { + point = PointVec2, + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + +--- (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed. -- @param #GROUP self -- @param DCSTypes#Vec2 Point The point to hold the position. -- @param #number Altitude The altitude to hold the position. -- @param #number Speed The speed flying when holding the position. -- @return #GROUP self function GROUP:TaskOrbitCircleAtVec2( Point, Altitude, Speed ) - self:F2( { self.GroupName, Point, Altitude, Speed } ) + self:F2( { self.GroupName, Point, Altitude, Speed } ) + + -- pattern = enum AI.Task.OribtPattern, + -- point = Vec2, + -- point2 = Vec2, + -- speed = Distance, + -- altitude = Distance --- pattern = enum AI.Task.OribtPattern, --- point = Vec2, --- point2 = Vec2, --- speed = Distance, --- altitude = Distance - local LandHeight = land.getHeight( Point ) - + self:T3( { LandHeight } ) - local DCSTask = { id = 'Orbit', - params = { pattern = AI.Task.OrbitPattern.CIRCLE, - point = Point, - speed = Speed, - altitude = Altitude + LandHeight - } - } + local DCSTask = { id = 'Orbit', + params = { pattern = AI.Task.OrbitPattern.CIRCLE, + point = Point, + speed = Speed, + altitude = Altitude + LandHeight + } + } + + + -- local AITask = { id = 'ControlledTask', + -- params = { task = { id = 'Orbit', + -- params = { pattern = AI.Task.OrbitPattern.CIRCLE, + -- point = Point, + -- speed = Speed, + -- altitude = Altitude + LandHeight + -- } + -- }, + -- stopCondition = { duration = Duration + -- } + -- } + -- } + -- ) - --- local AITask = { id = 'ControlledTask', --- params = { task = { id = 'Orbit', --- params = { pattern = AI.Task.OrbitPattern.CIRCLE, --- point = Point, --- speed = Speed, --- altitude = Altitude + LandHeight --- } --- }, --- stopCondition = { duration = Duration --- } --- } --- } --- ) - return DCSTask end ---- Orbit at the current position of the first unit of the group at a specified alititude +--- (AIR) Orbit at the current position of the first unit of the group at a specified alititude -- @param #GROUP self -- @param #number Altitude The altitude to hold the position. -- @param #number Speed The speed flying when holding the position. -- @return #GROUP self function GROUP:TaskOrbitCircle( Altitude, Speed ) - self:F2( { self.GroupName, Altitude, Speed } ) + self:F2( { self.GroupName, Altitude, Speed } ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then local GroupPoint = self:GetPointVec2() return self:TaskOrbitCircleAtVec2( GroupPoint, Altitude, Speed ) end - + return nil end ---- Hold position at the current position of the first unit of the group. +--- (AIR) Hold position at the current position of the first unit of the group. -- @param #GROUP self -- @param #number Duration The maximum duration in seconds to hold the position. -- @return #GROUP self function GROUP:TaskHoldPosition() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) return self:TaskOrbitCircle( 30, 10 ) end ---- Land the group at a Vec2Point. + + +--- (AIR) Attacking the map object (building, structure, e.t.c). +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the point the map object is closest to. The distance between the point and the map object must not be greater than 2000 meters. Object id is not used here because Mission Editor doesn't support map object identificators. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskAttackMapObject( PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- AttackMapObject = { +-- id = 'AttackMapObject', +-- params = { +-- point = Vec2, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'AttackMapObject', + params = { + point = PointVec2, + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Delivering weapon on the runway. +-- @param #GROUP self +-- @param Airbase#AIRBASE Airbase Airbase to attack. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskBombingRunway( Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack ) + self:F2( { self.GroupName, Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack } ) + +-- BombingRunway = { +-- id = 'BombingRunway', +-- params = { +-- runwayId = AirdromeId, +-- weaponType = number, +-- expend = enum AI.Task.WeaponExpend, +-- attackQty = number, +-- direction = Azimuth, +-- groupAttack = boolean, +-- } +-- } + + local DCSTask + DCSTask = { id = 'BombingRunway', + params = { + point = Airbase:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + groupAttack = GroupAttack, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Refueling from the nearest tanker. No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskRefueling() + self:F2( { self.GroupName } ) + +-- Refueling = { +-- id = 'Refueling', +-- params = {} +-- } + + local DCSTask + DCSTask = { id = 'Refueling', + params = { + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR HELICOPTER) Landing at the ground. For helicopters only. -- @param #GROUP self -- @param DCSTypes#Vec2 Point The point where to land. -- @param #number Duration The duration in seconds to stay on the ground. -- @return #GROUP self function GROUP:TaskLandAtVec2( Point, Duration ) - self:F2( { self.GroupName, Point, Duration } ) + self:F2( { self.GroupName, Point, Duration } ) +-- Land = { +-- id= 'Land', +-- params = { +-- point = Vec2, +-- durationFlag = boolean, +-- duration = Time +-- } +-- } + local DCSTask - - if Duration and Duration > 0 then - DCSTask = { id = 'Land', params = { point = Point, durationFlag = true, duration = Duration } } - else - DCSTask = { id = 'Land', params = { point = Point, durationFlag = false } } - end + if Duration and Duration > 0 then + DCSTask = { id = 'Land', + params = { + point = Point, + durationFlag = true, + duration = Duration, + }, + } + else + DCSTask = { id = 'Land', + params = { + point = Point, + durationFlag = false, + }, + } + end self:T3( DCSTask ) - return DCSTask + return DCSTask end ---- Land the group at a @{Zone#ZONE). +--- (AIR) Land the group at a @{Zone#ZONE). -- @param #GROUP self -- @param Zone#ZONE Zone The zone where to land. -- @param #number Duration The duration in seconds to stay on the ground. @@ -5070,80 +5340,104 @@ function GROUP:TaskLandAtZone( Zone, Duration, RandomPoint ) else Point = Zone:GetPointVec2() end - + local DCSTask = self:TaskLandAtVec2( Point, Duration ) self:T3( DCSTask ) return DCSTask end - ---- Attack the Unit. +--- (AIR) Following another airborne group. +-- The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. +-- If another group is on land the unit / group will orbit around. -- @param #GROUP self --- @param Unit#UNIT The unit. +-- @param Group#GROUP FollowGroup The group to be followed. +-- @param DCSTypes#Vec3 PointVec3 Position of the unit / lead unit of the group relative lead unit of another group in frame reference oriented by course of lead unit of another group. If another group is on land the unit / group will orbit around. +-- @param #number LastWaypointIndex Detach waypoint of another group. Once reached the unit / group Follow task is finished. -- @return DCSTask#Task The DCS task structure. -function GROUP:TaskAttackUnit( AttackUnit ) - self:F2( { self.GroupName, AttackUnit } ) +function GROUP:TaskFollow( FollowGroup, PointVec3, LastWaypointIndex ) + self:F2( { self.GroupName, FollowGroup, PointVec3, LastWaypointIndex } ) --- AttackUnit = { --- id = 'AttackUnit', --- params = { --- unitId = Unit.ID, --- weaponType = number, --- expend = enum AI.Task.WeaponExpend --- attackQty = number, --- direction = Azimuth, --- attackQtyLimit = boolean, --- groupAttack = boolean, --- } +-- Follow = { +-- id = 'Follow', +-- params = { +-- groupId = Group.ID, +-- pos = Vec3, +-- lastWptIndexFlag = boolean, +-- lastWptIndex = number +-- } -- } + + local LastWaypointIndexFlag = nil + if LastWaypointIndex then + LastWaypointIndexFlag = true + end - local DCSTask - DCSTask = { id = 'AttackUnit', - params = { unitId = AttackUnit:GetID(), - expend = AI.Task.WeaponExpend.TWO, - groupAttack = true, - }, - }, - + local DCSTask + DCSTask = { id = 'Follow', + params = { + groupId = FollowGroup:GetID(), + pos = PointVec3, + lastWptIndexFlag = LastWaypointIndexFlag, + lastWptIndex = LastWaypointIndex, + }, + }, + self:T3( { DCSTask } ) return DCSTask end ---- Attack a Group. + +--- (AIR) Escort another airborne group. +-- The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. +-- The unit / group will also protect that group from threats of specified types. -- @param #GROUP self --- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param Group#GROUP EscortGroup The group to be escorted. +-- @param DCSTypes#Vec3 PointVec3 Position of the unit / lead unit of the group relative lead unit of another group in frame reference oriented by course of lead unit of another group. If another group is on land the unit / group will orbit around. +-- @param #number LastWaypointIndex Detach waypoint of another group. Once reached the unit / group Follow task is finished. +-- @param #number EngagementDistanceMax Maximal distance from escorted group to threat. If the threat is already engaged by escort escort will disengage if the distance becomes greater than 1.5 * engagementDistMax. +-- @param #list TargetTypes Array of AttributeName that is contains threat categories allowed to engage. -- @return DCSTask#Task The DCS task structure. -function GROUP:TaskAttackGroup( AttackGroup ) - self:F2( { self.GroupName, AttackGroup } ) +function GROUP:TaskEscort( FollowGroup, PointVec3, LastWaypointIndex, EngagementDistance, TargetTypes ) + self:F2( { self.GroupName, FollowGroup, PointVec3, LastWaypointIndex, EngagementDistance, TargetTypes } ) --- AttackGroup = { --- id = 'AttackGroup', --- params = { --- groupId = Group.ID, --- weaponType = number, --- expend = enum AI.Task.WeaponExpend, --- attackQty = number, --- directionEnabled = boolean, --- direction = Azimuth, --- altitudeEnabled = boolean, --- altitude = Distance, --- attackQtyLimit = boolean, --- } --- } +-- Escort = { +-- id = 'Escort', +-- params = { +-- groupId = Group.ID, +-- pos = Vec3, +-- lastWptIndexFlag = boolean, +-- lastWptIndex = number, +-- engagementDistMax = Distance, +-- targetTypes = array of AttributeName, +-- } +-- } - local DCSTask - DCSTask = { id = 'AttackGroup', - params = { groupId = AttackGroup:GetID(), - expend = AI.Task.WeaponExpend.TWO, - }, - }, + local LastWaypointIndexFlag = nil + if LastWaypointIndex then + LastWaypointIndexFlag = true + end + local DCSTask + DCSTask = { id = 'Follow', + params = { + groupId = FollowGroup:GetID(), + pos = PointVec3, + lastWptIndexFlag = LastWaypointIndexFlag, + lastWptIndex = LastWaypointIndex, + engagementDistMax = EngagementDistance, + targetTypes = TargetTypes, + }, + }, + self:T3( { DCSTask } ) return DCSTask end ---- Fires at a VEC2 point. + +-- GROUND TASKS + +--- (GROUND) Fire at a VEC2 point until ammunition is finished. -- @param #GROUP self -- @param DCSTypes#Vec2 The point to fire at. -- @param DCSTypes#Distance Radius The radius of the zone to deploy the fire at. @@ -5151,25 +5445,406 @@ end function GROUP:TaskFireAtPoint( PointVec2, Radius ) self:F2( { self.GroupName, PointVec2, Radius } ) --- FireAtPoint = { --- id = 'FireAtPoint', --- params = { --- point = Vec2, --- radius = Distance, --- } --- } - - local DCSTask - DCSTask = { id = 'FireAtPoint', - params = { point = PointVec2, - radius = Radius, - } - } - + -- FireAtPoint = { + -- id = 'FireAtPoint', + -- params = { + -- point = Vec2, + -- radius = Distance, + -- } + -- } + + local DCSTask + DCSTask = { id = 'FireAtPoint', + params = { + point = PointVec2, + radius = Radius, + } + } + self:T3( { DCSTask } ) return DCSTask end +--- (GROUND) Hold ground group from moving. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskHold() + self:F2( { self.GroupName } ) + +-- Hold = { +-- id = 'Hold', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'Hold', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +-- TASKS FOR AIRBORNE AND GROUND UNITS/GROUPS + +--- (AIR + GROUND) The task makes the group/unit a FAC and orders the FAC to control the target (enemy ground group) destruction. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup Target GROUP. +-- @param #number WeaponType Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.Designation Designation (optional) Designation type. +-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. +-- @return DCSTask#Task The DCS task structure. +function GROUP:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation, Datalink ) + self:F2( { self.GroupName, AttackGroup, WeaponType, Designation, Datalink } ) + +-- FAC_AttackGroup = { +-- id = 'FAC_AttackGroup', +-- params = { +-- groupId = Group.ID, +-- weaponType = number, +-- designation = enum AI.Task.Designation, +-- datalink = boolean +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC_AttackGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + designation = Designation, + datalink = Datalink, + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +-- EN-ROUTE TASKS FOR AIRBORNE GROUPS + +--- (AIR) Engaging targets of defined types. +-- @param #GROUP self +-- @param DCSTypes#Distance Distance Maximal distance from the target to a route leg. If the target is on a greater distance it will be ignored. +-- @param #list<#DCSTypes#AttributeName> TargetTypes Array of target categories allowed to engage. +-- @param #number Priority All enroute tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageTargets( Distance, TargetTypes, Priority ) + self:F2( { self.GroupName, Distance, TargetTypes, Priority } ) + +-- EngageTargets ={ +-- id = 'EngageTargets', +-- params = { +-- maxDist = Distance, +-- targetTypes = array of AttributeName, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'EngageTargets', + params = { + maxDist = Distance, + targetTypes = TargetTypes, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Engaging a targets of defined types at circle-shaped zone. +-- @param #GROUP self +-- @param DCSTypes#Vec2 PointVec2 2D-coordinates of the zone. +-- @param DCSTypes#Distance Radius Radius of the zone. +-- @param #list<#DCSTypes#AttributeName> TargetTypes Array of target categories allowed to engage. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageTargets( PointVec2, Radius, TargetTypes, Priority ) + self:F2( { self.GroupName, PointVec2, Radius, TargetTypes, Priority } ) + +-- EngageTargetsInZone = { +-- id = 'EngageTargetsInZone', +-- params = { +-- point = Vec2, +-- zoneRadius = Distance, +-- targetTypes = array of AttributeName, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'EngageTargetsInZone', + params = { + point = PointVec2, + zoneRadius = Radius, + targetTypes = TargetTypes, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + +--- (AIR) Engaging a group. The task does not assign the target group to the unit/group to attack now; it just allows the unit/group to engage the target group as well as other assigned targets. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup The Group to be attacked. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param DCSTypes#Distance Altitude (optional) Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageGroup( AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit ) + self:F2( { self.GroupName, AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit } ) + + -- EngageGroup = { + -- id = 'EngageGroup ', + -- params = { + -- groupId = Group.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend, + -- attackQty = number, + -- directionEnabled = boolean, + -- direction = Azimuth, + -- altitudeEnabled = boolean, + -- altitude = Distance, + -- attackQtyLimit = boolean, + -- priority = number, + -- } + -- } + + local DirectionEnabled = nil + if Direction then + DirectionEnabled = true + end + + local AltitudeEnabled = nil + if Altitude then + AltitudeEnabled = true + end + + local DCSTask + DCSTask = { id = 'EngageGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + directionEnabled = DirectionEnabled, + direction = Direction, + altitudeEnabled = AltitudeEnabled, + altitude = Altitude, + attackQtyLimit = AttackQtyLimit, + priority = Priority, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Attack the Unit. +-- @param #GROUP self +-- @param Unit#UNIT AttackUnit The UNIT. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType (optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.WeaponExpend WeaponExpend (optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion. +-- @param #number AttackQty (optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo. +-- @param DCSTypes#Azimuth Direction (optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction. +-- @param #boolean AttackQtyLimit (optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks. +-- @param #boolean GroupAttack (optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEngageUnit( AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack ) + self:F2( { self.GroupName, AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack } ) + + -- EngageUnit = { + -- id = 'EngageUnit', + -- params = { + -- unitId = Unit.ID, + -- weaponType = number, + -- expend = enum AI.Task.WeaponExpend + -- attackQty = number, + -- direction = Azimuth, + -- attackQtyLimit = boolean, + -- groupAttack = boolean, + -- priority = number, + -- } + -- } + + local DCSTask + DCSTask = { id = 'EngageUnit', + params = { + unitId = AttackUnit:GetID(), + weaponType = WeaponType, + expend = WeaponExpend, + attackQty = AttackQty, + direction = Direction, + attackQtyLimit = AttackQtyLimit, + groupAttack = GroupAttack, + priority = Priority, + }, + }, + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Aircraft will act as an AWACS for friendly units (will provide them with information about contacts). No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskAWACS( ) + self:F2( { self.GroupName } ) + +-- AWACS = { +-- id = 'AWACS', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'AWACS', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR) Aircraft will act as a tanker for friendly units. No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskTanker( ) + self:F2( { self.GroupName } ) + +-- Tanker = { +-- id = 'Tanker', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'Tanker', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +-- En-route tasks for ground units/groups + +--- (GROUND) Ground unit (EW-radar) will act as an EWR for friendly units (will provide them with information about contacts). No parameters. +-- @param #GROUP self +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskEWR( ) + self:F2( { self.GroupName } ) + +-- EWR = { +-- id = 'EWR', +-- params = { +-- } +-- } + + local DCSTask + DCSTask = { id = 'EWR', + params = { + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +-- En-route tasks for airborne and ground units/groups + +--- (AIR + GROUND) The task makes the group/unit a FAC and lets the FAC to choose the target (enemy ground group) as well as other assigned targets. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param Group#GROUP AttackGroup Target GROUP. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @param #number WeaponType Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage. +-- @param DCSTypes#AI.Task.Designation Designation (optional) Designation type. +-- @param #boolean Datalink (optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskFAC_EngageGroup( AttackGroup, Priority, WeaponType, Designation, Datalink ) + self:F2( { self.GroupName, AttackGroup, WeaponType, Priority, Designation, Datalink } ) + +-- FAC_EngageGroup = { +-- id = 'FAC_EngageGroup', +-- params = { +-- groupId = Group.ID, +-- weaponType = number, +-- designation = enum AI.Task.Designation, +-- datalink = boolean, +-- priority = number, +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC_EngageGroup', + params = { + groupId = AttackGroup:GetID(), + weaponType = WeaponType, + designation = Designation, + datalink = Datalink, + priority = Priority, + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + +--- (AIR + GROUND) The task makes the group/unit a FAC and lets the FAC to choose a targets (enemy ground group) around as well as other assigned targets. +-- The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +-- If the task is assigned to the group lead unit will be a FAC. +-- @param #GROUP self +-- @param DCSTypes#Distance Radius The maximal distance from the FAC to a target. +-- @param #number Priority All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first. +-- @return DCSTask#Task The DCS task structure. +function GROUP:EnRouteTaskFAC( Radius, Priority ) + self:F2( { self.GroupName, Radius, Priority } ) + +-- FAC = { +-- id = 'FAC', +-- params = { +-- radius = Distance, +-- priority = number +-- } +-- } + + local DCSTask + DCSTask = { id = 'FAC', + params = { + radius = Radius, + priority = Priority + } + } + + self:T3( { DCSTask } ) + return DCSTask +end + + --- Move the group to a Vec2 Point, wait for a defined duration and embark a group. @@ -5179,22 +5854,22 @@ end -- @param #GROUP EmbarkingGroup The group to be embarked. -- @return DCSTask#Task The DCS task structure function GROUP:TaskEmbarkingAtVec2( Point, Duration, EmbarkingGroup ) - self:F2( { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } ) + self:F2( { self.GroupName, Point, Duration, EmbarkingGroup.DCSGroup } ) - local DCSTask - DCSTask = { id = 'Embarking', - params = { x = Point.x, - y = Point.y, - duration = Duration, - groupsForEmbarking = { EmbarkingGroup.GroupID }, - durationFlag = true, - distributionFlag = false, - distribution = {}, - } - } - - self:T3( { DCSTask } ) - return DCSTask + local DCSTask + DCSTask = { id = 'Embarking', + params = { x = Point.x, + y = Point.y, + duration = Duration, + groupsForEmbarking = { EmbarkingGroup.GroupID }, + durationFlag = true, + distributionFlag = false, + distribution = {}, + } + } + + self:T3( { DCSTask } ) + return DCSTask end --- Move to a defined Vec2 Point, and embark to a group when arrived within a defined Radius. @@ -5203,30 +5878,30 @@ end -- @param #number Radius The radius of the embarking zone around the Point. -- @return DCSTask#Task The DCS task structure. function GROUP:TaskEmbarkToTransportAtVec2( Point, Radius ) - self:F2( { self.GroupName, Point, Radius } ) + self:F2( { self.GroupName, Point, Radius } ) local DCSTask --DCSTask#Task - DCSTask = { id = 'EmbarkToTransport', - params = { x = Point.x, - y = Point.y, - zoneRadius = Radius, - } - } + DCSTask = { id = 'EmbarkToTransport', + params = { x = Point.x, + y = Point.y, + zoneRadius = Radius, + } + } self:T3( { DCSTask } ) - return DCSTask + return DCSTask end --- Return a Misson task from a mission template. -- @param #GROUP self -- @param #table TaskMission A table containing the mission task. --- @return DCSTask#Task +-- @return DCSTask#Task function GROUP:TaskMission( TaskMission ) - self:F2( Points ) - + self:F2( Points ) + local DCSTask DCSTask = { id = 'Mission', params = { TaskMission, }, } - + self:T3( { DCSTask } ) return DCSTask end @@ -5234,13 +5909,13 @@ end --- Return a Misson task to follow a given route defined by Points. -- @param #GROUP self -- @param #table Points A table of route points. --- @return DCSTask#Task +-- @return DCSTask#Task function GROUP:TaskRoute( Points ) self:F2( Points ) - + local DCSTask DCSTask = { id = 'Mission', params = { route = { points = Points, }, }, } - + self:T3( { DCSTask } ) return DCSTask end @@ -5254,22 +5929,22 @@ function GROUP:TaskRouteToVec2( Point, Speed ) self:F2( { Point, Speed } ) local GroupPoint = self:GetUnit( 1 ):GetPointVec2() - + local PointFrom = {} PointFrom.x = GroupPoint.x PointFrom.y = GroupPoint.y PointFrom.type = "Turning Point" PointFrom.action = "Turning Point" - PointFrom.speed = Speed + PointFrom.speed = Speed PointFrom.speed_locked = true PointFrom.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local PointTo = {} PointTo.x = Point.x @@ -5279,18 +5954,18 @@ function GROUP:TaskRouteToVec2( Point, Speed ) PointTo.speed = Speed PointTo.speed_locked = true PointTo.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local Points = { PointFrom, PointTo } - + self:T3( Points ) - + self:Route( Points ) return self @@ -5305,7 +5980,7 @@ function GROUP:TaskRouteToVec3( Point, Speed ) self:F2( { Point, Speed } ) local GroupPoint = self:GetUnit( 1 ):GetPointVec3() - + local PointFrom = {} PointFrom.x = GroupPoint.x PointFrom.y = GroupPoint.z @@ -5313,39 +5988,39 @@ function GROUP:TaskRouteToVec3( Point, Speed ) PointFrom.alt_type = "BARO" PointFrom.type = "Turning Point" PointFrom.action = "Turning Point" - PointFrom.speed = Speed + PointFrom.speed = Speed PointFrom.speed_locked = true PointFrom.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local PointTo = {} PointTo.x = Point.x PointTo.y = Point.z - PointTo.alt = Point.y + PointTo.alt = Point.y PointTo.alt_type = "BARO" PointTo.type = "Turning Point" PointTo.action = "Fly Over Point" PointTo.speed = Speed PointTo.speed_locked = true PointTo.properties = { - ["vnav"] = 1, - ["scale"] = 0, - ["angle"] = 0, - ["vangle"] = 0, - ["steer"] = 2, + ["vnav"] = 1, + ["scale"] = 0, + ["angle"] = 0, + ["vangle"] = 0, + ["steer"] = 2, } - + local Points = { PointFrom, PointTo } - + self:T3( Points ) - + self:Route( Points ) return self @@ -5356,22 +6031,22 @@ end --- Make the group to follow a given route. -- @param #GROUP self -- @param #table GoPoints A table of Route Points. --- @return #GROUP self +-- @return #GROUP self function GROUP:Route( GoPoints ) - self:F2( GoPoints ) + self:F2( GoPoints ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - local Points = routines.utils.deepCopy( GoPoints ) - local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, } - local Controller = self:_GetController() + local Points = routines.utils.deepCopy( GoPoints ) + local MissionTask = { id = 'Mission', params = { route = { points = Points, }, }, } + local Controller = self:_GetController() --Controller.setTask( Controller, MissionTask ) - --routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 ) + --routines.scheduleFunction( Controller.setTask, { Controller, MissionTask}, timer.getTime() + 1 ) SCHEDULER:New( Controller, Controller.setTask, { MissionTask }, 1 ) - return self + return self end - + return nil end @@ -5387,56 +6062,56 @@ end -- @param #number Speed The speed. -- @param Base#FORMATION Formation The formation string. function GROUP:TaskRouteToZone( Zone, Randomize, Speed, Formation ) - self:F2( Zone ) + self:F2( Zone ) local DCSGroup = self:GetDCSGroup() - + if DCSGroup then - - local GroupPoint = self:GetPointVec2() - - local PointFrom = {} - PointFrom.x = GroupPoint.x - PointFrom.y = GroupPoint.y - PointFrom.type = "Turning Point" - PointFrom.action = "Cone" - PointFrom.speed = 20 / 1.6 - - - local PointTo = {} - local ZonePoint - - if Randomize then - ZonePoint = Zone:GetRandomPointVec2() - else - ZonePoint = Zone:GetPointVec2() - end - - PointTo.x = ZonePoint.x - PointTo.y = ZonePoint.y - PointTo.type = "Turning Point" - - if Formation then - PointTo.action = Formation - else - PointTo.action = "Cone" - end - - if Speed then - PointTo.speed = Speed - else - PointTo.speed = 20 / 1.6 - end - - local Points = { PointFrom, PointTo } - - self:T3( Points ) - - self:Route( Points ) - - return self + + local GroupPoint = self:GetPointVec2() + + local PointFrom = {} + PointFrom.x = GroupPoint.x + PointFrom.y = GroupPoint.y + PointFrom.type = "Turning Point" + PointFrom.action = "Cone" + PointFrom.speed = 20 / 1.6 + + + local PointTo = {} + local ZonePoint + + if Randomize then + ZonePoint = Zone:GetRandomPointVec2() + else + ZonePoint = Zone:GetPointVec2() + end + + PointTo.x = ZonePoint.x + PointTo.y = ZonePoint.y + PointTo.type = "Turning Point" + + if Formation then + PointTo.action = Formation + else + PointTo.action = "Cone" + end + + if Speed then + PointTo.speed = Speed + else + PointTo.speed = 20 / 1.6 + end + + local Points = { PointFrom, PointTo } + + self:T3( Points ) + + self:Route( Points ) + + return self end - + return nil end @@ -5483,48 +6158,48 @@ end -- @param #number Begin The route point from where the copy will start. The base route point is 0. -- @param #number End The route point where the copy will end. The End point is the last point - the End point. The last point has base 0. -- @param #boolean Randomize Randomization of the route, when true. --- @param #number Radius When randomization is on, the randomization is within the radius. +-- @param #number Radius When randomization is on, the randomization is within the radius. function GROUP:CopyRoute( Begin, End, Randomize, Radius ) - self:F2( { Begin, End } ) + self:F2( { Begin, End } ) - local Points = {} - - -- Could be a Spawned Group - local GroupName = string.match( self:GetName(), ".*#" ) - if GroupName then - GroupName = GroupName:sub( 1, -2 ) - else - GroupName = self:GetName() - end - - self:T3( { GroupName } ) - - local Template = _DATABASE.Templates.Groups[GroupName].Template - - if Template then - if not Begin then - Begin = 0 - end - if not End then - End = 0 - end - - for TPointID = Begin + 1, #Template.route.points - End do - if Template.route.points[TPointID] then - Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] ) - if Randomize then - if not Radius then - Radius = 500 - end - Points[#Points].x = Points[#Points].x + math.random( Radius * -1, Radius ) - Points[#Points].y = Points[#Points].y + math.random( Radius * -1, Radius ) - end - end - end - return Points - end - - return nil + local Points = {} + + -- Could be a Spawned Group + local GroupName = string.match( self:GetName(), ".*#" ) + if GroupName then + GroupName = GroupName:sub( 1, -2 ) + else + GroupName = self:GetName() + end + + self:T3( { GroupName } ) + + local Template = _DATABASE.Templates.Groups[GroupName].Template + + if Template then + if not Begin then + Begin = 0 + end + if not End then + End = 0 + end + + for TPointID = Begin + 1, #Template.route.points - End do + if Template.route.points[TPointID] then + Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] ) + if Randomize then + if not Radius then + Radius = 500 + end + Points[#Points].x = Points[#Points].x + math.random( Radius * -1, Radius ) + Points[#Points].y = Points[#Points].y + math.random( Radius * -1, Radius ) + end + end + end + return Points + end + + return nil end @@ -5535,28 +6210,28 @@ function GROUP:GetDetectedTargets() if DCSGroup then return self:_GetController():getDetectedTargets() end - + return nil end function GROUP:IsTargetDetected( DCSObject ) self:F2( self.GroupName ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then - + local TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity - = self:_GetController().isTargetDetected( self:_GetController(), DCSObject, - Controller.Detection.VISUAL, - Controller.Detection.OPTIC, - Controller.Detection.RADAR, - Controller.Detection.IRST, - Controller.Detection.RWR, - Controller.Detection.DLINK - ) + = self:_GetController().isTargetDetected( self:_GetController(), DCSObject, + Controller.Detection.VISUAL, + Controller.Detection.OPTIC, + Controller.Detection.RADAR, + Controller.Detection.IRST, + Controller.Detection.RWR, + Controller.Detection.DLINK + ) return TargetIsDetected, TargetIsVisible, TargetLastTime, TargetKnowType, TargetKnowDistance, TargetLastPos, TargetLastVelocity end - + return nil end @@ -5567,16 +6242,16 @@ end -- @return #boolean function GROUP:OptionROEHoldFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -5584,12 +6259,12 @@ end -- @param Group#GROUP self -- @return Group#GROUP self function GROUP:OptionROEHoldFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_HOLD ) elseif self:IsGround() then @@ -5597,10 +6272,10 @@ function GROUP:OptionROEHoldFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.WEAPON_HOLD ) end - + return self end - + return nil end @@ -5609,16 +6284,16 @@ end -- @return #boolean function GROUP:OptionROEReturnFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -5626,12 +6301,12 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEReturnFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.RETURN_FIRE ) elseif self:IsGround() then @@ -5639,10 +6314,10 @@ function GROUP:OptionROEReturnFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.RETURN_FIRE ) end - + return self end - + return nil end @@ -5657,10 +6332,10 @@ function GROUP:OptionROEOpenFirePossible() if self:IsAir() or self:IsGround() or self:IsShip() then return true end - + return false end - + return nil end @@ -5668,12 +6343,12 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEOpenFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.OPEN_FIRE ) elseif self:IsGround() then @@ -5681,10 +6356,10 @@ function GROUP:OptionROEOpenFire() elseif self:IsShip() then Controller:setOption( AI.Option.Naval.id.ROE, AI.Option.Naval.val.ROE.OPEN_FIRE ) end - + return self end - + return nil end @@ -5693,16 +6368,16 @@ end -- @return #boolean function GROUP:OptionROEWeaponFreePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -5710,19 +6385,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROEWeaponFree() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.ROE, AI.Option.Air.val.ROE.WEAPON_FREE ) end - + return self end - + return nil end @@ -5731,16 +6406,16 @@ end -- @return #boolean function GROUP:OptionROTNoReactionPossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -5749,19 +6424,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTNoReaction() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.NO_REACTION ) end - + return self end - + return nil end @@ -5776,10 +6451,10 @@ function GROUP:OptionROTPassiveDefensePossible() if self:IsAir() then return true end - + return false end - + return nil end @@ -5787,19 +6462,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTPassiveDefense() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.PASSIVE_DEFENCE ) end - + return self end - + return nil end @@ -5808,16 +6483,16 @@ end -- @return #boolean function GROUP:OptionROTEvadeFirePossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -5826,19 +6501,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTEvadeFire() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.EVADE_FIRE ) end - + return self end - + return nil end @@ -5847,16 +6522,16 @@ end -- @return #boolean function GROUP:OptionROTVerticalPossible() self:F2( { self.GroupName } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then if self:IsAir() then return true end - + return false end - + return nil end @@ -5865,19 +6540,19 @@ end -- @param #GROUP self -- @return #GROUP self function GROUP:OptionROTVertical() - self:F2( { self.GroupName } ) + self:F2( { self.GroupName } ) local DCSGroup = self:GetDCSGroup() if DCSGroup then local Controller = self:_GetController() - + if self:IsAir() then Controller:setOption( AI.Option.Air.id.REACTION_ON_THREAT, AI.Option.Air.val.REACTION_ON_THREAT.BYPASS_AND_ESCAPE ) end - + return self end - + return nil end @@ -5890,12 +6565,12 @@ end -- @return Message#MESSAGE function GROUP:Message( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then return MESSAGE:New( Message, self:GetCallsign() .. " (" .. self:GetTypeName() .. ")", Duration, self:GetClassNameAndID() ) end - + return nil end @@ -5906,12 +6581,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToAll( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToAll() end - + return nil end @@ -5922,12 +6597,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToRed( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToRed() end - + return nil end @@ -5938,12 +6613,12 @@ end -- @param #Duration Duration The duration of the message. function GROUP:MessageToBlue( Message, Duration ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToBlue() end - + return nil end @@ -5955,12 +6630,12 @@ end -- @param Client#CLIENT Client The client object receiving the message. function GROUP:MessageToClient( Message, Duration, Client ) self:F2( { Message, Duration } ) - + local DCSGroup = self:GetDCSGroup() if DCSGroup then self:Message( Message, Duration ):ToClient( Client ) end - + return nil end --- UNIT Class diff --git a/Moose Training/Documentation/Airbase.html b/Moose Training/Documentation/Airbase.html new file mode 100644 index 000000000..2226818be --- /dev/null +++ b/Moose Training/Documentation/Airbase.html @@ -0,0 +1,662 @@ + + + + + + +
+
+ +
+
+
+
+ +
+

Module Airbase

+ +

AIRBASE Class

+ +

AIRBASE class

+

The AIRBASE class is a wrapper class to handle the DCS Airbase objects:

+ +
    +
  • Support all DCS Airbase APIs.
  • +
+ + +
    +
  • Enhance with Airbase specific APIs not in the DCS Airbase API set.
  • +
+ + +

AIRBASE reference methods

+

For each DCS Airbase object alive within a running mission, a AIRBASE wrapper object (instance) will be created within the _DATABASE object. +This is done at the beginning of the mission (when the mission starts).

+ +

The AIRBASE class does not contain a :New() method, rather it provides :Find() methods to retrieve the object reference +using the DCS Airbase or the DCS AirbaseName.

+ +

Another thing to know is that AIRBASE objects do not "contain" the DCS Airbase object. +The AIRBASE methods will reference the DCS Airbase object by name when it is needed during API execution. +If the DCS Airbase object does not exist or is nil, the AIRBASE methods will return nil and log an exception in the DCS.log file.

+ +

The AIRBASE class provides the following functions to retrieve quickly the relevant AIRBASE instance:

+ +
    +
  • AIRBASE.Find(): Find a AIRBASE instance from the _DATABASE object using a DCS Airbase object.
  • +
  • AIRBASE.FindByName(): Find a AIRBASE instance from the _DATABASE object using a DCS Airbase name.
  • +
+ +

IMPORTANT: ONE SHOULD NEVER SANATIZE these AIRBASE OBJECT REFERENCES! (make the AIRBASE object references nil).

+ +

DCS AIRBASE APIs

+

The DCS Airbase APIs are used extensively within MOOSE. The AIRBASE class has for each DCS Airbase API a corresponding method. +To be able to distinguish easily in your code the difference between a AIRBASE API call and a DCS Airbase API call, +the first letter of the method is also capitalized. So, by example, the DCS Airbase method DCSAirbase#Airbase.getName() +is implemented in the AIRBASE class as AIRBASE.GetName().

+ +

More functions will be added

+

During the MOOSE development, more functions will be added.

+ + +

Global(s)

+ + + + + +
AIRBASE + +
+

Type AIRBASE

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AIRBASE.CategoryName + +
AIRBASE.ClassName + +
AIRBASE:Find(DCSAirbase) +

Finds a AIRBASE from the _DATABASE using a DCSAirbase object.

+
AIRBASE:FindByName(AirbaseName) +

Find a AIRBASE in the _DATABASE using the name of an existing DCS Airbase.

+
AIRBASE:GetCallSign() +

Returns the Airbase's callsign - the localized string.

+
AIRBASE:GetCategoryName() +

Returns the DCS Airbase category name as defined within the DCS Airbase Descriptor.

+
AIRBASE:GetCoalition() +

Returns coalition of the Airbase.

+
AIRBASE:GetCountry() +

Returns country of the Airbase.

+
AIRBASE:GetDCSAirbase() + +
AIRBASE:GetDesc() +

Returns unit descriptor.

+
AIRBASE:GetID() +

Returns the unit's unique identifier.

+
AIRBASE:GetName() +

Returns DCS Airbase object name.

+
AIRBASE:GetPointVec2() +

Returns the DCSTypes#Vec2 vector indicating the point in 2D of the DCS Airbase within the mission.

+
AIRBASE:GetTypeName() +

Returns the type name of the DCS Airbase.

+
AIRBASE:IsAlive() +

Returns if the airbase is alive.

+
AIRBASE:Register(DCSAirbase, Database, AirbaseName) +

Create a new AIRBASE from DCSAirbase.

+
+ +

Global(s)

+
+
+ + #AIRBASE + +AIRBASE + +
+
+ + + +
+
+

Type Airbase

+ +

Type AIRBASE

+ +

The AIRBASE class

+ +

Field(s)

+
+
+ + + +AIRBASE.CategoryName + +
+
+ + + +
+
+
+
+ + #string + +AIRBASE.ClassName + +
+
+ + + +
+
+
+
+ + +AIRBASE:Find(DCSAirbase) + +
+
+ +

Finds a AIRBASE from the _DATABASE using a DCSAirbase object.

+ +

Parameter

+ +

Return value

+ +

Airbase#AIRBASE: +self

+ +
+
+
+
+ + +AIRBASE:FindByName(AirbaseName) + +
+
+ +

Find a AIRBASE in the _DATABASE using the name of an existing DCS Airbase.

+ +

Parameter

+
    +
  • + +

    #string AirbaseName : +The Airbase Name.

    + +
  • +
+

Return value

+ +

Airbase#AIRBASE: +self

+ +
+
+
+
+ + +AIRBASE:GetCallSign() + +
+
+ +

Returns the Airbase's callsign - the localized string.

+ +

Return values

+
    +
  1. + +

    #string: +The Callsign of the Airbase.

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:GetCategoryName() + +
+
+ +

Returns the DCS Airbase category name as defined within the DCS Airbase Descriptor.

+ +

Return value

+ +

#string: +The DCS Airbase Category Name

+ +
+
+
+
+ + +AIRBASE:GetCoalition() + +
+
+ +

Returns coalition of the Airbase.

+ +

Return values

+
    +
  1. + +

    DCSCoalitionObject#coalition.side: +The side of the coalition.

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:GetCountry() + +
+
+ +

Returns country of the Airbase.

+ +

Return values

+
    +
  1. + +

    DCScountry#country.id: +The country identifier.

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:GetDCSAirbase() + +
+
+ + + +
+
+
+
+ + +AIRBASE:GetDesc() + +
+
+ +

Returns unit descriptor.

+ + +

Descriptor type depends on unit category.

+ +

Return values

+
    +
  1. + +

    DCSAirbase#Airbase.Desc: +The Airbase descriptor.

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:GetID() + +
+
+ +

Returns the unit's unique identifier.

+ +

Return values

+
    +
  1. + +

    DCSAirbase#Airbase.ID: +Airbase ID

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:GetName() + +
+
+ +

Returns DCS Airbase object name.

+ + +

The function provides access to non-activated units too.

+ +

Return values

+
    +
  1. + +

    #string: +The name of the DCS Airbase.

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:GetPointVec2() + +
+
+ +

Returns the DCSTypes#Vec2 vector indicating the point in 2D of the DCS Airbase within the mission.

+ +

Return values

+
    +
  1. + +

    DCSTypes#Vec2: +The 2D point vector of the DCS Airbase.

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:GetTypeName() + +
+
+ +

Returns the type name of the DCS Airbase.

+ +

Return values

+
    +
  1. + +

    #string: +The type name of the DCS Airbase.

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:IsAlive() + +
+
+ +

Returns if the airbase is alive.

+ +

Return values

+
    +
  1. + +

    #boolean: +true if Airbase is alive.

    + +
  2. +
  3. + +

    #nil: +The DCS Airbase is not existing or alive.

    + +
  4. +
+
+
+
+
+ + +AIRBASE:Register(DCSAirbase, Database, AirbaseName) + +
+
+ +

Create a new AIRBASE from DCSAirbase.

+ +

Parameters

+ +

Return value

+ +

Airbase#AIRBASE:

+ + +
+
+ +
+ +
+ + diff --git a/Moose Training/Documentation/Base.html b/Moose Training/Documentation/Base.html index c35a7adac..b6d89a410 100644 --- a/Moose Training/Documentation/Base.html +++ b/Moose Training/Documentation/Base.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/CARGO.html b/Moose Training/Documentation/CARGO.html index f7ca9c91e..887fddee7 100644 --- a/Moose Training/Documentation/CARGO.html +++ b/Moose Training/Documentation/CARGO.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/CleanUp.html b/Moose Training/Documentation/CleanUp.html index c22bc448d..09d6b19f7 100644 --- a/Moose Training/Documentation/CleanUp.html +++ b/Moose Training/Documentation/CleanUp.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/Client.html b/Moose Training/Documentation/Client.html index 7ad2cd35e..25c6e929e 100644 --- a/Moose Training/Documentation/Client.html +++ b/Moose Training/Documentation/Client.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSAirbase.html b/Moose Training/Documentation/DCSAirbase.html index c5ad209a8..2d2c35185 100644 --- a/Moose Training/Documentation/DCSAirbase.html +++ b/Moose Training/Documentation/DCSAirbase.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSCoalitionObject.html b/Moose Training/Documentation/DCSCoalitionObject.html index d7a968f25..1394b09b8 100644 --- a/Moose Training/Documentation/DCSCoalitionObject.html +++ b/Moose Training/Documentation/DCSCoalitionObject.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSCommand.html b/Moose Training/Documentation/DCSCommand.html index 5f433a2f3..ffb46f8cb 100644 --- a/Moose Training/Documentation/DCSCommand.html +++ b/Moose Training/Documentation/DCSCommand.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSController.html b/Moose Training/Documentation/DCSController.html index 228983cdf..89cb04d28 100644 --- a/Moose Training/Documentation/DCSController.html +++ b/Moose Training/Documentation/DCSController.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSGroup.html b/Moose Training/Documentation/DCSGroup.html index d5df1b04a..c46f4755e 100644 --- a/Moose Training/Documentation/DCSGroup.html +++ b/Moose Training/Documentation/DCSGroup.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSObject.html b/Moose Training/Documentation/DCSObject.html index d536b3e22..08f490b23 100644 --- a/Moose Training/Documentation/DCSObject.html +++ b/Moose Training/Documentation/DCSObject.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSTask.html b/Moose Training/Documentation/DCSTask.html index adf8812c1..3950afc35 100644 --- a/Moose Training/Documentation/DCSTask.html +++ b/Moose Training/Documentation/DCSTask.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSTypes.html b/Moose Training/Documentation/DCSTypes.html index 56ccd79ff..8f4ec29be 100644 --- a/Moose Training/Documentation/DCSTypes.html +++ b/Moose Training/Documentation/DCSTypes.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSUnit.html b/Moose Training/Documentation/DCSUnit.html index e40060e37..c55ecc3e4 100644 --- a/Moose Training/Documentation/DCSUnit.html +++ b/Moose Training/Documentation/DCSUnit.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCSWorld.html b/Moose Training/Documentation/DCSWorld.html index 13b3fe634..8e993da85 100644 --- a/Moose Training/Documentation/DCSWorld.html +++ b/Moose Training/Documentation/DCSWorld.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DCStimer.html b/Moose Training/Documentation/DCStimer.html index b05ff053c..00f626d06 100644 --- a/Moose Training/Documentation/DCStimer.html +++ b/Moose Training/Documentation/DCStimer.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DEPLOYTASK.html b/Moose Training/Documentation/DEPLOYTASK.html index 53467e608..1fa64e415 100644 --- a/Moose Training/Documentation/DEPLOYTASK.html +++ b/Moose Training/Documentation/DEPLOYTASK.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DESTROYBASETASK.html b/Moose Training/Documentation/DESTROYBASETASK.html index aa3bef726..8de686c17 100644 --- a/Moose Training/Documentation/DESTROYBASETASK.html +++ b/Moose Training/Documentation/DESTROYBASETASK.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DESTROYGROUPSTASK.html b/Moose Training/Documentation/DESTROYGROUPSTASK.html index baa779ad1..0c9455cf6 100644 --- a/Moose Training/Documentation/DESTROYGROUPSTASK.html +++ b/Moose Training/Documentation/DESTROYGROUPSTASK.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DESTROYRADARSTASK.html b/Moose Training/Documentation/DESTROYRADARSTASK.html index cab844e6f..c88de6600 100644 --- a/Moose Training/Documentation/DESTROYRADARSTASK.html +++ b/Moose Training/Documentation/DESTROYRADARSTASK.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/DESTROYUNITTYPESTASK.html b/Moose Training/Documentation/DESTROYUNITTYPESTASK.html index f5ce3a192..17f188b27 100644 --- a/Moose Training/Documentation/DESTROYUNITTYPESTASK.html +++ b/Moose Training/Documentation/DESTROYUNITTYPESTASK.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/Database.html b/Moose Training/Documentation/Database.html index 211aacd2c..d73e87dd4 100644 --- a/Moose Training/Documentation/Database.html +++ b/Moose Training/Documentation/Database.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/Escort.html b/Moose Training/Documentation/Escort.html index 040d46ca3..1b3f58c93 100644 --- a/Moose Training/Documentation/Escort.html +++ b/Moose Training/Documentation/Escort.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/Event.html b/Moose Training/Documentation/Event.html index 1591464a5..8d0022235 100644 --- a/Moose Training/Documentation/Event.html +++ b/Moose Training/Documentation/Event.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/GOHOMETASK.html b/Moose Training/Documentation/GOHOMETASK.html index be69f3990..8290602af 100644 --- a/Moose Training/Documentation/GOHOMETASK.html +++ b/Moose Training/Documentation/GOHOMETASK.html @@ -17,6 +17,7 @@ index
    +
  • Airbase
  • Base
  • CARGO
  • CleanUp
  • diff --git a/Moose Training/Documentation/Group.html b/Moose Training/Documentation/Group.html index 4e957bb03..a18b037f6 100644 --- a/Moose Training/Documentation/Group.html +++ b/Moose Training/Documentation/Group.html @@ -17,6 +17,7 @@ index
@@ -950,6 +1047,346 @@ So all event listeners will catch the destroy event of this DCS Group.

+ +GROUP:EnRouteTaskAWACS() + +
+
+ +

(AIR) Aircraft will act as an AWACS for friendly units (will provide them with information about contacts).

+ + +

No parameters.

+ +

Return value

+ +

DCSTask#Task: +The DCS task structure.

+ +
+
+
+
+ + +GROUP:EnRouteTaskEWR() + +
+
+ +

(GROUND) Ground unit (EW-radar) will act as an EWR for friendly units (will provide them with information about contacts).

+ + +

No parameters.

+ +

Return value

+ +

DCSTask#Task: +The DCS task structure.

+ +
+
+
+
+ + +GROUP:EnRouteTaskEngageGroup(AttackGroup, Priority, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit) + +
+
+ +

(AIR) Engaging a group.

+ + +

The task does not assign the target group to the unit/group to attack now; it just allows the unit/group to engage the target group as well as other assigned targets.

+ +

Parameters

+
    +
  • + +

    Group#GROUP AttackGroup : +The Group to be attacked.

    + +
  • +
  • + +

    #number Priority : +All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.

    + +
  • +
  • + +

    #number WeaponType : +(optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

    + +
  • +
  • + +

    DCSTypes#AI.Task.WeaponExpend WeaponExpend : +(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion.

    + +
  • +
  • + +

    #number AttackQty : +(optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo.

    + +
  • +
  • + +

    DCSTypes#Azimuth Direction : +(optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction.

    + +
  • +
  • + +

    DCSTypes#Distance Altitude : +(optional) Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude.

    + +
  • +
  • + +

    #boolean AttackQtyLimit : +(optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks.

    + +
  • +
+

Return value

+ +

DCSTask#Task: +The DCS task structure.

+ +
+
+
+
+ + +GROUP:EnRouteTaskEngageTargets(Distance, <, Priority, TargetTypes) + +
+
+ +

(AIR) Engaging targets of defined types.

+ +

Parameters

+
    +
  • + +

    DCSTypes#Distance Distance : +Maximal distance from the target to a route leg. If the target is on a greater distance it will be ignored.

    + +
  • +
  • + +

    #list < : +DCSTypes#AttributeName> TargetTypes Array of target categories allowed to engage.

    + +
  • +
  • + +

    #number Priority : +All enroute tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.

    + +
  • +
  • + +

    TargetTypes :

    + +
  • +
+

Return value

+ +

DCSTask#Task: +The DCS task structure.

+ +
+
+
+
+ + +GROUP:EnRouteTaskEngageUnit(AttackUnit, Priority, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack) + +
+
+ +

(AIR) Attack the Unit.

+ +

Parameters

+
    +
  • + +

    Unit#UNIT AttackUnit : +The UNIT.

    + +
  • +
  • + +

    #number Priority : +All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.

    + +
  • +
  • + +

    #number WeaponType : +(optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

    + +
  • +
  • + +

    DCSTypes#AI.Task.WeaponExpend WeaponExpend : +(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion.

    + +
  • +
  • + +

    #number AttackQty : +(optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo.

    + +
  • +
  • + +

    DCSTypes#Azimuth Direction : +(optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction.

    + +
  • +
  • + +

    #boolean AttackQtyLimit : +(optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks.

    + +
  • +
  • + +

    #boolean GroupAttack : +(optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft.

    + +
  • +
+

Return value

+ +

DCSTask#Task: +The DCS task structure.

+ +
+
+
+
+ + +GROUP:EnRouteTaskFAC(Radius, Priority) + +
+
+ +

(AIR + GROUND) The task makes the group/unit a FAC and lets the FAC to choose a targets (enemy ground group) around as well as other assigned targets.

+ + +

The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +If the task is assigned to the group lead unit will be a FAC.

+ +

Parameters

+
    +
  • + +

    DCSTypes#Distance Radius : + The maximal distance from the FAC to a target.

    + +
  • +
  • + +

    #number Priority : +All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.

    + +
  • +
+

Return value

+ +

DCSTask#Task: +The DCS task structure.

+ +
+
+
+
+ + +GROUP:EnRouteTaskFAC_EngageGroup(AttackGroup, Priority, WeaponType, Designation, Datalink) + +
+
+ +

(AIR + GROUND) The task makes the group/unit a FAC and lets the FAC to choose the target (enemy ground group) as well as other assigned targets.

+ + +

The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +If the task is assigned to the group lead unit will be a FAC.

+ +

Parameters

+
    +
  • + +

    Group#GROUP AttackGroup : +Target GROUP.

    + +
  • +
  • + +

    #number Priority : +All en-route tasks have the priority parameter. This is a number (less value - higher priority) that determines actions related to what task will be performed first.

    + +
  • +
  • + +

    #number WeaponType : +Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

    + +
  • +
  • + +

    DCSTypes#AI.Task.Designation Designation : +(optional) Designation type.

    + +
  • +
  • + +

    #boolean Datalink : +(optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.

    + +
  • +
+

Return value

+ +

DCSTask#Task: +The DCS task structure.

+ +
+
+
+
+ + +GROUP:EnRouteTaskTanker() + +
+
+ +

(AIR) Aircraft will act as a tanker for friendly units.

+ + +

No parameters.

+ +

Return value

+ +

DCSTask#Task: +The DCS task structure.

+ +
+
+
+
+ GROUP:Find(DCSGroup) @@ -1028,7 +1465,7 @@ The CallSign of the first DCS Unit of the DCS Group.

-

Returns category of the DCS Group.

+

Returns category of the DCS Group.

Return value

@@ -1095,7 +1532,7 @@ The country identifier.

  • #nil: -The DCS Group is not existing or alive.

    +The DCS Group is not existing or alive.

  • @@ -1212,7 +1649,7 @@ The identifier of the DCS Group.

    -

    If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged.

    +

    If some of the DCS Units of the DCS Group are destroyed, the initial size of the DCS Group is unchanged.

    Return value

    @@ -1350,7 +1787,7 @@ Current Vec3 point of the first DCS Unit of the DCS Group.

    Returns current size of the DCS Group.

    -

    If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed.

    +

    If some of the DCS Units of the DCS Group are destroyed the size of the DCS Group is changed.

    Return value

    @@ -2174,7 +2611,7 @@ A table of Route Points.

    Return value

    #GROUP: -self

    +self

    @@ -2239,20 +2676,113 @@ self

    -GROUP:TaskAttackGroup(AttackGroup) +GROUP:TaskAttackGroup(AttackGroup, WeaponType, WeaponExpend, AttackQty, Direction, Altitude, AttackQtyLimit)
    -

    Attack a Group.

    +

    (AIR) Attack a Group.

    -

    Parameter

    +

    Parameters

    • Group#GROUP AttackGroup : The Group to be attacked.

      +
    • +
    • + +

      #number WeaponType : +(optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

      + +
    • +
    • + +

      DCSTypes#AI.Task.WeaponExpend WeaponExpend : +(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion.

      + +
    • +
    • + +

      #number AttackQty : +(optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo.

      + +
    • +
    • + +

      DCSTypes#Azimuth Direction : +(optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction.

      + +
    • +
    • + +

      DCSTypes#Distance Altitude : +(optional) Desired attack start altitude. Group/aircraft will make its attacks from the altitude. If the altitude is too low or too high to use weapon aircraft/group will choose closest altitude to the desired attack start altitude. If the desired altitude is defined group/aircraft will not attack from safe altitude.

      + +
    • +
    • + +

      #boolean AttackQtyLimit : +(optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks.

      + +
    • +
    +

    Return value

    + +

    DCSTask#Task: +The DCS task structure.

    + +
    + +
    +
    + + +GROUP:TaskAttackMapObject(PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack) + +
    +
    + +

    (AIR) Attacking the map object (building, structure, e.t.c).

    + +

    Parameters

    +
      +
    • + +

      DCSTypes#Vec2 PointVec2 : +2D-coordinates of the point the map object is closest to. The distance between the point and the map object must not be greater than 2000 meters. Object id is not used here because Mission Editor doesn't support map object identificators.

      + +
    • +
    • + +

      #number WeaponType : +(optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

      + +
    • +
    • + +

      DCSTypes#AI.Task.WeaponExpend WeaponExpend : +(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion.

      + +
    • +
    • + +

      #number AttackQty : +(optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo.

      + +
    • +
    • + +

      DCSTypes#Azimuth Direction : +(optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction.

      + +
    • +
    • + +

      #boolean GroupAttack : +(optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft.

      +

    Return value

    @@ -2266,24 +2796,169 @@ The DCS task structure.

    -GROUP:TaskAttackUnit(The, AttackUnit) +GROUP:TaskAttackUnit(AttackUnit, WeaponType, WeaponExpend, AttackQty, Direction, AttackQtyLimit, GroupAttack)
    -

    Attack the Unit.

    +

    (AIR) Attack the Unit.

    Parameters

    • -

      Unit#UNIT The : -unit.

      +

      Unit#UNIT AttackUnit : +The unit.

    • -

      AttackUnit :

      +

      #number WeaponType : +(optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

      + +
    • +
    • + +

      DCSTypes#AI.Task.WeaponExpend WeaponExpend : +(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion.

      + +
    • +
    • + +

      #number AttackQty : +(optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo.

      + +
    • +
    • + +

      DCSTypes#Azimuth Direction : +(optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction.

      + +
    • +
    • + +

      #boolean AttackQtyLimit : +(optional) The flag determines how to interpret attackQty parameter. If the flag is true then attackQty is a limit on maximal attack quantity for "AttackGroup" and "AttackUnit" tasks. If the flag is false then attackQty is a desired attack quantity for "Bombing" and "BombingRunway" tasks.

      + +
    • +
    • + +

      #boolean GroupAttack : +(optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft.

      + +
    • +
    +

    Return value

    + +

    DCSTask#Task: +The DCS task structure.

    + +
    +
    +
    +
    + + +GROUP:TaskBombing(PointVec2, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack) + +
    +
    + +

    (AIR) Delivering weapon at the point on the ground.

    + +

    Parameters

    +
      +
    • + +

      DCSTypes#Vec2 PointVec2 : +2D-coordinates of the point to deliver weapon at.

      + +
    • +
    • + +

      #number WeaponType : +(optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

      + +
    • +
    • + +

      DCSTypes#AI.Task.WeaponExpend WeaponExpend : +(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion.

      + +
    • +
    • + +

      #number AttackQty : +(optional) Desired quantity of passes. The parameter is not the same in AttackGroup and AttackUnit tasks.

      + +
    • +
    • + +

      DCSTypes#Azimuth Direction : +(optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction.

      + +
    • +
    • + +

      #boolean GroupAttack : +(optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft.

      + +
    • +
    +

    Return value

    + +

    DCSTask#Task: +The DCS task structure.

    + +
    +
    +
    +
    + + +GROUP:TaskBombingRunway(Airbase, WeaponType, WeaponExpend, AttackQty, Direction, GroupAttack) + +
    +
    + +

    (AIR) Delivering weapon on the runway.

    + +

    Parameters

    +
      +
    • + +

      Airbase#AIRBASE Airbase : +Airbase to attack.

      + +
    • +
    • + +

      #number WeaponType : +(optional) Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

      + +
    • +
    • + +

      DCSTypes#AI.Task.WeaponExpend WeaponExpend : +(optional) Determines how much weapon will be released at each attack. If parameter is not defined the unit / group will choose expend on its own discretion.

      + +
    • +
    • + +

      #number AttackQty : +(optional) This parameter limits maximal quantity of attack. The aicraft/group will not make more attack than allowed even if the target group not destroyed and the aicraft/group still have ammo. If not defined the aircraft/group will attack target until it will be destroyed or until the aircraft/group will run out of ammo.

      + +
    • +
    • + +

      DCSTypes#Azimuth Direction : +(optional) Desired ingress direction from the target to the attacking aircraft. Group/aircraft will make its attacks from the direction. Of course if there is no way to attack from the direction due the terrain group/aircraft will choose another direction.

      + +
    • +
    • + +

      #boolean GroupAttack : +(optional) Flag indicates that the target must be engaged by all aircrafts of the group. Has effect only if the task is assigned to a group, not to a single aircraft.

    @@ -2366,9 +3041,8 @@ CSTask#Task> DCSTasks

  • -

    #number lastWayPoint :

    - -

    return DCSTask#Task

    +

    #number lastWayPoint : +return DCSTask#Task

  • @@ -2480,13 +3154,132 @@ The DCS task structure

    + +GROUP:TaskEscort(EscortGroup, PointVec3, LastWaypointIndex, EngagementDistanceMax, <, FollowGroup, EngagementDistance, TargetTypes) + +
    +
    + +

    (AIR) Escort another airborne group.

    + + +

    The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. +The unit / group will also protect that group from threats of specified types.

    + +

    Parameters

    +
      +
    • + +

      Group#GROUP EscortGroup : +The group to be escorted.

      + +
    • +
    • + +

      DCSTypes#Vec3 PointVec3 : +Position of the unit / lead unit of the group relative lead unit of another group in frame reference oriented by course of lead unit of another group. If another group is on land the unit / group will orbit around.

      + +
    • +
    • + +

      #number LastWaypointIndex : +Detach waypoint of another group. Once reached the unit / group Follow task is finished.

      + +
    • +
    • + +

      #number EngagementDistanceMax : +Maximal distance from escorted group to threat. If the threat is already engaged by escort escort will disengage if the distance becomes greater than 1.5 * engagementDistMax.

      + +
    • +
    • + +

      #list < : +CSTypes#AttributeName> TargetTypes Array of AttributeName that is contains threat categories allowed to engage.

      + +
    • +
    • + +

      FollowGroup :

      + +
    • +
    • + +

      EngagementDistance :

      + +
    • +
    • + +

      TargetTypes :

      + +
    • +
    +

    Return value

    + +

    DCSTask#Task: +The DCS task structure.

    + +
    +
    +
    +
    + + +GROUP:TaskFAC_AttackGroup(AttackGroup, WeaponType, Designation, Datalink) + +
    +
    + +

    (AIR + GROUND) The task makes the group/unit a FAC and orders the FAC to control the target (enemy ground group) destruction.

    + + +

    The killer is player-controlled allied CAS-aircraft that is in contact with the FAC. +If the task is assigned to the group lead unit will be a FAC.

    + +

    Parameters

    +
      +
    • + +

      Group#GROUP AttackGroup : +Target GROUP.

      + +
    • +
    • + +

      #number WeaponType : +Bitmask of weapon types those allowed to use. If parameter is not defined that means no limits on weapon usage.

      + +
    • +
    • + +

      DCSTypes#AI.Task.Designation Designation : +(optional) Designation type.

      + +
    • +
    • + +

      #boolean Datalink : +(optional) Allows to use datalink to send the target information to attack aircraft. Enabled by default.

      + +
    • +
    +

    Return value

    + +

    DCSTask#Task: +The DCS task structure.

    + +
    +
    +
    +
    + GROUP:TaskFireAtPoint(The, Radius, PointVec2)
    -

    Fires at a VEC2 point.

    +

    (GROUND) Fire at a VEC2 point until ammunition is finished.

    Parameters

      @@ -2518,6 +3311,49 @@ The DCS task structure.

      + +GROUP:TaskFollow(FollowGroup, PointVec3, LastWaypointIndex) + +
      +
      + +

      (AIR) Following another airborne group.

      + + +

      The unit / group will follow lead unit of another group, wingmens of both groups will continue following their leaders. +If another group is on land the unit / group will orbit around.

      + +

      Parameters

      +
        +
      • + +

        Group#GROUP FollowGroup : +The group to be followed.

        + +
      • +
      • + +

        DCSTypes#Vec3 PointVec3 : +Position of the unit / lead unit of the group relative lead unit of another group in frame reference oriented by course of lead unit of another group. If another group is on land the unit / group will orbit around.

        + +
      • +
      • + +

        #number LastWaypointIndex : +Detach waypoint of another group. Once reached the unit / group Follow task is finished.

        + +
      • +
      +

      Return value

      + +

      DCSTask#Task: +The DCS task structure.

      + +
      +
      +
      +
      + GROUP:TaskFunction(WayPoint, WayPointIndex, FunctionString, FunctionArguments) @@ -2554,13 +3390,31 @@ The DCS task structure.

      + +GROUP:TaskHold() + +
      +
      + +

      (GROUND) Hold ground group from moving.

      + +

      Return value

      + +

      DCSTask#Task: +The DCS task structure.

      + +
      +
      +
      +
      + GROUP:TaskHoldPosition(Duration)
      -

      Hold position at the current position of the first unit of the group.

      +

      (AIR) Hold position at the current position of the first unit of the group.

      Parameter

        @@ -2587,7 +3441,10 @@ self

      -

      Land the group at a Vec2Point.

      +

      (AIR HELICOPTER) Landing at the ground.

      + + +

      For helicopters only.

      Parameters

        @@ -2620,7 +3477,7 @@ self

        -

        Land the group at a @{Zone#ZONE).

        +

        (AIR) Land the group at a @{Zone#ZONE).

        Parameters

          @@ -2685,7 +3542,7 @@ A table containing the mission task.

          -

          Orbit at the current position of the first unit of the group at a specified alititude

          +

          (AIR) Orbit at the current position of the first unit of the group at a specified alititude

          Parameters

            @@ -2718,7 +3575,7 @@ self

            -

            Orbit at a specified position at a specified alititude during a specified duration with a specified speed.

            +

            (AIR) Orbit at a specified position at a specified alititude during a specified duration with a specified speed.

            Parameters

              @@ -2751,6 +3608,27 @@ self

              + +GROUP:TaskRefueling() + +
              +
              + +

              (AIR) Refueling from the nearest tanker.

              + + +

              No parameters.

              + +

              Return value

              + +

              DCSTask#Task: +The DCS task structure.

              + +
              +
              +
              +
              + GROUP:TaskRoute(Points) @@ -2895,7 +3773,7 @@ The formation string.

              -

              Return a WrappedAction Task taking a Command

              +

              Return a WrappedAction Task taking a Command

              Parameters

                diff --git a/Moose Training/Documentation/GroupSet.html b/Moose Training/Documentation/GroupSet.html index a2f772f33..ec91f7267 100644 --- a/Moose Training/Documentation/GroupSet.html +++ b/Moose Training/Documentation/GroupSet.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/MISSION.html b/Moose Training/Documentation/MISSION.html index 785f9854a..080e4f1ec 100644 --- a/Moose Training/Documentation/MISSION.html +++ b/Moose Training/Documentation/MISSION.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/MOVEMENT.html b/Moose Training/Documentation/MOVEMENT.html index ef93fb7c1..feee71367 100644 --- a/Moose Training/Documentation/MOVEMENT.html +++ b/Moose Training/Documentation/MOVEMENT.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Menu.html b/Moose Training/Documentation/Menu.html index 7086e16b5..33582dadc 100644 --- a/Moose Training/Documentation/Menu.html +++ b/Moose Training/Documentation/Menu.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Message.html b/Moose Training/Documentation/Message.html index 5b3fd432f..e61742e06 100644 --- a/Moose Training/Documentation/Message.html +++ b/Moose Training/Documentation/Message.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/MissileTrainer.html b/Moose Training/Documentation/MissileTrainer.html index 10678955f..46f34d872 100644 --- a/Moose Training/Documentation/MissileTrainer.html +++ b/Moose Training/Documentation/MissileTrainer.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/NOTASK.html b/Moose Training/Documentation/NOTASK.html index 66d88c1ba..3c056316d 100644 --- a/Moose Training/Documentation/NOTASK.html +++ b/Moose Training/Documentation/NOTASK.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/PICKUPTASK.html b/Moose Training/Documentation/PICKUPTASK.html index 50e1e220d..e73b68b2a 100644 --- a/Moose Training/Documentation/PICKUPTASK.html +++ b/Moose Training/Documentation/PICKUPTASK.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/ROUTETASK.html b/Moose Training/Documentation/ROUTETASK.html index efd64169e..05c8b48a8 100644 --- a/Moose Training/Documentation/ROUTETASK.html +++ b/Moose Training/Documentation/ROUTETASK.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/STAGE.html b/Moose Training/Documentation/STAGE.html index a4476cf94..34233aaa0 100644 --- a/Moose Training/Documentation/STAGE.html +++ b/Moose Training/Documentation/STAGE.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Scheduler.html b/Moose Training/Documentation/Scheduler.html index 59557d5cf..8272a801a 100644 --- a/Moose Training/Documentation/Scheduler.html +++ b/Moose Training/Documentation/Scheduler.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Scoring.html b/Moose Training/Documentation/Scoring.html index 199f2d13d..5779476cc 100644 --- a/Moose Training/Documentation/Scoring.html +++ b/Moose Training/Documentation/Scoring.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Sead.html b/Moose Training/Documentation/Sead.html index 68a532b60..96abe0840 100644 --- a/Moose Training/Documentation/Sead.html +++ b/Moose Training/Documentation/Sead.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Set.html b/Moose Training/Documentation/Set.html index 5d11030b7..6a1c4fc64 100644 --- a/Moose Training/Documentation/Set.html +++ b/Moose Training/Documentation/Set.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Spawn.html b/Moose Training/Documentation/Spawn.html index 049fe44e6..7420637c5 100644 --- a/Moose Training/Documentation/Spawn.html +++ b/Moose Training/Documentation/Spawn.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/StaticObject.html b/Moose Training/Documentation/StaticObject.html index cf7022ee9..4c683810a 100644 --- a/Moose Training/Documentation/StaticObject.html +++ b/Moose Training/Documentation/StaticObject.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/TASK.html b/Moose Training/Documentation/TASK.html index 7e915c020..95a1bb086 100644 --- a/Moose Training/Documentation/TASK.html +++ b/Moose Training/Documentation/TASK.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Unit.html b/Moose Training/Documentation/Unit.html index 7d8f241d8..3d7fab51f 100644 --- a/Moose Training/Documentation/Unit.html +++ b/Moose Training/Documentation/Unit.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/UnitSet.html b/Moose Training/Documentation/UnitSet.html index 7c83c33bf..6b2a18d04 100644 --- a/Moose Training/Documentation/UnitSet.html +++ b/Moose Training/Documentation/UnitSet.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/Zone.html b/Moose Training/Documentation/Zone.html index faee3f062..315f8ebe5 100644 --- a/Moose Training/Documentation/Zone.html +++ b/Moose Training/Documentation/Zone.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/env.html b/Moose Training/Documentation/env.html index 0a644d77e..7afe0823f 100644 --- a/Moose Training/Documentation/env.html +++ b/Moose Training/Documentation/env.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • diff --git a/Moose Training/Documentation/index.html b/Moose Training/Documentation/index.html index 274f1043b..734897a86 100644 --- a/Moose Training/Documentation/index.html +++ b/Moose Training/Documentation/index.html @@ -17,6 +17,7 @@ index
                +
              • Airbase
              • Base
              • CARGO
              • CleanUp
              • @@ -70,6 +71,19 @@

                Module

                + + + +
                Airbase +

                AIRBASE Class

                + +

                AIRBASE class

                +

                The AIRBASE class is a wrapper class to handle the DCS Airbase objects:

                + +
                  +
                • Support all DCS Airbase APIs.
                • +
                +
                Base diff --git a/Moose Training/Documentation/land.html b/Moose Training/Documentation/land.html index 1df4c274e..0a1a6c817 100644 --- a/Moose Training/Documentation/land.html +++ b/Moose Training/Documentation/land.html @@ -17,6 +17,7 @@ index
                  +
                • Airbase
                • Base
                • CARGO
                • CleanUp
                • diff --git a/Moose Training/Documentation/routines.html b/Moose Training/Documentation/routines.html index 7807762a3..e9e546ca5 100644 --- a/Moose Training/Documentation/routines.html +++ b/Moose Training/Documentation/routines.html @@ -17,6 +17,7 @@ index