From 42e9cae87632d9897d2ae9cdf64c1df709d42c32 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Tue, 15 Feb 2022 14:41:45 +0100 Subject: [PATCH] added back GROUP:GetHighestThreat() --- Moose Development/Moose/Wrapper/Group.lua | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 4f653f6d5..3655729d1 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -2609,6 +2609,41 @@ function GROUP:GetSkill() return skill end + +--- Get the unit in the group with the highest threat level, which is still alive. +-- @param #GROUP self +-- @return Wrapper.Unit#UNIT The most dangerous unit in the group. +-- @return #number Threat level of the unit. +function GROUP:GetHighestThreat() + + -- Get units of the group. + local units=self:GetUnits() + + if units then + + local threat=nil ; local maxtl=0 + for _,_unit in pairs(units or {}) do + local unit=_unit --Wrapper.Unit#UNIT + + if unit and unit:IsAlive() then + + -- Threat level of group. + local tl=unit:GetThreatLevel() + + -- Check if greater the current threat. + if tl>maxtl then + maxtl=tl + threat=unit + end + end + end + + return threat, maxtl + end + + return nil, nil +end + --do -- Smoke -- ----- Signal a flare at the position of the GROUP.