From 15b1ed028e660e71c9485d0b6e92e59258bfe613 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 1 Jan 2025 14:38:07 +0100 Subject: [PATCH 1/3] #MANTIS - better handling of stats, verbose dist calc in km, coord in MGRS0 now --- Moose Development/Moose/Functional/Mantis.lua | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/Moose Development/Moose/Functional/Mantis.lua b/Moose Development/Moose/Functional/Mantis.lua index 34c5c5ee3..0124af4ba 100644 --- a/Moose Development/Moose/Functional/Mantis.lua +++ b/Moose Development/Moose/Functional/Mantis.lua @@ -1287,9 +1287,9 @@ do -- DEBUG set = self:_PreFilterHeight(height) end - local friendlyset -- Core.Set#SET_GROUP - if self.checkforfriendlies == true then - friendlyset = SET_GROUP:New():FilterCoalitions(self.Coalition):FilterCategories({"plane","helicopter"}):FilterFunction(function(grp) if grp and grp:InAir() then return true else return false end end):FilterOnce() + --self.friendlyset -- Core.Set#SET_GROUP + if self.checkforfriendlies == true and self.friendlyset == nil then + self.friendlyset = SET_GROUP:New():FilterCoalitions(self.Coalition):FilterCategories({"plane","helicopter"}):FilterFunction(function(grp) if grp and grp:InAir() then return true else return false end end):FilterStart() end for _,_coord in pairs (set) do local coord = _coord -- get current coord to check @@ -1305,20 +1305,21 @@ do zonecheck = self:_CheckCoordinateInZones(coord) end if self.verbose and self.debug then - local dectstring = coord:ToStringLLDMS() - local samstring = samcoordinate:ToStringLLDMS() + --local dectstring = coord:ToStringLLDMS() + local samstring = samcoordinate:ToStringMGRS({MGRS_Accuracy=0}) + samstring = string.gsub(samstring,"%s","") local inrange = "false" if targetdistance <= rad then inrange = "true" end - local text = string.format("Checking SAM at %s | Targetdist %d | Rad %d | Inrange %s", samstring, targetdistance, rad, inrange) + local text = string.format("Checking SAM at %s | Tgtdist %.1fkm | Rad %.1fkm | Inrange %s", samstring, targetdistance/1000, rad/1000, inrange) local m = MESSAGE:New(text,10,"Check"):ToAllIf(self.debug) self:T(self.lid..text) end -- friendlies around? local nofriendlies = true if self.checkforfriendlies == true then - local closestfriend, distance = friendlyset:GetClosestGroup(samcoordinate) + local closestfriend, distance = self.friendlyset:GetClosestGroup(samcoordinate) if closestfriend and distance and distance < rad then nofriendlies = false end @@ -1618,7 +1619,7 @@ do --self:I({grpname,grprange, grpheight}) elseif type == MANTIS.SamType.SHORT then table.insert( SAM_Tbl_sh, {grpname, grpcoord, grprange, grpheight, blind}) - -- self:I({grpname,grprange, grpheight}) + --self:I({grpname,grprange, grpheight}) self.ShoradGroupSet:Add(grpname,group) if self.autoshorad then self.Shorad.Groupset = self.ShoradGroupSet @@ -1677,9 +1678,9 @@ do function MANTIS:_CheckLoop(samset,detset,dlink,limit) self:T(self.lid .. "CheckLoop " .. #detset .. " Coordinates") local switchedon = 0 - local statusreport = REPORT:New("\nMANTIS Status") local instatusred = 0 local instatusgreen = 0 + local activeshorads = 0 local SEADactive = 0 for _,_data in pairs (samset) do local samcoordinate = _data[2] @@ -1756,22 +1757,13 @@ do instatusred=instatusred+1 end end - local activeshorads = 0 if self.Shorad then for _,_name in pairs(self.Shorad.ActiveGroups or {}) do activeshorads=activeshorads+1 end end - statusreport:Add("+-----------------------------+") - statusreport:Add(string.format("+ SAM in RED State: %2d",instatusred)) - statusreport:Add(string.format("+ SAM in GREEN State: %2d",instatusgreen)) - if self.Shorad then - statusreport:Add(string.format("+ SHORAD active: %2d",activeshorads)) - end - statusreport:Add("+-----------------------------+") - MESSAGE:New(statusreport:Text(),10,nil,true):ToAll():ToLog() end - return self + return instatusred, instatusgreen, activeshorads end --- [Internal] Check detection function @@ -1789,6 +1781,9 @@ do if rand > 65 then -- 1/3 of cases self:_RefreshSAMTable() end + local instatusred = 0 + local instatusgreen = 0 + local activeshorads = 0 -- switch SAMs on/off if (n)one of the detected groups is inside their reach if self.automode then local samset = self.SAM_Table_Long -- table of i.1=names, i.2=coordinates, i.3=firing range, i.4=firing height @@ -1796,10 +1791,21 @@ do local samset = self.SAM_Table_Medium -- table of i.1=names, i.2=coordinates, i.3=firing range, i.4=firing height self:_CheckLoop(samset,detset,dlink,self.maxmidrange) local samset = self.SAM_Table_Short -- table of i.1=names, i.2=coordinates, i.3=firing range, i.4=firing height - self:_CheckLoop(samset,detset,dlink,self.maxshortrange) + instatusred, instatusgreen, activeshorads = self:_CheckLoop(samset,detset,dlink,self.maxshortrange) else local samset = self:_GetSAMTable() -- table of i.1=names, i.2=coordinates, i.3=firing range, i.4=firing height - self:_CheckLoop(samset,detset,dlink,self.maxclassic) + instatusred, instatusgreen, activeshorads = self:_CheckLoop(samset,detset,dlink,self.maxclassic) + end + if self.debug or self.verbose then + local statusreport = REPORT:New("\nMANTIS Status "..self.name) + statusreport:Add("+-----------------------------+") + statusreport:Add(string.format("+ SAM in RED State: %2d",instatusred)) + statusreport:Add(string.format("+ SAM in GREEN State: %2d",instatusgreen)) + if self.Shorad then + statusreport:Add(string.format("+ SHORAD active: %2d",activeshorads)) + end + statusreport:Add("+-----------------------------+") + MESSAGE:New(statusreport:Text(),10):ToAll():ToLog() end return self end From d0736b0b56e57dec62968579c99de790098a66f8 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 1 Jan 2025 17:55:55 +0100 Subject: [PATCH 2/3] #SHORAD - Switch shorad group back to green&no emissions&scoot if it's directly attacked by a missile --- Moose Development/Moose/Functional/Shorad.lua | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Functional/Shorad.lua b/Moose Development/Moose/Functional/Shorad.lua index d4f70447f..dd0fd7637 100644 --- a/Moose Development/Moose/Functional/Shorad.lua +++ b/Moose Development/Moose/Functional/Shorad.lua @@ -21,7 +21,7 @@ -- @image Functional.Shorad.jpg -- -- Date: Nov 2021 --- Last Update: Nov 2023 +-- Last Update: Jan 2025 ------------------------------------------------------------------------- --- **SHORAD** class, extends Core.Base#BASE @@ -521,7 +521,27 @@ do -- go through set and find the one(s) to activate local TDiff = 4 for _,_group in pairs (shoradset) do - if _group:IsAnyInZone(targetzone) then + + local groupname = _group:GetName() + + if groupname == TargetGroup then + -- Shot at a SHORAD group + if self.UseEmOnOff then + _group:EnableEmission(false) + end + _group:OptionAlarmStateGreen() + self.ActiveGroups[groupname] = nil + local text = string.format("Shot at SHORAD %s! Evading!", _group:GetName()) + self:T(text) + local m = MESSAGE:New(text,10,"SHORAD"):ToAllIf(self.debug) + + --Shoot and Scoot + if self.shootandscoot then + self:__ShootAndScoot(1,_group) + end + + elseif _group:IsAnyInZone(targetzone) then + -- shot at a group we protect local text = string.format("Waking up SHORAD %s", _group:GetName()) self:T(text) local m = MESSAGE:New(text,10,"SHORAD"):ToAllIf(self.debug) @@ -529,7 +549,6 @@ do _group:EnableEmission(true) end _group:OptionAlarmStateRed() - local groupname = _group:GetName() if self.ActiveGroups[groupname] == nil then -- no timer yet for this group self.ActiveGroups[groupname] = { Timing = ActiveTimer } local endtime = timer.getTime() + (ActiveTimer * math.random(75,100) / 100 ) -- randomize wakeup a bit From 203f0c8abc76b5f6f14648674473887c07410f39 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Thu, 2 Jan 2025 11:18:44 +0100 Subject: [PATCH 3/3] #docu --- Moose Development/Moose/Core/Settings.lua | 26 +++++++++++------------ Moose Development/Moose/Globals.lua | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Moose Development/Moose/Core/Settings.lua b/Moose Development/Moose/Core/Settings.lua index 81a60a7f8..066fd1fd6 100644 --- a/Moose Development/Moose/Core/Settings.lua +++ b/Moose Development/Moose/Core/Settings.lua @@ -494,7 +494,7 @@ do -- SETTINGS return (self.A2ASystem and self.A2ASystem == "MGRS") or (not self.A2ASystem and _SETTINGS:IsA2A_MGRS()) end - -- @param #SETTINGS self + --- @param #SETTINGS self -- @param Wrapper.Group#GROUP MenuGroup Group for which to add menus. -- @param #table RootMenu Root menu table -- @return #SETTINGS @@ -948,49 +948,49 @@ do -- SETTINGS return self end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:A2GMenuSystem( MenuGroup, RootMenu, A2GSystem ) self.A2GSystem = A2GSystem MESSAGE:New( string.format( "Settings: Default A2G coordinate system set to %s for all players!", A2GSystem ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:A2AMenuSystem( MenuGroup, RootMenu, A2ASystem ) self.A2ASystem = A2ASystem MESSAGE:New( string.format( "Settings: Default A2A coordinate system set to %s for all players!", A2ASystem ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuLL_DDM_Accuracy( MenuGroup, RootMenu, LL_Accuracy ) self.LL_Accuracy = LL_Accuracy MESSAGE:New( string.format( "Settings: Default LL accuracy set to %s for all players!", LL_Accuracy ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuMGRS_Accuracy( MenuGroup, RootMenu, MGRS_Accuracy ) self.MGRS_Accuracy = MGRS_Accuracy MESSAGE:New( string.format( "Settings: Default MGRS accuracy set to %s for all players!", MGRS_Accuracy ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuMWSystem( MenuGroup, RootMenu, MW ) self.Metric = MW MESSAGE:New( string.format( "Settings: Default measurement format set to %s for all players!", MW and "Metric" or "Imperial" ), 5 ):ToAll() self:SetSystemMenu( MenuGroup, RootMenu ) end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuMessageTimingsSystem( MenuGroup, RootMenu, MessageType, MessageTime ) self:SetMessageTime( MessageType, MessageTime ) MESSAGE:New( string.format( "Settings: Default message time set for %s to %d.", MessageType, MessageTime ), 5 ):ToAll() end do - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuGroupA2GSystem( PlayerUnit, PlayerGroup, PlayerName, A2GSystem ) --BASE:E( {PlayerUnit:GetName(), A2GSystem } ) self.A2GSystem = A2GSystem @@ -1001,7 +1001,7 @@ do -- SETTINGS end end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuGroupA2ASystem( PlayerUnit, PlayerGroup, PlayerName, A2ASystem ) self.A2ASystem = A2ASystem MESSAGE:New( string.format( "Settings: A2A format set to %s for player %s.", A2ASystem, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1011,7 +1011,7 @@ do -- SETTINGS end end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuGroupLL_DDM_AccuracySystem( PlayerUnit, PlayerGroup, PlayerName, LL_Accuracy ) self.LL_Accuracy = LL_Accuracy MESSAGE:New( string.format( "Settings: LL format accuracy set to %d decimal places for player %s.", LL_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1021,7 +1021,7 @@ do -- SETTINGS end end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuGroupMGRS_AccuracySystem( PlayerUnit, PlayerGroup, PlayerName, MGRS_Accuracy ) self.MGRS_Accuracy = MGRS_Accuracy MESSAGE:New( string.format( "Settings: MGRS format accuracy set to %d for player %s.", MGRS_Accuracy, PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1031,7 +1031,7 @@ do -- SETTINGS end end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuGroupMWSystem( PlayerUnit, PlayerGroup, PlayerName, MW ) self.Metric = MW MESSAGE:New( string.format( "Settings: Measurement format set to %s for player %s.", MW and "Metric" or "Imperial", PlayerName ), 5 ):ToGroup( PlayerGroup ) @@ -1041,7 +1041,7 @@ do -- SETTINGS end end - -- @param #SETTINGS self + --- @param #SETTINGS self function SETTINGS:MenuGroupMessageTimingsSystem( PlayerUnit, PlayerGroup, PlayerName, MessageType, MessageTime ) self:SetMessageTime( MessageType, MessageTime ) MESSAGE:New( string.format( "Settings: Default message time set for %s to %d.", MessageType, MessageTime ), 5 ):ToGroup( PlayerGroup ) diff --git a/Moose Development/Moose/Globals.lua b/Moose Development/Moose/Globals.lua index 4762a10fb..771547060 100644 --- a/Moose Development/Moose/Globals.lua +++ b/Moose Development/Moose/Globals.lua @@ -10,7 +10,7 @@ _SCHEDULEDISPATCHER = SCHEDULEDISPATCHER:New() -- Core.ScheduleDispatcher#SCHEDU _DATABASE = DATABASE:New() -- Core.Database#DATABASE --- Settings -_SETTINGS = SETTINGS:Set() +_SETTINGS = SETTINGS:Set() -- Core.Settings#SETTINGS _SETTINGS:SetPlayerMenuOn() --- Register cargos.