Now removes AI aircraft on landing

This commit is contained in:
Ambroise Garel 2025-07-25 13:05:53 +02:00
parent cfcb772c17
commit ddd1332454
2 changed files with 16 additions and 0 deletions

View File

@ -114,6 +114,7 @@ do
TUM.playerScore.onEvent(event) TUM.playerScore.onEvent(event)
TUM.mission.onEvent(event) TUM.mission.onEvent(event)
TUM.supportWingmen.onEvent(event) TUM.supportWingmen.onEvent(event)
TUM.mizCleaner.onEvent(event) -- Must be last, can remove units which could cause bugs in other onEvent methods
end end
function TUM.onEvent(event) function TUM.onEvent(event)

View File

@ -3,6 +3,7 @@
-- ==================================================================================== -- ====================================================================================
-- (local) removeAIWingmen() -- (local) removeAIWingmen()
-- TUM.mizCleaner.onStartUp() -- TUM.mizCleaner.onStartUp()
-- TUM.mizCleaner.onEvent(event)
-- ==================================================================================== -- ====================================================================================
TUM.mizCleaner = {} TUM.mizCleaner = {}
@ -52,4 +53,18 @@ do
removeAIWingmen() removeAIWingmen()
return true return true
end end
-------------------------------------
-- Called when an event is raised
-- @param event The DCS World event
-------------------------------------
function TUM.mizCleaner.onEvent(event)
-- Remove AI aircraft when they land, so they "free room" (e.g. don't occupy an "enemy air force unit" slot) for new aircraft
if event.id ~= world.event.S_EVENT_LAND then return end
if not event.initiator then return end
if Object.getCategory(event.initiator) ~= Object.Category.UNIT then return end -- Not a unit
if event.initiator:getPlayerName() then return end -- Don't remove player aircraft, that would cause horrendous bugs
event.initiator:destroy()
end
end end