Focha Posted October 24, 2024 Posted October 24, 2024 (edited) Hi all, I want to spawn AI plane unit in a large area, lets say CombatTrigger, when a player (blue coalition, plane), pass in a specific trigger zone, lets say ZoneTrigger. If the players or AI units leave the CombatTrigger, then the group is deactivated. If the players pass on the area again, they respawn this unit. I've tried a code, but for some reason, I cannot make it happen. Code below. Can anyone help me, thank you. mist.flagFunc.units_in_zones{ units = {'[blue][plane]'}, -- Replace with the player aircraft coalition and category zones = {'TriggerZone'}, -- The name of the small trigger zone where players enter flag = 1, -- Set flag 1 when players enter the trigger zone stopFlag = 2, -- Stop checking for players when flag 2 is raised } -- Function to spawn AI when players enter the small trigger zone function spawnAI() local aiGroup = mist.respawnGroup("AI_Group", true) -- Replace "AI_Group" with the name of the AI group in the mission editor trigger.action.outText("AI Group Spawned!", 10) -- Inform players that AI has spawned end -- Function to deactivate AI if AI or players leave the combat zone function deactivateAI() local aiGroup = Group.getByName("AI_Group") if aiGroup then aiGroup:destroy() trigger.action.outText("AI Group Deactivated!", 10) -- Inform players that AI has been deactivated end end -- Schedule the spawning of AI when players enter the small zone (trigger zone) mist.scheduleFunction(function() if trigger.misc.getUserFlag(1) == 1 then -- Check if players have entered the trigger zone spawnAI() mist.flagFunc.units_out_zones{ units = {'[blue][plane]', 'AI_Group'}, -- Players and AI group zones = {'CombatZone'}, -- The large combat zone flag = 2 -- Set flag 2 if AI or players leave the combat zone } trigger.action.setUserFlag(1, 0) -- Reset flag 1 end end, {}, timer.getTime() + 1, 1) -- Schedule AI deactivation if AI or players leave the combat zone mist.scheduleFunction(function() if trigger.misc.getUserFlag(2) == 1 then -- Check if AI or players have left the combat zone deactivateAI() trigger.action.setUserFlag(2, 0) -- Reset flag 2 end end, {}, timer.getTime() + 1, 1) Edited October 24, 2024 by Focha Adding screen shot. ASUS N552VX | i7-6700HQ @ 2.59GHz | 16 GB DDR3 | NVIDIA GF GTX 950M 4 Gb | 250 Gb SSD | 1 Tb HD SATA II Backup | TIR4 | Microsoft S. FF 2+X52 Throttle+Saitek Pedals | Win 10 64 bits
Focha Posted November 5, 2024 Author Posted November 5, 2024 Is this possible, even if not using Mist? ASUS N552VX | i7-6700HQ @ 2.59GHz | 16 GB DDR3 | NVIDIA GF GTX 950M 4 Gb | 250 Gb SSD | 1 Tb HD SATA II Backup | TIR4 | Microsoft S. FF 2+X52 Throttle+Saitek Pedals | Win 10 64 bits
Wrecking Crew Posted November 5, 2024 Posted November 5, 2024 This _Zone Trigger mission uses just ME events.. BTW, those Mist unit in zone functions are typically used with a Mission Start event. The 'flag' in it goes On/True every second, when the function is run in the DCS engine. So, keep that in mind, that flag goes True every second. _Zone Trigger 29C0b.miz Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.
Recommended Posts