From 09b7922b84494f40a33557c9759e82dc6ca46c70 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 16 May 2025 11:58:40 +0200 Subject: [PATCH 1/4] Small fixes --- Moose Development/Moose/Core/Database.lua | 2 ++ Moose Development/Moose/Functional/Mantis.lua | 26 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 4aec2393a..85bde137c 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -872,6 +872,8 @@ end -- @return Wrapper.Group#GROUP The found GROUP. function DATABASE:FindGroup( GroupName ) + if type(GroupName) ~= "string" or GroupName == "" then return end + local GroupFound = self.GROUPS[GroupName] if GroupFound == nil and GroupName ~= nil and self.Templates.Groups[GroupName] == nil then diff --git a/Moose Development/Moose/Functional/Mantis.lua b/Moose Development/Moose/Functional/Mantis.lua index 989b400e0..965762d07 100644 --- a/Moose Development/Moose/Functional/Mantis.lua +++ b/Moose Development/Moose/Functional/Mantis.lua @@ -64,6 +64,7 @@ -- @field #number SmokeDecoyColor Color to use, defaults to SMOKECOLOR.White -- @field #number checkcounter Counter for SAM Table refreshes. -- @field #number DLinkCacheTime Seconds after which cached contacts in DLink will decay. +-- @field #boolean logsamstatus Log SAM status in dcs.log every cycle if true -- @extends Core.Base#BASE @@ -322,6 +323,7 @@ MANTIS = { SmokeDecoyColor = SMOKECOLOR.White, checkcounter = 1, DLinkCacheTime = 120, + logsamstatus = false, } --- Advanced state enumerator @@ -647,6 +649,8 @@ do table.insert(self.ewr_templates,awacs) end + self.logsamstatus = false + self:T({self.ewr_templates}) self.SAM_Group = SET_GROUP:New():FilterPrefixes(self.SAM_Templates_Prefix):FilterCoalitions(self.Coalition) @@ -678,7 +682,7 @@ do -- TODO Version -- @field #string version - self.version="0.9.29" + self.version="0.9.30" self:I(string.format("***** Starting MANTIS Version %s *****", self.version)) --- FSM Functions --- @@ -1695,7 +1699,9 @@ do local grpname = group:GetName() local grpcoord = group:GetCoordinate() local grprange, grpheight,type,blind = self:_GetSAMRange(grpname) - local radaralive = group:IsSAM() + -- TODO the below might stop working at some point after some hours, needs testing + --local radaralive = group:IsSAM() + local radaralive = true table.insert( SAM_Tbl, {grpname, grpcoord, grprange, grpheight, blind, type}) -- make the table lighter, as I don't really use the zone here table.insert( SEAD_Grps, grpname ) if type == MANTIS.SamType.LONG and radaralive then @@ -1878,8 +1884,9 @@ do -- @param #MANTIS self -- @param Functional.Detection#DETECTION_AREAS detection Detection object -- @param #boolean dlink + -- @param #boolean reporttolog -- @return #MANTIS self - function MANTIS:_Check(detection,dlink) + function MANTIS:_Check(detection,dlink,reporttolog) self:T(self.lid .. "Check") --get detected set local detset = detection:GetDetectedItemCoordinates() @@ -1906,7 +1913,8 @@ do local samset = self:_GetSAMTable() -- table of i.1=names, i.2=coordinates, i.3=firing range, i.4=firing height instatusred, instatusgreen, activeshorads = self:_CheckLoop(samset,detset,dlink,self.maxclassic) end - if self.debug or self.verbose then + + local function GetReport() local statusreport = REPORT:New("\nMANTIS Status "..self.name) statusreport:Add("+-----------------------------+") statusreport:Add(string.format("+ SAM in RED State: %2d",instatusred)) @@ -1915,7 +1923,15 @@ do statusreport:Add(string.format("+ SHORAD active: %2d",activeshorads)) end statusreport:Add("+-----------------------------+") + return statusreport + end + + if self.debug or self.verbose then + local statusreport = GetReport() MESSAGE:New(statusreport:Text(),10):ToAll():ToLog() + elseif reporttolog == true then + local statusreport = GetReport() + MESSAGE:New(statusreport:Text(),10):ToLog() end return self end @@ -2023,7 +2039,7 @@ do self:T({From, Event, To}) -- check detection if not self.state2flag then - self:_Check(self.Detection,self.DLink) + self:_Check(self.Detection,self.DLink,self.logsamstatus) end local EWRAlive = self:_CheckAnyEWRAlive() From b126cc00d05ec3e139864467443dbcd6177a1a21 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 16 May 2025 13:43:03 +0200 Subject: [PATCH 2/4] xx --- Moose Development/Moose/Functional/Mantis.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Moose Development/Moose/Functional/Mantis.lua b/Moose Development/Moose/Functional/Mantis.lua index 965762d07..8ec4939d7 100644 --- a/Moose Development/Moose/Functional/Mantis.lua +++ b/Moose Development/Moose/Functional/Mantis.lua @@ -1863,7 +1863,7 @@ do end --end alive end --end check end --for loop - if self.debug or self.verbose then + if self.debug or self.verbose or self.logsamstatus then for _,_status in pairs(self.SamStateTracker) do if _status == "GREEN" then instatusgreen=instatusgreen+1 From 997baf21a0af023916a8b20221daa0e8dfda28f9 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 21 May 2025 10:04:58 +0200 Subject: [PATCH 3/4] #CSAR fix for ADF beacons --- Moose Development/Moose/Ops/CSAR.lua | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Moose Development/Moose/Ops/CSAR.lua b/Moose Development/Moose/Ops/CSAR.lua index 76f6df917..f1a1578ae 100644 --- a/Moose Development/Moose/Ops/CSAR.lua +++ b/Moose Development/Moose/Ops/CSAR.lua @@ -313,7 +313,7 @@ CSAR.AircraftType["CH-47Fbl1"] = 31 --- CSAR class version. -- @field #string version -CSAR.version="1.0.31" +CSAR.version="1.0.32" ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- ToDo list @@ -468,7 +468,7 @@ function CSAR:New(Coalition, Template, Alias) -- added 1.0.15 self.allowbronco = false -- set to true to use the Bronco mod as a CSAR plane - self.ADFRadioPwr = 1000 + self.ADFRadioPwr = 500 -- added 1.0.16 self.PilotWeight = 80 @@ -2333,9 +2333,9 @@ end -- @param #CSAR self -- @param Wrapper.Group#GROUP _group Group #GROUP object. -- @param #number _freq Frequency to use --- @param #string _name Beacon Name to use +-- @param #string BeaconName Beacon Name to use -- @return #CSAR self -function CSAR:_AddBeaconToGroup(_group, _freq, _name) +function CSAR:_AddBeaconToGroup(_group, _freq, BeaconName) self:T(self.lid .. " _AddBeaconToGroup") if self.CreateRadioBeacons == false then return end local _group = _group @@ -2356,10 +2356,11 @@ function CSAR:_AddBeaconToGroup(_group, _freq, _name) if _radioUnit then local name = _radioUnit:GetName() local Frequency = _freq -- Freq in Hertz - local name = _radioUnit:GetName() + --local name = _radioUnit:GetName() local Sound = "l10n/DEFAULT/"..self.radioSound local vec3 = _radioUnit:GetVec3() or _radioUnit:GetPositionVec3() or {x=0,y=0,z=0} - trigger.action.radioTransmission(Sound, vec3, 0, false, Frequency, self.ADFRadioPwr or 1000,_name) -- Beacon in MP only runs for exactly 30secs straight + self:I(self.lid..string.format("Added Radio Beacon %d Hertz | Name %s | Position {%d,%d,%d}",Frequency,BeaconName,vec3.x,vec3.y,vec3.z)) + trigger.action.radioTransmission(Sound, vec3, 0, true, Frequency, self.ADFRadioPwr or 500,BeaconName) -- Beacon in MP only runs for exactly 30secs straight end end @@ -2380,9 +2381,13 @@ function CSAR:_RefreshRadioBeacons() local group = pilot.group local frequency = pilot.frequency or 0 -- thanks to @Thrud local bname = pilot.BeaconName or pilot.name..math.random(1,100000) - trigger.action.stopRadioTransmission(bname) + --trigger.action.stopRadioTransmission(bname) if group and group:IsAlive() and frequency > 0 then - self:_AddBeaconToGroup(group,frequency,bname) + --self:_AddBeaconToGroup(group,frequency,bname) + else + if frequency > 0 then + trigger.action.stopRadioTransmission(bname) + end end end end From a4feafab8e9d4da5100238ebf21d80924b7cd90e Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Wed, 21 May 2025 10:21:48 +0200 Subject: [PATCH 4/4] #POINT - improved IsDay() for Kola --- Moose Development/Moose/Core/Point.lua | 11 +++++++++-- Moose Development/Moose/Utilities/Utils.lua | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index f1aa66289..35ad76b4c 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -2992,8 +2992,10 @@ do -- COORDINATE local sunrise=UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, true, Tdiff) local sunset=UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, false, Tdiff) - if sunrise == "N/R" then return false end - if sunrise == "N/S" then return true end + if type(sunrise) == "string" or type(sunset) == "string" then + if sunrise == "N/R" then return false end + if sunset == "N/S" then return true end + end local time=UTILS.ClockToSeconds(clock) @@ -3011,6 +3013,11 @@ do -- COORDINATE -- Todays sun set in sec. local sunset=self:GetSunset(true) + + if type(sunrise) == "string" or type(sunset) == "string" then + if sunrise == "N/R" then return false end + if sunset == "N/S" then return true end + end -- Seconds passed since midnight. local time=UTILS.SecondsOfToday() diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index 73ce154c9..19e6889b3 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -2145,9 +2145,9 @@ function UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, Rising, Tlocal) local cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec * cos(latitude)) if rising and cosH > 1 then - return "N/S" -- The sun never rises on this location on the specified date + return "N/R" -- The sun never rises on this location on the specified date elseif cosH < -1 then - return "N/R" -- The sun never sets on this location on the specified date + return "N/S" -- The sun never sets on this location on the specified date end -- Finish calculating H and convert into hours