mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
GROUP - change to GetUnits(n) to make it more robust, now returns first alive unit,actually. Similar changes to GetHeading()
This commit is contained in:
parent
cc49791997
commit
41e8ddea8c
@ -714,8 +714,22 @@ function GROUP:GetDCSUnit( UnitNumber )
|
|||||||
local DCSGroup = self:GetDCSObject()
|
local DCSGroup = self:GetDCSObject()
|
||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
local DCSUnitFound=DCSGroup:getUnit( UnitNumber )
|
|
||||||
return DCSUnitFound
|
local UnitFound = nil
|
||||||
|
-- 2.7.1 dead event bug, return the first alive unit instead
|
||||||
|
local units = DCSGroup:getUnits() or {}
|
||||||
|
|
||||||
|
for _,_unit in pairs(units) do
|
||||||
|
|
||||||
|
local UnitFound = UNIT:Find(_unit)
|
||||||
|
|
||||||
|
if UnitFound and UnitFound:IsAlive() then
|
||||||
|
|
||||||
|
return UnitFound
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -1093,13 +1107,15 @@ end
|
|||||||
function GROUP:GetHeading()
|
function GROUP:GetHeading()
|
||||||
self:F2(self.GroupName)
|
self:F2(self.GroupName)
|
||||||
|
|
||||||
|
self:F2(self.GroupName)
|
||||||
|
|
||||||
local GroupSize = self:GetSize()
|
local GroupSize = self:GetSize()
|
||||||
local HeadingAccumulator = 0
|
local HeadingAccumulator = 0
|
||||||
|
|
||||||
local n=0
|
local n=0
|
||||||
|
local Units = self:GetUnits()
|
||||||
|
|
||||||
if GroupSize then
|
if GroupSize then
|
||||||
for i = 1, GroupSize do
|
for _,unit in pairs(Units) do
|
||||||
local unit=self:GetUnit(i)
|
|
||||||
if unit and unit:IsAlive() then
|
if unit and unit:IsAlive() then
|
||||||
HeadingAccumulator = HeadingAccumulator + unit:GetHeading()
|
HeadingAccumulator = HeadingAccumulator + unit:GetHeading()
|
||||||
n=n+1
|
n=n+1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user