AI Patrol — sans MOOSE

Overview

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.


What Changed

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:


Logic Flow Diagrams

AI Spawn and CAP Initialization Flow

AI Spawn and CAP FlowInit at mission loadDestroy template groupsStart spawn timer(5 s delay, 120 s interval)Start CAP timer(6 s delay, 120 s interval)Register engine-shutdownevent handler (event.id == 19)AI Groups(RedAI_1, RedAI_2,BlueAI_1, BlueAI_2)AI.spawnPatrol()Count playersper coalitionIs group alive?mist.respawnInZonein random spawn zoneAI.CAP()setupNativeCAP()Engine shutdownevent (id 19)Is AI unit?No player, on ground?Unit:destroy() Not aliveRespawnedAlive & not yet taskedNative CAP set(EngageTargets + Orbit)YesNo

Requirements

In-Mission Setup

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

Script Dependencies

Dependency Purpose
mist.lua mist.respawnInZone and mist.scheduleFunction

No MOOSE files, no MOOSE.lua init, no _SETTINGS call.


Script Files

File Description
AI_Patrol_sans_moose.lua Main script — spawn logic + native CAP tasks + engine-shutdown cleanup

How It Works

1. Spawn (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

2. Native CAP (setupNativeCAP)

Every 120 seconds AI.CAP() runs. For each group that is alive, it builds a single native DCS Mission task containing:

  1. EngageTargets — auto-engage any Air target within the configured engageRange (10 000 m).
  2. Orbit — fly a circular orbit at a randomised altitude and speed around the patrol zone centre.

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.

3. Cleanup

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.


Installation

  1. Add AI_Patrol_sans_moose.lua to the mission via Trigger → DO SCRIPT FILE.
  2. Ensure mist.lua is loaded before this script in the trigger order.
  3. Remove any previous MOOSE-based AI spawn script from the mission.
  4. Remove the MOOSE script loader from the mission (if present).

Parameters

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.

Compatibility


Changelog

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.