mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
WAREHOUSE, AIRWING & SQUADRON
- Added function for hot start to SQUADRON - Addressed bug #1560
This commit is contained in:
parent
76a53ab154
commit
c80cebb824
@ -1607,8 +1607,12 @@ do -- COORDINATE
|
||||
roadtype="railroads"
|
||||
end
|
||||
local x,y = land.getClosestPointOnRoads(roadtype, self.x, self.z)
|
||||
local coord=nil
|
||||
if x and y then
|
||||
local vec2={ x = x, y = y }
|
||||
return COORDINATE:NewFromVec2(vec2)
|
||||
coord=COORDINATE:NewFromVec2(vec2)
|
||||
end
|
||||
return coord
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -5790,21 +5790,32 @@ end
|
||||
-- @param #WAREHOUSE.Queueitem request Request belonging to this asset. Needed for the name/alias.
|
||||
-- @param #table parking Parking data for this asset.
|
||||
-- @param #boolean uncontrolled Spawn aircraft in uncontrolled state.
|
||||
-- @param #boolean hotstart Spawn aircraft with engines already on. Default is a cold start with engines off.
|
||||
-- @return Wrapper.Group#GROUP The spawned group or nil if the group could not be spawned.
|
||||
function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrolled, hotstart)
|
||||
function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrolled)
|
||||
|
||||
if asset and asset.category==Group.Category.AIRPLANE or asset.category==Group.Category.HELICOPTER then
|
||||
|
||||
-- Prepare the spawn template.
|
||||
local template=self:_SpawnAssetPrepareTemplate(asset, alias)
|
||||
|
||||
-- Cold start (default).
|
||||
local _type=COORDINATE.WaypointType.TakeOffParking
|
||||
local _action=COORDINATE.WaypointAction.FromParkingArea
|
||||
|
||||
-- Hot start.
|
||||
if asset.takeoffType and asset.takeoffType==COORDINATE.WaypointType.TakeOffParkingHot then
|
||||
_type=COORDINATE.WaypointType.TakeOffParkingHot
|
||||
_action=COORDINATE.WaypointAction.FromParkingAreaHot
|
||||
uncontrolled=false
|
||||
end
|
||||
|
||||
|
||||
-- Set route points.
|
||||
if request.transporttype==WAREHOUSE.TransportType.SELFPROPELLED then
|
||||
|
||||
-- Get flight path if the group goes to another warehouse by itself.
|
||||
if request.toself then
|
||||
local wp=self.airbase:GetCoordinate():WaypointAir("RADIO", COORDINATE.WaypointType.TakeOffParking, COORDINATE.WaypointAction.FromParkingArea, 0, false, self.airbase, {}, "Parking")
|
||||
local wp=self.airbase:GetCoordinate():WaypointAir("RADIO", _type, _action, 0, false, self.airbase, {}, "Parking")
|
||||
template.route.points={wp}
|
||||
else
|
||||
template.route.points=self:_GetFlightplan(asset, self.airbase, request.warehouse.airbase)
|
||||
@ -5812,16 +5823,6 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol
|
||||
|
||||
else
|
||||
|
||||
-- Cold start (default).
|
||||
local _type=COORDINATE.WaypointType.TakeOffParking
|
||||
local _action=COORDINATE.WaypointAction.FromParkingArea
|
||||
|
||||
-- Hot start.
|
||||
if hotstart then
|
||||
_type=COORDINATE.WaypointType.TakeOffParkingHot
|
||||
_action=COORDINATE.WaypointAction.FromParkingAreaHot
|
||||
end
|
||||
|
||||
-- First route point is the warehouse airbase.
|
||||
template.route.points[1]=self.airbase:GetCoordinate():WaypointAir("BARO", _type, _action, 0, true, self.airbase, nil, "Spawnpoint")
|
||||
|
||||
@ -9040,9 +9041,23 @@ function WAREHOUSE:_GetFlightplan(asset, departure, destination)
|
||||
local wp={}
|
||||
local c={}
|
||||
|
||||
-- Cold start (default).
|
||||
local _type=COORDINATE.WaypointType.TakeOffParking
|
||||
local _action=COORDINATE.WaypointAction.FromParkingArea
|
||||
|
||||
-- Hot start.
|
||||
if asset.takeoffType and asset.takeoffType==COORDINATE.WaypointType.TakeOffParkingHot then
|
||||
env.info("FF hot")
|
||||
_type=COORDINATE.WaypointType.TakeOffParkingHot
|
||||
_action=COORDINATE.WaypointAction.FromParkingAreaHot
|
||||
else
|
||||
env.info("FF cold")
|
||||
end
|
||||
|
||||
|
||||
--- Departure/Take-off
|
||||
c[#c+1]=Pdeparture
|
||||
wp[#wp+1]=Pdeparture:WaypointAir("RADIO", COORDINATE.WaypointType.TakeOffParking, COORDINATE.WaypointAction.FromParkingArea, VxClimb*3.6, true, departure, nil, "Departure")
|
||||
wp[#wp+1]=Pdeparture:WaypointAir("RADIO", _type, _action, VxClimb*3.6, true, departure, nil, "Departure")
|
||||
|
||||
--- Begin of Cruise
|
||||
local Pcruise=Pdeparture:Translate(d_climb, heading)
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
-- @field #table pointsCAP Table of CAP points.
|
||||
-- @field #table pointsTANKER Table of Tanker points.
|
||||
-- @field #table pointsAWACS Table of AWACS points.
|
||||
-- @field #boolean markpoints Display markers on the F10 map.
|
||||
-- @field Ops.WingCommander#WINGCOMMANDER wingcommander The wing commander responsible for this airwing.
|
||||
--
|
||||
-- @field Ops.RescueHelo#RESCUEHELO rescuehelo The rescue helo.
|
||||
@ -153,7 +154,7 @@ AIRWING = {
|
||||
|
||||
--- AIRWING class version.
|
||||
-- @field #string version
|
||||
AIRWING.version="0.5.1"
|
||||
AIRWING.version="0.5.2"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- ToDo list
|
||||
@ -1552,6 +1553,9 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
||||
asset.nunits=squad.ngrouping
|
||||
end
|
||||
|
||||
-- Set takeoff type.
|
||||
asset.takeoffType=squad.takeoffType
|
||||
|
||||
-- Create callsign and modex (needs to be after grouping).
|
||||
squad:GetCallsign(asset)
|
||||
squad:GetModex(asset)
|
||||
@ -1617,10 +1621,15 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
-- Call parent warehouse function first.
|
||||
self:GetParent(self).onafterAssetSpawned(self, From, Event, To, group, asset, request)
|
||||
|
||||
-- Get the SQUADRON of the asset.
|
||||
local squadron=self:GetSquadronOfAsset(asset)
|
||||
|
||||
-- Check if we have a squadron or if this was some other request.
|
||||
if squadron then
|
||||
|
||||
-- Create a flight group.
|
||||
local flightgroup=self:_CreateFlightGroup(asset)
|
||||
|
||||
|
||||
---
|
||||
-- Asset
|
||||
---
|
||||
@ -1638,9 +1647,6 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
-- Squadron
|
||||
---
|
||||
|
||||
-- Get the SQUADRON of the asset.
|
||||
local squadron=self:GetSquadronOfAsset(asset)
|
||||
|
||||
-- Get TACAN channel.
|
||||
local Tacan=squadron:FetchTacan()
|
||||
if Tacan then
|
||||
@ -1689,8 +1695,6 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Add group to the detection set of the WINGCOMMANDER.
|
||||
if self.wingcommander and self.wingcommander.chief then
|
||||
self.wingcommander.chief.detectionset:AddGroup(asset.flightgroup.group)
|
||||
@ -1698,6 +1702,8 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--- On after "AssetDead" event triggered when an asset group died.
|
||||
-- @param #AIRWING self
|
||||
-- @param #string From From state.
|
||||
@ -1822,34 +1828,6 @@ function AIRWING:_CreateFlightGroup(asset)
|
||||
-- Set home base.
|
||||
flightgroup.homebase=self.airbase
|
||||
|
||||
--[[
|
||||
|
||||
--- Check if out of missiles. For A2A missions ==> RTB.
|
||||
function flightgroup:OnAfterOutOfMissiles()
|
||||
local airwing=flightgroup:GetAirWing()
|
||||
|
||||
end
|
||||
|
||||
--- Check if out of missiles. For A2G missions ==> RTB. But need to check A2G missiles, rockets as well.
|
||||
function flightgroup:OnAfterOutOfBombs()
|
||||
local airwing=flightgroup:GetAirWing()
|
||||
|
||||
end
|
||||
|
||||
--- Mission started.
|
||||
function flightgroup:OnAfterMissionStart(From, Event, To, Mission)
|
||||
local airwing=flightgroup:GetAirWing()
|
||||
|
||||
end
|
||||
|
||||
--- Flight is DEAD.
|
||||
function flightgroup:OnAfterFlightDead(From, Event, To)
|
||||
local airwing=flightgroup:GetAirWing()
|
||||
|
||||
end
|
||||
|
||||
]]
|
||||
|
||||
return flightgroup
|
||||
end
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
-- @field #table tacanChannel List of TACAN channels available to the squadron.
|
||||
-- @field #number radioFreq Radio frequency in MHz the squad uses.
|
||||
-- @field #number radioModu Radio modulation the squad uses.
|
||||
-- @field #number takeoffType Take of type.
|
||||
-- @extends Core.Fsm#FSM
|
||||
|
||||
--- *It is unbelievable what a squadron of twelve aircraft did to tip the balance.* -- Adolf Galland
|
||||
@ -87,12 +88,13 @@ SQUADRON = {
|
||||
|
||||
--- SQUADRON class version.
|
||||
-- @field #string version
|
||||
SQUADRON.version="0.5.0"
|
||||
SQUADRON.version="0.5.2"
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
-- TODO list
|
||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
-- TODO: Parking spots for squadrons?
|
||||
-- DONE: Engage radius.
|
||||
-- DONE: Modex.
|
||||
-- DONE: Call signs.
|
||||
@ -282,6 +284,41 @@ function SQUADRON:SetGrouping(nunits)
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set takeoff type. All assets of this squadron will be spawned with cold (default) or hot engines.
|
||||
-- Spawning on runways is not supported.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #string TakeoffType Take off type: "Cold" (default) or "Hot" with engines on.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetTakeoffType(TakeoffType)
|
||||
TakeoffType=TakeoffType or "Cold"
|
||||
if TakeoffType:lower()=="hot" then
|
||||
self.takeoffType=COORDINATE.WaypointType.TakeOffParkingHot
|
||||
elseif TakeoffType:lower()=="cold" then
|
||||
self.takeoffType=COORDINATE.WaypointType.TakeOffParking
|
||||
else
|
||||
self.takeoffType=COORDINATE.WaypointType.TakeOffParking
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set takeoff type cold (default).
|
||||
-- @param #SQUADRON self
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetTakeoffCold()
|
||||
self:SetTakeoffType("Cold")
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set takeoff type hot.
|
||||
-- @param #SQUADRON self
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetTakeoffHot()
|
||||
self:SetTakeoffType("Hot")
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
--- Set mission types this squadron is able to perform.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #table MissionTypes Table of mission types. Can also be passed as a #string if only one type.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user