mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
FC
- Improvements
This commit is contained in:
parent
23733bb1a6
commit
7c4cb5ea7f
@ -6,7 +6,9 @@
|
|||||||
--
|
--
|
||||||
-- * Manage aircraft departure and arrival
|
-- * Manage aircraft departure and arrival
|
||||||
-- * Handles AI and human players
|
-- * Handles AI and human players
|
||||||
|
-- * Limit number of AI groups taxiing and landing simultaniously
|
||||||
-- * Immersive voice overs via SRS text-to-speech
|
-- * Immersive voice overs via SRS text-to-speech
|
||||||
|
-- * Define holding zones for airdromes
|
||||||
--
|
--
|
||||||
-- ===
|
-- ===
|
||||||
--
|
--
|
||||||
@ -67,7 +69,7 @@
|
|||||||
-- * As soon as AI aircraft taxi or land, we completely loose control. All is governed by the internal DCS AI logic.
|
-- * As soon as AI aircraft taxi or land, we completely loose control. All is governed by the internal DCS AI logic.
|
||||||
-- * We have no control over the active runway or which runway is used by the AI if there are multiple.
|
-- * We have no control over the active runway or which runway is used by the AI if there are multiple.
|
||||||
-- * Only one player/client per group as we can create menus only for a group and not for a specific unit.
|
-- * Only one player/client per group as we can create menus only for a group and not for a specific unit.
|
||||||
-- * Only FLIGHTGROUPS are controlled.
|
-- * Only FLIGHTGROUPS are controlled. This means some older classes, *e.g.* RAT are not supported (yet).
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- @field #FLIGHTCONTROL
|
-- @field #FLIGHTCONTROL
|
||||||
@ -158,7 +160,7 @@ FLIGHTCONTROL.FlightStatus={
|
|||||||
|
|
||||||
--- FlightControl class version.
|
--- FlightControl class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
FLIGHTCONTROL.version="0.5.0"
|
FLIGHTCONTROL.version="0.5.1"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -529,8 +531,8 @@ function FLIGHTCONTROL:OnEventBirth(EventData)
|
|||||||
|
|
||||||
if EventData and EventData.IniGroupName and EventData.IniUnit then
|
if EventData and EventData.IniGroupName and EventData.IniUnit then
|
||||||
|
|
||||||
self:I(self.lid..string.format("BIRTH: unit = %s", tostring(EventData.IniUnitName)))
|
self:T3(self.lid..string.format("BIRTH: unit = %s", tostring(EventData.IniUnitName)))
|
||||||
self:T2(self.lid..string.format("BIRTH: group = %s", tostring(EventData.IniGroupName)))
|
self:T3(self.lid..string.format("BIRTH: group = %s", tostring(EventData.IniGroupName)))
|
||||||
|
|
||||||
-- Unit that was born.
|
-- Unit that was born.
|
||||||
local unit=EventData.IniUnit
|
local unit=EventData.IniUnit
|
||||||
@ -539,7 +541,7 @@ function FLIGHTCONTROL:OnEventBirth(EventData)
|
|||||||
if unit:IsAir() then
|
if unit:IsAir() then
|
||||||
|
|
||||||
local bornhere=EventData.Place and EventData.Place:GetName()==self.airbasename or false
|
local bornhere=EventData.Place and EventData.Place:GetName()==self.airbasename or false
|
||||||
env.info("FF born here ".. tostring(bornhere))
|
--env.info("FF born here ".. tostring(bornhere))
|
||||||
|
|
||||||
-- We got a player?
|
-- We got a player?
|
||||||
local playerunit, playername=self:_GetPlayerUnitAndName(EventData.IniUnitName)
|
local playerunit, playername=self:_GetPlayerUnitAndName(EventData.IniUnitName)
|
||||||
@ -684,8 +686,6 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
-- Holding flight --
|
-- Holding flight --
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
env.info("FF next flight holding")
|
|
||||||
|
|
||||||
-- No other flight is taking off and number of landing flights is below threshold.
|
-- No other flight is taking off and number of landing flights is below threshold.
|
||||||
if ntakeoff==0 and nlanding<self.Nlanding then
|
if ntakeoff==0 and nlanding<self.Nlanding then
|
||||||
|
|
||||||
@ -700,8 +700,11 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
-- Get callsign.
|
-- Get callsign.
|
||||||
local callsign=flight:GetCallsignName()
|
local callsign=flight:GetCallsignName()
|
||||||
|
|
||||||
|
-- Runway.
|
||||||
|
local runway=self:GetActiveRunwayText()
|
||||||
|
|
||||||
-- Message.
|
-- Message.
|
||||||
local text=string.format("%s, %s, you are cleared to land.", callsign, self.alias)
|
local text=string.format("%s, %s, you are cleared to land, runway %s", callsign, self.alias, runway)
|
||||||
|
|
||||||
-- Transmit message.
|
-- Transmit message.
|
||||||
self:TransmissionTower(text, flight)
|
self:TransmissionTower(text, flight)
|
||||||
@ -712,10 +715,12 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
self:_LandAI(flight, parking)
|
self:_LandAI(flight, parking)
|
||||||
else
|
else
|
||||||
-- TODO: Humans have to confirm via F10 menu.
|
-- TODO: Humans have to confirm via F10 menu.
|
||||||
|
self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.LANDING)
|
||||||
|
flight:_UpdateMenu()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set time last flight got landing clearance.
|
-- Set time last flight got landing clearance.
|
||||||
self.Tlanding=timer.getAbsTime()
|
--self.Tlanding=timer.getAbsTime()
|
||||||
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@ -738,10 +743,10 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
local runway=self:GetActiveRunwayText()
|
local runway=self:GetActiveRunwayText()
|
||||||
|
|
||||||
-- Message.
|
-- Message.
|
||||||
local text=string.format("%s, %s, taxi to holding point, runway %s", callsign, self.alias, runway)
|
local text=string.format("%s, %s, taxi to runway %s, hold short", callsign, self.alias, runway)
|
||||||
|
|
||||||
if self:GetFlightStatus(flight)==FLIGHTCONTROL.FlightStatus.READYTO then
|
if self:GetFlightStatus(flight)==FLIGHTCONTROL.FlightStatus.READYTO then
|
||||||
text=string.format("%s, %s, cleared for take-off, runway %s, hold short", callsign, self.alias, runway)
|
text=string.format("%s, %s, cleared for take-off, runway %s", callsign, self.alias, runway)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Transmit message.
|
-- Transmit message.
|
||||||
@ -822,12 +827,15 @@ end
|
|||||||
-- @return #table Parking data for holding flights or nil.
|
-- @return #table Parking data for holding flights or nil.
|
||||||
function FLIGHTCONTROL:_GetNextFlight()
|
function FLIGHTCONTROL:_GetNextFlight()
|
||||||
|
|
||||||
|
-- Get flight that is holding.
|
||||||
local flightholding=self:_GetNextFightHolding()
|
local flightholding=self:_GetNextFightHolding()
|
||||||
|
|
||||||
|
-- Get flight that is parking.
|
||||||
local flightparking=self:_GetNextFightParking()
|
local flightparking=self:_GetNextFightParking()
|
||||||
|
|
||||||
-- If no flight is waiting for landing just return the takeoff flight or nil.
|
-- If no flight is waiting for landing just return the takeoff flight or nil.
|
||||||
if not flightholding then
|
if not flightholding then
|
||||||
self:T(self.lid..string.format("Next flight that is not holding"))
|
--self:T(self.lid..string.format("Next flight that is not holding"))
|
||||||
return flightparking, false, nil
|
return flightparking, false, nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1543,7 +1551,7 @@ end
|
|||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Human Player Functions
|
-- Payer Menu
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Create player menu.
|
--- Create player menu.
|
||||||
@ -1552,13 +1560,18 @@ end
|
|||||||
-- @param #table atcmenu ATC root menu table.
|
-- @param #table atcmenu ATC root menu table.
|
||||||
function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
||||||
|
|
||||||
|
-- Group info.
|
||||||
local group=flight.group
|
local group=flight.group
|
||||||
local groupname=flight.groupname
|
local groupname=flight.groupname
|
||||||
local gid=group:GetID()
|
local gid=group:GetID()
|
||||||
|
|
||||||
|
-- Flight status.
|
||||||
local flightstatus=self:GetFlightStatus(flight)
|
local flightstatus=self:GetFlightStatus(flight)
|
||||||
|
|
||||||
|
-- Are we controlling this flight.
|
||||||
local gotcontrol=self:IsControlling(flight)
|
local gotcontrol=self:IsControlling(flight)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Creating ATC player menu for flight %s: in state=%s status=%s, gotcontrol=%s", tostring(flight.groupname), flight:GetState(), flightstatus, tostring(gotcontrol)))
|
self:I(self.lid..string.format("Creating ATC player menu for flight %s: in state=%s status=%s, gotcontrol=%s", tostring(flight.groupname), flight:GetState(), flightstatus, tostring(gotcontrol)))
|
||||||
|
|
||||||
local airbasename=self.airbasename
|
local airbasename=self.airbasename
|
||||||
@ -1572,26 +1585,39 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
|||||||
|
|
||||||
atcmenu[airbasename] = atcmenu[airbasename] or {}
|
atcmenu[airbasename] = atcmenu[airbasename] or {}
|
||||||
|
|
||||||
|
-- Remove menu if it exists.
|
||||||
if atcmenu[airbasename].root then
|
if atcmenu[airbasename].root then
|
||||||
local rootmenu=atcmenu[airbasename].root --Core.Menu#MENU_GROUP
|
local rootmenu=atcmenu[airbasename].root --Core.Menu#MENU_GROUP
|
||||||
rootmenu:Remove()
|
rootmenu:Remove()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Airbase root menu.
|
-- Airbase root menu.
|
||||||
atcmenu[airbasename].root = MENU_GROUP:New(group, airbaseName2, atcmenu.root) --:SetTime(Tnow):SetTag(Tag)
|
atcmenu[airbasename].root = MENU_GROUP:New(group, airbaseName2, atcmenu.root)
|
||||||
|
|
||||||
|
-- Shortcut to root menu.
|
||||||
local rootmenu=atcmenu[airbasename].root --Core.Menu#MENU_GROUP
|
local rootmenu=atcmenu[airbasename].root --Core.Menu#MENU_GROUP
|
||||||
|
|
||||||
-- Help Menu.
|
---
|
||||||
local helpmenu=MENU_GROUP:New(group, "Help", rootmenu)--:SetTime(Tnow):SetTag(Tag)
|
-- Help Menu
|
||||||
|
---
|
||||||
|
local helpmenu=MENU_GROUP:New(group, "Help", rootmenu)
|
||||||
|
MENU_GROUP_COMMAND:New(group, "Mark Holding", helpmenu, self._PlayerNotImplemented, self, groupname)
|
||||||
|
MENU_GROUP_COMMAND:New(group, "Skill Level", helpmenu, self._PlayerNotImplemented, self, groupname)
|
||||||
|
MENU_GROUP_COMMAND:New(group, "Subtitles On/Off", helpmenu, self._PlayerNotImplemented, self, groupname)
|
||||||
|
MENU_GROUP_COMMAND:New(group, "My Voice On/Off", helpmenu, self._PlayerNotImplemented, self, groupname)
|
||||||
|
MENU_GROUP_COMMAND:New(group, "My Status", helpmenu, self._PlayerMyStatus, self, groupname)
|
||||||
|
|
||||||
-- Some info.
|
---
|
||||||
local infomenu=MENU_GROUP:New(group, "Info", rootmenu)--:SetTime(Tnow):SetTag(Tag)
|
-- Info Menu
|
||||||
MENU_GROUP_COMMAND:New(group, "Airbase", infomenu, self._PlayerRequestInfo, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
---
|
||||||
MENU_GROUP_COMMAND:New(group, "Queues", infomenu, self._PlayerRequestInfoQueues, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
local infomenu=MENU_GROUP:New(group, "Info", rootmenu)
|
||||||
MENU_GROUP_COMMAND:New(group, "ATIS", infomenu, self._PlayerRequestInfoATIS, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Airbase", infomenu, self._PlayerRequestInfo, self, groupname)
|
||||||
|
MENU_GROUP_COMMAND:New(group, "Queues", infomenu, self._PlayerRequestInfoQueues, self, groupname)
|
||||||
|
MENU_GROUP_COMMAND:New(group, "ATIS", infomenu, self._PlayerRequestInfoATIS, self, groupname)
|
||||||
|
|
||||||
-- Root Commands.
|
---
|
||||||
|
-- Root Menu
|
||||||
|
---
|
||||||
if gotcontrol then
|
if gotcontrol then
|
||||||
|
|
||||||
local status=self:GetFlightStatus(flight)
|
local status=self:GetFlightStatus(flight)
|
||||||
@ -1606,9 +1632,9 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
|||||||
---
|
---
|
||||||
|
|
||||||
if status==FLIGHTCONTROL.FlightStatus.READYTX then
|
if status==FLIGHTCONTROL.FlightStatus.READYTX then
|
||||||
MENU_GROUP_COMMAND:New(group, "Abort Taxi", rootmenu, self._PlayerAbortTaxi, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Abort Taxi", rootmenu, self._PlayerAbortTaxi, self, groupname)
|
||||||
else
|
else
|
||||||
MENU_GROUP_COMMAND:New(group, "Request Taxi", rootmenu, self._PlayerRequestTaxi, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Request Taxi", rootmenu, self._PlayerRequestTaxi, self, groupname)
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif flight:IsTaxiing() then
|
elseif flight:IsTaxiing() then
|
||||||
@ -1617,21 +1643,19 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
|||||||
---
|
---
|
||||||
|
|
||||||
if status==FLIGHTCONTROL.FlightStatus.READYTO then
|
if status==FLIGHTCONTROL.FlightStatus.READYTO then
|
||||||
MENU_GROUP_COMMAND:New(group, "Abort Takeoff", rootmenu, self._PlayerAbortTakeoff, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Abort Takeoff", rootmenu, self._PlayerAbortTakeoff, self, groupname)
|
||||||
elseif status==FLIGHTCONTROL.FlightStatus.TAKEOFF then
|
elseif status==FLIGHTCONTROL.FlightStatus.TAKEOFF then
|
||||||
MENU_GROUP_COMMAND:New(group, "Abort Takeoff", rootmenu, self._PlayerAbortTakeoff, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Abort Takeoff", rootmenu, self._PlayerAbortTakeoff, self, groupname)
|
||||||
elseif status==FLIGHTCONTROL.FlightStatus.READYTX or status==FLIGHTCONTROL.FlightStatus.TAXIOUT then
|
elseif status==FLIGHTCONTROL.FlightStatus.READYTX or status==FLIGHTCONTROL.FlightStatus.TAXIOUT then
|
||||||
MENU_GROUP_COMMAND:New(group, "Abort Taxi", rootmenu, self._PlayerAbortTaxi, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Abort Taxi", rootmenu, self._PlayerAbortTaxi, self, groupname)
|
||||||
MENU_GROUP_COMMAND:New(group, "Request Takeoff", rootmenu, self._PlayerRequestTakeoff, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Request Takeoff", rootmenu, self._PlayerRequestTakeoff, self, groupname)
|
||||||
elseif status==FLIGHTCONTROL.FlightStatus.TAXIINB then
|
elseif status==FLIGHTCONTROL.FlightStatus.TAXIINB then
|
||||||
-- Could be after "abort taxi" call and we changed our mind (again)
|
-- Could be after "abort taxi" call and we changed our mind (again)
|
||||||
MENU_GROUP_COMMAND:New(group, "Request Taxi", rootmenu, self._PlayerRequestTaxi, self, groupname)
|
MENU_GROUP_COMMAND:New(group, "Request Taxi", rootmenu, self._PlayerRequestTaxi, self, groupname)
|
||||||
MENU_GROUP_COMMAND:New(group, "Request Parking", rootmenu, self._PlayerRequestParking, self, groupname)
|
MENU_GROUP_COMMAND:New(group, "Request Parking", rootmenu, self._PlayerRequestParking, self, groupname)
|
||||||
end
|
end
|
||||||
|
|
||||||
MENU_GROUP_COMMAND:New(group, "Arrived at Parking", rootmenu, self._PlayerArrived, self, groupname)
|
MENU_GROUP_COMMAND:New(group, "Arrived and Parking", rootmenu, self._PlayerArrived, self, groupname)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
elseif flight:IsAirborne() then
|
elseif flight:IsAirborne() then
|
||||||
---
|
---
|
||||||
@ -1639,14 +1663,32 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
|||||||
---
|
---
|
||||||
|
|
||||||
elseif flight:IsInbound() then
|
elseif flight:IsInbound() then
|
||||||
|
---
|
||||||
|
-- Inbound
|
||||||
|
---
|
||||||
|
|
||||||
MENU_GROUP_COMMAND:New(group, "Holding", rootmenu, self._PlayerHolding, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Abort Inbound", rootmenu, self._PlayerAbortInbound, self, groupname)
|
||||||
--TODO: abort inbound
|
MENU_GROUP_COMMAND:New(group, "Holding", rootmenu, self._PlayerHolding, self, groupname)
|
||||||
|
|
||||||
|
elseif flight:IsHolding() then
|
||||||
|
---
|
||||||
|
-- Holding
|
||||||
|
---
|
||||||
|
|
||||||
|
MENU_GROUP_COMMAND:New(group, "Abort Holding", rootmenu, self._PlayerAbortHolding, self, groupname)
|
||||||
|
MENU_GROUP_COMMAND:New(group, "Landing", rootmenu, self._PlayerConfirmLanding, self, groupname)
|
||||||
|
|
||||||
|
elseif flight:IsLanding() then
|
||||||
|
---
|
||||||
|
-- Landing
|
||||||
|
---
|
||||||
|
|
||||||
|
MENU_GROUP_COMMAND:New(group, "Abort Landing", rootmenu, self._PlayerAbortLanding, self, groupname)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if flight:IsInbound() or flight:IsHolding() or flight:IsLanding() or flight:IsLanded() then
|
if flight:IsInbound() or flight:IsHolding() or flight:IsLanding() or flight:IsLanded() then
|
||||||
MENU_GROUP_COMMAND:New(group, "Request Parking", rootmenu, self._PlayerRequestParking, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Request Parking", rootmenu, self._PlayerRequestParking, self, groupname)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -1656,111 +1698,66 @@ function FLIGHTCONTROL:_CreatePlayerMenu(flight, atcmenu)
|
|||||||
---
|
---
|
||||||
|
|
||||||
if flight:IsAirborne() then
|
if flight:IsAirborne() then
|
||||||
MENU_GROUP_COMMAND:New(group, "Inbound", rootmenu, self._PlayerInbound, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
MENU_GROUP_COMMAND:New(group, "Inbound", rootmenu, self._PlayerRequestInbound, self, groupname)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if gotcontrol then
|
|
||||||
MENU_GROUP_COMMAND:New(group, "My Status", rootmenu, self._PlayerMyStatus, self, groupname)--:SetTime(Tnow):SetTag(Tag)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Reset the menu.
|
|
||||||
--rootmenu:Remove(Tnow, Tag)
|
|
||||||
--rootmenu:Set()
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Player menu request info.
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Player Menu: Help
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Player menu not implemented.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
function FLIGHTCONTROL:_PlayerRequestParking(groupname)
|
function FLIGHTCONTROL:_PlayerNotImplemented(groupname)
|
||||||
|
|
||||||
-- Get flight group.
|
-- Get flight group.
|
||||||
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
||||||
|
|
||||||
if flight then
|
if flight then
|
||||||
|
|
||||||
local group=flight:GetGroup()
|
local text=string.format("Sorry, this feature is not implemented yet!")
|
||||||
local coord=flight:GetCoordinate()
|
self:TextMessageToFlight(text, flight)
|
||||||
|
|
||||||
--TODO: terminal type for helos!
|
|
||||||
local spot=self:GetClosestParkingSpot(coord, nil, true)
|
|
||||||
|
|
||||||
-- Get callsign.
|
|
||||||
local callsign=flight:GetCallsignName()
|
|
||||||
|
|
||||||
-- Message text.
|
|
||||||
local text=string.format("%s, tower, your assigned parking position is terminal ID %d. Check the F10 map for details.", callsign, spot.TerminalID)
|
|
||||||
|
|
||||||
-- Transmit message.
|
|
||||||
self:TransmissionTower(text, flight)
|
|
||||||
|
|
||||||
-- Create mark on F10 map.
|
|
||||||
if spot.Marker then
|
|
||||||
spot.Marker:Remove()
|
|
||||||
end
|
|
||||||
spot.Marker:SetText("Your assigned parking spot!"):ToGroup(group)
|
|
||||||
|
|
||||||
-- Set parking of player element.
|
|
||||||
for _,_element in pairs(flight.elements) do
|
|
||||||
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
|
||||||
if not element.ai then
|
|
||||||
element.parking=spot
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Player arrived at parking position.
|
--- Player status.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
function FLIGHTCONTROL:_PlayerArrived(groupname)
|
function FLIGHTCONTROL:_PlayerMyStatus(groupname)
|
||||||
|
|
||||||
-- Get flight group.
|
-- Get flight group.
|
||||||
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
||||||
|
|
||||||
if flight then
|
if flight then
|
||||||
|
|
||||||
local group=flight:GetGroup()
|
local fc=flight.flightcontrol
|
||||||
local coord=flight:GetCoordinate()
|
|
||||||
|
|
||||||
--Closest parking spot.
|
-- Status text.
|
||||||
local spot=self:GetClosestParkingSpot(coord, nil, true)
|
local text=string.format("My Status:")
|
||||||
|
text=text..string.format("\nCallsign: %s", tostring(flight:GetCallsignName()))
|
||||||
|
text=text..string.format("\nFlight status: %s", tostring(flight:GetState()))
|
||||||
|
text=text..string.format("\nFlight control: %s status=%s", tostring(fc and fc.airbasename or "N/A"), tostring(fc and fc:GetFlightStatus(flight) or "N/A"))
|
||||||
|
|
||||||
-- Get callsign.
|
-- Send message.
|
||||||
local callsign=flight:GetCallsignName()
|
self:TextMessageToFlight(text, flight, 10, true)
|
||||||
|
|
||||||
-- Message text.
|
|
||||||
local text=string.format("Tower, %s, arrived at parking position. Terminal ID %d.", callsign, spot.TerminalID)
|
|
||||||
|
|
||||||
-- Transmit message.
|
|
||||||
self:TransmissionTower(text, flight)
|
|
||||||
|
|
||||||
self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.PARKING)
|
|
||||||
|
|
||||||
self:_CreatePlayerMenu(flight, flight.menu.atc)
|
|
||||||
|
|
||||||
-- Create mark on F10 map.
|
|
||||||
if spot.Marker then
|
|
||||||
spot.Marker:Remove()
|
|
||||||
end
|
|
||||||
spot.Marker:SetText("Your current parking spot!"):ToGroup(group)
|
|
||||||
|
|
||||||
-- Set parking of player element.
|
|
||||||
for _,_element in pairs(flight.elements) do
|
|
||||||
local element=_element --Ops.OpsGroup#OPSGROUP.Element
|
|
||||||
if not element.ai then
|
|
||||||
element.parking=spot
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
else
|
||||||
|
MESSAGE:New(string.format("Cannot find flight group %s.", tostring(groupname)), 5):ToAll()
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Player Menu: Info
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Player menu request info.
|
--- Player menu request info.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
@ -1824,7 +1821,6 @@ function FLIGHTCONTROL:_PlayerRequestInfoATIS(groupname)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Player menu request info.
|
--- Player menu request info.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
@ -1857,6 +1853,10 @@ function FLIGHTCONTROL:_PlayerRequestInfoQueues(groupname)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Player Menu: Inbound
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Player calls inbound.
|
--- Player calls inbound.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
@ -1895,6 +1895,9 @@ function FLIGHTCONTROL:_PlayerRequestInbound(groupname)
|
|||||||
-- Call RTB event.
|
-- Call RTB event.
|
||||||
flight:RTB(self.airbase)
|
flight:RTB(self.airbase)
|
||||||
|
|
||||||
|
-- Set flightcontrol for this flight.
|
||||||
|
flight:SetFlightControl(self)
|
||||||
|
|
||||||
-- Add flight to inbound queue.
|
-- Add flight to inbound queue.
|
||||||
self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.INBOUND)
|
self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.INBOUND)
|
||||||
|
|
||||||
@ -1927,6 +1930,9 @@ function FLIGHTCONTROL:_PlayerRequestInbound(groupname)
|
|||||||
-- Send message.
|
-- Send message.
|
||||||
self:TransmissionTower(text, flight, 15)
|
self:TransmissionTower(text, flight, 15)
|
||||||
|
|
||||||
|
-- Create player menu.
|
||||||
|
self:_CreatePlayerMenu(flight, flight.menu.atc)
|
||||||
|
|
||||||
else
|
else
|
||||||
self:E(self.lid..string.format("WARNING: Could not get holding stack for flight %s", flight:GetName()))
|
self:E(self.lid..string.format("WARNING: Could not get holding stack for flight %s", flight:GetName()))
|
||||||
end
|
end
|
||||||
@ -1955,7 +1961,7 @@ function FLIGHTCONTROL:_PlayerRequestInbound(groupname)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Player calls inbound.
|
--- Player aborts inbound.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
function FLIGHTCONTROL:_PlayerAbortInbound(groupname)
|
function FLIGHTCONTROL:_PlayerAbortInbound(groupname)
|
||||||
@ -1976,18 +1982,25 @@ function FLIGHTCONTROL:_PlayerAbortInbound(groupname)
|
|||||||
-- Radio message.
|
-- Radio message.
|
||||||
self:TransmissionPilot(text, flight)
|
self:TransmissionPilot(text, flight)
|
||||||
|
|
||||||
-- Add flight to inbound queue.
|
|
||||||
self:_RemoveFlight(flight)
|
|
||||||
|
|
||||||
-- Set flight.
|
|
||||||
flight.stack.flightgroup=nil
|
|
||||||
flight.stack=nil
|
|
||||||
|
|
||||||
-- Message text.
|
-- Message text.
|
||||||
local text=string.format("%s, %s, roger, have a nice day!", callsign, self.alias)
|
local text=string.format("%s, %s, roger, have a nice day!", callsign, self.alias)
|
||||||
|
|
||||||
-- Send message.
|
-- Send message.
|
||||||
self:TransmissionTower(text, flight, 15)
|
self:TransmissionTower(text, flight, 5)
|
||||||
|
|
||||||
|
-- Set flight.
|
||||||
|
if flight.stack then
|
||||||
|
flight.stack.flightgroup=nil
|
||||||
|
flight.stack=nil
|
||||||
|
else
|
||||||
|
self:E(self.lid.."ERROR: No stack!")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set flight to cruise.
|
||||||
|
flight:Cruise()
|
||||||
|
|
||||||
|
-- Remove flight. This also updates the menu.
|
||||||
|
self:_RemoveFlight(flight)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -2004,6 +2017,10 @@ function FLIGHTCONTROL:_PlayerAbortInbound(groupname)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Player Menu: Holding
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Player calls holding.
|
--- Player calls holding.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
@ -2027,7 +2044,7 @@ function FLIGHTCONTROL:_PlayerHolding(groupname)
|
|||||||
|
|
||||||
local dist=stack.pos0:Get2DDistance(Coordinate)
|
local dist=stack.pos0:Get2DDistance(Coordinate)
|
||||||
|
|
||||||
if dist<5000 then
|
if dist<5000 or true then
|
||||||
|
|
||||||
-- Message to flight
|
-- Message to flight
|
||||||
local text=string.format("Roger, you are added to the holding queue!")
|
local text=string.format("Roger, you are added to the holding queue!")
|
||||||
@ -2065,28 +2082,63 @@ function FLIGHTCONTROL:_PlayerHolding(groupname)
|
|||||||
self:TextMessageToFlight(text, flight, 10, true)
|
self:TextMessageToFlight(text, flight, 10, true)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
--TODO: Error
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create player menu.
|
--- Player aborts holding.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
function FLIGHTCONTROL:_PlayerMyStatus(groupname)
|
function FLIGHTCONTROL:_PlayerAbortHolding(groupname)
|
||||||
|
|
||||||
-- Get flight group.
|
-- Get flight group.
|
||||||
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
||||||
|
|
||||||
if flight then
|
if flight then
|
||||||
|
|
||||||
local fc=flight.flightcontrol
|
if flight:IsHolding() and self:IsControlling(flight) then
|
||||||
|
|
||||||
-- Status text.
|
-- Call sign.
|
||||||
local text=string.format("My Status:")
|
local callsign=flight:GetCallsignName()
|
||||||
text=text..string.format("\nFlight status: %s", tostring(flight:GetState()))
|
|
||||||
text=text..string.format("\nFlight control: %s status=%s", tostring(fc and fc.airbasename or "N/A"), tostring(fc and fc:GetFlightStatus(flight) or "N/A"))
|
|
||||||
|
|
||||||
-- Send message.
|
-- Pilot calls inbound for landing.
|
||||||
self:TextMessageToFlight(text, flight, 10, true)
|
local text=string.format("%s, %s, abort holding", self.alias, callsign)
|
||||||
|
|
||||||
|
-- Radio message.
|
||||||
|
self:TransmissionPilot(text, flight)
|
||||||
|
|
||||||
|
-- Message text.
|
||||||
|
local text=string.format("%s, %s, roger, have a nice day!", callsign, self.alias)
|
||||||
|
|
||||||
|
-- Send message.
|
||||||
|
self:TransmissionTower(text, flight, 10)
|
||||||
|
|
||||||
|
-- Not holding any more.
|
||||||
|
flight.Tholding=nil
|
||||||
|
|
||||||
|
-- Set flight to cruise.
|
||||||
|
flight:Cruise()
|
||||||
|
|
||||||
|
-- Set flight.
|
||||||
|
if flight.stack then
|
||||||
|
flight.stack.flightgroup=nil
|
||||||
|
flight.stack=nil
|
||||||
|
else
|
||||||
|
self:E(self.lid.."ERROR: No stack!")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Remove flight. This also updates the menu.
|
||||||
|
self:_RemoveFlight(flight)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Error you are not airborne!
|
||||||
|
local text=string.format("Negative, you must be HOLDING and CONTROLLED by us!")
|
||||||
|
|
||||||
|
-- Send message.
|
||||||
|
self:TextMessageToFlight(text, flight, 10)
|
||||||
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
MESSAGE:New(string.format("Cannot find flight group %s.", tostring(groupname)), 5):ToAll()
|
MESSAGE:New(string.format("Cannot find flight group %s.", tostring(groupname)), 5):ToAll()
|
||||||
@ -2094,6 +2146,130 @@ function FLIGHTCONTROL:_PlayerMyStatus(groupname)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Player Menu: Landing
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Player confirms landing.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #string groupname Name of the flight group.
|
||||||
|
function FLIGHTCONTROL:_PlayerConfirmLanding(groupname)
|
||||||
|
|
||||||
|
-- Get flight group.
|
||||||
|
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
||||||
|
|
||||||
|
if flight then
|
||||||
|
|
||||||
|
if flight:IsHolding() and self:IsControlling(flight) then
|
||||||
|
|
||||||
|
-- Call sign.
|
||||||
|
local callsign=flight:GetCallsignName()
|
||||||
|
|
||||||
|
-- Pilot calls inbound for landing.
|
||||||
|
local text=string.format("%s, %s, leaving pattern for landing", self.alias, callsign)
|
||||||
|
|
||||||
|
-- Radio message.
|
||||||
|
self:TransmissionPilot(text, flight)
|
||||||
|
|
||||||
|
-- Set flight.
|
||||||
|
if flight.stack then
|
||||||
|
flight.stack.flightgroup=nil
|
||||||
|
flight.stack=nil
|
||||||
|
else
|
||||||
|
self:E(self.lid.."ERROR: No stack!")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Not holding any more.
|
||||||
|
flight.Tholding=nil
|
||||||
|
|
||||||
|
-- Set flight to landing.
|
||||||
|
flight:Landing()
|
||||||
|
|
||||||
|
-- Message text.
|
||||||
|
local text=string.format("%s, continue approach", callsign)
|
||||||
|
|
||||||
|
-- Send message.
|
||||||
|
self:TransmissionTower(text, flight, 10)
|
||||||
|
|
||||||
|
-- Create player menu.
|
||||||
|
self:_CreatePlayerMenu(flight, flight.menu.atc)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Error you are not airborne!
|
||||||
|
local text=string.format("Negative, you must be HOLDING and CONTROLLED by us!")
|
||||||
|
|
||||||
|
-- Send message.
|
||||||
|
self:TextMessageToFlight(text, flight, 10)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
MESSAGE:New(string.format("Cannot find flight group %s.", tostring(groupname)), 5):ToAll()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Player aborts landing.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #string groupname Name of the flight group.
|
||||||
|
function FLIGHTCONTROL:_PlayerAbortLanding(groupname)
|
||||||
|
|
||||||
|
-- Get flight group.
|
||||||
|
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
||||||
|
|
||||||
|
if flight then
|
||||||
|
|
||||||
|
if flight:IsLanding() and self:IsControlling(flight) then
|
||||||
|
|
||||||
|
-- Call sign.
|
||||||
|
local callsign=flight:GetCallsignName()
|
||||||
|
|
||||||
|
-- Pilot calls inbound for landing.
|
||||||
|
local text=string.format("%s, %s, abort landing", self.alias, callsign)
|
||||||
|
|
||||||
|
-- Radio message.
|
||||||
|
self:TransmissionPilot(text, flight)
|
||||||
|
|
||||||
|
-- Message text.
|
||||||
|
local text=string.format("%s, %s, roger, have a nice day!", callsign, self.alias)
|
||||||
|
|
||||||
|
-- Send message.
|
||||||
|
self:TransmissionTower(text, flight, 10)
|
||||||
|
|
||||||
|
-- Set flight.
|
||||||
|
if flight.stack then
|
||||||
|
flight.stack.flightgroup=nil
|
||||||
|
flight.stack=nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Not holding any more.
|
||||||
|
flight.Tholding=nil
|
||||||
|
|
||||||
|
-- Set flight to cruise.
|
||||||
|
flight:Cruise()
|
||||||
|
|
||||||
|
-- Remove flight. This also updates the menu.
|
||||||
|
self:_RemoveFlight(flight)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Error you are not airborne!
|
||||||
|
local text=string.format("Negative, you must be LANDING and CONTROLLED by us!")
|
||||||
|
|
||||||
|
-- Send message.
|
||||||
|
self:TextMessageToFlight(text, flight, 10)
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
MESSAGE:New(string.format("Cannot find flight group %s.", tostring(groupname)), 5):ToAll()
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Player Menu: Taxi
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Player requests taxi.
|
--- Player requests taxi.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
@ -2183,6 +2359,10 @@ function FLIGHTCONTROL:_PlayerAbortTaxi(groupname)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Player Menu: Takeoff
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Player requests takeoff.
|
--- Player requests takeoff.
|
||||||
-- @param #FLIGHTCONTROL self
|
-- @param #FLIGHTCONTROL self
|
||||||
-- @param #string groupname Name of the flight group.
|
-- @param #string groupname Name of the flight group.
|
||||||
@ -2257,6 +2437,102 @@ function FLIGHTCONTROL:_PlayerAbortTakeoff(groupname)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
-- Player Menu: Parking
|
||||||
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
--- Player menu request info.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #string groupname Name of the flight group.
|
||||||
|
function FLIGHTCONTROL:_PlayerRequestParking(groupname)
|
||||||
|
|
||||||
|
-- Get flight group.
|
||||||
|
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
||||||
|
|
||||||
|
if flight then
|
||||||
|
|
||||||
|
local group=flight:GetGroup()
|
||||||
|
local coord=flight:GetCoordinate()
|
||||||
|
|
||||||
|
--TODO: terminal type for helos!
|
||||||
|
local spot=self:GetClosestParkingSpot(coord, nil, true)
|
||||||
|
|
||||||
|
-- Get callsign.
|
||||||
|
local callsign=flight:GetCallsignName()
|
||||||
|
|
||||||
|
-- Message text.
|
||||||
|
local text=string.format("%s, your assigned parking position is terminal ID %d. Check the F10 map for details.", callsign, spot.TerminalID)
|
||||||
|
|
||||||
|
-- Transmit message.
|
||||||
|
self:TransmissionTower(text, flight)
|
||||||
|
|
||||||
|
-- Create mark on F10 map.
|
||||||
|
if spot.Marker then
|
||||||
|
spot.Marker:Remove()
|
||||||
|
end
|
||||||
|
spot.Marker:SetText("Your assigned parking spot!"):ToGroup(group)
|
||||||
|
|
||||||
|
-- Set parking of player element.
|
||||||
|
for _,_element in pairs(flight.elements) do
|
||||||
|
local element=_element --Ops.FlightGroup#FLIGHTGROUP.Element
|
||||||
|
if not element.ai then
|
||||||
|
element.parking=spot
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Player arrived at parking position.
|
||||||
|
-- @param #FLIGHTCONTROL self
|
||||||
|
-- @param #string groupname Name of the flight group.
|
||||||
|
function FLIGHTCONTROL:_PlayerArrived(groupname)
|
||||||
|
|
||||||
|
-- Get flight group.
|
||||||
|
local flight=_DATABASE:GetOpsGroup(groupname) --Ops.FlightGroup#FLIGHTGROUP
|
||||||
|
|
||||||
|
if flight then
|
||||||
|
|
||||||
|
local group=flight:GetGroup()
|
||||||
|
local coord=flight:GetCoordinate()
|
||||||
|
|
||||||
|
--Closest parking spot.
|
||||||
|
local spot=self:GetClosestParkingSpot(coord, nil, true)
|
||||||
|
|
||||||
|
-- Get callsign.
|
||||||
|
local callsign=flight:GetCallsignName()
|
||||||
|
|
||||||
|
-- Message text.
|
||||||
|
local text=string.format("Tower, %s, arrived at parking position. Terminal ID %d.", callsign, spot.TerminalID)
|
||||||
|
|
||||||
|
-- Transmit message.
|
||||||
|
self:TransmissionTower(text, flight)
|
||||||
|
|
||||||
|
-- Set flight status to PARKING.
|
||||||
|
self:SetFlightStatus(flight, FLIGHTCONTROL.FlightStatus.PARKING)
|
||||||
|
|
||||||
|
-- Create player menu.
|
||||||
|
self:_CreatePlayerMenu(flight, flight.menu.atc)
|
||||||
|
|
||||||
|
-- Create mark on F10 map.
|
||||||
|
if spot.Marker then
|
||||||
|
spot.Marker:Remove()
|
||||||
|
end
|
||||||
|
spot.Marker:SetText("Your current parking spot!"):ToGroup(group)
|
||||||
|
|
||||||
|
-- Set parking of player element.
|
||||||
|
for _,_element in pairs(flight.elements) do
|
||||||
|
local element=_element --Ops.OpsGroup#OPSGROUP.Element
|
||||||
|
if not element.ai then
|
||||||
|
element.parking=spot
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Flight and Element Functions
|
-- Flight and Element Functions
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@ -2297,6 +2573,8 @@ end
|
|||||||
-- @param Ops.FlightGroup#FLIGHTGROUP flight The flight to be removed.
|
-- @param Ops.FlightGroup#FLIGHTGROUP flight The flight to be removed.
|
||||||
function FLIGHTCONTROL:_RemoveFlight(flight)
|
function FLIGHTCONTROL:_RemoveFlight(flight)
|
||||||
|
|
||||||
|
flight.flightcontrol=nil
|
||||||
|
|
||||||
self:_RemoveFlightFromQueue(self.flights, flight, "flights")
|
self:_RemoveFlightFromQueue(self.flights, flight, "flights")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -812,12 +812,13 @@ function FLIGHTGROUP:Status()
|
|||||||
-- Get distance to assigned parking spot.
|
-- Get distance to assigned parking spot.
|
||||||
local dist=element.unit:GetCoordinate():Get2DDistance(element.parking.Coordinate)
|
local dist=element.unit:GetCoordinate():Get2DDistance(element.parking.Coordinate)
|
||||||
|
|
||||||
env.info(string.format("FF dist to parking spot %d = %.1f meters", element.parking.TerminalID, dist))
|
--env.info(string.format("FF dist to parking spot %d = %.1f meters", element.parking.TerminalID, dist))
|
||||||
|
|
||||||
-- If distance >10 meters, we consider the unit as taxiing.
|
-- If distance >10 meters, we consider the unit as taxiing.
|
||||||
|
-- At least for fighters, the initial distance seems to be 1.8 meters.
|
||||||
-- TODO: Check distance threshold! If element is taxiing, the parking spot is free again.
|
-- TODO: Check distance threshold! If element is taxiing, the parking spot is free again.
|
||||||
-- When the next plane is spawned on this spot, collisions should be avoided!
|
-- When the next plane is spawned on this spot, collisions should be avoided!
|
||||||
if dist>5 then
|
if dist>10 then
|
||||||
if element.status==OPSGROUP.ElementStatus.ENGINEON then
|
if element.status==OPSGROUP.ElementStatus.ENGINEON then
|
||||||
self:ElementTaxiing(element)
|
self:ElementTaxiing(element)
|
||||||
end
|
end
|
||||||
@ -1678,10 +1679,7 @@ function FLIGHTGROUP:onafterTaxiing(From, Event, To)
|
|||||||
-- Parking over.
|
-- Parking over.
|
||||||
self.Tparking=nil
|
self.Tparking=nil
|
||||||
|
|
||||||
-- TODO: need a better check for the airbase.
|
if self.flightcontrol and self.flightcontrol:IsControlling(self) then
|
||||||
local airbase=self:GetClosestAirbase()
|
|
||||||
|
|
||||||
if self.flightcontrol and airbase and self.flightcontrol.airbasename==airbase:GetName() then
|
|
||||||
|
|
||||||
-- Add AI flight to takeoff queue.
|
-- Add AI flight to takeoff queue.
|
||||||
if self.isAI then
|
if self.isAI then
|
||||||
@ -2546,7 +2544,7 @@ function FLIGHTGROUP:_LandAtAirbase(airbase, SpeedTo, SpeedHold, SpeedLand)
|
|||||||
-- Do we have a flight control?
|
-- Do we have a flight control?
|
||||||
local fc=_DATABASE:GetFlightControl(airbase:GetName())
|
local fc=_DATABASE:GetFlightControl(airbase:GetName())
|
||||||
|
|
||||||
if fc then
|
if fc and self.isAI then
|
||||||
|
|
||||||
-- Get holding point from flight control.
|
-- Get holding point from flight control.
|
||||||
local HoldingPoint=fc:_GetHoldingpoint(self)
|
local HoldingPoint=fc:_GetHoldingpoint(self)
|
||||||
|
|||||||
@ -7176,13 +7176,13 @@ function OPSGROUP:onafterStop(From, Event, To)
|
|||||||
|
|
||||||
-- Flightcontrol.
|
-- Flightcontrol.
|
||||||
if self.flightcontrol then
|
if self.flightcontrol then
|
||||||
self.flightcontrol:_RemoveFlight(self)
|
|
||||||
for _,_element in pairs(self.elements) do
|
for _,_element in pairs(self.elements) do
|
||||||
local element=_element --#OPSGROUP.Element
|
local element=_element --#OPSGROUP.Element
|
||||||
if element.parking then
|
if element.parking then
|
||||||
self.flightcontrol:SetParkingFree(element.parking)
|
self.flightcontrol:SetParkingFree(element.parking)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
self.flightcontrol:_RemoveFlight(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self:IsAlive() and not (self:IsDead() or self:IsStopped()) then
|
if self:IsAlive() and not (self:IsDead() or self:IsStopped()) then
|
||||||
|
|||||||
@ -1000,6 +1000,23 @@ function AIRBASE:_InitParkingSpots()
|
|||||||
self.NparkingTerminal[terminalType]=0
|
self.NparkingTerminal[terminalType]=0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get client coordinates.
|
||||||
|
local function isClient(coord)
|
||||||
|
local clients=_DATABASE.CLIENTS
|
||||||
|
for clientname, client in pairs(clients) do
|
||||||
|
local template=_DATABASE:GetGroupTemplateFromUnitName(clientname)
|
||||||
|
local units=template.units
|
||||||
|
for i,unit in pairs(units) do
|
||||||
|
local Coord=COORDINATE:New(unit.x, unit.alt, unit.y)
|
||||||
|
local dist=Coord:Get2DDistance(coord)
|
||||||
|
if dist<2 then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
-- Put coordinates of parking spots into table.
|
-- Put coordinates of parking spots into table.
|
||||||
for _,spot in pairs(parkingdata) do
|
for _,spot in pairs(parkingdata) do
|
||||||
|
|
||||||
@ -1013,6 +1030,7 @@ function AIRBASE:_InitParkingSpots()
|
|||||||
park.TerminalID0=spot.Term_Index_0
|
park.TerminalID0=spot.Term_Index_0
|
||||||
park.TerminalType=spot.Term_Type
|
park.TerminalType=spot.Term_Type
|
||||||
park.TOAC=spot.TO_AC
|
park.TOAC=spot.TO_AC
|
||||||
|
park.ClientSpot=isClient(park.Coordinate)
|
||||||
|
|
||||||
self.NparkingTotal=self.NparkingTotal+1
|
self.NparkingTotal=self.NparkingTotal+1
|
||||||
|
|
||||||
@ -1072,7 +1090,6 @@ function AIRBASE:GetParkingSpotsTable(termtype)
|
|||||||
spot.Free=_isfree(_spot) -- updated
|
spot.Free=_isfree(_spot) -- updated
|
||||||
spot.TOAC=_spot.TO_AC -- updated
|
spot.TOAC=_spot.TO_AC -- updated
|
||||||
spot.AirbaseName=self.AirbaseName
|
spot.AirbaseName=self.AirbaseName
|
||||||
spot.ClientSpot=nil --TODO
|
|
||||||
|
|
||||||
table.insert(spots, spot)
|
table.insert(spots, spot)
|
||||||
|
|
||||||
@ -1110,7 +1127,6 @@ function AIRBASE:GetFreeParkingSpotsTable(termtype, allowTOAC)
|
|||||||
spot.Free=true -- updated
|
spot.Free=true -- updated
|
||||||
spot.TOAC=_spot.TO_AC -- updated
|
spot.TOAC=_spot.TO_AC -- updated
|
||||||
spot.AirbaseName=self.AirbaseName
|
spot.AirbaseName=self.AirbaseName
|
||||||
spot.ClientSpot=nil --TODO
|
|
||||||
|
|
||||||
table.insert(freespots, spot)
|
table.insert(freespots, spot)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user