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"
|
roadtype="railroads"
|
||||||
end
|
end
|
||||||
local x,y = land.getClosestPointOnRoads(roadtype, self.x, self.z)
|
local x,y = land.getClosestPointOnRoads(roadtype, self.x, self.z)
|
||||||
|
local coord=nil
|
||||||
|
if x and y then
|
||||||
local vec2={ x = x, y = y }
|
local vec2={ x = x, y = y }
|
||||||
return COORDINATE:NewFromVec2(vec2)
|
coord=COORDINATE:NewFromVec2(vec2)
|
||||||
|
end
|
||||||
|
return coord
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5790,21 +5790,32 @@ end
|
|||||||
-- @param #WAREHOUSE.Queueitem request Request belonging to this asset. Needed for the name/alias.
|
-- @param #WAREHOUSE.Queueitem request Request belonging to this asset. Needed for the name/alias.
|
||||||
-- @param #table parking Parking data for this asset.
|
-- @param #table parking Parking data for this asset.
|
||||||
-- @param #boolean uncontrolled Spawn aircraft in uncontrolled state.
|
-- @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.
|
-- @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
|
if asset and asset.category==Group.Category.AIRPLANE or asset.category==Group.Category.HELICOPTER then
|
||||||
|
|
||||||
-- Prepare the spawn template.
|
-- Prepare the spawn template.
|
||||||
local template=self:_SpawnAssetPrepareTemplate(asset, alias)
|
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.
|
-- Set route points.
|
||||||
if request.transporttype==WAREHOUSE.TransportType.SELFPROPELLED then
|
if request.transporttype==WAREHOUSE.TransportType.SELFPROPELLED then
|
||||||
|
|
||||||
-- Get flight path if the group goes to another warehouse by itself.
|
-- Get flight path if the group goes to another warehouse by itself.
|
||||||
if request.toself then
|
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}
|
template.route.points={wp}
|
||||||
else
|
else
|
||||||
template.route.points=self:_GetFlightplan(asset, self.airbase, request.warehouse.airbase)
|
template.route.points=self:_GetFlightplan(asset, self.airbase, request.warehouse.airbase)
|
||||||
@ -5812,16 +5823,6 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol
|
|||||||
|
|
||||||
else
|
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.
|
-- First route point is the warehouse airbase.
|
||||||
template.route.points[1]=self.airbase:GetCoordinate():WaypointAir("BARO", _type, _action, 0, true, self.airbase, nil, "Spawnpoint")
|
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 wp={}
|
||||||
local c={}
|
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
|
--- Departure/Take-off
|
||||||
c[#c+1]=Pdeparture
|
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
|
--- Begin of Cruise
|
||||||
local Pcruise=Pdeparture:Translate(d_climb, heading)
|
local Pcruise=Pdeparture:Translate(d_climb, heading)
|
||||||
|
|||||||
@ -32,6 +32,7 @@
|
|||||||
-- @field #table pointsCAP Table of CAP points.
|
-- @field #table pointsCAP Table of CAP points.
|
||||||
-- @field #table pointsTANKER Table of Tanker points.
|
-- @field #table pointsTANKER Table of Tanker points.
|
||||||
-- @field #table pointsAWACS Table of AWACS 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.WingCommander#WINGCOMMANDER wingcommander The wing commander responsible for this airwing.
|
||||||
--
|
--
|
||||||
-- @field Ops.RescueHelo#RESCUEHELO rescuehelo The rescue helo.
|
-- @field Ops.RescueHelo#RESCUEHELO rescuehelo The rescue helo.
|
||||||
@ -153,7 +154,7 @@ AIRWING = {
|
|||||||
|
|
||||||
--- AIRWING class version.
|
--- AIRWING class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
AIRWING.version="0.5.1"
|
AIRWING.version="0.5.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- ToDo list
|
-- ToDo list
|
||||||
@ -1552,6 +1553,9 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
|||||||
asset.nunits=squad.ngrouping
|
asset.nunits=squad.ngrouping
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Set takeoff type.
|
||||||
|
asset.takeoffType=squad.takeoffType
|
||||||
|
|
||||||
-- Create callsign and modex (needs to be after grouping).
|
-- Create callsign and modex (needs to be after grouping).
|
||||||
squad:GetCallsign(asset)
|
squad:GetCallsign(asset)
|
||||||
squad:GetModex(asset)
|
squad:GetModex(asset)
|
||||||
@ -1617,10 +1621,15 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
-- Call parent warehouse function first.
|
-- Call parent warehouse function first.
|
||||||
self:GetParent(self).onafterAssetSpawned(self, From, Event, To, group, asset, request)
|
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.
|
-- Create a flight group.
|
||||||
local flightgroup=self:_CreateFlightGroup(asset)
|
local flightgroup=self:_CreateFlightGroup(asset)
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Asset
|
-- Asset
|
||||||
---
|
---
|
||||||
@ -1638,9 +1647,6 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
-- Squadron
|
-- Squadron
|
||||||
---
|
---
|
||||||
|
|
||||||
-- Get the SQUADRON of the asset.
|
|
||||||
local squadron=self:GetSquadronOfAsset(asset)
|
|
||||||
|
|
||||||
-- Get TACAN channel.
|
-- Get TACAN channel.
|
||||||
local Tacan=squadron:FetchTacan()
|
local Tacan=squadron:FetchTacan()
|
||||||
if Tacan then
|
if Tacan then
|
||||||
@ -1689,8 +1695,6 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Add group to the detection set of the WINGCOMMANDER.
|
-- Add group to the detection set of the WINGCOMMANDER.
|
||||||
if self.wingcommander and self.wingcommander.chief then
|
if self.wingcommander and self.wingcommander.chief then
|
||||||
self.wingcommander.chief.detectionset:AddGroup(asset.flightgroup.group)
|
self.wingcommander.chief.detectionset:AddGroup(asset.flightgroup.group)
|
||||||
@ -1698,6 +1702,8 @@ function AIRWING:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- On after "AssetDead" event triggered when an asset group died.
|
--- On after "AssetDead" event triggered when an asset group died.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
@ -1822,34 +1828,6 @@ function AIRWING:_CreateFlightGroup(asset)
|
|||||||
-- Set home base.
|
-- Set home base.
|
||||||
flightgroup.homebase=self.airbase
|
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
|
return flightgroup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
-- @field #table tacanChannel List of TACAN channels available to the squadron.
|
-- @field #table tacanChannel List of TACAN channels available to the squadron.
|
||||||
-- @field #number radioFreq Radio frequency in MHz the squad uses.
|
-- @field #number radioFreq Radio frequency in MHz the squad uses.
|
||||||
-- @field #number radioModu Radio modulation the squad uses.
|
-- @field #number radioModu Radio modulation the squad uses.
|
||||||
|
-- @field #number takeoffType Take of type.
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
--- *It is unbelievable what a squadron of twelve aircraft did to tip the balance.* -- Adolf Galland
|
--- *It is unbelievable what a squadron of twelve aircraft did to tip the balance.* -- Adolf Galland
|
||||||
@ -87,12 +88,13 @@ SQUADRON = {
|
|||||||
|
|
||||||
--- SQUADRON class version.
|
--- SQUADRON class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
SQUADRON.version="0.5.0"
|
SQUADRON.version="0.5.2"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
-- TODO: Parking spots for squadrons?
|
||||||
-- DONE: Engage radius.
|
-- DONE: Engage radius.
|
||||||
-- DONE: Modex.
|
-- DONE: Modex.
|
||||||
-- DONE: Call signs.
|
-- DONE: Call signs.
|
||||||
@ -282,6 +284,41 @@ function SQUADRON:SetGrouping(nunits)
|
|||||||
return self
|
return self
|
||||||
end
|
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.
|
--- Set mission types this squadron is able to perform.
|
||||||
-- @param #SQUADRON self
|
-- @param #SQUADRON self
|
||||||
-- @param #table MissionTypes Table of mission types. Can also be passed as a #string if only one type.
|
-- @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