Merge branch 'master' into FF/Ops

This commit is contained in:
Frank 2021-05-02 00:25:07 +02:00
commit cfa851beea
5 changed files with 372 additions and 332 deletions

File diff suppressed because it is too large Load Diff

View File

@ -51,7 +51,7 @@
-- @field #number adv_state Advanced mode state tracker -- @field #number adv_state Advanced mode state tracker
-- @field #boolean advAwacs Boolean switch to use Awacs as a separate detection stream -- @field #boolean advAwacs Boolean switch to use Awacs as a separate detection stream
-- @field #number awacsrange Detection range of an optional Awacs unit -- @field #number awacsrange Detection range of an optional Awacs unit
-- @field #boolean UseAIOnOff Decide if we are using AI on/off (true) or AlarmState red/green (default) -- @field #boolean UseEmOnOff Decide if we are using Emissions on/off (true) or AlarmState red/green (default)
-- @field Functional.Shorad#SHORAD Shorad SHORAD Object, if available -- @field Functional.Shorad#SHORAD Shorad SHORAD Object, if available
-- @field #boolean ShoradLink If true, #MANTIS has #SHORAD enabled -- @field #boolean ShoradLink If true, #MANTIS has #SHORAD enabled
-- @field #number ShoradTime Timer in seconds, how long #SHORAD will be active after a detection inside of the defense range -- @field #number ShoradTime Timer in seconds, how long #SHORAD will be active after a detection inside of the defense range
@ -191,7 +191,7 @@ MANTIS = {
ShoradLink = false, ShoradLink = false,
ShoradTime = 600, ShoradTime = 600,
ShoradActDistance = 15000, ShoradActDistance = 15000,
UseAIOnOff = false, UseEmOnOff = true,
} }
----------------------------------------------------------------------- -----------------------------------------------------------------------
@ -208,7 +208,7 @@ do
--@param #string coaltion Coalition side of your setup, e.g. "blue", "red" or "neutral" --@param #string coaltion Coalition side of your setup, e.g. "blue", "red" or "neutral"
--@param #boolean dynamic Use constant (true) filtering or just filter once (false, default) (optional) --@param #boolean dynamic Use constant (true) filtering or just filter once (false, default) (optional)
--@param #string awacs Group name of your Awacs (optional) --@param #string awacs Group name of your Awacs (optional)
--@param #boolean AIOnOff Make MANTIS switch AI on and off instead of changing the alarm state between RED and GREEN (optional) --@param #boolean EmOnOff Make MANTIS switch Emissions on and off instead of changing the alarm state between RED and GREEN (optional, deault true)
--@return #MANTIS self --@return #MANTIS self
--@usage Start up your MANTIS with a basic setting --@usage Start up your MANTIS with a basic setting
-- --
@ -230,7 +230,7 @@ do
-- `mybluemantis = MANTIS:New("bluemantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")` -- `mybluemantis = MANTIS:New("bluemantis","Blue SAM","Blue EWR",nil,"blue",false,"Blue Awacs")`
-- `mybluemantis:Start()` -- `mybluemantis:Start()`
-- --
function MANTIS:New(name,samprefix,ewrprefix,hq,coaltion,dynamic,awacs, AIOnOff) function MANTIS:New(name,samprefix,ewrprefix,hq,coaltion,dynamic,awacs, EmOnOff)
-- DONE: Create some user functions for these -- DONE: Create some user functions for these
-- DONE: Make HQ useful -- DONE: Make HQ useful
@ -264,7 +264,11 @@ do
self.ShoradTime = 600 self.ShoradTime = 600
self.ShoradActDistance = 15000 self.ShoradActDistance = 15000
-- TODO: add emissions on/off when available .... in 2 weeks -- TODO: add emissions on/off when available .... in 2 weeks
self.UseAIOnOff = AIOnOff or false if EmOnOff then
if EmOnOff == false then
self.UseEmOnOff = false
end
end
if type(awacs) == "string" then if type(awacs) == "string" then
self.advAwacs = true self.advAwacs = true
@ -304,7 +308,7 @@ do
end end
-- @field #string version -- @field #string version
self.version="0.4.0" self.version="0.4.1"
self:I(string.format("***** Starting MANTIS Version %s *****", self.version)) self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
return self return self
@ -463,11 +467,11 @@ do
end end
end end
--- Set using AI on/off instead of changing alarm state --- Set using Emissions on/off instead of changing alarm state
-- @param #MANTIS self -- @param #MANTIS self
-- @param #boolean switch Decide if we are changing alarm state or AI state -- @param #boolean switch Decide if we are changing alarm state or Emission state
function MANTIS:SetUsingAIOnOff(switch) function MANTIS:SetUsingEmOnOff(switch)
self.UseAIOnOff = switch or false self.UseEmOnOff = switch or false
end end
--- [Internal] Function to check if HQ is alive --- [Internal] Function to check if HQ is alive
@ -714,8 +718,9 @@ do
for _i,_group in pairs (SAM_Grps) do for _i,_group in pairs (SAM_Grps) do
local group = _group local group = _group
-- TODO: add emissions on/off -- TODO: add emissions on/off
if self.UseAIOnOff then if self.UseEmOnOff then
group:SetAIOff() group:EnableEmission(false)
--group:SetAIOff()
else else
group:OptionAlarmStateGreen() -- AI off group:OptionAlarmStateGreen() -- AI off
end end
@ -822,9 +827,10 @@ do
if IsInZone then --check any target in zone if IsInZone then --check any target in zone
if samgroup:IsAlive() then if samgroup:IsAlive() then
-- switch on SAM -- switch on SAM
if self.UseAIOnOff then if self.UseEmOnOff then
-- TODO: add emissions on/off -- TODO: add emissions on/off
samgroup:SetAIOn() --samgroup:SetAIOn()
samgroup:EnableEmission(true)
end end
samgroup:OptionAlarmStateRed() samgroup:OptionAlarmStateRed()
-- link in to SHORAD if available -- link in to SHORAD if available
@ -843,9 +849,10 @@ do
else else
if samgroup:IsAlive() then if samgroup:IsAlive() then
-- switch off SAM -- switch off SAM
if self.UseAIOnOff then if self.UseEmOnOff then
-- TODO: add emissions on/off -- TODO: add emissions on/off
samgroup:SetAIOff() samgroup:EnableEmission(false)
--samgroup:SetAIOff()
else else
samgroup:OptionAlarmStateGreen() samgroup:OptionAlarmStateGreen()
end end
@ -883,9 +890,10 @@ do
local name = _data[1] local name = _data[1]
local samgroup = GROUP:FindByName(name) local samgroup = GROUP:FindByName(name)
if samgroup:IsAlive() then if samgroup:IsAlive() then
if self.UseAIOnOff then if self.UseEmOnOff then
-- TODO: add emissions on/off -- TODO: add emissions on/off
samgroup:SetAIOn() --samgroup:SetAIOn()
samgroup:EnableEmission(true)
end end
samgroup:OptionAlarmStateRed() samgroup:OptionAlarmStateRed()
end -- end alive end -- end alive

