mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-18 13:16:03 +00:00
Ops
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
-- @field #number coalition Coalition side number, e.g. coalition.side.RED.
|
-- @field #number coalition Coalition side number, e.g. coalition.side.RED.
|
||||||
-- @field #table filterCategory Category filters.
|
-- @field #table filterCategory Category filters.
|
||||||
-- @field Core.Set#SET_ZONE acceptzoneset Set of accept zones. If defined, only contacts in these zones are considered.
|
-- @field Core.Set#SET_ZONE acceptzoneset Set of accept zones. If defined, only contacts in these zones are considered.
|
||||||
-- @field Core.Set#SET_ZONE rejectzoneset Set of reject zones. Contacts in these zones are not considered.
|
-- @field Core.Set#SET_ZONE rejectzoneset Set of reject zones. Contacts in these zones are not considered, even if they are in accept zones.
|
||||||
-- @field #table Contacts Table of detected items.
|
-- @field #table Contacts Table of detected items.
|
||||||
-- @field #table ContactsLost Table of lost detected items.
|
-- @field #table ContactsLost Table of lost detected items.
|
||||||
-- @field #table ContactsUnknown Table of new detected items.
|
-- @field #table ContactsUnknown Table of new detected items.
|
||||||
|
|||||||
@@ -74,15 +74,15 @@ SQUADRON = {
|
|||||||
|
|
||||||
--- SQUADRON class version.
|
--- SQUADRON class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
SQUADRON.version="0.0.3"
|
SQUADRON.version="0.0.5"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- DONE: Engage radius.
|
-- DONE: Engage radius.
|
||||||
-- TODO: Modex.
|
-- DONE: Modex.
|
||||||
-- TODO: Call signs.
|
-- DONE: Call signs.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Constructor
|
-- Constructor
|
||||||
@@ -463,7 +463,7 @@ function SQUADRON:CanMission(Mission)
|
|||||||
local asset=_asset --#AIRWING.SquadronAsset
|
local asset=_asset --#AIRWING.SquadronAsset
|
||||||
|
|
||||||
-- Set range is valid.
|
-- Set range is valid.
|
||||||
if TargetDistance<=self.engageRange then
|
if TargetDistance<=self.engageRange or (Mission.engageMaxDistance and TargetDistance<=Mission.engageMaxDistance) then
|
||||||
|
|
||||||
-- Check if asset is currently on a mission (STARTED or QUEUED).
|
-- Check if asset is currently on a mission (STARTED or QUEUED).
|
||||||
if self.airwing:IsAssetOnMission(asset) then
|
if self.airwing:IsAssetOnMission(asset) then
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
-- @field #string lid Class id string for output to DCS log file.
|
-- @field #string lid Class id string for output to DCS log file.
|
||||||
-- @field #table airwings Table of airwings.
|
-- @field #table airwings Table of airwings.
|
||||||
-- @field #table missionqueue Mission queue.
|
-- @field #table missionqueue Mission queue.
|
||||||
|
-- @field Core.Set#SET_ZONE borderzoneset Set of zones defining the border of our territory.
|
||||||
|
-- @field Core.Set#SET_ZONE yellowzoneset Set of zones defining the extended border. Defcon is set to YELLOW if enemy activity is detected.
|
||||||
|
-- @field Core.Set#SET_ZONE engagezoneset Set of zones defining the extended border. Defcon is set to YELLOW if enemy activity is detected.
|
||||||
-- @extends Ops.Intelligence#INTEL
|
-- @extends Ops.Intelligence#INTEL
|
||||||
|
|
||||||
--- Be surprised!
|
--- Be surprised!
|
||||||
@@ -37,6 +40,9 @@ WINGCOMMANDER = {
|
|||||||
lid = nil,
|
lid = nil,
|
||||||
airwings = {},
|
airwings = {},
|
||||||
missionqueue = {},
|
missionqueue = {},
|
||||||
|
borderzoneset = nil,
|
||||||
|
yellowzoneset = nil,
|
||||||
|
engagezoneset = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Contact details.
|
--- Contact details.
|
||||||
@@ -44,6 +50,17 @@ WINGCOMMANDER = {
|
|||||||
-- @field Ops.Auftrag#AUFTRAG mission The assigned mission.
|
-- @field Ops.Auftrag#AUFTRAG mission The assigned mission.
|
||||||
-- @extends Ops.Intelligence#INTEL.DetectedItem
|
-- @extends Ops.Intelligence#INTEL.DetectedItem
|
||||||
|
|
||||||
|
--- Defence condition.
|
||||||
|
-- @type WINGCOMMANDER.DefCon
|
||||||
|
-- @field #string GREEN No enemy activities detected.
|
||||||
|
-- @field #string YELLOW Enemy near our border.
|
||||||
|
-- @field #string RED Enemy within our border.
|
||||||
|
WINGCOMMANDER.DefCon = {
|
||||||
|
GREEN="Green",
|
||||||
|
YELLOW="Yellow",
|
||||||
|
RED="Red",
|
||||||
|
}
|
||||||
|
|
||||||
--- WINGCOMMANDER class version.
|
--- WINGCOMMANDER class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
WINGCOMMANDER.version="0.0.3"
|
WINGCOMMANDER.version="0.0.3"
|
||||||
@@ -77,6 +94,8 @@ function WINGCOMMANDER:New(AgentSet, Coalition)
|
|||||||
-- Set some string id for output to DCS.log file.
|
-- Set some string id for output to DCS.log file.
|
||||||
--self.lid=string.format("WINGCOMMANDER | ")
|
--self.lid=string.format("WINGCOMMANDER | ")
|
||||||
|
|
||||||
|
self:SetBorderZones()
|
||||||
|
|
||||||
-- Add FSM transitions.
|
-- Add FSM transitions.
|
||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("*", "MissionAssign", "*") -- Mission was assigned to an AIRWING.
|
self:AddTransition("*", "MissionAssign", "*") -- Mission was assigned to an AIRWING.
|
||||||
@@ -173,6 +192,30 @@ function WINGCOMMANDER:RemoveMission(Mission)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set accept zones. Only contacts detected in this/these zone(s) are considered.
|
||||||
|
-- @param #WINGCOMMANDER self
|
||||||
|
-- @param Core.Set#SET_ZONE BorderZoneSet Set of zones, defining our borders.
|
||||||
|
-- @return #WINGCOMMANDER self
|
||||||
|
function WINGCOMMANDER:SetBorderZones(BorderZoneSet)
|
||||||
|
self.borderzoneset=BorderZoneSet or SET_ZONE:New()
|
||||||
|
|
||||||
|
for _,zone in pairs(self.borderzoneset.Set) do
|
||||||
|
self:AddAcceptZone(zone)
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set accept zones. Only contacts detected in this zone are considered.
|
||||||
|
-- @param #WINGCOMMANDER self
|
||||||
|
-- @param Core.Zone#ZONEBorderZone Add a zone to the accept zone set.
|
||||||
|
-- @return #WINGCOMMANDER self
|
||||||
|
function WINGCOMMANDER:AddBorderZone(BorderZone)
|
||||||
|
self.borderzoneset:AddZone(BorderZone)
|
||||||
|
|
||||||
|
self:AddAcceptZone(BorderZone)
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Start & Status
|
-- Start & Status
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -346,10 +389,10 @@ function WINGCOMMANDER:GetAirwingForMission(Mission)
|
|||||||
if coord then
|
if coord then
|
||||||
|
|
||||||
-- Distance from airwing to target.
|
-- Distance from airwing to target.
|
||||||
local dist=coord:Get2DDistance(airwing:GetCoordinate())
|
local dist=UTILS.MetersToNM(coord:Get2DDistance(airwing:GetCoordinate()))
|
||||||
|
|
||||||
-- Add airwing to table of airwings that can.
|
-- Add airwing to table of airwings that can.
|
||||||
table.insert(airwings, {airwing=airwing, dist=dist, targetcoord=coord})
|
table.insert(airwings, {airwing=airwing, dist=dist, targetcoord=coord, nassets=#assets})
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -360,9 +403,19 @@ function WINGCOMMANDER:GetAirwingForMission(Mission)
|
|||||||
-- Can anyone?
|
-- Can anyone?
|
||||||
if #airwings>0 then
|
if #airwings>0 then
|
||||||
|
|
||||||
-- Sort table wrt distace
|
--- Something like:
|
||||||
|
-- * Closest airwing that can should be first prio.
|
||||||
|
-- * However, there should be a certain "quantization". if wing is 50 or 60 NM way should not really matter. In that case, the airwing with more resources should get the job.
|
||||||
|
local function score(a)
|
||||||
|
local d=math.round(a.dist/10)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Sort table wrt distance and number of assets.
|
||||||
|
-- Distances within 10 NM are equal and the airwing with more assets is preferred.
|
||||||
local function sortdist(a,b)
|
local function sortdist(a,b)
|
||||||
return a.dist<b.dist
|
local ad=math.round(a.dist/10) -- dist 55 NM ==> 5.5 ==> 6
|
||||||
|
local bd=math.round(b.dist/10) -- dist 63 NM ==> 6.3 ==> 6
|
||||||
|
return ad<bd or (ad==bd and a.nassets>b.nassets)
|
||||||
end
|
end
|
||||||
table.sort(airwings, sortdist)
|
table.sort(airwings, sortdist)
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ ENUMS.WeaponFlag={
|
|||||||
-- @field #string PINPOINTSTRIKE Pinpoint strike.
|
-- @field #string PINPOINTSTRIKE Pinpoint strike.
|
||||||
-- @field #string RECONNAISSANCE Reconnaissance mission.
|
-- @field #string RECONNAISSANCE Reconnaissance mission.
|
||||||
-- @field #string REFUELLING Refuelling mission.
|
-- @field #string REFUELLING Refuelling mission.
|
||||||
-- @field #string RUNWAYATTAC Attack the runway of an airdrome.
|
-- @field #string RUNWAYATTACK Attack the runway of an airdrome.
|
||||||
-- @field #string SEAD Suppression of Enemy Air Defenses.
|
-- @field #string SEAD Suppression of Enemy Air Defenses.
|
||||||
-- @field #string TRANSPORT Troop transport.
|
-- @field #string TRANSPORT Troop transport.
|
||||||
ENUMS.MissionTask={
|
ENUMS.MissionTask={
|
||||||
|
|||||||
Reference in New Issue
Block a user