Skip to content

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 BoriginCoalition 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 ACTIVE or if CLEARED (terminal state, never reactivatable). Otherwise: moves to ACTIVE, resets idleTime to 0, starts the cycle scheduler at the region's frequency, starts the threat alert if THREAT_ALERT_ENABLED, draws the F10 polygon if visible.
  • inactivate() — always stops the schedulers. If the state was CLEARED, fully purges the active groups. Otherwise (from ACTIVE), moves back to IDLE without destroying the groups — they persist and are picked back up at the next activation.
  • CLEARED — decided by checkClearedStatus(): a region becomes CLEARED when every base it contains belongs to the coalition opposite originCoalition (a region with no linked base can never reach it). The transition calls inactivate(), 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).

  1. Enemy player detection — walks coalition.getPlayers(), tests polygon membership (point-in-quad); includes both air and ground players.
  2. Force Balancing availability update (FB mode only).
  3. Spawn decision / idle counting — with no enemy, idleTime accumulates; past IDLE_LIMIT (300s by default), the region automatically goes back to IDLE (groups kept). With an enemy present, idleTime resets 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 (maxGroups is ignored).
    • NOFB mode: one group per tick as long as both the simultaneous cap maxGroups and the attrition cap maxCycles allow it.
  4. ScavenginglandedUnitDelete() 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.
  5. Maintenance — removes dead/empty groups from activeGroups.
  6. CLEARED check.
  7. F10 redraw if the region is still ACTIVE and visible.

Activation triggers

Two modes, set by DM.Config.TYPE_CONTROL:

  • "TERRAIN" (the actual configured default) — DM.Manager:_checkAutoActivation() runs at the frequency DM.Config.AUTO_ACTIVATION_CHECK_INTERVAL (60s by default, but configurable — not a hardcoded constant) and automatically activates any IDLE region containing at least one human player of the enemy coalition.
  • "MANUEL" — no automatic activation; triggered only via DM.Manager:activateRegion()/inactivateRegion(), the F10 menu, or DM.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).