Skip to content

Flak Tower And WDDM Anchor Compositions

rayswaynl edited this page Jul 6, 2026 · 1 revision

Flak Tower And WDDM Anchor Compositions

Source-verified 2026-07-06 against branch claude/cmdcon44-wddm @ 1ac5a3f — the cmdcon44-c (Build 89) commit "thin-tower flak + WDDM-authored defense positions & fortifications". Paths relative to Missions/[55-2hc]warfarev2_073v48co.chernarus/ unless noted. Arma 2 OA 1.64.

This page documents the in-mission anchor-composition pipeline: how a commander buys a cheap "anchor ghost" from the build menu and the server expands it into a whole multi-object defensive position — walls, statics, and (the cmdcon44-c headline) the Flak Tower, an AA gun auto-manned on top of a lattice light tower. It covers the full chain: anchor ghost → RequestDefense (composition cap) → Server_ConstructPosition (per-child spawn + AUTOZ deck measure) → ConstructDefenseHandleDefense (HC-delegated manning), plus the .wddm.json authoring loop and the flak-tower flag set.

Disambiguation. "WDDM" names two related but distinct things. The browser tool (Warfare Dynamic Defense Manager, one of the Warfare web tools) is the editor Ray uses to author composition layouts. This page is about the mission-side runtime that consumes those layouts. The historical Commander positions branch audit audited the original feat/commander-positions branch this pipeline descends from; the cmdcon44 chain is the current landing of that feature (superseding the branch-audit state).

Pipeline at a glance

