From 423ebbf7b83e89c548fd80dc350095535cbf32f2 Mon Sep 17 00:00:00 2001 From: Ambroise Garel <47314805+akaAgar@users.noreply.github.com> Date: Tue, 29 Jul 2025 16:27:04 +0200 Subject: [PATCH] Added ATC commands --- Script/Library/RadioMessages.lua | 18 +++++------ Script/The Universal Mission/ATC.lua | 47 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 9 deletions(-) diff --git a/Script/Library/RadioMessages.lua b/Script/Library/RadioMessages.lua index cee1f27..5d5e462 100644 --- a/Script/Library/RadioMessages.lua +++ b/Script/Library/RadioMessages.lua @@ -202,15 +202,15 @@ Library.radioMessages = { }, atcRequireNearestAirbase = { -- TODO: voiceover - "Roger. Vectoring you to the nearest airbase.", - "Copy. Coordinates to nearest field inbound.", - "Roger. Guide you direct to the nearest recovery airfield." + "Roger. Vectoring you to the nearest airbase.\n$1", + "Copy. Coordinates to nearest field inbound.\n$1", + "Roger. Guide you direct to the nearest recovery airfield.\n$1" }, - atcRequireWeather = { -- TODO: voiceover - "Roger. Weather info coming up now.", - "Copy. Weather report inbound.", - "This is control, checking conditions now.", - "Copy. Weather data on the way." + atcWeatherUpdate = { -- TODO: voiceover + "Roger. Weather info coming up now.\n$1", + "Copy. Weather report inbound.\n$1", + "This is control, checking conditions now.\n$1", + "Copy. Weather data on the way.\n$1" }, atcSafeLanding = { "Be advised: $1 is wheels down at $2 and clear of runway.", "All aircraft, $1 has landed at $2 and vacated active. Runway is open for next inbound.", "Traffic, $1 is on deck at $2 and heading to parking. Runway clear.", "All flights, $1 just rolled out at $2 and cleared the active.", "Heads up, $1 landed at $2 and moving to the ramp. Runway available for next approach." }, atcSafeLandingPlayer = { "$1, wheels on deck, welcome back. You may taxi to the parking area.", "$1, good copy on landing. Exit when able, proceed to the parking area.", "$1, touchdown confirmed. Continue to parking.", "$1, welcome home. Clear of runway and taxi to parking area.", "$1, nice landing. Taxi to parking when ready." }, @@ -312,7 +312,7 @@ Library.radioMessages = { "Control, negative on original destination, request alternate field nearest current position.", "Control, requesting location and frequency for closest towered airfield." }, - playerATCRequireWeather = { -- TODO: voiceover + playerATCWeatherUpdate = { -- TODO: voiceover "Control, request latest weather update, over.", "Control, need current weather and visibility.", "Control, what's the weather looking like out there?", diff --git a/Script/The Universal Mission/ATC.lua b/Script/The Universal Mission/ATC.lua index 25082d7..7d1e701 100644 --- a/Script/The Universal Mission/ATC.lua +++ b/Script/The Universal Mission/ATC.lua @@ -38,4 +38,51 @@ do TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(p), "commandObjectiveCoordinates"..msgIDSuffix, { obj.name, navInfo }, "Command", delayRadioAnswer) end end + + function TUM.atc.requireNearestAirbase(delayRadioAnswer) + local players = coalition.getPlayers(TUM.settings.getPlayerCoalition()) + for _,p in ipairs(players) do + local airbaseInfo = "- No airbase available near you at the moment." -- TODO: proper "no airbase" message + + local validAirbaseTypes = { Airbase.Category.AIRDROME } + if p:hasAttribute("Helicopters") then table.insert(validAirbaseTypes, Airbase.Category.HELIPAD) end + local pDesc = p:getDesc() + if pDesc.LandRWCategories and #pDesc.LandRWCategories > 0 then + -- TODO: check player unit description to filter compatible carrier types + table.insert(validAirbaseTypes, Airbase.Category.SHIP) + end + + local allAirbases = coalition.getAirbases(TUM.settings.getPlayerCoalition()) + if allAirbases and #allAirbases > 0 then + allAirbases = DCSEx.dcs.getNearestObjects(DCSEx.math.vec3ToVec2(p:getPoint()), allAirbases) + + for i=1,#allAirbases do + local abDesc = airbaseInfo[i]:getDesc() + + if DCSEx.table.contains(validAirbaseTypes, abDesc.category) then + airbaseInfo = abDesc.displayName + break + end + end + end + + TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(p), "atcRequireNearestAirbase", { airbaseInfo }, "Control", delayRadioAnswer) + end + end + + function TUM.atc.requestWeatherUpdate(delayRadioAnswer) + local weatherInfo = "- It is currenly "..DCSEx.string.getTimeString() + if Library.environment.isItNightTime() then + weatherInfo = weatherInfo.." (night, sunrise at "..DCSEx.string.getTimeString(Library.environment.getDayTime(nil, false))..")\n" + else + weatherInfo = weatherInfo.." (day, sunset at "..DCSEx.string.getTimeString(Library.environment.getDayTime(nil, true))..")\n" + end + + weatherInfo = weatherInfo.."- Average windspeed is "..tostring(DCSEx.floor(Library.environment.getWindAverage())).."m/s\n" + + local players = coalition.getPlayers(TUM.settings.getPlayerCoalition()) + for _,p in ipairs(players) do + TUM.radio.playForUnit(DCSEx.dcs.getObjectIDAsNumber(p), "atcWeatherUpdate", { weatherInfo }, "Control", delayRadioAnswer) + end + end end