Misc — Auxiliary Drop-In Scripts

Catch-all directory for small, reusable mission scripts that don't fit into the other categories.

Directory Structure

Misc/
├── README.md                -- This file
├── README.html              -- Generated HTML documentation
├── ai_patrol_random.lua     -- Player-dependent AI CAP patrols (native DCS tasks)
├── random_aa.lua            -- Random AA group shutdown / reactivation
├── target_counter.lua       -- Static-object death counter with flag updates
└── old/                     -- Original extracted scripts
    ├── Randomized_AI_spawn_working.lua
    ├── 4YA_RandomAA.lua
    └── 18th_june_B_Tgt3.lua

Scripts

ai_patrol_random.lua

Spawns AI patrol flights in random zones based on live player counts. Uses native DCS tasks — no MOOSE required.

What it does: - Checks player count every 2 minutes. - If no AI group exists and players are below max_players, respawns it in its designated spawn zone via mist.respawnInZone. - Assigns a native EngageTargets + Orbit CAP task to the spawned group. - Destroys template groups on init so they don't clutter the airfield. - Cleans up landed AI units that shut down their engines.

CONFIG keys:

Key Default Description
mission_duration 20700 Total mission time in seconds
spawn_interval 120 Seconds between spawn checks
cap_interval 120 Seconds between CAP task refreshes
max_players 6 Player-count ceiling for spawns
patrols table Array of patrol definitions (side, group, zones, altitudes, speeds, engage range). See inline comments.

Mission Editor setup: Create groups RedAI_1, RedAI_2, BlueAI_1, BlueAI_2 (templates with waypoints optional — script overrides route). Also create trigger zones Red_Spawn_1, Red_Spawn_2, Blue_Spawn_1, Blue_Spawn_2 and patrol zones Red_Patrol_Zone_1, Red_Patrol_Zone_2, Blue_Patrol_Zone_1, Blue_Patrol_Zone_2.


random_aa.lua

Randomly toggles AI anti-aircraft groups on and off to simulate unreliable wartime AA coverage.

What it does: - Scans all ground groups for a name substring (e.g. "Random"). - Every cycle, each matched group has a configurable chance to shut down (hold fire). - After a random duration, the group reactivates (open fire). - Uses pcall error wrapping and DCS controller options for reliability.

CONFIG keys:

Key Default Description
group_name_filter "Random" Substring to match in group names
shutdown_chance 20 Percent chance to shutdown per cycle
shutdown_min 120 Minimum shutdown duration (seconds)
shutdown_max 600 Maximum shutdown duration (seconds)
cycle_seconds 120 Evaluation interval
initial_delay 10 Seconds before first evaluation

Mission Editor setup: Name your AA groups with the chosen filter string (e.g. Random_Flak_1, Random_Bofors_2). Script auto-discovers them — no manual list required.


target_counter.lua

Counts destruction of named static objects and increments DCS user flags.

What it does: - Listens for S_EVENT_HIT on static objects. - When a tracked object is hit, increments one or more user flags. - Optionally broadcasts coalition-scoped alerts. - Automatically removes its event handler once the target limit is reached. - Uses pcall error wrapping and nil-safe DCS object access.

CONFIG keys:

Key Default Description
target_names table Static object names to monitor
flags {55, 1010} DCS user flags to increment per hit
target_limit 13 Stop listening after this many targets destroyed (0 = unlimited)
alerts table Optional coalition alert messages. coalition = 1 for Red, 2 for Blue.

Mission Editor setup: Place static objects (e.g. train cars, bridges) and name them exactly as listed in CONFIG.target_names. Create DCS user flags (e.g. 55, 1010) and read them via mission editor triggers.


Changelog

v1.0 — 2024-05-29