WDDM editor (browser) ──> docs/design/compositions/*.wddm.json   (layout source of truth)
        │                                 │
        │                    Tools/WddmToSqf/wddm_to_sqf.py
        │                                 ▼
        │       missionNamespace setVariable ['WFBE_NEURODEF_*', [[cls,[x,y,z],dir],...]]
        │              (pasted into Server/Init/Init_Defenses.sqf)
        ▼
Build menu: commander buys an ANCHOR GHOST classname (e.g. Land_Ind_TankSmall)
        ▼
Client/Module/CoIn/coin_interface.sqf:753  ──"RequestDefense" PVF──>  server
        ▼
Server/PVFunctions/RequestDefense.sqf — anchor? cap OK? ──Spawn──> Server_ConstructPosition
        ▼
Server/Functions/Server_ConstructPosition.sqf — per child: rotate offset, Call ConstructDefense
        ▼                                        (flak host: boundingBox AUTOZ deck measure)
Server/Construction/Construction_StationaryDefense.sqf — crewable child? ──Spawn──> HandleDefense
        ▼
Server/Functions/Server_HandleDefense.sqf — HC delegation + 45 s fallback + 420 s re-man

Anchor ghosts and the template map (Server/Init/Init_Defenses.sqf)

Anchors are not editor-placed objects — they are cheap placeholder classnames that exist only as build-menu entries and placement cursors. The registry:

Surface Content Source
WFBE_POSITION_ANCHOR_NAMES 14 anchor classnames (Land_Ind_BoardsPack1, Land_CncBlock_Stripes, Land_Barrel_sand, Land_Ind_BoardsPack2, Land_WoodenRamp, RoadCone, Paleta1, Paleta2, Land_Ind_Timbers, Misc_cargo_cont_small, Land_Ind_TankSmall, Land_Misc_Cargo1B, Land_transport_crates_EP1, Land_Barrel_water) Server/Init/Init_Defenses.sqf:966
WFBE_POSITION_TEMPLATE_MAP rows of [anchorClassname, baseTemplateVar, factionSpecific?]; faction-specific rows get _WEST/_EAST appended at build time Server/Init/Init_Defenses.sqf:948-965
Flak-tower row ['Land_Ind_TankSmall','WFBE_NEURODEF_FLAKTOWER',true] Server/Init/Init_Defenses.sqf:960

A template variable holds the composition as [['classname',[xOffset,yOffset,zOffset],relativeDir], ...] — the same element shape Server_CreateDefenseTemplate.sqf consumes elsewhere (see Server composition spawner reference).

Authoring: .wddm.json is the layout source of truth

Item Detail
Location docs/design/compositions/*.wddm.json (mission repo root, not inside the mission folder) — 21 files as of cmdcon44-c (AA/artillery/mixed positions per faction, three fort_* fortifications, plus base-building layout studies)
Schema name (must start WFBE_NEURODEF_), parentW/parentD/parentDir, structureType, fortOnly, mode, notes, and objs: [{cls, x, y, z, dir, role}, ...]; only name + objs feed the converter — the rest is editor/review metadata
Converter Tools/WddmToSqf/wddm_to_sqf.py — reads every .wddm.json in the compositions dir and prints missionNamespace setVariable ['WFBE_NEURODEF_*', [...]]; blocks. CLI (script docstring): no args = all to stdout; --name <VAR> = one; --check = validate JSON + element shape (exit 1 on error); --emit-file OUT.sqf = standalone include
Landing the emitted blocks are hand-pasted into Server/Init/Init_Defenses.sqf (fort compositions at :898-944, AA/arty/mixed at :668-887). The in-file comment is explicit: the .wddm.json is the SOURCE OF TRUTH; to change a layout, edit it in WDDM and re-run the converter (do not hand-edit these arrays) (Server/Init/Init_Defenses.sqf:651-653)

Exception — the flak tower itself is hand-authored SQF, not WDDM-emitted. There is no flaktower*.wddm.json; the two-element template (host tower at ground, AA gun at deck height) is built inline at Server/Init/Init_Defenses.sqf:632-643, reading the flag constants below. The WDDM/converter loop owns the multi-object layout compositions; the flak tower's layout is trivial enough to live directly in the init.

Build-menu trigger (client side)

Item Detail Source
Menu entry Land_Ind_TankSmall registered with label 'Flak Tower — AA on light tower (1 AI)', price 1400, category Defense Common/Config/Core/Core_CIV.sqf:225-229
Side gating each side's structure file appends the anchor to WFBE_%1DEFENSENAMES behind the WFBE_C_DEF_FLAKTOWER sub-flag — WEST Structures_CO_US.sqf:260-263, EAST Structures_CO_RU.sqf:249-251, GUER Structures_CO_GUE.sqf:184-186, TK-army Structures_OA_TKA.sqf:188-189 (all under Common/Config/Core_Structures/) see left
Placement UI the CoIn "coin" placement interface — the commander's MCoin (after HQ deploy) or the repair-truck RCoin; category tabs are built from WFBE_%1DEFENSENAMES (Client/Init/Init_Coin.sqf:46,74) Client/Functions/Client_FNC_Special.sqf:72-74
Request ["RequestDefense", [sideJoined,_class,_pos,_dir,manningDefense,(_logic == RCoin),player]] Call WFBE_CO_FNC_SendToServer — the player object rides along so the server can refund on rejection Client/Module/CoIn/coin_interface.sqf:746-754

RequestDefense — the anchor fork and the composition cap

Server/PVFunctions/RequestDefense.sqf receives every defense placement. The anchor test is _isAnchor = (WFBE_POSITION_ANCHOR_NAMES find _defenseType) != -1 (RequestDefense.sqf:79), and the routing fork appears in three parallel branches (budget-gate-passed / outside-base-area / budget-gate-off — RequestDefense.sqf:284-289,295-299,306-310):

  • anchor → [_side,_defenseType,_pos,_dir,_manned] Spawn Server_ConstructPosition (a Spawn, so the PV handler returns immediately while children build asynchronously);
  • non-anchor → the normal single-object ConstructDefense Call.

Composition cap (inside a base area, budget gate on): WFBE_C_WDDM_COMP_CAP (default 3, Common/Init/Init_CommonConstants.sqf:1556) bounds how many compositions can live per base area (RequestDefense.sqf:143-168). Enforcement counts distinct placement IDs: every composition child is stamped WFBE_WDDMPositionAnchor = "<anchorType>_<counter>" at build time, so the cap logic collects live objects in WFBE_C_BASE_AREA_RANGE (default 250, Init_CommonConstants.sqf:1121) of the nearest base center and counts unique IDs. At/over the cap the request is rejected as WddmCompositionCapReached and the placing player is refunded via the LocalizeMessage channel (RequestDefense.sqf:259,272). The general defense-budget machinery around this (statics cap 25, threat gate) is documented in Defense category & budget.

Server_ConstructPosition — per-child spawn, auto-manning route, AUTOZ

Server/Functions/Server_ConstructPosition.sqf resolves the anchor via WFBE_POSITION_TEMPLATE_MAP (faction-specific templates get _WEST for west, else _EAST — there is no _GUER branch; a resistance build resolves the _EAST template, Server_ConstructPosition.sqf:42), then iterates the children (:58-111):

Step Behavior Source
World placement each child's [x,y] offset is rotated about the requested _pos by direct trigonometry (a prior modelToWorld helper-object approach was unreliable — could land compositions at the map corner) Server/Functions/Server_ConstructPosition.sqf:50-52,58-74
Per-child routing [_cls, _side, _worldPos, _worldDir, _manned, false, WFBE_C_BASE_DEFENSE_MANNING_RANGE, false, true] Call ConstructDefense — the trailing true is the _wddmChild flag Server/Functions/Server_ConstructPosition.sqf:75
Child stamps WFBE_WDDMPositionChild = true (in Construction_StationaryDefense.sqf:32-34) and WFBE_WDDMPositionAnchor = <placementID> (feeds the composition cap) Server/Functions/Server_ConstructPosition.sqf:54-56,78

Routing every child through the stock ConstructDefense is what buys auto-manning for free: ConstructDefense (alias for Server/Construction/Construction_StationaryDefense.sqf, registered Server/Init/Init_Server.sqf:35) spawns a HandleDefense manning loop for any child with emptyPositions "gunner" > 0 (Construction_StationaryDefense.sqf:97-149, Spawn HandleDefense at :148) — plus the usual killed/damaged EH wiring, scoring, and prop placement. Nothing is manning-special-cased for compositions.

AUTOZ deck measurement (the flak-tower mechanism). Server_ConstructPosition reads WFBE_C_DEF_FLAKTOWER_STRUCTURE and WFBE_C_DEF_FLAKTOWER_AUTOZ at :25-26. When a ground-level child (z <= 0.1) matching the host classname spawns, the builder measures the just-created object: _bb = boundingBox _one; _deckTop = (_bb select 1) select 2 — the model's max-z corner, which for a ground-sitting tower is the deck height (Server_ConstructPosition.sqf:83-89). Any elevated child (z > 0.1 in the template — the AA gun) is then lifted to _deckTop (AUTOZ on and measurement sane) or keeps the template's baked z (AUTOZ off / measurement failed), via setPosATL + setVectorDirAndUp (Server_ConstructPosition.sqf:90-107), logging an INFORMATION "elevated child mounted on deck" line. The mechanism is generic — any composition with a non-zero-z child gets the lift — but the flak tower is currently its only consumer (every other composition is flat).

HandleDefense — HC delegation, 45 s fallback, 420 s re-man

Server/Functions/Server_HandleDefense.sqf (alias registered Server/Init/Init_Server.sqf:44) is the per-gun manning loop, shared by all base defenses:

Mechanic Behavior Source
Duplicate-loop guard WFBE_DefenseManningLoopActive variable on the gun Server/Functions/Server_HandleDefense.sqf:7-12
Instant mount _moveInGunner = true — owner call 2026-06-11: all base-defense crews teleport into the seat (no barracks walk, no pathfinding cost) Server/Functions/Server_HandleDefense.sqf:16
HC delegation with live headless clients, manning is delegated via WFBE_CO_FNC_DelegateAIStaticDefenceHeadless (crew class = the side's WFBE_%1SOLDIER: USMC_Soldier / RU_Soldier / GUE_Soldier_1) Server/Functions/Server_HandleDefense.sqf:51-62
45 s fallback delegation is fire-and-forget to a random HC with no retry — a watcher thread waits deadline = time + 45; if no live gunner is seated by then, the server creates and seats one itself and logs a WARNING Server/Functions/Server_HandleDefense.sqf:63-88
No-HC path zero live HCs → server seats the gunner directly, no grace window Server/Functions/Server_HandleDefense.sqf:89-99
Re-man cycle the outer while {alive _defense && _sideStillValid} loop sleeps 420 s per pass and re-mans if the gunner is null/dead Server/Functions/Server_HandleDefense.sqf:21,104
Ownership exit if the base area changed hands (AI16), _sideStillValid goes false and the loop stops re-manning for the old owner Server/Functions/Server_HandleDefense.sqf:25-37

The manning loop only starts at all while the base area is under WFBE_C_BASE_DEFENSE_MAX_AI (default 40, Init_CommonConstants.sqf:1106) manning AI (Construction_StationaryDefense.sqf:97). Related: Static-defense manning covers the town-emplacement manning family; HC delegation target selection covers how the HC is picked.

The flak-tower flag set and fallback ladder

All in Common/Init/Init_CommonConstants.sqf, all isNil-guarded:

Constant Default Meaning Source
WFBE_C_DEF_FLAKTOWER 1 menu sub-flag — gates the anchor's DEFENSENAMES entry per side (only honored while WFBE_C_DEFMENU_V2 = 1, :1742) Common/Init/Init_CommonConstants.sqf:1747
WFBE_C_DEF_FLAKTOWER_STRUCTURE "Land_Ind_IlluminantTower" host tower classname (the cmdcon44-c "thin tower" — A2 lattice illuminant tower) Common/Init/Init_CommonConstants.sqf:1779
WFBE_C_DEF_FLAKTOWER_DECK_Z 17.0 fallback deck height — a documented estimate (no empirical in-repo height existed), used only when AUTOZ is off or the boundingBox measure fails Common/Init/Init_CommonConstants.sqf:1780
WFBE_C_DEF_FLAKTOWER_AUTOZ 1 1 = measure the deck via boundingBox at build time; 0 = force DECK_Z Common/Init/Init_CommonConstants.sqf:1781

The composition arrays (Server/Init/Init_Defenses.sqf:632-643): WEST = host + Stinger_Pod_US_EP1 at deck z (A2-OA has no US static bullet-AA, so the Stinger pod is the WEST mount); EAST = host + ZU23_TK_EP1 (the true ZU-23 auto-cannon). GUER note: the GUER structures file's comment reasons about ZU23_TK_GUE_EP1 being faction-authentic, but a GUER build resolves the shared _EAST template and therefore gets ZU23_TK_EP1 — a comment-vs-code mismatch worth knowing when reading the source (Common/Config/Core_Structures/Structures_CO_GUE.sqf:184-186 vs Server/Init/Init_Defenses.sqf:640-643).

One-flag fallback ladder (Init_CommonConstants.sqf:1772-1778, restated at Init_Defenses.sqf:625-630): if the thin-tower mount misbehaves on the box, Ray flips the host by editing the flag constants — there is no in-code selector; the ladder is documentation for a manual constant change:

Rung _STRUCTURE _DECK_Z _AUTOZ
Bunker MVP (rock-solid, short) Land_fortified_nest_big_EP1 2.7 0
Airfield control tower (tall, boxy) Land_Mil_ControlTower 12.5 (comment leaves AUTOZ unstated — default 1 unless also set)
Original watchtower Land_Fort_Watchtower_EP1 5.4 0

Related constants

Constant Default Meaning Source
WFBE_C_DEFMENU_V2 1 master flag for the redone Defenses/Fortifications menu Common/Init/Init_CommonConstants.sqf:1742
WFBE_C_DEFMENU_V2_POSITIONS 1 gates the six reworked AA/artillery/mixed compositions and the three WDDM FORT_* fortification anchors Common/Init/Init_CommonConstants.sqf:1791
WFBE_C_WDDM_COMP_CAP 3 max WDDM compositions per base area (size-independent) Common/Init/Init_CommonConstants.sqf:1556
WFBE_C_DEFENSE_BUDGET 1 master gate for the per-base-area defense caps Common/Init/Init_CommonConstants.sqf:1553
WFBE_C_BASE_DEFENSE_STATICS_CAP 25 max player-placed single statics per base area Common/Init/Init_CommonConstants.sqf:1554
WFBE_C_DEFENSE_THREAT_MIN 3 min enemy ground units in base range before the statics/mines threat gate fires Common/Init/Init_CommonConstants.sqf:1555
WFBE_C_BASE_DEFENSE_MAX_AI 40 max AI manning defenses per base area (manning-loop start gate) Common/Init/Init_CommonConstants.sqf:1106
WFBE_C_BASE_DEFENSE_MANNING_RANGE 250 manning distance passed through to ConstructDefense Common/Init/Init_CommonConstants.sqf:1107
WFBE_C_BASE_AREA_RANGE 250 base-area radius for the budget/cap logic Common/Init/Init_CommonConstants.sqf:1121

NEEDS-BOX-VERIFY

Flagged as unproven-from-source in the repo itself:

  • Gun-on-lattice stability: whether the AA gun physically sits stable on the illuminant tower's deck at runtime — statics-on-structures are physics-fragile in A2 (settle/jitter). Explicit NEEDS-BOX-VERIFY markers at Server/Init/Init_Defenses.sqf:616 and Init_CommonConstants.sqf:1774-1775. The gunner itself is immune to the ladder problem (teleported in via moveInGunner, stays always-active — no sim/distance gating, standing HARD rule).
  • The 17.0 DECK_Z estimate was never empirically confirmed; even the AUTOZ boundingBox read is a runtime-computed value not yet observed in a live RPT (Init_CommonConstants.sqf:1764-1766).

Continue Reading

Sidebar

Clone this wiki locally