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 #boolean advAwacs Boolean switch to use Awacs as a separate detection stream
-- @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 #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
@ -191,7 +191,7 @@ MANTIS = {
ShoradLink = false,
ShoradTime = 600,
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 #boolean dynamic Use constant (true) filtering or just filter once (false, default) (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
--@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: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: Make HQ useful
@ -264,7 +264,11 @@ do
self.ShoradTime = 600
self.ShoradActDistance = 15000
-- 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
self.advAwacs = true
@ -304,7 +308,7 @@ do
end
-- @field #string version
self.version="0.4.0"
self.version="0.4.1"
self:I(string.format("***** Starting MANTIS Version %s *****", self.version))
return self
@ -463,11 +467,11 @@ do
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 #boolean switch Decide if we are changing alarm state or AI state
function MANTIS:SetUsingAIOnOff(switch)
self.UseAIOnOff = switch or false
-- @param #boolean switch Decide if we are changing alarm state or Emission state
function MANTIS:SetUsingEmOnOff(switch)
self.UseEmOnOff = switch or false
end
--- [Internal] Function to check if HQ is alive
@ -714,8 +718,9 @@ do
for _i,_group in pairs (SAM_Grps) do
local group = _group
-- TODO: add emissions on/off
if self.UseAIOnOff then
group:SetAIOff()
if self.UseEmOnOff then
group:EnableEmission(false)
--group:SetAIOff()
else
group:OptionAlarmStateGreen() -- AI off
end
@ -822,9 +827,10 @@ do
if IsInZone then --check any target in zone
if samgroup:IsAlive() then
-- switch on SAM
if self.UseAIOnOff then
if self.UseEmOnOff then
-- TODO: add emissions on/off
samgroup:SetAIOn()
--samgroup:SetAIOn()
samgroup:EnableEmission(true)
end
samgroup:OptionAlarmStateRed()
-- link in to SHORAD if available
@ -843,9 +849,10 @@ do
else
if samgroup:IsAlive() then
-- switch off SAM
if self.UseAIOnOff then
if self.UseEmOnOff then
-- TODO: add emissions on/off
samgroup:SetAIOff()
samgroup:EnableEmission(false)
--samgroup:SetAIOff()
else
samgroup:OptionAlarmStateGreen()
end
@ -883,9 +890,10 @@ do
local name = _data[1]
local samgroup = GROUP:FindByName(name)
if samgroup:IsAlive() then
if self.UseAIOnOff then
if self.UseEmOnOff then
-- TODO: add emissions on/off
samgroup:SetAIOn()
--samgroup:SetAIOn()
samgroup:EnableEmission(true)
end
samgroup:OptionAlarmStateRed()
end -- end alive

View File

@ -109,7 +109,7 @@ function SEAD:New( SEADGroupPrefixes )
end
self:HandleEvent( EVENTS.Shot )
self:I("*** SEAD - Started Version 0.2.5")
self:I("*** SEAD - Started Version 0.2.7")
return self
end
@ -205,15 +205,18 @@ function SEAD:OnEventShot( EventData )
SEADWeaponName == "weapons.missiles.AGM_84H" --AGM84 anti-radiation missiles fired
--]]
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 _targetMim = EventData.Weapon:getTarget() -- Identify target
local _targetMimname = Unit.getName(_targetMim) -- Unit name
local _targetMimgroup = Unit.getGroup(Weapon.getTarget(SEADWeapon)) --targeted group
local _targetMimgroupName = _targetMimgroup:getName() -- group name
local _targetskill = _DATABASE.Templates.Units[_targetMimname].Template.skill
self:T( self.SEADGroupPrefixes )
self:T( _targetMimgroupName )
local _targetUnit = UNIT:Find(_targetMim) -- Unit name by DCS Object
if _targetUnit and _targetUnit:IsAlive() then
local _targetMimgroup = _targetUnit:GetGroup()
local _targetMimgroupName = _targetMimgroup:GetName() -- group name
--local _targetskill = _DATABASE.Templates.Units[_targetUnit].Template.skill
self:T( self.SEADGroupPrefixes )
self:T( _targetMimgroupName )
end
-- see if we are shot at
local SEADGroupFound = false
for SEADGroupPrefixID, SEADGroupPrefix in pairs( self.SEADGroupPrefixes ) do
@ -249,6 +252,7 @@ function SEAD:OnEventShot( EventData )
local range = self.EngagementRange -- Feature Request #1355
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.groupName:enableEmission(true)
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
end
@ -261,6 +265,7 @@ function SEAD:OnEventShot( EventData )
SuppressionEndTime = delay
}
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
end
end

View File

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

View File

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