diff --git a/Moose Development/Moose/Core/Radio.lua b/Moose Development/Moose/Core/Radio.lua index 412e18430..b6c13185c 100644 --- a/Moose Development/Moose/Core/Radio.lua +++ b/Moose Development/Moose/Core/Radio.lua @@ -517,7 +517,7 @@ end -- local myUnit = UNIT:FindByName("MyUnit") -- local myBeacon = myUnit:GetBeacon() -- Creates the beacon -- --- myBeacon:TACAN(20, "Y", "TEXACO", true) -- Activate the beacon +-- myBeacon:ActivateTACAN(20, "Y", "TEXACO", true) -- Activate the beacon function BEACON:ActivateTACAN(Channel, Mode, Message, Bearing, Duration) self:T({channel=Channel, mode=Mode, callsign=Message, bearing=Bearing, duration=Duration}) diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index da29434fe..966afb94d 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -8395,28 +8395,35 @@ function AIRBOSS:OnEventEngineShutdown(EventData) -- Debug message. self:T(self.lid..string.format("AI unit %s shut down its engines!", _unitName)) - if self.despawnshutdown then + -- Get flight. + local flight=self:_GetFlightFromGroupInQueue(EventData.IniGroup, self.flights) + + -- Only AI flights. + if flight and flight.ai then - -- Get flight. - local flight=self:_GetFlightFromGroupInQueue(EventData.IniGroup, self.flights) - - -- Only AI flights. - if flight and flight.ai then + -- Check if all elements were recovered. + local recovered=self:_CheckSectionRecovered(flight) - -- Check if all elements were recovered. - local recovered=self:_CheckSectionRecovered(flight) + -- Despawn group and completely remove flight. + if recovered then + self:T(self.lid..string.format("AI group %s completely recovered. Despawning group after engine shutdown event as requested in 5 seconds.", tostring(EventData.IniGroupName))) - -- Despawn group and completely remove flight. - if recovered then - self:T(self.lid..string.format("AI group %s completely recovered. Despawning group after engine shutdown event as requested in 5 seconds.", tostring(EventData.IniGroupName))) + -- Remove flight. + self:_RemoveFlight(flight) + + -- Check if this is a tanker or AWACS associated with the carrier. + local istanker=self.tanker and self.tanker.tanker:GetName()==EventData.IniGroupName + local isawacs=self.awacs and self.awacs.tanker:GetName()==EventData.IniGroupName + + -- Destroy group if desired. Recovery tankers have their own logic for despawning. + if self.despawnshutdown and not (istanker or isawacs) then EventData.IniGroup:Destroy(nil, 5) - self:_RemoveFlight(flight) end + end + end - - end - + end end --- Airboss event handler for event that a unit takes off. diff --git a/Moose Development/Moose/Ops/RecoveryTanker.lua b/Moose Development/Moose/Ops/RecoveryTanker.lua index bd2adab50..e77f91ad2 100644 --- a/Moose Development/Moose/Ops/RecoveryTanker.lua +++ b/Moose Development/Moose/Ops/RecoveryTanker.lua @@ -813,6 +813,13 @@ function RECOVERYTANKER:IsReturning() return self:is("Returning") end +--- Check if tanker has returned to base. +-- @param #RECOVERYTANKER self +-- @return #boolean If true, tanker has returned to base. +function RECOVERYTANKER:IsReturned() + return self:is("Returned") +end + --- Check if tanker is currently operating. -- @param #RECOVERYTANKER self -- @return #boolean If true, tanker is operating. @@ -1058,6 +1065,16 @@ function RECOVERYTANKER:onafterStatus(From, Event, To) end end + elseif self:IsReturning() then + + -- Tanker is returning to its base. + self:T2(self.lid.."Tanker is returning.") + + elseif self:IsReturned() then + + -- Tanker landed. Waiting for engine shutdown... + self:T2(self.lid.."Tanker returned. waiting for engine shutdown.") + end -- Call status again in 30 seconds. @@ -1084,6 +1101,7 @@ function RECOVERYTANKER:onafterStatus(From, Event, To) end end + end end @@ -1313,7 +1331,8 @@ function RECOVERYTANKER:OnEventEngineShutdown(EventData) group:InitModex(self.modex) -- Respawn tanker. Delaying respawn due to DCS bug https://github.com/FlightControl-Master/MOOSE/issues/1076 - SCHEDULER:New(nil , group.RespawnAtCurrentAirbase, {group}, 1) + --SCHEDULER:New(nil , group.RespawnAtCurrentAirbase, {group}, 1) + self:ScheduleOnce(1, GROUP.RespawnAtCurrentAirbase, group) -- Create tanker beacon and activate TACAN. if self.TACANon then @@ -1331,7 +1350,8 @@ function RECOVERYTANKER:OnEventEngineShutdown(EventData) end -- Initial route. - SCHEDULER:New(nil, self._InitRoute, {self, -self.distStern+UTILS.NMToMeters(3)}, 2) + --SCHEDULER:New(nil, self._InitRoute, {self, -self.distStern+UTILS.NMToMeters(3)}, 2) + self:ScheduleOnce(2, RECOVERYTANKER._InitRoute, self, -self.distStern+UTILS.NMToMeters(3)) end end @@ -1593,7 +1613,8 @@ function RECOVERYTANKER:_ActivateTACAN(delay) if delay and delay>0 then -- Schedule TACAN activation. - SCHEDULER:New(nil, self._ActivateTACAN, {self}, delay) + --SCHEDULER:New(nil, self._ActivateTACAN, {self}, delay) + self:ScheduleOnce(delay, RECOVERYTANKER._ActivateTACAN, self) else @@ -1604,7 +1625,7 @@ function RECOVERYTANKER:_ActivateTACAN(delay) if unit and unit:IsAlive() then -- Debug message. - local text=string.format("Activating recovery tanker TACAN beacon: channel=%d mode=%s, morse=%s.", self.TACANchannel, self.TACANmode, self.TACANmorse) + local text=string.format("Activating TACAN beacon: channel=%d mode=%s, morse=%s.", self.TACANchannel, self.TACANmode, self.TACANmorse) MESSAGE:New(text, 10, "DEBUG"):ToAllIf(self.Debug) self:T(self.lid..text) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 5d1ff66c5..a6f372e1a 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -349,7 +349,8 @@ function GROUP:Destroy( GenerateEvent, delay ) self:F2( self.GroupName ) if delay and delay>0 then - SCHEDULER:New(nil, GROUP.Destroy, {self, GenerateEvent}, delay) + --SCHEDULER:New(nil, GROUP.Destroy, {self, GenerateEvent}, delay) + self:ScheduleOnce(delay, GROUP.Destroy, self, GenerateEvent) else local DCSGroup = self:GetDCSObject()