mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-07-20 22:03:25 +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.
|
||||
-- @param Core.Set#SET_GROUP self
|
||||
-- @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 )
|
||||
|
||||
self:Add( group:GetName(), group )
|
||||
@@ -1076,7 +1076,7 @@ do -- SET_GROUP
|
||||
--- Add GROUP(s) to SET_GROUP.
|
||||
-- @param Core.Set#SET_GROUP self
|
||||
-- @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 )
|
||||
|
||||
local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames }
|
||||
@@ -1091,7 +1091,7 @@ do -- SET_GROUP
|
||||
--- Remove GROUP(s) from SET_GROUP.
|
||||
-- @param Core.Set#SET_GROUP self
|
||||
-- @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 )
|
||||
|
||||
local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames }
|
||||
@@ -2004,8 +2004,8 @@ do -- SET_UNIT
|
||||
|
||||
--- Remove UNIT(s) from SET_UNIT.
|
||||
-- @param Core.Set#SET_UNIT self
|
||||
-- @param Wrapper.Unit#UNIT RemoveUnitNames A single name or an array of UNIT names.
|
||||
-- @return self
|
||||
-- @param #table RemoveUnitNames A single name or an array of UNIT names.
|
||||
-- @return Core.Set#SET_UNIT self
|
||||
function SET_UNIT:RemoveUnitsByName( RemoveUnitNames )
|
||||
|
||||
local RemoveUnitNamesArray = ( type( RemoveUnitNames ) == "table" ) and RemoveUnitNames or { RemoveUnitNames }
|
||||
|
||||
@@ -352,12 +352,9 @@ end
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:AddMission(Mission)
|
||||
|
||||
-- Set status to QUEUED.
|
||||
Mission:Queued()
|
||||
-- Set status to QUEUED. This also attaches the airwing to this mission.
|
||||
Mission:Queued(self)
|
||||
|
||||
-- Set airwing.
|
||||
Mission.airwing=self
|
||||
|
||||
-- Add mission to queue.
|
||||
table.insert(self.missionqueue, Mission)
|
||||
|
||||
@@ -388,15 +385,34 @@ function AIRWING:RemoveMission(Mission)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set CAP zones.
|
||||
--- Set number of CAP flights constantly carried out.
|
||||
-- @param #AIRWING self
|
||||
-- @param #number n Number of flights. Default 1.
|
||||
-- @return #AIRWING self
|
||||
function AIRWING:SetCAPflights(n)
|
||||
self.nflightsCAP=n
|
||||
function AIRWING:SetNumberCAP(n)
|
||||
self.nflightsCAP=n or 1
|
||||
return self
|
||||
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.
|
||||
-- @param #AIRWING self
|
||||
-- @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()
|
||||
|
||||
-- Check CAP missions.
|
||||
self:CheckCAP()
|
||||
--self:CheckCAP()
|
||||
|
||||
self:CheckTANKER()
|
||||
--self:CheckTANKER()
|
||||
|
||||
self:CheckAWACS()
|
||||
--self:CheckAWACS()
|
||||
|
||||
------------------
|
||||
-- Mission Info --
|
||||
@@ -549,7 +565,7 @@ end
|
||||
--- Get next mission.
|
||||
-- @param #AIRWING self
|
||||
-- @return Ops.Auftrag#AUFTRAG Next mission or *nil*.
|
||||
function AIRWING:_CheckCAP()
|
||||
function AIRWING:CheckCAP()
|
||||
|
||||
local Ncap=self:CountAssetsOnMission(AUFTRAG.Type.PATROL)
|
||||
|
||||
@@ -1349,7 +1365,6 @@ function AIRWING:ReportWarehouseStock()
|
||||
MESSAGE:New(text, 10, "AIRWING", true):ToCoalition(self:GetCoalition())
|
||||
end
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
-- @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.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 engageDirection Engagement direction in degrees.
|
||||
-- @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 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 #string squadname Name of the assigned Airwing squadron.
|
||||
-- @field #table assets Airwing Assets assigned for this mission.
|
||||
@@ -273,6 +274,26 @@ end
|
||||
-- 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.
|
||||
-- @param #AUFTRAG self
|
||||
-- @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.
|
||||
function AUFTRAG:onafterQueued(From, Event, To, Airwing)
|
||||
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
|
||||
|
||||
|
||||
@@ -939,7 +961,7 @@ function AUFTRAG:CountMissionTargets()
|
||||
end
|
||||
|
||||
if self.engageTargetUnitset then
|
||||
local n=self.engageTargetUnitset:CountAlive()
|
||||
local n=self.engageTargetUnitset:Count()
|
||||
N=N+n
|
||||
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)
|
||||
|
||||
table.insert(DCStasks, DCStask)
|
||||
|
||||
end
|
||||
|
||||
elseif self.type==AUFTRAG.Type.AWACS then
|
||||
@@ -1108,6 +1132,14 @@ function AUFTRAG:GetDCSMissionTask()
|
||||
-------------------
|
||||
|
||||
-- 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
|
||||
|
||||
@@ -1150,7 +1182,12 @@ function AUFTRAG:GetDCSMissionTask()
|
||||
|
||||
|
||||
-- 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 --
|
||||
@@ -1176,5 +1213,6 @@ function AUFTRAG:GetDCSMissionTask()
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -173,7 +173,7 @@ end
|
||||
-- User functions
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
--- Set accept zones.
|
||||
--- Set accept zones. Only contacts detected in this/these zone(s) are considered.
|
||||
-- @param #INTEL self
|
||||
-- @param Core.Set#SET_ZONE AcceptZoneSet Set of accept zones
|
||||
-- @return #INTEL self
|
||||
@@ -182,7 +182,7 @@ function INTEL:SetAcceptZones(AcceptZoneSet)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set accept zones.
|
||||
--- Set accept zones. Only contacts detected in this zone are considered.
|
||||
-- @param #INTEL self
|
||||
-- @param Core.Zone#ZONE AcceptZone Add a zone to the accept zone set.
|
||||
-- @return #INTEL self
|
||||
@@ -191,7 +191,8 @@ function INTEL:AddAcceptZone(AcceptZone)
|
||||
return self
|
||||
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.
|
||||
-- @param #INTEL self
|
||||
-- @param #number TimeInterval Time interval in seconds. Default is 120 sec.
|
||||
@@ -309,7 +310,7 @@ function INTEL:UpdateIntel()
|
||||
end
|
||||
|
||||
-- Remove filtered units.
|
||||
DetectedSet:RemoveUnitsByName(remove)
|
||||
--DetectedSet:RemoveUnitsByName(remove)
|
||||
|
||||
-- Create detected contacts.
|
||||
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.
|
||||
if self:CheckContactLost(item) then
|
||||
|
||||
-- Trigger LostContact event. This also adds the contact to the self.ContactsLost table.
|
||||
self:LostContact(item)
|
||||
|
||||
-- Remove contact from table.
|
||||
self:RemoveContact(item)
|
||||
self:RemoveContact(item)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -450,6 +454,13 @@ function INTEL:GetContactByName(groupname)
|
||||
return nil
|
||||
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.
|
||||
-- @param #INTEL self
|
||||
-- @param #INTEL.DetectedItem Contact The contact to be removed.
|
||||
@@ -466,13 +477,6 @@ function INTEL:RemoveContact(Contact)
|
||||
|
||||
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.
|
||||
-- @param #INTEL self
|
||||
-- @param #INTEL.DetectedItem Contact The contact to be removed.
|
||||
@@ -489,4 +493,8 @@ function INTEL:CheckContactLost(Contact)
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -50,7 +50,7 @@ SQUADRON = {
|
||||
|
||||
--- SQUADRON class version.
|
||||
-- @field #string version
|
||||
SQUADRON.version="0.0.1"
|
||||
SQUADRON.version="0.0.2"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@@ -75,20 +75,11 @@ function SQUADRON:New(SquadronName, TemplateGroupName)
|
||||
--self.flightgroup=AIGroup
|
||||
self.name=tostring(SquadronName)
|
||||
|
||||
-- Set home airbase.
|
||||
self.homebase=airbase
|
||||
|
||||
-- Set some string id for output to DCS.log file.
|
||||
self.sid=string.format("SQUADRON %s | ", self.squadronname)
|
||||
|
||||
-- Start State.
|
||||
self:SetStartState("Stopped")
|
||||
|
||||
-- Init set of detected units.
|
||||
self.detectedunits=SET_UNIT:New()
|
||||
|
||||
-- TODO Tasks?
|
||||
self.tasks=tasks or {}
|
||||
|
||||
-- Add FSM transitions.
|
||||
-- From State --> Event --> To State
|
||||
@@ -150,6 +141,7 @@ end
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetLivery(liveryname)
|
||||
self.livery=liveryname
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set airwing.
|
||||
@@ -158,8 +150,32 @@ end
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetAirwing(Airwing)
|
||||
self.airwing=Airwing
|
||||
return self
|
||||
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
|
||||
@@ -196,8 +212,8 @@ function SQUADRON:onafterStatus(From, Event, To)
|
||||
self:_CheckAssetStatus()
|
||||
|
||||
-- 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())
|
||||
self:I(self.sid..text)
|
||||
--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)
|
||||
|
||||
end
|
||||
|
||||
@@ -215,3 +231,7 @@ function SQUADRON:_CheckAssetStatus()
|
||||
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -140,9 +140,11 @@ end
|
||||
-- @return #WINGCOMMANDER self
|
||||
function WINGCOMMANDER:AddAirwing(Airwing)
|
||||
|
||||
--table.insert(self.airwings, Airwing)
|
||||
|
||||
self.airwings[Airwing.alias]=Airwing
|
||||
-- This airwing is managed by this wing commander.
|
||||
Airwing.wingcommander=self
|
||||
|
||||
table.insert(self.airwings, Airwing)
|
||||
--self.airwings[Airwing.alias]=Airwing
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -225,9 +227,9 @@ function WINGCOMMANDER:onafterStatus(From, Event, To)
|
||||
for _,_contact in pairs(self.ContactsLost) do
|
||||
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()
|
||||
self:I(self.lid..text)
|
||||
|
||||
@@ -277,13 +279,27 @@ function WINGCOMMANDER:onafterStatus(From, Event, To)
|
||||
elseif category==Group.Category.SHIP then
|
||||
|
||||
--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
|
||||
|
||||
|
||||
-- Add mission to queue.
|
||||
if mission then
|
||||
mission.nassets=1
|
||||
contact.mission=mission
|
||||
self:AddMission(mission)
|
||||
end
|
||||
|
||||
@@ -431,4 +447,8 @@ function WINGCOMMANDER:CheckResources()
|
||||
end
|
||||
|
||||
return capabilities
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user