From a2b9b6d530cafe5d00c51182cac67231ec44bd4e Mon Sep 17 00:00:00 2001 From: Ambroise Garel <47314805+akaAgar@users.noreply.github.com> Date: Tue, 29 Jul 2025 13:25:40 +0200 Subject: [PATCH] Friendly CAP flights now take off from near the centerpoint of mission player slots --- README.md | 3 ++- Script/The Universal Mission/AirForce.lua | 25 ++++++++--------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index ea9a680..a73972d 100644 --- a/README.md +++ b/README.md @@ -232,10 +232,11 @@ The core script is quite simple and small, I probably won't need too much help w - Added "Using the mission menu" section to this README file, detailing all available commands - Added "weapons introduction date" table for upcoming "time period" setting (datamined from Briefing Room, many thanks to @john681611) - All AI aircraft now despawned on landing to free CPU cycles and allow space for new aircraft - - AWACS aircraft now spawned near the centerpoint of all mission player slots + - AWACS aircraft now spawned near the centerpoint of mission player slots - Changed AWACS aircraft detection logic (a tiny bit less realistic but more efficient) - Changed some UTF-8 symbols in F10 menu, added UTF-8 symbol for "Objectives" submenu - Fixed missing airbase name in "aircraft landed safely" messages + - Friendly CAP flights now take off from near the centerpoint of mission player slots - Improved display of XP modifiers in menu - Improved wording of many lines and commands, correct a bunch of typos - Increased minimum aircraft spawn altitude to avoir crashes in nearby hills diff --git a/Script/The Universal Mission/AirForce.lua b/Script/The Universal Mission/AirForce.lua index cfa5ffb..651b53a 100644 --- a/Script/The Universal Mission/AirForce.lua +++ b/Script/The Universal Mission/AirForce.lua @@ -136,13 +136,11 @@ do end if not validAirbases or #validAirbases == 0 then return false end -- No airbases found for this coalition, nowhere to take off from - local center = nil if side == TUM.settings.getPlayerCoalition() then - center = playerCenter + validAirbases = { DCSEx.dcs.getNearestObject(playerCenter, validAirbases) } else - center = TUM.objectives.getCenter() + validAirbases = DCSEx.dcs.getNearestObjects(TUM.objectives.getCenter(), validAirbases) end - validAirbases = DCSEx.dcs.getNearestObjects(center, validAirbases) local airborneUnitCount = getAirborneUnitCount(side) @@ -152,7 +150,8 @@ do randomizeDesiredAircraftCount(side) end - return launchNewAircraftGroup(side, airbases) + -- return launchNewAircraftGroup(side, airbases) + return launchNewAircraftGroup(side, validAirbases) end end @@ -195,19 +194,13 @@ do end function TUM.airForce.onStartUp() - playerCenter = { x = env.mission.map.centerX, y = env.mission.map.centerY } - - local playerSlots = DCSEx.envMission.getPlayerGroups() - if #playerSlots > 0 then - playerCenter = { x = 0, y = 0 } - for _,p in ipairs(playerSlots) do - playerCenter.x = playerCenter.x + p.x - playerCenter.y = playerCenter.y + p.y - end - playerCenter.x = playerCenter.x / #playerSlots - playerCenter.y = playerCenter.y / #playerSlots + playerCenter = DCSEx.envMission.getPlayerGroupsCenterPoint() + if not playerCenter then + playerCenter = { x = env.mission.map.centerX, y = env.mission.map.centerY } end + -- TODO: build list of airbases now instead of of each update() (but what about destroyed airbases?) + return true end end