Skip to content

Spawn Engine — DM.utils

sources/DynamicMission.lua:230-1281.

Mission database reconstruction

scanMissionDBs() rebuilds two tables on load (a one-time scan, never refreshed during the mission) directly from env.mission: zonesByName (trigger zones, with .radius computed as the max distance to the farthest vertex for a quad) and groupsByName (every plane/helicopter/ship/vehicle/static group, all coalitions/countries flattened together).

makeUnitTable(tbl, exclude): the full tag grammar

Tag Effect
<exact unit name> Includes that specific unit
[-u]<name> Excludes that specific unit
[g]<group> Includes every unit of the group
[-g]<group> Excludes every unit of the group
[c][category]Country Includes every unit of the country (filterable by category)
[-c][category]Country Excludes the same
[all][category] Includes every unit (filterable by category)
[-all][category] Excludes every unit (filterable by category)

Recognized categories: [helicopter], [plane], [ship], [vehicle], [static].

Confirmed quirk

Any unrecognized category tag (e.g. [air]) is not identified and silently falls back to category = "", which matches every category — [all][air] would therefore behave exactly like [all]. checkEnemiesProximityForDefenses() (see Airbases) used to call makeUnitTable({'[all][air]'}); that call has since been simplified to makeUnitTable({'[all]'}), strictly equivalent — the code now explicitly assumes (with a comment backing it up) that it scans both air and ground, instead of doing so implicitly via a misread tag.

An exclude parameter (string or array) can additionally strip whole categories from the [c]/[all] branches, independently of the tag used.

cloneInZone(gpName, zone, disperse, maxDisp, v)

Clones a template's unit layout into a target zone: a valid terrain point picked at random within the zone's radius (up to 100 attempts), valid terrain types determined by category (ships → water only; vehicles → land/road; air → land/road/shallow water/water/runway), individual unit dispersion if requested, random altitude within a category-appropriate band for air units, then the template's original route is reattached before the actual spawn. Templates of category static are explicitly rejected (never used by DynamicMission).