This script provides randomized, player-count-dependent AI Combat Air Patrol (CAP) for both RED and BLUE coalitions. It replaces the legacy Randomized_AI_spawn_working.lua (and its later mission-specific variants) which required the MOOSE scripting framework. This version retains the same spawn and patrol behaviour using only native DCS API tasks, cutting the MOOSE dependency entirely.
The only remaining external dependency is MIST (mist.respawnInZone and mist.scheduleFunction), which is already used throughout the mission set.
| Feature | Old (MOOSE) | New (sans MOOSE) |
|---|---|---|
| Framework | MOOSE + MIST | MIST only |
| Player menu toggle | _SETTINGS:SetPlayerMenuOff() |
Removed (was MOOSE-specific) |
| Group lookup | GROUP:FindByName(...) |
Group.getByName(...) (native DCS) |
| Zone lookup | ZONE:New(...) |
trigger.misc.getZone(...) (native DCS) |
| CAP controller | AI_CAP_ZONE:New(...) with MOOSE FSM |
Custom setupNativeCAP(...) using controller:setTask() |
| Engage + Orbit | MOOSE internal task wrapper | Native ComboTask (EngageTargets + Orbit) |
| ROE / threat reaction | MOOSE defaults | Explicit WEAPON_FREE + EVADE_FIRE via AI.Option |
The core behaviour is preserved:
| Editor Element | Names Required |
|---|---|
| Template groups (set to late activation or destroyed at load) | RedAI_1, RedAI_2, BlueAI_1, BlueAI_2 |
| Spawn trigger zones | Red_Spawn_1, Red_Spawn_2, Blue_Spawn_1, Blue_Spawn_2 |
| Patrol trigger zones | Red_Patrol_Zone_1, Red_Patrol_Zone_2, Blue_Patrol_Zone_1, Blue_Patrol_Zone_2 |
| Dependency | Purpose |
|---|---|
mist.lua |
mist.respawnInZone and mist.scheduleFunction |
No MOOSE files, no MOOSE.lua init, no _SETTINGS call.
| File | Description |
|---|---|
AI_Patrol_sans_moose.lua |
Main script — spawn logic + native CAP tasks + engine-shutdown cleanup |
AI.spawnPatrol)Every 120 seconds the script checks whether each template group is alive. If a group is dead and its coalition has ≤ 6 human players, MIST respawns it inside the corresponding spawn zone.
if not Group.getByName("RedAI_1") and redPlayerCount <= 6 then
mist.respawnInZone("RedAI_1", "Red_Spawn_1")
end
setupNativeCAP)Every 120 seconds AI.CAP() runs. For each group that is alive, it builds a single native DCS Mission task containing:
Air target within the configured engageRange (10 000 m).The altitude is randomised between 1 000–3 000 m and speed between 400–500 km/h (converted to m/s), matching the original MOOSE parameters.
A capSetup table tracks the group ID of each group so the CAP task is only applied once per group instance. Without this, re-applying the task every 120 s would snap the aircraft back to waypoint 1.
An event handler listens for S_EVENT_ENGINE_SHUTDOWN (event ID 19). When an AI unit shuts down on the ground, it is destroyed to prevent dead groups from cluttering the airfield and blocking respawns.
AI_Patrol_sans_moose.lua to the mission via Trigger → DO SCRIPT FILE.mist.lua is loaded before this script in the trigger order.| Parameter | Value | Description |
|---|---|---|
mission_duration |
20700 |
Total mission runtime in seconds (~5.75 h). Schedulers stop after this. |
| Spawn interval | 120 s |
How often the script checks / respawns dead AI groups. |
| CAP interval | 120 s |
How often the script checks / assigns CAP tasks to alive groups. |
| Min altitude | 1000 m |
Floor of the randomised patrol altitude. |
| Max altitude | 3000 m |
Ceiling of the randomised patrol altitude. |
| Min speed | 400 km/h |
Floor of the randomised patrol speed. |
| Max speed | 500 km/h |
Ceiling of the randomised patrol speed. |
| Engage range | 10 000 m |
AI will only chase / shoot at targets inside this radius. |
| Max players per coalition | 6 |
AI stops respawning when more than 6 players are present on that side. |
| Version | Date | Changes |
|---|---|---|
| 1.1.0 | 2026-05-08 | Diagram optimization: removed false sequential dependencies between AI groups; updated logic flow to show parallel spawn and CAP branches. |
| 1.0.0 | 2026-05-08 | Initial release — removed MOOSE dependency, replaced AI_CAP_ZONE with native DCS EngageTargets + Orbit tasks. |