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
|
||||
warehouse=UNIT:FindByName(warehouse)
|
||||
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)
|
||||
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 Wrapper.Group#GROUP tanker Tanker group.
|
||||
-- @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 altitude Tanker orbit pattern altitude.
|
||||
-- @field #number distStern Race-track distance astern.
|
||||
@ -56,6 +59,9 @@ RECOVERYTANKER = {
|
||||
tankergroupname = nil,
|
||||
tanker = nil,
|
||||
airbase = nil,
|
||||
beacon = nil,
|
||||
TACANchannel = nil,
|
||||
TACANmode = nil,
|
||||
altitude = nil,
|
||||
speed = nil,
|
||||
distStern = nil,
|
||||
@ -72,7 +78,7 @@ RECOVERYTANKER = {
|
||||
|
||||
--- Class version.
|
||||
-- @field #string version
|
||||
RECOVERYTANKER.version="0.9.2"
|
||||
RECOVERYTANKER.version="0.9.3"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- 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: Write documenation.
|
||||
-- DONE: Set AA TACAN.
|
||||
-- DONE: Add refueling event/state.
|
||||
-- DONE: Possibility to add already present/spawned aircraft, e.g. for warehouse.
|
||||
|
||||
@ -118,6 +125,7 @@ function RECOVERYTANKER:New(carrierunit, tankergroupname)
|
||||
self:SetTakeoffAir()
|
||||
self:SetLowFuelThreshold()
|
||||
self:SetRespawnOnOff()
|
||||
self:SetTACAN()
|
||||
|
||||
-----------------------
|
||||
--- FSM Transitions ---
|
||||
@ -334,6 +342,17 @@ function RECOVERYTANKER:SetUseUncontrolledAircraft()
|
||||
return self
|
||||
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.
|
||||
-- @param #RECOVERYTANKER self
|
||||
-- @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)
|
||||
|
||||
if self.tanker:IsAlive() then
|
||||
|
||||
-- Start uncontrolled group.
|
||||
self.tanker:StartUncontrolled()
|
||||
|
||||
else
|
||||
-- No group by that name!
|
||||
self:E(string.format("ERROR: No uncontrolled (alive) tanker group with name %s could be found!", self.tankergroupname))
|
||||
return
|
||||
end
|
||||
@ -419,6 +441,10 @@ function RECOVERYTANKER:onafterStart(From, Event, To)
|
||||
|
||||
end
|
||||
|
||||
-- Create tanker beacon.
|
||||
self.beacon=BEACON:New(self.tanker:GetUnit(1))
|
||||
self.beacon:ActivateTACAN(self.TACANchannel, self.TACANmode, "TKR", true)
|
||||
|
||||
-- Init status check.
|
||||
self:__Status(10)
|
||||
end
|
||||
@ -478,7 +504,7 @@ end
|
||||
function RECOVERYTANKER:onbeforeRTB(From, Event, To)
|
||||
|
||||
-- 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.
|
||||
if self.respawn then
|
||||
@ -491,6 +517,10 @@ function RECOVERYTANKER:onbeforeRTB(From, Event, To)
|
||||
self.tanker:InitHeading(self.tanker:GetHeading())
|
||||
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.
|
||||
SCHEDULER:New(nil, self._PatternUpdate, {self}, 2)
|
||||
|
||||
@ -563,6 +593,10 @@ function RECOVERYTANKER:OnEventEngineShutdown(EventData)
|
||||
-- Respawn tanker.
|
||||
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.
|
||||
self:_InitRoute()
|
||||
end
|
||||
|
||||
@ -34,6 +34,9 @@
|
||||
-- @field #number offsetX Offset in meters to carrier in longitudinal 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 #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
|
||||
|
||||
--- Rescue Helo
|
||||
@ -48,25 +51,28 @@
|
||||
--
|
||||
-- @field #RESCUEHELO
|
||||
RESCUEHELO = {
|
||||
ClassName = "RESCUEHELO",
|
||||
carrier = nil,
|
||||
carriertype = nil,
|
||||
helogroupname = nil,
|
||||
helo = nil,
|
||||
airbase = nil,
|
||||
takeoff = nil,
|
||||
followset = nil,
|
||||
formation = nil,
|
||||
lowfuel = nil,
|
||||
altitude = nil,
|
||||
offsetX = nil,
|
||||
offsetZ = nil,
|
||||
rescuezone = nil,
|
||||
ClassName = "RESCUEHELO",
|
||||
carrier = nil,
|
||||
carriertype = nil,
|
||||
helogroupname = nil,
|
||||
helo = nil,
|
||||
airbase = nil,
|
||||
takeoff = nil,
|
||||
followset = nil,
|
||||
formation = nil,
|
||||
lowfuel = nil,
|
||||
altitude = nil,
|
||||
offsetX = nil,
|
||||
offsetZ = nil,
|
||||
rescuezone = nil,
|
||||
respawn = nil,
|
||||
respawninair = nil,
|
||||
uncontrolledac = nil,
|
||||
}
|
||||
|
||||
--- Class version.
|
||||
-- @field #string version
|
||||
RESCUEHELO.version="0.9.2"
|
||||
RESCUEHELO.version="0.9.3"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
@ -273,6 +279,56 @@ function RESCUEHELO:SetOffsetZ(distance)
|
||||
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.
|
||||
-- @param #RESCUEHELO self
|
||||
-- @return #boolean If true, helo is returning to base.
|
||||
@ -312,9 +368,9 @@ function RESCUEHELO:OnEventLand(EventData)
|
||||
-- Respawn the Helo.
|
||||
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
|
||||
|
||||
@ -425,15 +481,40 @@ function RESCUEHELO:onafterStart(From, Event, To)
|
||||
|
||||
else
|
||||
|
||||
-- Spawn at airbase.
|
||||
self.helo=Spawn:SpawnAtAirbase(self.airbase, self.takeoff)
|
||||
-- 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
|
||||
|
||||
-- Spawn at airbase.
|
||||
self.helo=Spawn:SpawnAtAirbase(self.airbase, self.takeoff)
|
||||
|
||||
-- Delay before formation is started.
|
||||
if self.takeoff==SPAWN.Takeoff.Runway then
|
||||
delay=5
|
||||
elseif self.takeoff==SPAWN.Takeoff.Hot then
|
||||
delay=30
|
||||
elseif self.takeoff==SPAWN.Takeoff.Cold then
|
||||
delay=60
|
||||
end
|
||||
|
||||
if self.takeoff==SPAWN.Takeoff.Runway then
|
||||
delay=5
|
||||
elseif self.takeoff==SPAWN.Takeoff.Hot then
|
||||
delay=30
|
||||
elseif self.takeoff==SPAWN.Takeoff.Cold then
|
||||
delay=60
|
||||
end
|
||||
|
||||
end
|
||||
@ -454,9 +535,6 @@ function RESCUEHELO:onafterStart(From, Event, To)
|
||||
-- Start formation FSM.
|
||||
self.formation:__Start(delay)
|
||||
|
||||
-- Start uncontrolled helo.
|
||||
--HeloSpawn:StartUncontrolled(120)
|
||||
|
||||
-- Init status check
|
||||
self:__Status(1)
|
||||
|
||||
@ -550,8 +628,8 @@ end
|
||||
-- @return #boolean If true, transition is allowed.
|
||||
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.
|
||||
local text=string.format("Respawning rescue helo group %s in air.", self.helo:GetName())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user