Regions — DM.Region¶
Class defined in sources/DynamicMission.lua:2142-3311 (full section, header included:
2077-3311).
Zone nomenclature¶
The zone name is split into 8 segments, separated by _ or - (interchangeable, but two
separators can't touch):
RG_[R/B]_[NAME]_[FREQ]_[FB/NOFB]_[SEG6]_[MAX_C]_[VIS]
1 2 3 4 5 6 7 8
| Seg. | Role | Verified parsing rule |
|---|---|---|
| 1 | Prefix | Must be RG (case-insensitive) — rejected otherwise |
| 2 | Coalition | R or B → originCoalition 1 (Red) or 2 (Blue); error otherwise |
| 3 | Short name | Strictly alphanumeric; error otherwise |
| 4 | FREQ (cycle frequency, s) | If invalid/≤0, falls back to DM.Config.REGION_TICK_INTERVAL (30s) with a warning — non-blocking |
| 5 | Mode | FB or NOFB — blocking error on any other value |
| 6 | Dual meaning depending on segment 5 | See below |
| 7 | MAX_C (max spawn cycles) | Falls back to 10 with a warning if invalid |
| 8 | F10 map visibility | 1 → visible; any other value → invisible (warning if it wasn't literally 0) |
Segment 6 — meaning conditioned by mode
FB mode: segment 6 = ratioFB, a decimal Force Balancing ratio (e.g. 1.5).
maxGroups is then locked at 999 (effectively unlimited) — capacity is governed solely by
the ratio.
NOFB mode: segment 6 = maxGroups, an integer cap on simultaneous groups. ratioFB is
set to 0 (unused).
The parsing that actually runs is DM.Region:_parseNomenclature (an instance method).
State machine¶
Only three states are used: "IDLE", "ACTIVE", "CLEARED".
- IDLE (initial state) — scheduler stopped, the region does nothing before activation.
- activate() — a no-op if already
ACTIVEor ifCLEARED(terminal state, never reactivatable). Otherwise: moves toACTIVE, resetsidleTimeto 0, starts the cycle scheduler at the region's frequency, starts the threat alert ifTHREAT_ALERT_ENABLED, draws the F10 polygon if visible. - inactivate() — always stops the schedulers. If the state was
CLEARED, fully purges the active groups. Otherwise (fromACTIVE), moves back toIDLEwithout destroying the groups — they persist and are picked back up at the next activation. - CLEARED — decided by
checkClearedStatus(): a region becomesCLEAREDwhen every base it contains belongs to the coalition oppositeoriginCoalition(a region with no linked base can never reach it). The transition callsinactivate(), which purges every group.
runCycle(): the 7-phase tick¶
Only runs while status == "ACTIVE", on a timer.scheduleFunction self-rescheduled at the
region's frequency (segment 4).
- Enemy player detection — walks
coalition.getPlayers(), tests polygon membership (point-in-quad); includes both air and ground players. - Force Balancing availability update (FB mode only).
- Spawn decision / idle counting — with no enemy,
idleTimeaccumulates; pastIDLE_LIMIT(300s by default), the region automatically goes back toIDLE(groups kept). With an enemy present,idleTimeresets to zero and:- FB mode: target headcount =
ceil(enemy_count × ratioFB); one more group spawns if the current count is below it, subject only to the attrition cap (maxGroupsis ignored). - NOFB mode: one group per tick as long as both the simultaneous cap
maxGroupsand the attrition capmaxCyclesallow it.
- FB mode: target headcount =
- Scavenging —
landedUnitDelete()runs every cycle, enemy present or not. Removes air units (plane/helicopter) that have landed (speed < 1 m/s) and are outside a 100m radius of any base in the region. Ground units are explicitly excluded from this cleanup. - Maintenance — removes dead/empty groups from
activeGroups. - CLEARED check.
- F10 redraw if the region is still
ACTIVEand visible.
Activation triggers¶
Two modes, set by DM.Config.TYPE_CONTROL:
"TERRAIN"(the actual configured default) —DM.Manager:_checkAutoActivation()runs at the frequencyDM.Config.AUTO_ACTIVATION_CHECK_INTERVAL(60s by default, but configurable — not a hardcoded constant) and automatically activates anyIDLEregion containing at least one human player of the enemy coalition."MANUEL"— no automatic activation; triggered only viaDM.Manager:activateRegion()/inactivateRegion(), the F10 menu, orDM.TestUtils.
An always-present F10 menu (independent of TYPE_CONTROL) exposes "+ Activate" /
"− Deactivate" per region under F10 → DM → RG → [short name] — a mission-maker/player control
lever distinct from the test menu.
F10 map visibility (segment 8)¶
When enabled, a quadrilateral (trigger.action.quadToAll) is drawn, colored by the region
bases' current majority coalition (not the origin coalition) — 20% fill opacity, 100% border,
8-unit line thickness. The redraw is skipped if the coalition hasn't changed since the last draw
(an optimization).