diff --git a/Moose Development/Moose/Functional/Mantis.lua b/Moose Development/Moose/Functional/Mantis.lua index c4564fb94..4d6565262 100644 --- a/Moose Development/Moose/Functional/Mantis.lua +++ b/Moose Development/Moose/Functional/Mantis.lua @@ -20,7 +20,7 @@ -- @module Functional.Mantis -- @image Functional.Mantis.jpg --- Date: Feb 2021 +-- Date: Apr 2021 ------------------------------------------------------------------------- --- **MANTIS** class, extends #Core.Base#BASE @@ -51,6 +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 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 @@ -189,7 +190,8 @@ MANTIS = { Shorad = nil, ShoradLink = false, ShoradTime = 600, - ShoradActDistance = 15000, + ShoradActDistance = 15000, + UseAIOnOff = false, } ----------------------------------------------------------------------- @@ -206,6 +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) --@return #MANTIS self --@usage Start up your MANTIS with a basic setting -- @@ -227,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) + function MANTIS:New(name,samprefix,ewrprefix,hq,coaltion,dynamic,awacs, AIOnOff) -- DONE: Create some user functions for these -- DONE: Make HQ useful @@ -260,6 +263,8 @@ do self.ShoradLink = false self.ShoradTime = 600 self.ShoradActDistance = 15000 + -- TODO: add emissions on/off when available .... in 2 weeks + self.UseAIOnOff = AIOnOff or false if type(awacs) == "string" then self.advAwacs = true @@ -299,7 +304,7 @@ do end -- @field #string version - self.version="0.3.7" + self.version="0.4.0" self:I(string.format("***** Starting MANTIS Version %s *****", self.version)) return self @@ -458,6 +463,13 @@ do end end + --- Set using AI 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 + end + --- [Internal] Function to check if HQ is alive -- @param #MANTIS self -- @return #boolean True if HQ is alive, else false @@ -701,7 +713,12 @@ do --cycle through groups and set alarm state etc for _i,_group in pairs (SAM_Grps) do local group = _group - group:OptionAlarmStateGreen() -- AI off + -- TODO: add emissions on/off + if self.UseAIOnOff then + group:SetAIOff() + else + group:OptionAlarmStateGreen() -- AI off + end group:SetOption(AI.Option.Ground.id.AC_ENGAGEMENT_RANGE_RESTRICTION,engagerange) --default engagement will be 75% of firing range if group:IsGround() then local grpname = group:GetName() @@ -804,7 +821,11 @@ do local IsInZone, Distance = self:CheckObjectInZone(detset, samcoordinate) if IsInZone then --check any target in zone if samgroup:IsAlive() then - -- switch off SAM + -- switch on SAM + if self.UseAIOnOff then + -- TODO: add emissions on/off + samgroup:SetAIOn() + end samgroup:OptionAlarmStateRed() -- link in to SHORAD if available -- DONE: Test integration fully @@ -822,7 +843,12 @@ do else if samgroup:IsAlive() then -- switch off SAM - samgroup:OptionAlarmStateGreen() + if self.UseAIOnOff then + -- TODO: add emissions on/off + samgroup:SetAIOff() + else + samgroup:OptionAlarmStateGreen() + end --samgroup:OptionROEWeaponFree() --samgroup:SetAIOn() local text = string.format("SAM %s switched to alarm state GREEN!", name) @@ -857,6 +883,10 @@ do local name = _data[1] local samgroup = GROUP:FindByName(name) if samgroup:IsAlive() then + if self.UseAIOnOff then + -- TODO: add emissions on/off + samgroup:SetAIOn() + end samgroup:OptionAlarmStateRed() end -- end alive end -- end for loop