RH, GROUP

This commit is contained in:
Frank
2019-08-18 21:02:23 +02:00
parent aade1eebf1
commit 94bbb8a9a4
2 changed files with 107 additions and 100 deletions
+5 -3
View File
@@ -907,7 +907,7 @@ function RESCUEHELO:onafterStart(From, Event, To)
-- Use an uncontrolled aircraft group.
self.helo=GROUP:FindByName(self.helogroupname)
if self.helo:IsAlive() then
if self.helo and self.helo:IsAlive() then
-- Start uncontrolled group.
self.helo:StartUncontrolled()
@@ -1020,7 +1020,7 @@ function RESCUEHELO:onafterStatus(From, Event, To)
else
-- Send helo back to base.
self:RTB()
self:RTB(self.airbase)
end
@@ -1211,7 +1211,9 @@ function RESCUEHELO:onafterReturned(From, Event, To, airbase)
self.helo:InitModex(self.modex)
-- Respawn helo at current airbase.
self.helo:RespawnAtCurrentAirbase()
if self.helo and self.helo:IsAlive() then
self:ScheduleOnce(5, self.helo.RespawnAtCurrentAirbase, self.helo)
end
-- Restart the formation.
self:__Run(10)
@@ -1773,6 +1773,8 @@ end
function GROUP:RespawnAtCurrentAirbase(SpawnTemplate, Takeoff, Uncontrolled) -- R2.4
self:F2( { SpawnTemplate, Takeoff, Uncontrolled} )
if self and self:IsAlive() then
-- Get closest airbase. Should be the one we are currently on.
local airbase=self:GetCoordinate():GetClosestAirbase()
@@ -1878,6 +1880,9 @@ function GROUP:RespawnAtCurrentAirbase(SpawnTemplate, Takeoff, Uncontrolled) --
return self
end
else
self:E("WARNING: GROUP is not alive!")
end
return nil
end