#SET_OPSGROUP - fix for teleport/respawn

This commit is contained in:
Applevangelist
2024-12-06 14:06:56 +01:00
parent e53f1aa68d
commit 855ea764b1

View File

@@ -7942,11 +7942,20 @@ do -- SET_OPSGROUP
if Event.IniDCSUnit and Event.IniDCSGroup then if Event.IniDCSUnit and Event.IniDCSGroup then
local DCSgroup = Event.IniDCSGroup --DCS#Group local DCSgroup = Event.IniDCSGroup --DCS#Group
if DCSgroup:getInitialSize() == DCSgroup:getSize() then -- This seems to be not a good check as even for the first birth event, getSize returns the total number of units in the group. -- group:CountAliveUnits() alternative as this fails for Respawn/Teleport
local CountAliveActive = 0
for index, data in pairs(DCSgroup:getUnits()) do
if data:isExist() and data:isActive() then
CountAliveActive = CountAliveActive + 1
end
end
if DCSgroup:getInitialSize() == DCSgroup:getSize() then
local groupname, group = self:AddInDatabase(Event) local groupname, group = self:AddInDatabase(Event)
if group and group:CountAliveUnits()==DCSgroup:getInitialSize() then -- group:CountAliveUnits() alternative
if group and CountAliveActive == DCSgroup:getInitialSize() then
if group and self:IsIncludeObject(group) then if group and self:IsIncludeObject(group) then
self:Add(groupname, group) self:Add(groupname, group)
end end