I would try this bit of code from this thread (http://forums.eagle.ru/showthread.php?t=124836) let me know if this works.
Mission setup:
AI Flight Groups - (Set Options - RTB on out of Ammo, RTB on Low Fuel)
AI Flight Groups - Advanced waypoint commands (flag 999 to true) as a STOP condition on all CAP, CAS, Orbit commands and return to base.
Mission Complete Trigger - (Flag 999 set true)
Script:
SCRIPT - Respawns AI Flight Group when they are all dead
SCRIPT - Respawns AI Flight if Leader is NOT IN THE AIR - CRASHED, KILLED or has LANDED. (To be Disabled when I figure out how to check all flight members have landed)
SCRIPT - Respawns AI Flight only when All of group have landed and powered down. (WIP)
Disabled - RESPAWN on LOW FUEL
SCRIPT - Will not RESPAWN any GROUPS once Flag 999 = 1
New LUA Predicate code for DRAGONS the DAM
----------------------------------------------------------------
-- Condition --> LUA PREDICATE:
local groupName = 'A-10C #1.1 AI' -- MISSON EDITOR: FLIGHT GROUP NAME
local lowFuelThreshold = 0.08 -- RTB when less then this amount of fuel (10%)
env.setErrorMessageBoxEnabled(false) -- Message Box on error: FALSE=No Box, TRUE=Show Box
-- ***********
-- Add 1 to Group Name for new Flight Group when it respawns
if barons_respawn_script and barons_respawn_script[groupName] then
groupName = groupName .. barons_respawn_script[groupName]
end
-- Set Flag 999 to true in Mission when Mission is Completed and No more waves of AI Aircraft are needed
flag_999 = trigger.misc.getUserFlag('999')
-- If the Whole Flight Group is DEAD respawn replacements until Flag 999=1
local group = Group.getByName(groupName)
if (not group and flag_999 == 0) then
return true
end
-- If Flight Groups LEADER is DEAD or LANDED respawn replacements until Flag 999=1
group = group:getUnits()[1]
if (not group and flag_999 == 0) or (Unit.inAir(group) == false and flag_999 == 0) then
return true
end
--[[
-- If Groups Fuel is below Threshold send out a replacement Flight Group until Flag 999=1
if (group:getFuel() < lowFuelThreshold and flag_999 == 0) then
return true
end
]]