View File

@ -109,7 +109,7 @@ function SEAD:New( SEADGroupPrefixes )
end end
self:HandleEvent( EVENTS.Shot ) self:HandleEvent( EVENTS.Shot )
self:I("*** SEAD - Started Version 0.2.5") self:I("*** SEAD - Started Version 0.2.7")
return self return self
end end
@ -205,15 +205,18 @@ function SEAD:OnEventShot( EventData )
SEADWeaponName == "weapons.missiles.AGM_84H" --AGM84 anti-radiation missiles fired SEADWeaponName == "weapons.missiles.AGM_84H" --AGM84 anti-radiation missiles fired
--]] --]]
if self:_CheckHarms(SEADWeaponName) then if self:_CheckHarms(SEADWeaponName) then
local _targetskill = "Random"
local _targetMimgroupName = "none"
local _evade = math.random (1,100) -- random number for chance of evading action local _evade = math.random (1,100) -- random number for chance of evading action
local _targetMim = EventData.Weapon:getTarget() -- Identify target local _targetMim = EventData.Weapon:getTarget() -- Identify target
local _targetMimname = Unit.getName(_targetMim) -- Unit name local _targetUnit = UNIT:Find(_targetMim) -- Unit name by DCS Object
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon)) --targeted group if _targetUnit and _targetUnit:IsAlive() then
local _targetMimgroupName = _targetMimgroup:getName() -- group name local _targetMimgroup = _targetUnit:GetGroup()
local _targetskill = _DATABASE.Templates.Units[_targetMimname].Template.skill local _targetMimgroupName = _targetMimgroup:GetName() -- group name
self:T( self.SEADGroupPrefixes ) --local _targetskill = _DATABASE.Templates.Units[_targetUnit].Template.skill
self:T( _targetMimgroupName ) self:T( self.SEADGroupPrefixes )
self:T( _targetMimgroupName )
end
-- see if we are shot at -- see if we are shot at
local SEADGroupFound = false local SEADGroupFound = false
for SEADGroupPrefixID, SEADGroupPrefix in pairs( self.SEADGroupPrefixes ) do for SEADGroupPrefixID, SEADGroupPrefix in pairs( self.SEADGroupPrefixes ) do
@ -249,6 +252,7 @@ function SEAD:OnEventShot( EventData )
local range = self.EngagementRange -- Feature Request #1355 local range = self.EngagementRange -- Feature Request #1355
self:T(string.format("*** SEAD - Engagement Range is %d", range)) self:T(string.format("*** SEAD - Engagement Range is %d", range))
id.ctrl:setOption(AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.RED) id.ctrl:setOption(AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.RED)
--id.groupName:enableEmission(true)
id.ctrl:setOption(AI.Option.Ground.id.AC_ENGAGEMENT_RANGE_RESTRICTION,range) --Feature Request #1355 id.ctrl:setOption(AI.Option.Ground.id.AC_ENGAGEMENT_RANGE_RESTRICTION,range) --Feature Request #1355
self.SuppressedGroups[id.groupName] = nil --delete group id from table when done self.SuppressedGroups[id.groupName] = nil --delete group id from table when done
end end
@ -261,6 +265,7 @@ function SEAD:OnEventShot( EventData )
SuppressionEndTime = delay SuppressionEndTime = delay
} }
Controller.setOption(_targetMimcont, AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.GREEN) Controller.setOption(_targetMimcont, AI.Option.Ground.id.ALARM_STATE,AI.Option.Ground.val.ALARM_STATE.GREEN)
--_targetMimgroup:enableEmission(false)
timer.scheduleFunction(SuppressionEnd, id, SuppressionEndTime) --Schedule the SuppressionEnd() function timer.scheduleFunction(SuppressionEnd, id, SuppressionEndTime) --Schedule the SuppressionEnd() function
end end
end end

