From 15b1ed028e660e71c9485d0b6e92e59258bfe613 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 1 Jan 2025 14:38:07 +0100 Subject: [PATCH] #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