Check that objectives are spawned on unique parking spots

This commit is contained in:
Ambroise Garel 2025-09-17 14:24:11 +02:00
parent 0bc9780dd4
commit 13d341c4a8
2 changed files with 12 additions and 1 deletions

View File

@ -62,6 +62,7 @@ do
closeMission(true)
TUM.intermission.removeMissionZonesMarkers()
TUM.objectivesMaker.clear()
for _=1,TUM.settings.getValue(TUM.settings.id.TARGET_COUNT) do
TUM.objectives.add()
end

View File

@ -6,6 +6,8 @@
TUM.objectivesMaker = {}
do
local usedParkingSpots = {}
local function pickRandomTask()
local taskFamily = TUM.settings.getValue(TUM.settings.id.TASKING)
@ -41,6 +43,10 @@ do
return possiblePoints[1]
end
function TUM.objectivesMaker.clear()
usedParkingSpots = {}
end
function TUM.objectivesMaker.create()
local zone = DCSEx.zones.getByName(TUM.settings.getValue(TUM.settings.id.TARGET_LOCATION, true))
@ -88,7 +94,11 @@ do
local parkings = pickedAirbase:getParking()
local validParkings = {}
for _,p in pairs(parkings) do
if p.Term_Type == 104 then table.insert(validParkings, p) end
local parkingUniqueID = pickedAirbase:getID() * 10000 + p.Term_Index
if p.Term_Type == 104 and not DCSEx.table.contains(usedParkingSpots, parkingUniqueID) then
table.insert(usedParkingSpots, parkingUniqueID) -- Make sure parking spot won't be used by another objective
table.insert(validParkings, p)
end
end
if #validParkings == 0 then
TUM.log("Failed to find a valid airbase parking to spawn a target.", TUM.logger.logLevel.WARNING)