mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-19 13:46:08 +00:00
Ops
This commit is contained in:
@@ -1060,7 +1060,7 @@ do -- SET_GROUP
|
|||||||
-- Note that for each unit in the group that is set, a default cargo bay limit is initialized.
|
-- Note that for each unit in the group that is set, a default cargo bay limit is initialized.
|
||||||
-- @param Core.Set#SET_GROUP self
|
-- @param Core.Set#SET_GROUP self
|
||||||
-- @param Wrapper.Group#GROUP group The group which should be added to the set.
|
-- @param Wrapper.Group#GROUP group The group which should be added to the set.
|
||||||
-- @return self
|
-- @return Core.Set#SET_GROUP self
|
||||||
function SET_GROUP:AddGroup( group )
|
function SET_GROUP:AddGroup( group )
|
||||||
|
|
||||||
self:Add( group:GetName(), group )
|
self:Add( group:GetName(), group )
|
||||||
@@ -1076,7 +1076,7 @@ do -- SET_GROUP
|
|||||||
--- Add GROUP(s) to SET_GROUP.
|
--- Add GROUP(s) to SET_GROUP.
|
||||||
-- @param Core.Set#SET_GROUP self
|
-- @param Core.Set#SET_GROUP self
|
||||||
-- @param #string AddGroupNames A single name or an array of GROUP names.
|
-- @param #string AddGroupNames A single name or an array of GROUP names.
|
||||||
-- @return self
|
-- @return Core.Set#SET_GROUP self
|
||||||
function SET_GROUP:AddGroupsByName( AddGroupNames )
|
function SET_GROUP:AddGroupsByName( AddGroupNames )
|
||||||
|
|
||||||
local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames }
|
local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames }
|
||||||
@@ -1091,7 +1091,7 @@ do -- SET_GROUP
|
|||||||
--- Remove GROUP(s) from SET_GROUP.
|
--- Remove GROUP(s) from SET_GROUP.
|
||||||
-- @param Core.Set#SET_GROUP self
|
-- @param Core.Set#SET_GROUP self
|
||||||
-- @param Wrapper.Group#GROUP RemoveGroupNames A single name or an array of GROUP names.
|
-- @param Wrapper.Group#GROUP RemoveGroupNames A single name or an array of GROUP names.
|
||||||
-- @return self
|
-- @return Core.Set#SET_GROUP self
|
||||||
function SET_GROUP:RemoveGroupsByName( RemoveGroupNames )
|
function SET_GROUP:RemoveGroupsByName( RemoveGroupNames )
|
||||||
|
|
||||||
local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames }
|
local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames }
|
||||||
@@ -2004,8 +2004,8 @@ do -- SET_UNIT
|
|||||||
|
|
||||||
--- Remove UNIT(s) from SET_UNIT.
|
--- Remove UNIT(s) from SET_UNIT.
|
||||||
-- @param Core.Set#SET_UNIT self
|
-- @param Core.Set#SET_UNIT self
|
||||||
-- @param Wrapper.Unit#UNIT RemoveUnitNames A single name or an array of UNIT names.
|
-- @param #table RemoveUnitNames A single name or an array of UNIT names.
|
||||||
-- @return self
|
-- @return Core.Set#SET_UNIT self
|
||||||
function SET_UNIT:RemoveUnitsByName( RemoveUnitNames )
|
function SET_UNIT:RemoveUnitsByName( RemoveUnitNames )
|
||||||
|
|
||||||
local RemoveUnitNamesArray = ( type( RemoveUnitNames ) == "table" ) and RemoveUnitNames or { RemoveUnitNames }
|
local RemoveUnitNamesArray = ( type( RemoveUnitNames ) == "table" ) and RemoveUnitNames or { RemoveUnitNames }
|
||||||
|
|||||||
@@ -352,11 +352,8 @@ end
|
|||||||
-- @return #AIRWING self
|
-- @return #AIRWING self
|
||||||
function AIRWING:AddMission(Mission)
|
function AIRWING:AddMission(Mission)
|
||||||
|
|
||||||
-- Set status to QUEUED.
|
-- Set status to QUEUED. This also attaches the airwing to this mission.
|
||||||
Mission:Queued()
|
Mission:Queued(self)
|
||||||
|
|
||||||
-- Set airwing.
|
|
||||||
Mission.airwing=self
|
|
||||||
|
|
||||||
-- Add mission to queue.
|
-- Add mission to queue.
|
||||||
table.insert(self.missionqueue, Mission)
|
table.insert(self.missionqueue, Mission)
|
||||||
@@ -388,15 +385,34 @@ function AIRWING:RemoveMission(Mission)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set CAP zones.
|
--- Set number of CAP flights constantly carried out.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param #number n Number of flights. Default 1.
|
-- @param #number n Number of flights. Default 1.
|
||||||
-- @return #AIRWING self
|
-- @return #AIRWING self
|
||||||
function AIRWING:SetCAPflights(n)
|
function AIRWING:SetNumberCAP(n)
|
||||||
self.nflightsCAP=n
|
self.nflightsCAP=n or 1
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set number of TANKER flights constantly in the air.
|
||||||
|
-- @param #AIRWING self
|
||||||
|
-- @param #number n Number of flights. Default 1.
|
||||||
|
-- @return #AIRWING self
|
||||||
|
function AIRWING:SetNumberTANKER(n)
|
||||||
|
self.nflightsTANKER=n or 1
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set number of AWACS flights constantly in the air.
|
||||||
|
-- @param #AIRWING self
|
||||||
|
-- @param #number n Number of flights. Default 1.
|
||||||
|
-- @return #AIRWING self
|
||||||
|
function AIRWING:SetNumberAWACS(n)
|
||||||
|
self.nflightsAWACS=n or 1
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Add a patrol Point for CAP missions.
|
--- Add a patrol Point for CAP missions.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param Core.Zone#ZONE AcceptZone Add a zone to the CAP zone set.
|
-- @param Core.Zone#ZONE AcceptZone Add a zone to the CAP zone set.
|
||||||
@@ -453,11 +469,11 @@ function AIRWING:onafterStatus(From, Event, To)
|
|||||||
local fsmstate=self:GetState()
|
local fsmstate=self:GetState()
|
||||||
|
|
||||||
-- Check CAP missions.
|
-- Check CAP missions.
|
||||||
self:CheckCAP()
|
--self:CheckCAP()
|
||||||
|
|
||||||
self:CheckTANKER()
|
--self:CheckTANKER()
|
||||||
|
|
||||||
self:CheckAWACS()
|
--self:CheckAWACS()
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
-- Mission Info --
|
-- Mission Info --
|
||||||
@@ -549,7 +565,7 @@ end
|
|||||||
--- Get next mission.
|
--- Get next mission.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @return Ops.Auftrag#AUFTRAG Next mission or *nil*.
|
-- @return Ops.Auftrag#AUFTRAG Next mission or *nil*.
|
||||||
function AIRWING:_CheckCAP()
|
function AIRWING:CheckCAP()
|
||||||
|
|
||||||
local Ncap=self:CountAssetsOnMission(AUFTRAG.Type.PATROL)
|
local Ncap=self:CountAssetsOnMission(AUFTRAG.Type.PATROL)
|
||||||
|
|
||||||
@@ -1349,7 +1365,6 @@ function AIRWING:ReportWarehouseStock()
|
|||||||
MESSAGE:New(text, 10, "AIRWING", true):ToCoalition(self:GetCoalition())
|
MESSAGE:New(text, 10, "AIRWING", true):ToCoalition(self:GetCoalition())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
-- @field #table engageTargetTypes Table of target types that are engaged in the engagement zone.
|
-- @field #table engageTargetTypes Table of target types that are engaged in the engagement zone.
|
||||||
-- @field Core.Point#COORDINATE engageCoord Coordinate of target location.
|
-- @field Core.Point#COORDINATE engageCoord Coordinate of target location.
|
||||||
-- @field Core.Set#SET_GROUP engageTargetGroupset Set of target groups to attack.
|
-- @field Core.Set#SET_GROUP engageTargetGroupset Set of target groups to attack.
|
||||||
-- @field Core.Set#SET_GROUP engageTargetUnitset Set of target units to attack.
|
-- @field Core.Set#SET_UNIT engageTargetUnitset Set of target units to attack.
|
||||||
-- @field #number engageAltitude Engagement altitude in meters.
|
-- @field #number engageAltitude Engagement altitude in meters.
|
||||||
-- @field #number engageDirection Engagement direction in degrees.
|
-- @field #number engageDirection Engagement direction in degrees.
|
||||||
-- @field #number engageQuantity Number of times a target is engaged.
|
-- @field #number engageQuantity Number of times a target is engaged.
|
||||||
@@ -54,6 +54,7 @@
|
|||||||
-- @field Wrapper.Group#GROUP escortGroup The group to be escorted.
|
-- @field Wrapper.Group#GROUP escortGroup The group to be escorted.
|
||||||
-- @field DCS#Vec3 escortVec3 The 3D offset vector from the escorted group to the escort group.
|
-- @field DCS#Vec3 escortVec3 The 3D offset vector from the escorted group to the escort group.
|
||||||
--
|
--
|
||||||
|
-- @field Ops.WingCommander#WINGCOMMANDER wingcommander The WINGCOMMANDER managing this mission.
|
||||||
-- @field Ops.AirWing#AIRWING airwing The assigned airwing.
|
-- @field Ops.AirWing#AIRWING airwing The assigned airwing.
|
||||||
-- @field #string squadname Name of the assigned Airwing squadron.
|
-- @field #string squadname Name of the assigned Airwing squadron.
|
||||||
-- @field #table assets Airwing Assets assigned for this mission.
|
-- @field #table assets Airwing Assets assigned for this mission.
|
||||||
@@ -273,6 +274,26 @@ end
|
|||||||
-- Create Missions
|
-- Create Missions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Create an ANTI-SHIP mission.
|
||||||
|
-- @param #AUFTRAG self
|
||||||
|
-- @param Core.Set#SET_UNIT TargetGroupSet The set of target units.
|
||||||
|
-- @return #AUFTRAG self
|
||||||
|
function AUFTRAG:NewANTISHIP(TargetUnitSet)
|
||||||
|
|
||||||
|
if TargetUnitSet:IsInstanceOf("UNIT") then
|
||||||
|
TargetUnitSet=SET_UNIT:New():AddGroup(TargetUnitSet)
|
||||||
|
end
|
||||||
|
|
||||||
|
local mission=AUFTRAG:New(AUFTRAG.Type.ANTISHIP)
|
||||||
|
|
||||||
|
mission.engageTargetUnitset=TargetUnitSet
|
||||||
|
mission.engageTargetUnitset:FilterDeads():FilterCrashes()
|
||||||
|
|
||||||
|
mission.DCStask=mission:GetDCSMissionTask()
|
||||||
|
|
||||||
|
return mission
|
||||||
|
end
|
||||||
|
|
||||||
--- Create an ORBIT mission.
|
--- Create an ORBIT mission.
|
||||||
-- @param #AUFTRAG self
|
-- @param #AUFTRAG self
|
||||||
-- @param Core.Point#COORDINATE Coordinate Where to orbit. Altitude is also taken from the coordinate.
|
-- @param Core.Point#COORDINATE Coordinate Where to orbit. Altitude is also taken from the coordinate.
|
||||||
@@ -762,7 +783,8 @@ end
|
|||||||
-- @param Ops.AirWing#AIRWING Airwing The airwing.
|
-- @param Ops.AirWing#AIRWING Airwing The airwing.
|
||||||
function AUFTRAG:onafterQueued(From, Event, To, Airwing)
|
function AUFTRAG:onafterQueued(From, Event, To, Airwing)
|
||||||
self.status=AUFTRAG.Status.QUEUED
|
self.status=AUFTRAG.Status.QUEUED
|
||||||
self:I(self.lid..string.format("New mission status=%s", self.status))
|
self.airwing=Airwing
|
||||||
|
self:I(self.lid..string.format("New mission status=%s at airwing %s", self.status, tostring(Airwing.alias)))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -939,7 +961,7 @@ function AUFTRAG:CountMissionTargets()
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.engageTargetUnitset then
|
if self.engageTargetUnitset then
|
||||||
local n=self.engageTargetUnitset:CountAlive()
|
local n=self.engageTargetUnitset:Count()
|
||||||
N=N+n
|
N=N+n
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1003,6 +1025,8 @@ function AUFTRAG:GetDCSMissionTask()
|
|||||||
|
|
||||||
local DCStask=CONTROLLABLE.TaskAttackUnit(nil, TargetUnit, self.engageAltitude, self.WeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude, self.engageWeaponType)
|
local DCStask=CONTROLLABLE.TaskAttackUnit(nil, TargetUnit, self.engageAltitude, self.WeaponExpend, self.engageQuantity, self.engageDirection, self.engageAltitude, self.engageWeaponType)
|
||||||
|
|
||||||
|
table.insert(DCStasks, DCStask)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif self.type==AUFTRAG.Type.AWACS then
|
elseif self.type==AUFTRAG.Type.AWACS then
|
||||||
@@ -1109,6 +1133,14 @@ function AUFTRAG:GetDCSMissionTask()
|
|||||||
|
|
||||||
-- Done below as also other mission types use the orbit task.
|
-- Done below as also other mission types use the orbit task.
|
||||||
|
|
||||||
|
elseif self.type==AUFTRAG.Type.PATROL then
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
-- PATROL Mission --
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
-- Done below as also other mission types use the orbit task.
|
||||||
|
|
||||||
elseif self.type==AUFTRAG.Type.RECON then
|
elseif self.type==AUFTRAG.Type.RECON then
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
@@ -1150,7 +1182,12 @@ function AUFTRAG:GetDCSMissionTask()
|
|||||||
|
|
||||||
|
|
||||||
-- Set ORBIT task. Also applies to other missions: AWACS, TANKER, CAP, CAS.
|
-- Set ORBIT task. Also applies to other missions: AWACS, TANKER, CAP, CAS.
|
||||||
if self.type==AUFTRAG.Type.ORBIT or self.type==AUFTRAG.Type.CAP or self.type==AUFTRAG.Type.CAS or self.type==AUFTRAG.Type.AWACS or self.type==AUFTRAG.Type.TANKER then
|
if self.type==AUFTRAG.Type.ORBIT or
|
||||||
|
self.type==AUFTRAG.Type.CAP or
|
||||||
|
self.type==AUFTRAG.Type.CAS or
|
||||||
|
self.type==AUFTRAG.Type.PATROL or
|
||||||
|
self.type==AUFTRAG.Type.AWACS or
|
||||||
|
self.type==AUFTRAG.Type.TANKER then
|
||||||
|
|
||||||
-------------------
|
-------------------
|
||||||
-- ORBIT Mission --
|
-- ORBIT Mission --
|
||||||
@@ -1176,5 +1213,6 @@ function AUFTRAG:GetDCSMissionTask()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ end
|
|||||||
-- User functions
|
-- User functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Set accept zones.
|
--- Set accept zones. Only contacts detected in this/these zone(s) are considered.
|
||||||
-- @param #INTEL self
|
-- @param #INTEL self
|
||||||
-- @param Core.Set#SET_ZONE AcceptZoneSet Set of accept zones
|
-- @param Core.Set#SET_ZONE AcceptZoneSet Set of accept zones
|
||||||
-- @return #INTEL self
|
-- @return #INTEL self
|
||||||
@@ -182,7 +182,7 @@ function INTEL:SetAcceptZones(AcceptZoneSet)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set accept zones.
|
--- Set accept zones. Only contacts detected in this zone are considered.
|
||||||
-- @param #INTEL self
|
-- @param #INTEL self
|
||||||
-- @param Core.Zone#ZONE AcceptZone Add a zone to the accept zone set.
|
-- @param Core.Zone#ZONE AcceptZone Add a zone to the accept zone set.
|
||||||
-- @return #INTEL self
|
-- @return #INTEL self
|
||||||
@@ -191,7 +191,8 @@ function INTEL:AddAcceptZone(AcceptZone)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set forget contacts time interval. Previously known contacts that are not detected any more, are "lost" after this time.
|
--- Set forget contacts time interval.
|
||||||
|
-- Previously known contacts that are not detected any more, are "lost" after this time.
|
||||||
-- This avoids fast oscillations between a contact being detected and undetected.
|
-- This avoids fast oscillations between a contact being detected and undetected.
|
||||||
-- @param #INTEL self
|
-- @param #INTEL self
|
||||||
-- @param #number TimeInterval Time interval in seconds. Default is 120 sec.
|
-- @param #number TimeInterval Time interval in seconds. Default is 120 sec.
|
||||||
@@ -309,7 +310,7 @@ function INTEL:UpdateIntel()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Remove filtered units.
|
-- Remove filtered units.
|
||||||
DetectedSet:RemoveUnitsByName(remove)
|
--DetectedSet:RemoveUnitsByName(remove)
|
||||||
|
|
||||||
-- Create detected contacts.
|
-- Create detected contacts.
|
||||||
self:CreateDetectedItems(DetectedSet)
|
self:CreateDetectedItems(DetectedSet)
|
||||||
@@ -395,10 +396,13 @@ function INTEL:CreateDetectedItems(detectedunitset)
|
|||||||
|
|
||||||
-- Check if deltaT>Tforget. We dont want quick oscillations between detected and undetected states.
|
-- Check if deltaT>Tforget. We dont want quick oscillations between detected and undetected states.
|
||||||
if self:CheckContactLost(item) then
|
if self:CheckContactLost(item) then
|
||||||
|
|
||||||
-- Trigger LostContact event. This also adds the contact to the self.ContactsLost table.
|
-- Trigger LostContact event. This also adds the contact to the self.ContactsLost table.
|
||||||
self:LostContact(item)
|
self:LostContact(item)
|
||||||
|
|
||||||
-- Remove contact from table.
|
-- Remove contact from table.
|
||||||
self:RemoveContact(item)
|
self:RemoveContact(item)
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -450,6 +454,13 @@ function INTEL:GetContactByName(groupname)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add a contact to our list.
|
||||||
|
-- @param #INTEL self
|
||||||
|
-- @param #INTEL.DetectedItem Contact The contact to be removed.
|
||||||
|
function INTEL:AddContact(Contact)
|
||||||
|
table.insert(self.Contacts, Contact)
|
||||||
|
end
|
||||||
|
|
||||||
--- Remove a contact from our list.
|
--- Remove a contact from our list.
|
||||||
-- @param #INTEL self
|
-- @param #INTEL self
|
||||||
-- @param #INTEL.DetectedItem Contact The contact to be removed.
|
-- @param #INTEL.DetectedItem Contact The contact to be removed.
|
||||||
@@ -466,13 +477,6 @@ function INTEL:RemoveContact(Contact)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Remove a contact from our list.
|
|
||||||
-- @param #INTEL self
|
|
||||||
-- @param #INTEL.DetectedItem Contact The contact to be removed.
|
|
||||||
function INTEL:AddContact(Contact)
|
|
||||||
table.insert(self.Contacts, Contact)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Remove a contact from our list.
|
--- Remove a contact from our list.
|
||||||
-- @param #INTEL self
|
-- @param #INTEL self
|
||||||
-- @param #INTEL.DetectedItem Contact The contact to be removed.
|
-- @param #INTEL.DetectedItem Contact The contact to be removed.
|
||||||
@@ -490,3 +494,7 @@ function INTEL:CheckContactLost(Contact)
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ SQUADRON = {
|
|||||||
|
|
||||||
--- SQUADRON class version.
|
--- SQUADRON class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
SQUADRON.version="0.0.1"
|
SQUADRON.version="0.0.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@@ -75,21 +75,12 @@ function SQUADRON:New(SquadronName, TemplateGroupName)
|
|||||||
--self.flightgroup=AIGroup
|
--self.flightgroup=AIGroup
|
||||||
self.name=tostring(SquadronName)
|
self.name=tostring(SquadronName)
|
||||||
|
|
||||||
-- Set home airbase.
|
|
||||||
self.homebase=airbase
|
|
||||||
|
|
||||||
-- Set some string id for output to DCS.log file.
|
-- Set some string id for output to DCS.log file.
|
||||||
self.sid=string.format("SQUADRON %s | ", self.squadronname)
|
self.sid=string.format("SQUADRON %s | ", self.squadronname)
|
||||||
|
|
||||||
-- Start State.
|
-- Start State.
|
||||||
self:SetStartState("Stopped")
|
self:SetStartState("Stopped")
|
||||||
|
|
||||||
-- Init set of detected units.
|
|
||||||
self.detectedunits=SET_UNIT:New()
|
|
||||||
|
|
||||||
-- TODO Tasks?
|
|
||||||
self.tasks=tasks or {}
|
|
||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("Stopped", "Start", "Running") -- Start FSM.
|
self:AddTransition("Stopped", "Start", "Running") -- Start FSM.
|
||||||
@@ -150,6 +141,7 @@ end
|
|||||||
-- @return #SQUADRON self
|
-- @return #SQUADRON self
|
||||||
function SQUADRON:SetLivery(liveryname)
|
function SQUADRON:SetLivery(liveryname)
|
||||||
self.livery=liveryname
|
self.livery=liveryname
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set airwing.
|
--- Set airwing.
|
||||||
@@ -158,8 +150,32 @@ end
|
|||||||
-- @return #SQUADRON self
|
-- @return #SQUADRON self
|
||||||
function SQUADRON:SetAirwing(Airwing)
|
function SQUADRON:SetAirwing(Airwing)
|
||||||
self.airwing=Airwing
|
self.airwing=Airwing
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Add airwing asset to squadron.
|
||||||
|
-- @param #SQUADRON self
|
||||||
|
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The airwing asset.
|
||||||
|
-- @return #SQUADRON self
|
||||||
|
function SQUADRON:AddAsset(Asset)
|
||||||
|
table.insert(self.assets, Asset)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Remove airwing asset from squadron.
|
||||||
|
-- @param #SQUADRON self
|
||||||
|
-- @param Ops.AirWing#AIRWING.SquadronAsset Asset The airwing asset.
|
||||||
|
-- @return #SQUADRON self
|
||||||
|
function SQUADRON:DelAsset(Asset)
|
||||||
|
for i,_asset in pairs(self.assets) do
|
||||||
|
local asset=_asset --Ops.AirWing#AIRWING.SquadronAsset
|
||||||
|
if Asset.uid==asset.uid then
|
||||||
|
table.remove(self.assets, i)
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Start & Status
|
-- Start & Status
|
||||||
@@ -196,8 +212,8 @@ function SQUADRON:onafterStatus(From, Event, To)
|
|||||||
self:_CheckAssetStatus()
|
self:_CheckAssetStatus()
|
||||||
|
|
||||||
-- Short info.
|
-- Short info.
|
||||||
local text=string.format("Flight status %s [%d/%d]. Task=%d/%d. Waypoint=%d/%d. Detected=%d", fsmstate, #self.element, #self.element, self.taskcurrent, #self.taskqueue, self.currentwp or 0, #self.waypoints or 0, self.detectedunits:Count())
|
--local text=string.format("Flight status %s [%d/%d]. Task=%d/%d. Waypoint=%d/%d. Detected=%d", fsmstate, #self.element, #self.element, self.taskcurrent, #self.taskqueue, self.currentwp or 0, #self.waypoints or 0, self.detectedunits:Count())
|
||||||
self:I(self.sid..text)
|
--self:I(self.sid..text)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -215,3 +231,7 @@ function SQUADRON:_CheckAssetStatus()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -140,9 +140,11 @@ end
|
|||||||
-- @return #WINGCOMMANDER self
|
-- @return #WINGCOMMANDER self
|
||||||
function WINGCOMMANDER:AddAirwing(Airwing)
|
function WINGCOMMANDER:AddAirwing(Airwing)
|
||||||
|
|
||||||
--table.insert(self.airwings, Airwing)
|
-- This airwing is managed by this wing commander.
|
||||||
|
Airwing.wingcommander=self
|
||||||
|
|
||||||
self.airwings[Airwing.alias]=Airwing
|
table.insert(self.airwings, Airwing)
|
||||||
|
--self.airwings[Airwing.alias]=Airwing
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -225,9 +227,9 @@ function WINGCOMMANDER:onafterStatus(From, Event, To)
|
|||||||
for _,_contact in pairs(self.ContactsLost) do
|
for _,_contact in pairs(self.ContactsLost) do
|
||||||
local contact=_contact --#WINGCOMMANDER.Contact
|
local contact=_contact --#WINGCOMMANDER.Contact
|
||||||
|
|
||||||
if contact.mission then
|
if contact.mission and contact.mission:IsNotOver() then
|
||||||
|
|
||||||
local text=string.format("Lost contact to target! %s mission %s will be cancelled.", contact.mission.type:upper(), contact.mission.name)
|
local text=string.format("Lost contact to target %s! %s mission %s will be cancelled.", contact.groupname, contact.mission.type:upper(), contact.mission.name)
|
||||||
MESSAGE:New(text, 120, "WINGCOMMANDER"):ToAll()
|
MESSAGE:New(text, 120, "WINGCOMMANDER"):ToAll()
|
||||||
self:I(self.lid..text)
|
self:I(self.lid..text)
|
||||||
|
|
||||||
@@ -278,12 +280,26 @@ function WINGCOMMANDER:onafterStatus(From, Event, To)
|
|||||||
|
|
||||||
--TODO: ANTISHIP
|
--TODO: ANTISHIP
|
||||||
|
|
||||||
|
local TargetUnitSet=SET_UNIT:New()
|
||||||
|
|
||||||
|
for _,_unit in pairs(group:GetUnits()) do
|
||||||
|
local unit=_unit --Wrapper.Unit#UNIT
|
||||||
|
if unit and unit:IsAlive() and unit:GetThreatLevel()>0 then
|
||||||
|
TargetUnitSet:AddUnit(unit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if TargetUnitSet:Count()>0 then
|
||||||
|
mission=AUFTRAG:NewANTISHIP(TargetUnitSet)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Add mission to queue.
|
-- Add mission to queue.
|
||||||
if mission then
|
if mission then
|
||||||
mission.nassets=1
|
mission.nassets=1
|
||||||
|
contact.mission=mission
|
||||||
self:AddMission(mission)
|
self:AddMission(mission)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -432,3 +448,7 @@ function WINGCOMMANDER:CheckResources()
|
|||||||
|
|
||||||
return capabilities
|
return capabilities
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user