diff --git a/Script/Script.lua b/Script/Script.lua index 808eae9..89fb6a5 100644 --- a/Script/Script.lua +++ b/Script/Script.lua @@ -114,6 +114,7 @@ do TUM.playerScore.onEvent(event) TUM.mission.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 function TUM.onEvent(event) diff --git a/Script/The Universal Mission/MizCleaner.lua b/Script/The Universal Mission/MizCleaner.lua index dba2f42..17cc06d 100644 --- a/Script/The Universal Mission/MizCleaner.lua +++ b/Script/The Universal Mission/MizCleaner.lua @@ -3,6 +3,7 @@ -- ==================================================================================== -- (local) removeAIWingmen() -- TUM.mizCleaner.onStartUp() +-- TUM.mizCleaner.onEvent(event) -- ==================================================================================== TUM.mizCleaner = {} @@ -52,4 +53,18 @@ do removeAIWingmen() return true 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