Merge branch 'master' into develop

This commit is contained in:
Frank 2020-12-16 00:12:38 +01:00
commit 42a6f3272d

View File

@ -12,12 +12,19 @@
-- Leverage attack range setup added by DCS in 11/20 -- Leverage attack range setup added by DCS in 11/20
-- --
-- === -- ===
--
-- ## Missions:
-- --
-- ### [MANTIS - Modular, Automatic and Network capable Targeting and Interception System](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/MTS%20-%20Mantis/MTS-010%20-%20Basic%20Mantis%20Demo)
--
-- ===
--
-- ### Authors : **applevangelist ** -- ### Authors : **applevangelist **
-- --
-- @module Functional.Mantis -- @module Functional.Mantis
-- @image Functional.Mantis.jpg
-- Date: Dec 2020 -- Date: Dec 2020
--
------------------------------------------------------------------------- -------------------------------------------------------------------------
--- **MANTIS** class, extends @{Core.Base#BASE} --- **MANTIS** class, extends @{Core.Base#BASE}
-- @type MANTIS -- @type MANTIS
@ -48,21 +55,27 @@
-- Controls a network of SAM sites. Use detection to switch on the AA site closest to the enemy. -- Controls a network of SAM sites. Use detection to switch on the AA site closest to the enemy.
-- Leverage evasiveness from @{Functional.Sead#SEAD}. -- Leverage evasiveness from @{Functional.Sead#SEAD}.
-- Leverage attack range setup added by DCS in 11/20. -- Leverage attack range setup added by DCS in 11/20.
-- @usage --
-- Set up your SAM sites in the mission editor. Name the groups with common prefix like "Red SAM". -- Set up your SAM sites in the mission editor. Name the groups with common prefix like "Red SAM".
-- Set up your EWR system in the mission editor. Name the groups with common prefix like "Red EWR". Can be e.g. AWACS or a combination of AWACS and Search Radars like e.g. EWR 1L13 etc. -- Set up your EWR system in the mission editor. Name the groups with common prefix like "Red EWR". Can be e.g. AWACS or a combination of AWACS and Search Radars like e.g. EWR 1L13 etc.
-- [optional] Set up your HQ. Can be any group, e.g. a command vehicle. -- [optional] Set up your HQ. Can be any group, e.g. a command vehicle.
-- --
-- Start up your MANTIS -- Start up your MANTIS
-- --
-- `myredmantis = MANTIS:New("myredmantis","Red SAM","Red EWR",nil,"red",false)` -- `myredmantis = MANTIS:New("myredmantis","Red SAM","Red EWR",nil,"red",false)`
-- [optional] Use `MANTIS:SetEWRGrouping(radius)`, `MANTIS:SetEWRRange(radius)`, `MANTIS:SetSAMRadius(radius)`, `MANTIS:SetDetectInterval(interval)` to fine-tune your setup. --
-- [optional] Use
-- + `MANTIS:SetEWRGrouping(radius)`
-- + `MANTIS:SetEWRRange(radius)`
-- + `MANTIS:SetSAMRadius(radius)`
-- + `MANTIS:SetDetectInterval(interval)`
-- to fine-tune your setup.
-- --
-- `myredmantis:Start()` -- `myredmantis:Start()`
-- --
-- @field #MANTIS -- @field #MANTIS
MANTIS = { MANTIS = {
ClassName = "MANTIS", ClassName = "MANTIS",
name = "mymantis", name = "mymantis",
SAM_Templates_Prefix = "", SAM_Templates_Prefix = "",
SAM_Group = nil, SAM_Group = nil,
@ -109,10 +122,10 @@ do
self.detectinterval = 30 self.detectinterval = 30
-- @field #string version -- @field #string version
self.version="0.2.1" self.version="0.2.2"
env.info(string.format("***** Starting MANTIS Version %s *****", self.version)) env.info(string.format("***** Starting MANTIS Version %s *****", self.version))
-- Set some string id for output to DCS.log file. -- Set the string id for output to DCS.log file.
self.lid=string.format("MANTIS %s | ", self.name) self.lid=string.format("MANTIS %s | ", self.name)
-- Debug trace. -- Debug trace.
@ -124,14 +137,14 @@ do
end end
if self.dynamic then if self.dynamic then
-- get SAM SET_GROUP -- Set SAM SET_GROUP
self.SAM_Group = SET_GROUP:New():FilterPrefixes(self.SAM_Templates_Prefix):FilterCoalitions(self.Coalition):FilterStart() self.SAM_Group = SET_GROUP:New():FilterPrefixes(self.SAM_Templates_Prefix):FilterCoalitions(self.Coalition):FilterStart()
-- get EWR SET_GROUP -- Set EWR SET_GROUP
self.EWR_Group = SET_GROUP:New():FilterPrefixes({self.SAM_Templates_Prefix,self.EWR_Templates_Prefix}):FilterCoalitions(self.Coalition):FilterStart() self.EWR_Group = SET_GROUP:New():FilterPrefixes({self.SAM_Templates_Prefix,self.EWR_Templates_Prefix}):FilterCoalitions(self.Coalition):FilterStart()
else else
-- get SAM SET_GROUP -- Set SAM SET_GROUP
self.SAM_Group = SET_GROUP:New():FilterPrefixes(self.SAM_Templates_Prefix):FilterCoalitions(self.Coalition):FilterOnce() self.SAM_Group = SET_GROUP:New():FilterPrefixes(self.SAM_Templates_Prefix):FilterCoalitions(self.Coalition):FilterOnce()
-- get EWR SET_GROUP -- Set EWR SET_GROUP
self.EWR_Group = SET_GROUP:New():FilterPrefixes({self.SAM_Templates_Prefix,self.EWR_Templates_Prefix}):FilterCoalitions(self.Coalition):FilterOnce() self.EWR_Group = SET_GROUP:New():FilterPrefixes({self.SAM_Templates_Prefix,self.EWR_Templates_Prefix}):FilterCoalitions(self.Coalition):FilterOnce()
end end
@ -204,7 +217,7 @@ do
self.detectinterval = interval self.detectinterval = interval
end end
--- Function to check if no object is in the given SAM zone --- Function to check if any object is in the given SAM zone
-- @param #MANTIS self -- @param #MANTIS self
-- @param #table dectset Table of coordinates of detected items -- @param #table dectset Table of coordinates of detected items
-- @param samcoordinate Core.Point#COORDINATE Coordinate object. -- @param samcoordinate Core.Point#COORDINATE Coordinate object.
@ -237,12 +250,13 @@ do
self:F(self.lid.."Starting Detection") self:F(self.lid.."Starting Detection")
-- start detection -- start detection
groupset = self.EWR_Group local groupset = self.EWR_Group
local grouping = self.grouping or 5000 local grouping = self.grouping or 5000
local acceptrange = self.acceptrange or 80000 local acceptrange = self.acceptrange or 80000
local interval = self.detectinterval or 60 local interval = self.detectinterval or 60
_MANTISdetection = DETECTION_AREAS:New( groupset, grouping ) --group detected objects to 5000m zones --@param Functional.Detection #DETECTION_AREAS _MANTISdetection [internal] The MANTIS detection object
_MANTISdetection = DETECTION_AREAS:New( groupset, grouping ) --[internal] Groups detected objects to 5000m zones
_MANTISdetection:FilterCategories({ Unit.Category.AIRPLANE, Unit.Category.HELICOPTER }) _MANTISdetection:FilterCategories({ Unit.Category.AIRPLANE, Unit.Category.HELICOPTER })
_MANTISdetection:SetAcceptRange(acceptrange) _MANTISdetection:SetAcceptRange(acceptrange)
_MANTISdetection:SetRefreshTimeInterval(interval) _MANTISdetection:SetRefreshTimeInterval(interval)
@ -253,7 +267,7 @@ do
if DetectedItem.IsDetected then if DetectedItem.IsDetected then
local Coordinate = DetectedItem.Coordinate -- Core.Point#COORDINATE local Coordinate = DetectedItem.Coordinate -- Core.Point#COORDINATE
local text = "MANTIS: Detection at "..Coordinate:ToStringLLDMS() local text = "MANTIS: Detection at "..Coordinate:ToStringLLDMS()
m = MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug) local m = MESSAGE:New(text,10,"MANTIS"):ToAllIf(self.debug)
end end
end end
return _MANTISdetection return _MANTISdetection
@ -328,8 +342,8 @@ do
samgroup:OptionAlarmStateRed() samgroup:OptionAlarmStateRed()
--samgroup:OptionROEWeaponFree() --samgroup:OptionROEWeaponFree()
--samgroup:SetAIOn() --samgroup:SetAIOn()
text = string.format("SAM %s switched to alarm state RED!", name) local text = string.format("SAM %s switched to alarm state RED!", name)
m=MESSAGE:New(text,15,"MANTIS"):ToAllIf(self.debug) local m=MESSAGE:New(text,15,"MANTIS"):ToAllIf(self.debug)
end --end alive end --end alive
else else
if samgroup:IsAlive() then if samgroup:IsAlive() then
@ -337,8 +351,8 @@ do
samgroup:OptionAlarmStateGreen() samgroup:OptionAlarmStateGreen()
--samgroup:OptionROEWeaponFree() --samgroup:OptionROEWeaponFree()
--samgroup:SetAIOn() --samgroup:SetAIOn()
text = string.format("SAM %s switched to alarm state GREEN!", name) local text = string.format("SAM %s switched to alarm state GREEN!", name)
m=MESSAGE:New(text,15,"MANTIS"):ToAllIf(self.debug) local m=MESSAGE:New(text,15,"MANTIS"):ToAllIf(self.debug)
end --end alive end --end alive
end --end check end --end check
end --for for loop end --for for loop