mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
AIRBOSS v0.3.1
Tanker v0.9.3 * added TACAN option Helo v0.9.3 * added respawn and uncontrolled
This commit is contained in:
parent
51a1f56011
commit
ba1cb61f4d
@ -1800,7 +1800,7 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
if type(warehouse)=="string" then
|
if type(warehouse)=="string" then
|
||||||
warehouse=UNIT:FindByName(warehouse)
|
warehouse=UNIT:FindByName(warehouse)
|
||||||
if warehouse==nil then
|
if warehouse==nil then
|
||||||
env.info(string.format("FF no warehouse unit with name %s found trying static.", warehouse))
|
env.info(string.format("No warehouse unit with name %s found trying static.", warehouse))
|
||||||
warehouse=STATIC:FindByName(warehouse, true)
|
warehouse=STATIC:FindByName(warehouse, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,9 @@
|
|||||||
-- @field #string tankergroupname Name of the late activated tanker template group.
|
-- @field #string tankergroupname Name of the late activated tanker template group.
|
||||||
-- @field Wrapper.Group#GROUP tanker Tanker group.
|
-- @field Wrapper.Group#GROUP tanker Tanker group.
|
||||||
-- @field Wrapper.Airbase#AIRBASE airbase The home airbase object of the tanker. Normally the aircraft carrier.
|
-- @field Wrapper.Airbase#AIRBASE airbase The home airbase object of the tanker. Normally the aircraft carrier.
|
||||||
|
-- @field Core.Radio#BEACON beacon Tanker TACAN beacon.
|
||||||
|
-- @field #number TACANchannel TACAN channel. Default 1.
|
||||||
|
-- @field #string TACANmode TACAN mode, i.e. "X" or "Y". Default "Y".
|
||||||
-- @field #number speed Tanker speed when flying pattern.
|
-- @field #number speed Tanker speed when flying pattern.
|
||||||
-- @field #number altitude Tanker orbit pattern altitude.
|
-- @field #number altitude Tanker orbit pattern altitude.
|
||||||
-- @field #number distStern Race-track distance astern.
|
-- @field #number distStern Race-track distance astern.
|
||||||
@ -56,6 +59,9 @@ RECOVERYTANKER = {
|
|||||||
tankergroupname = nil,
|
tankergroupname = nil,
|
||||||
tanker = nil,
|
tanker = nil,
|
||||||
airbase = nil,
|
airbase = nil,
|
||||||
|
beacon = nil,
|
||||||
|
TACANchannel = nil,
|
||||||
|
TACANmode = nil,
|
||||||
altitude = nil,
|
altitude = nil,
|
||||||
speed = nil,
|
speed = nil,
|
||||||
distStern = nil,
|
distStern = nil,
|
||||||
@ -72,7 +78,7 @@ RECOVERYTANKER = {
|
|||||||
|
|
||||||
--- Class version.
|
--- Class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
RECOVERYTANKER.version="0.9.2"
|
RECOVERYTANKER.version="0.9.3"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -80,6 +86,7 @@ RECOVERYTANKER.version="0.9.2"
|
|||||||
|
|
||||||
-- TODO: Smarter pattern update function. E.g. (small) zone around carrier. Only update position when carrier leaves zone or changes heading?
|
-- TODO: Smarter pattern update function. E.g. (small) zone around carrier. Only update position when carrier leaves zone or changes heading?
|
||||||
-- TODO: Write documenation.
|
-- TODO: Write documenation.
|
||||||
|
-- DONE: Set AA TACAN.
|
||||||
-- DONE: Add refueling event/state.
|
-- DONE: Add refueling event/state.
|
||||||
-- DONE: Possibility to add already present/spawned aircraft, e.g. for warehouse.
|
-- DONE: Possibility to add already present/spawned aircraft, e.g. for warehouse.
|
||||||
|
|
||||||
@ -118,6 +125,7 @@ function RECOVERYTANKER:New(carrierunit, tankergroupname)
|
|||||||
self:SetTakeoffAir()
|
self:SetTakeoffAir()
|
||||||
self:SetLowFuelThreshold()
|
self:SetLowFuelThreshold()
|
||||||
self:SetRespawnOnOff()
|
self:SetRespawnOnOff()
|
||||||
|
self:SetTACAN()
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
--- FSM Transitions ---
|
--- FSM Transitions ---
|
||||||
@ -334,6 +342,17 @@ function RECOVERYTANKER:SetUseUncontrolledAircraft()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set TACAN channel of tanker.
|
||||||
|
-- @param #RECOVERYTANKER self
|
||||||
|
-- @param #number channel TACAN channel. Default 1.
|
||||||
|
-- @param #string mode TACAN mode, i.e. "X" or "Y". Default "Y".
|
||||||
|
-- @return #RECOVERYTANKER self
|
||||||
|
function RECOVERYTANKER:SetTACAN(channel, mode)
|
||||||
|
self.TACANchannel=channel or 1
|
||||||
|
self.TACANmode=mode or "Y"
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if tanker is returning to base.
|
--- Check if tanker is returning to base.
|
||||||
-- @param #RECOVERYTANKER self
|
-- @param #RECOVERYTANKER self
|
||||||
-- @return #boolean If true, tanker is returning to base.
|
-- @return #boolean If true, tanker is returning to base.
|
||||||
@ -400,9 +419,12 @@ function RECOVERYTANKER:onafterStart(From, Event, To)
|
|||||||
self.tanker=GROUP:FindByName(self.tankergroupname)
|
self.tanker=GROUP:FindByName(self.tankergroupname)
|
||||||
|
|
||||||
if self.tanker:IsAlive() then
|
if self.tanker:IsAlive() then
|
||||||
|
|
||||||
-- Start uncontrolled group.
|
-- Start uncontrolled group.
|
||||||
self.tanker:StartUncontrolled()
|
self.tanker:StartUncontrolled()
|
||||||
|
|
||||||
else
|
else
|
||||||
|
-- No group by that name!
|
||||||
self:E(string.format("ERROR: No uncontrolled (alive) tanker group with name %s could be found!", self.tankergroupname))
|
self:E(string.format("ERROR: No uncontrolled (alive) tanker group with name %s could be found!", self.tankergroupname))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -419,6 +441,10 @@ function RECOVERYTANKER:onafterStart(From, Event, To)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Create tanker beacon.
|
||||||
|
self.beacon=BEACON:New(self.tanker:GetUnit(1))
|
||||||
|
self.beacon:ActivateTACAN(self.TACANchannel, self.TACANmode, "TKR", true)
|
||||||
|
|
||||||
-- Init status check.
|
-- Init status check.
|
||||||
self:__Status(10)
|
self:__Status(10)
|
||||||
end
|
end
|
||||||
@ -478,7 +504,7 @@ end
|
|||||||
function RECOVERYTANKER:onbeforeRTB(From, Event, To)
|
function RECOVERYTANKER:onbeforeRTB(From, Event, To)
|
||||||
|
|
||||||
-- Check if spawn in air is activated.
|
-- Check if spawn in air is activated.
|
||||||
if self.takeoff==SPAWN.Takeoff.Air then
|
if self.takeoff==SPAWN.Takeoff.Air or self.respawninair then
|
||||||
|
|
||||||
-- Check that respawn should happen.
|
-- Check that respawn should happen.
|
||||||
if self.respawn then
|
if self.respawn then
|
||||||
@ -491,6 +517,10 @@ function RECOVERYTANKER:onbeforeRTB(From, Event, To)
|
|||||||
self.tanker:InitHeading(self.tanker:GetHeading())
|
self.tanker:InitHeading(self.tanker:GetHeading())
|
||||||
self.tanker=self.tanker:Respawn(nil, true)
|
self.tanker=self.tanker:Respawn(nil, true)
|
||||||
|
|
||||||
|
-- Create tanker beacon.
|
||||||
|
self.beacon=BEACON:New(self.tanker:GetUnit(1))
|
||||||
|
self.beacon:ActivateTACAN(self.TACANchannel, self.TACANmode, "TKR", true)
|
||||||
|
|
||||||
-- Update Pattern in 2 seconds. Need to give a bit time so that the respawned group is in the game.
|
-- Update Pattern in 2 seconds. Need to give a bit time so that the respawned group is in the game.
|
||||||
SCHEDULER:New(nil, self._PatternUpdate, {self}, 2)
|
SCHEDULER:New(nil, self._PatternUpdate, {self}, 2)
|
||||||
|
|
||||||
@ -563,6 +593,10 @@ function RECOVERYTANKER:OnEventEngineShutdown(EventData)
|
|||||||
-- Respawn tanker.
|
-- Respawn tanker.
|
||||||
self.tanker=group:RespawnAtCurrentAirbase()
|
self.tanker=group:RespawnAtCurrentAirbase()
|
||||||
|
|
||||||
|
-- Create tanker beacon.
|
||||||
|
self.beacon=BEACON:New(self.tanker:GetUnit(1))
|
||||||
|
self.beacon:ActivateTACAN(self.TACANchannel, self.TACANmode, "TKR", true)
|
||||||
|
|
||||||
-- Initial route.
|
-- Initial route.
|
||||||
self:_InitRoute()
|
self:_InitRoute()
|
||||||
end
|
end
|
||||||
|
|||||||
@ -34,6 +34,9 @@
|
|||||||
-- @field #number offsetX Offset in meters to carrier in longitudinal direction.
|
-- @field #number offsetX Offset in meters to carrier in longitudinal direction.
|
||||||
-- @field #number offsetZ Offset in meters to carrier in latitudinal direction.
|
-- @field #number offsetZ Offset in meters to carrier in latitudinal direction.
|
||||||
-- @field Core.Zone#ZONE_RADIUS rescuezone Zone around the carrier in which helo will rescue crashed or ejected units.
|
-- @field Core.Zone#ZONE_RADIUS rescuezone Zone around the carrier in which helo will rescue crashed or ejected units.
|
||||||
|
-- @field #boolean respawn If true, helo be respawned (default). If false, no respawning will happen.
|
||||||
|
-- @field #boolean respawninair If true, helo will always be respawned in air. This has no impact on the initial spawn setting.
|
||||||
|
-- @field #boolean uncontrolledac If true, use and uncontrolled helo group already present in the mission.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- Rescue Helo
|
--- Rescue Helo
|
||||||
@ -62,11 +65,14 @@ RESCUEHELO = {
|
|||||||
offsetX = nil,
|
offsetX = nil,
|
||||||
offsetZ = nil,
|
offsetZ = nil,
|
||||||
rescuezone = nil,
|
rescuezone = nil,
|
||||||
|
respawn = nil,
|
||||||
|
respawninair = nil,
|
||||||
|
uncontrolledac = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Class version.
|
--- Class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
RESCUEHELO.version="0.9.2"
|
RESCUEHELO.version="0.9.3"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -273,6 +279,56 @@ function RESCUEHELO:SetOffsetZ(distance)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Enable respawning of helo. Note that this is the default behaviour.
|
||||||
|
-- @param #RESCUEHELO self
|
||||||
|
-- @return #RESCUEHELO self
|
||||||
|
function RESCUEHELO:SetRespawnOn()
|
||||||
|
self.respawn=true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Disable respawning of helo.
|
||||||
|
-- @param #RESCUEHELO self
|
||||||
|
-- @return #RESCUEHELO self
|
||||||
|
function RESCUEHELO:SetRespawnOff()
|
||||||
|
self.respawn=false
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set whether helo shall be respawned or not.
|
||||||
|
-- @param #RESCUEHELO self
|
||||||
|
-- @param #boolean switch If true (or nil), helo will be respawned. If false, helo will not be respawned.
|
||||||
|
-- @return #RESCUEHELO self
|
||||||
|
function RESCUEHELO:SetRespawnOnOff(switch)
|
||||||
|
if switch==nil or switch==true then
|
||||||
|
self.respawn=true
|
||||||
|
else
|
||||||
|
self.respawn=false
|
||||||
|
end
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Helo will be respawned in air, even it was initially spawned on the carrier.
|
||||||
|
-- So only the first spawn will be on the carrier while all subsequent spawns will happen in air.
|
||||||
|
-- This allows for undisrupted operations and less problems on the carrier deck.
|
||||||
|
-- @param #RESCUEHELO self
|
||||||
|
-- @return #RESCUEHELO self
|
||||||
|
function RESCUEHELO:SetRespawnInAir()
|
||||||
|
self.respawninair=true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Use an uncontrolled aircraft already present in the mission rather than spawning a new helo as initial rescue helo.
|
||||||
|
-- This can be useful when interfaced with, e.g., a warehouse.
|
||||||
|
-- The group name is the one specified in the @{#RESCUEHELO.New} function.
|
||||||
|
-- @param #RESCUEHELO self
|
||||||
|
-- @return #RESCUEHELO self
|
||||||
|
function RESCUEHELO:SetUseUncontrolledAircraft()
|
||||||
|
self.uncontrolledac=true
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if helo is returning to base.
|
--- Check if helo is returning to base.
|
||||||
-- @param #RESCUEHELO self
|
-- @param #RESCUEHELO self
|
||||||
-- @return #boolean If true, helo is returning to base.
|
-- @return #boolean If true, helo is returning to base.
|
||||||
@ -312,9 +368,9 @@ function RESCUEHELO:OnEventLand(EventData)
|
|||||||
-- Respawn the Helo.
|
-- Respawn the Helo.
|
||||||
self:I(string.format("Respawning rescue helo group %s at home base.", groupname))
|
self:I(string.format("Respawning rescue helo group %s at home base.", groupname))
|
||||||
|
|
||||||
if self.takeoff==SPAWN.Takeoff.Air then
|
if self.takeoff==SPAWN.Takeoff.Air or self.respawninair then
|
||||||
|
|
||||||
self:E("ERROR: Rescue helo %s landed. This should not happen for Takeoff=Air!", groupname)
|
self:E("ERROR: Rescue helo %s landed. This should not happen for Takeoff=Air or respawninair=true!", groupname)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -423,11 +479,34 @@ function RESCUEHELO:onafterStart(From, Event, To)
|
|||||||
-- Start formation in 1 seconds
|
-- Start formation in 1 seconds
|
||||||
delay=1
|
delay=1
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Check if an uncontrolled helo group was requested.
|
||||||
|
if self.useuncontrolled then
|
||||||
|
|
||||||
|
-- Use an uncontrolled aircraft group.
|
||||||
|
self.helo=GROUP:FindByName(self.helogroupname)
|
||||||
|
|
||||||
|
if self.helo:IsAlive() then
|
||||||
|
|
||||||
|
-- Start uncontrolled group.
|
||||||
|
self.helo:StartUncontrolled()
|
||||||
|
|
||||||
|
-- Delay before formation is started.
|
||||||
|
delay=60
|
||||||
|
|
||||||
|
else
|
||||||
|
-- No group of that name!
|
||||||
|
self:E(string.format("ERROR: No uncontrolled (alive) rescue helo group with name %s could be found!", self.helogroupname))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Spawn at airbase.
|
-- Spawn at airbase.
|
||||||
self.helo=Spawn:SpawnAtAirbase(self.airbase, self.takeoff)
|
self.helo=Spawn:SpawnAtAirbase(self.airbase, self.takeoff)
|
||||||
|
|
||||||
|
-- Delay before formation is started.
|
||||||
if self.takeoff==SPAWN.Takeoff.Runway then
|
if self.takeoff==SPAWN.Takeoff.Runway then
|
||||||
delay=5
|
delay=5
|
||||||
elseif self.takeoff==SPAWN.Takeoff.Hot then
|
elseif self.takeoff==SPAWN.Takeoff.Hot then
|
||||||
@ -438,6 +517,8 @@ function RESCUEHELO:onafterStart(From, Event, To)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-- Set of group(s) to follow Mother.
|
-- Set of group(s) to follow Mother.
|
||||||
self.followset=SET_GROUP:New()
|
self.followset=SET_GROUP:New()
|
||||||
self.followset:AddGroup(self.helo)
|
self.followset:AddGroup(self.helo)
|
||||||
@ -454,9 +535,6 @@ function RESCUEHELO:onafterStart(From, Event, To)
|
|||||||
-- Start formation FSM.
|
-- Start formation FSM.
|
||||||
self.formation:__Start(delay)
|
self.formation:__Start(delay)
|
||||||
|
|
||||||
-- Start uncontrolled helo.
|
|
||||||
--HeloSpawn:StartUncontrolled(120)
|
|
||||||
|
|
||||||
-- Init status check
|
-- Init status check
|
||||||
self:__Status(1)
|
self:__Status(1)
|
||||||
|
|
||||||
@ -550,8 +628,8 @@ end
|
|||||||
-- @return #boolean If true, transition is allowed.
|
-- @return #boolean If true, transition is allowed.
|
||||||
function RESCUEHELO:onbeforeRTB(From, Event, To)
|
function RESCUEHELO:onbeforeRTB(From, Event, To)
|
||||||
|
|
||||||
if self.takeoff==SPAWN.Takeoff.Air then
|
|
||||||
-- For takeoff in air, we just respawn the helo with full fuel.
|
-- For takeoff in air, we just respawn the helo with full fuel.
|
||||||
|
if (self.takeoff==SPAWN.Takeoff.Air or self.respawninair) and self.respawn then
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
local text=string.format("Respawning rescue helo group %s in air.", self.helo:GetName())
|
local text=string.format("Respawning rescue helo group %s in air.", self.helo:GetName())
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user