View File

@ -18,7 +18,7 @@
-- @module Functional.Shorad -- @module Functional.Shorad
-- @image Functional.Shorad.jpg -- @image Functional.Shorad.jpg
-- --
-- Date: Feb 2021 -- Date: May 2021
------------------------------------------------------------------------- -------------------------------------------------------------------------
--- **SHORAD** class, extends Core.Base#BASE --- **SHORAD** class, extends Core.Base#BASE
@ -38,7 +38,7 @@
-- @field #boolean DefendMavs Default true, intercept incoming AG-Missiles -- @field #boolean DefendMavs Default true, intercept incoming AG-Missiles
-- @field #number DefenseLowProb Default 70, minimum detection limit -- @field #number DefenseLowProb Default 70, minimum detection limit
-- @field #number DefenseHighProb Default 90, maximim detection limit -- @field #number DefenseHighProb Default 90, maximim detection limit
-- @field #boolean UseAIOnOff Decide if we are using AI on/off (true) or AlarmState red/green (default). -- @field #boolean UseEmOnOff Decide if we are using Emission on/off (default) or AlarmState red/green.
-- @extends Core.Base#BASE -- @extends Core.Base#BASE
--- *Good friends are worth defending.* Mr Tushman, Wonder (the Movie) --- *Good friends are worth defending.* Mr Tushman, Wonder (the Movie)
@ -96,7 +96,7 @@ SHORAD = {
DefendMavs = true, DefendMavs = true,
DefenseLowProb = 70, DefenseLowProb = 70,
DefenseHighProb = 90, DefenseHighProb = 90,
UseAIOnOff = false, UseEmOnOff = false,
} }
----------------------------------------------------------------------- -----------------------------------------------------------------------
@ -176,8 +176,8 @@ do
self.DefendMavs = true self.DefendMavs = true
self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin self.DefenseLowProb = 70 -- probability to detect a missile shot, low margin
self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin self.DefenseHighProb = 90 -- probability to detect a missile shot, high margin
self.UseAIOnOff = false -- Decide if we are using AI on/off (true) or AlarmState red/green (default) self.UseEmOnOff = false -- Decide if we are using Emission on/off (default) or AlarmState red/green
self:I("*** SHORAD - Started Version 0.1.0") self:I("*** SHORAD - Started Version 0.2.1")
-- Set the string id for output to DCS.log file. -- Set the string id for output to DCS.log file.
self.lid=string.format("SHORAD %s | ", self.name) self.lid=string.format("SHORAD %s | ", self.name)
self:_InitState() self:_InitState()
@ -192,8 +192,9 @@ do
self:T({set = set}) self:T({set = set})
local aliveset = set:GetAliveSet() --#table local aliveset = set:GetAliveSet() --#table
for _,_group in pairs (aliveset) do for _,_group in pairs (aliveset) do
if self.UseAIOnOff then if self.UseEmOnOff then
_group:SetAIOff() --_group:SetAIOff()
_group:EnableEmission(false)
else else
_group:OptionAlarmStateGreen() --Wrapper.Group#GROUP _group:OptionAlarmStateGreen() --Wrapper.Group#GROUP
end end
@ -279,11 +280,11 @@ do
self.Radius = radius self.Radius = radius
end end
--- Set using AI on/off instead of changing alarm state --- Set using Emission on/off instead of changing alarm state
-- @param #SHORAD self -- @param #SHORAD self
-- @param #boolean switch Decide if we are changing alarm state or AI state -- @param #boolean switch Decide if we are changing alarm state or AI state
function SHORAD:SetUsingAIOnOff(switch) function SHORAD:SetUsingEmOnOff(switch)
self.UseAIOnOff = switch or false self.UseEmOnOff = switch or false
end end
--- Check if a HARM was fired --- Check if a HARM was fired
@ -410,8 +411,9 @@ do
local function SleepShorad(group) local function SleepShorad(group)
local groupname = group:GetName() local groupname = group:GetName()
self.ActiveGroups[groupname] = nil self.ActiveGroups[groupname] = nil
if self.UseAIOnOff then if self.UseEmOnOff then
group:SetAIOff() group:EnableEmission(false)
--group:SetAIOff()
else else
group:OptionAlarmStateGreen() group:OptionAlarmStateGreen()
end end
@ -425,8 +427,9 @@ do
local text = string.format("Waking up SHORAD %s", _group:GetName()) local text = string.format("Waking up SHORAD %s", _group:GetName())
self:T(text) self:T(text)
local m = MESSAGE:New(text,10,"SHORAD"):ToAllIf(self.debug) local m = MESSAGE:New(text,10,"SHORAD"):ToAllIf(self.debug)
if self.UseAIOnOff then if self.UseEmOnOff then
_group:SetAIOn() _group:SetAIOn()
_group:EnableEmission(true)
end end
_group:OptionAlarmStateRed() _group:OptionAlarmStateRed()
local groupname = _group:GetName() local groupname = _group:GetName()
@ -461,23 +464,31 @@ do
end end
local text = string.format("%s Missile Launched = %s | Detected probability state is %s", self.lid, ShootingWeaponName, DetectedText) local text = string.format("%s Missile Launched = %s | Detected probability state is %s", self.lid, ShootingWeaponName, DetectedText)
self:T( text ) self:T( text )
local m = MESSAGE:New(text,15,"Info"):ToAllIf(self.debug) local m = MESSAGE:New(text,10,"Info"):ToAllIf(self.debug)
-- --
if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then if (self:_CheckHarms(ShootingWeaponName) or self:_CheckMavs(ShootingWeaponName)) and IsDetected then
-- get target data -- get target data
local targetdata = EventData.Weapon:getTarget() -- Identify target local targetdata = EventData.Weapon:getTarget() -- Identify target
local targetunitname = Unit.getName(targetdata) -- Unit name local targetunit = UNIT:Find(targetdata)
local targetgroup = Unit.getGroup(Weapon.getTarget(ShootingWeapon)) --targeted group --local targetunitname = Unit.getName(targetdata) -- Unit name
local targetgroupname = targetgroup:getName() -- group name if targetunit and targetunit:IsAlive() then
-- check if we or a SAM site are the target local targetunitname = targetunit:GetName()
--local TargetGroup = EventData.TgtGroup -- Wrapper.Group#GROUP --local targetgroup = Unit.getGroup(Weapon.getTarget(ShootingWeapon)) --targeted group
local shotatus = self:_CheckShotAtShorad(targetgroupname) --#boolean local targetgroup = targetunit:GetGroup()
local shotatsams = self:_CheckShotAtSams(targetgroupname) --#boolean local targetgroupname = targetgroup:GetName() -- group name
-- if being shot at, find closest SHORADs to activate local text = string.format("%s Missile Target = %s", self.lid, tostring(targetgroupname))
if shotatsams or shotatus then self:T( text )
self:T({shotatsams=shotatsams,shotatus=shotatus}) local m = MESSAGE:New(text,10,"Info"):ToAllIf(self.debug)
self:WakeUpShorad(targetgroupname, self.Radius, self.ActiveTimer) -- check if we or a SAM site are the target
end --local TargetGroup = EventData.TgtGroup -- Wrapper.Group#GROUP
local shotatus = self:_CheckShotAtShorad(targetgroupname) --#boolean
local shotatsams = self:_CheckShotAtSams(targetgroupname) --#boolean
-- if being shot at, find closest SHORADs to activate
if shotatsams or shotatus then
self:T({shotatsams=shotatsams,shotatus=shotatus})
self:WakeUpShorad(targetgroupname, self.Radius, self.ActiveTimer)
end
end
end end
end end
end end

View File

@ -1460,7 +1460,7 @@ function CONTROLLABLE:TaskFireAtPoint( Vec2, Radius, AmmoCount, WeaponType, Alti
DCSTask.params.weaponType=WeaponType DCSTask.params.weaponType=WeaponType
end end
self:I(DCSTask) --self:I(DCSTask)
return DCSTask return DCSTask
end end