This commit is contained in:
Frank
2020-10-20 23:04:15 +02:00
parent 459ff26868
commit 8696ce0cc1
6 changed files with 135 additions and 41 deletions

View File

@@ -2169,6 +2169,40 @@ function GROUP:GetThreatLevel()
return threatlevelMax
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
--- Returns true if the first unit of the GROUP is in the air.
-- @param Wrapper.Group#GROUP self