From 8ef781a9ac6fd1f6ef2bdfe9a716924d3a295ca6 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 21 Feb 2025 10:39:21 +0100 Subject: [PATCH] #SET_BASE - added `GetThreatLevelMax()` --- Moose Development/Moose/Core/Set.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 2a9fb1e67..56ec9ecab 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -531,6 +531,21 @@ do -- SET_BASE return self.SomeIteratorLimit or self:Count() end + + --- Get max threat level of all objects in the SET. + -- @param #SET_BASE self + -- @return #number Max threat level found. + function SET_BASE:GetThreatLevelMax() + local ThreatMax = 0 + for _,_unit in pairs(self.Set or {}) do + local unit = _unit -- Wrapper.Unit#UNIT + local threat = unit.GetThreatLevel and unit:GetThreatLevel() or 0 + if threat > ThreatMax then + ThreatMax = threat + end + end + return ThreatMax + end --- Filters for the defined collection. -- @param #SET_BASE self @@ -7985,7 +8000,7 @@ function SET_OPSGROUP:_EventOnBirth(Event) function SET_OPSGROUP:_EventOnDeadOrCrash( Event ) --self:F( { Event } ) - if Event.IniDCSUnit then + if Event.IniDCSGroup then local ObjectName, Object = self:FindInDatabase( Event ) if ObjectName then if Event.IniDCSGroup:getSize() == 1 then -- Only remove if the last unit of the group was destroyed.