mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Update OpsGroup.lua
- Delayed spawn
This commit is contained in:
parent
ee880a893e
commit
98a613261c
@ -7675,6 +7675,7 @@ function OPSGROUP:Teleport(Coordinate, Delay, NoPauseMission)
|
||||
unit.heading=math.rad(heading)
|
||||
unit.psi=-unit.heading
|
||||
else
|
||||
-- Remove unit from spawn template because it is already dead
|
||||
table.remove(units, i)
|
||||
end
|
||||
end
|
||||
@ -7760,33 +7761,46 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
||||
|
||||
|
||||
-- Despawn old group. Dont trigger any remove unit event since this is a respawn.
|
||||
--self:Despawn(0, true)
|
||||
|
||||
else
|
||||
|
||||
---
|
||||
-- Group is NOT ALIVE
|
||||
---
|
||||
|
||||
-- Ensure elements in utero.
|
||||
for _,_element in pairs(self.elements) do
|
||||
local element=_element --#OPSGROUP.Element
|
||||
self:ElementInUtero(element)
|
||||
end
|
||||
self:Despawn(0, true)
|
||||
|
||||
end
|
||||
|
||||
-- Ensure elements in utero.
|
||||
for _,_element in pairs(self.elements) do
|
||||
local element=_element --#OPSGROUP.Element
|
||||
if element and element.status~=OPSGROUP.ElementStatus.DEAD then
|
||||
self:ElementInUtero(element)
|
||||
end
|
||||
end
|
||||
|
||||
-- Spawn with a little delay (especially Navy groups caused problems if they were instantly respawned)
|
||||
self:_Spawn(0.01, Template)
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Spawn group from a given template.
|
||||
-- @param #OPSGROUP self
|
||||
-- @param #number Delay Delay in seconds before respawn happens. Default 0.
|
||||
-- @param DCS#Template Template (optional) The template of the Group retrieved with GROUP:GetTemplate(). If the template is not provided, the template will be retrieved of the group itself.
|
||||
-- @return #OPSGROUP self
|
||||
function OPSGROUP:_Spawn(Delay, Template)
|
||||
if Delay and Delay>0 then
|
||||
self:ScheduleOnce(Delay, OPSGROUP._Spawn, self, 0, Template)
|
||||
else
|
||||
-- Debug output.
|
||||
self:T2({Template=Template})
|
||||
|
||||
-- Spawn new group.
|
||||
--self.group=_DATABASE:Spawn(Template)
|
||||
local countryID=self.group:GetCountry()
|
||||
local categoryID=self.group:GetCategory()
|
||||
local dcsgroup=coalition.addGroup(countryID, categoryID, Template)
|
||||
self.group=_DATABASE:Spawn(Template)
|
||||
--local countryID=self.group:GetCountry()
|
||||
--local categoryID=self.group:GetCategory()
|
||||
--local dcsgroup=coalition.addGroup(countryID, categoryID, Template)
|
||||
|
||||
-- Set DCS group and controller.
|
||||
self.dcsgroup=dcsgroup or self:GetDCSGroup()
|
||||
self.dcsgroup=self:GetDCSGroup()
|
||||
self.controller=self.dcsgroup:getController()
|
||||
|
||||
-- Set activation and controlled state.
|
||||
@ -7805,14 +7819,11 @@ function OPSGROUP:_Respawn(Delay, Template, Reset)
|
||||
self:_InitWaypoints()
|
||||
|
||||
-- Init Group. This call is delayed because NAVY groups did not like to be initialized just yet (group did not contain any units).
|
||||
self:_InitGroup(Template, 0.1)
|
||||
self:_InitGroup(Template)
|
||||
|
||||
-- Reset events.
|
||||
--self:ResetEvents()
|
||||
|
||||
--self:ResetEvents()
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- On after "InUtero" event.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user