Skip to content

Countermeasures Module Reference

rayswaynl edited this page Jul 3, 2026 · 1 revision

Countermeasures Module Reference

Source-verified 2026-07-03 against origin/claude/build84-cmdcon36@5fca3239069a5eff6335f06fecb26bb72e8c9ceb. Paths below are relative to Missions/[55-2hc]warfarev2_073v48co.chernarus/ unless noted. Maintained Vanilla Takistan and Zargabad carry the same Client/Module/CM/ and Common/Module/IRS/ file set.

This is the current Build84 route page for vehicle countermeasures. Use it to decide which system owns a missile-defense behavior before editing code.

Need Owner path Current status
Vanilla Arma 2 aircraft flares and missile spoofing Client/Module/CM/CM_Countermeasures.sqf, CM_Flares.sqf, CM_Spoofing.sqf Compiled only when WFBE_C_MODULE_WFBE_FLARES > 0 && WF_A2_Vanilla (Client/Init/Init_Client.sqf:1154).
Operation Arrowhead auto flares for aircraft Client/Module/CM/CM_AutoCM_OA.sqf Enabled by current defaults: WFBE_C_MODULE_AUTO_CM_OA=1 and WFBE_C_MODULE_WFBE_FLARES parameter default 2.
Native OA manual flare magazines Vehicle config plus strip/rearm helpers Kept or removed by Client_BuildUnit.sqf, Server_BuyUnit.sqf, Common_RearmVehicleOA.sqf, and Common_RemoveCountermeasures.sqf.
Ground-vehicle IR smoke Common/Module/IRS/ Separate IRS system using wfbe_irs_flares, smoke shells, and irLock ammo. It does not consume FlareCount.
GUER Ka-137 flare stock Client_BuildUnit.sqf and Server_GuerAirDef.sqf Player drones receive manual flare magazines; AI air-defense drones receive a rolled FlareCount auto-CM budget plus a manual magazine.

The older Vehicle countermeasure flares and spoofing page still has useful vanilla-CM internals, but it predates the Build84 OA auto-CM default flip. Treat this page as the current route map.

Gates And Defaults

Gate Default / parameter Meaning Source
WFBE_C_MODULE_WFBE_FLARES lobby values 0/1/2, default 2 Master countermeasure mode: disabled, enabled with upgrade, or always enabled. Rsc/Parameters.hpp:389-393
WFBE_C_MODULE_AUTO_CM_OA lobby values 0/1, default 1; SQF fallback also 1 Adds automatic flare deployment for OA aircraft when the master flare gate allows a flare budget. Rsc/Parameters.hpp:394-398, Common/Init/Init_CommonConstants.sqf:1401
WFBE_UP_FLARESCM upgrade gate used only when master mode is 1 In mode 1, a side must own the flare/CM upgrade before aircraft receive the CM handler and budget. Common/Init/Init_Unit.sqf:136-160
WFBE_C_MODULE_WFBE_IRSMOKE separate IRS flag Controls ground-vehicle IR smoke, not aircraft flares. IRS IR-smoke missile countermeasure

One source comment in CM_AutoCM_OA.sqf:1 still describes the feature as default-off. The Build84 constants and lobby parameter disagree: current default is on.

Boot And Attach Flow

flowchart TD
    Param["Rsc/Parameters.hpp"] --> Flares["WFBE_C_MODULE_WFBE_FLARES"]
    Param --> Auto["WFBE_C_MODULE_AUTO_CM_OA"]
    Flares --> VanillaBoot["WF_A2_Vanilla: Client/Init/Init_Client.sqf compiles CM_Init"]
    VanillaBoot --> VanillaFns["CM_Countermeasures / CM_Flares / CM_Spoofing"]
    Flares --> InitUnit["Common/Init/Init_Unit.sqf unit creation"]
    Auto --> InitUnit
    InitUnit --> SetBudget["CM_Set.sqf seeds FlareCount and FlareActive"]
    InitUnit --> VanillaEH["Vanilla incomingMissile -> CM_Countermeasures"]
    InitUnit --> OAEH["OA incomingMissile -> WFBE_CL_FNC_AutoCM_OA"]
    OAEH --> LocalFlare["createVehicleLocal FlareCountermeasure"]
    VanillaEH --> VanillaFlare["model flare_launcher flares + CM_Spoofing"]
Loading

Important boundaries:

  • CM_Init.sqf only compiles the vanilla CM functions; it does not own the OA auto-CM function.
  • Init_Unit.sqf is the attachment point for both vanilla CM and OA auto-CM. This means a vehicle receives its handler at unit creation, not from a persistent polling loop.
  • CM_Set.sqf waits for commonInitComplete, sleeps 2 seconds, then writes FlareCount and FlareActive.
  • In OA, Common_RemoveCountermeasures.sqf strips native flare magazines when the master gate is off or mode 1 lacks the upgrade.

FlareCount Contract

FlareCount is the shared aircraft flare budget variable.

Writer Shape Notes
CM_Set.sqf:7-9 FlareCount = WFBE_C_UNITS_COUNTERMEASURE_PLANES for planes, otherwise WFBE_C_UNITS_COUNTERMEASURE_CHOPPERS; FlareActive=false Used by both vanilla CM and OA auto-CM.
Common_RearmVehicle.sqf:22-27 resets FlareCount on vanilla rearm Mode 1 still checks WFBE_UP_FLARESCM.
Server_GuerAirDef.sqf:115-132 public setVariable ["FlareCount", rolledCount, true] after a 3 second delay Deliberately wins the later CM_Set.sqf default write for AI Ka-137 hulls.
CM_AutoCM_OA.sqf:23-32 decrements by one per local flare created No magazine rounding; a partial budget like 13 is meaningful.
CM_Flares.sqf:12-16 decrements once per model flare_launcher selection per burst Vanilla path depends on model memory points.

FlareActive is a per-vehicle re-entrancy lock. Both the vanilla and OA paths skip if another burst is already active.

OA Auto-CM Path

CM_AutoCM_OA.sqf is model-agnostic because stock OA aircraft do not reliably expose the flare_launcher memory points used by the old vanilla script.

On each incomingMissile event it:

  • exits if the vehicle is dead or below 5 m altitude;
  • reads CfgAmmo >> ammo >> AirLock and only reacts to air-locking ordnance;
  • exits if FlareActive is already true or FlareCount <= 0;
  • emits up to eight local FlareCountermeasure objects, 0.3 seconds apart;
  • spawns each flare behind and below the aircraft with half vehicle velocity and a downward bias;
  • deletes each local flare after roughly 4.5 to 5.5 seconds.

This path has no pilot chat warning and does not run CM_Spoofing; it is a direct decoy budget consumer.

Vanilla CM Path

The vanilla CM path remains the Maddmatt-style system documented in the older page:

  • CM_Countermeasures.sqf checks altitude, AirLock, FlareActive, and FlareCount.
  • It warns the player-driver with a vehicle chat line.
  • It spawns CM_Spoofing once and calls CM_Flares eight times.
  • CM_Flares.sqf discovers flare_launcher1, flare_launcher2, etc. model selections, emits flare particles/lights locally, and cleans them up after a short delay.
  • CM_Spoofing.sqf tries to jitter the incoming missile heading when it closes on the target.

Use Vehicle countermeasure flares and spoofing for the detailed old-script mechanics, but re-check line numbers against Build84 before citing them.

Native OA Manual Flares

OA aircraft can also carry real CMFlareLauncher magazines. WASP keeps this separate from the auto-CM budget:

  • Client_BuildUnit.sqf:661-668, Server_BuyUnit.sqf:237-243, and Common_RearmVehicleOA.sqf:40-46 remove native countermeasure magazines when the master gate is disabled or the side lacks the upgrade in mode 1.
  • Common_RemoveCountermeasures.sqf removes 60/120/240Rnd_CMFlare* magazines from turret path [-1] when CMFlareLauncher is present.
  • The OA auto-CM script consumes FlareCount; it does not burn a magazine round.

So a vehicle can have:

Capability Backing state
Manual OA flare button / AI native magazine behavior CMFlareLauncher plus a *CMFlare*Magazine on the vehicle turret
WASP automatic OA decoy burst FlareCount integer plus incomingMissile EH to WFBE_CL_FNC_AutoCM_OA

Do not assume one proves the other.

GUER Ka-137 Special Cases

Build84 gives the GUER Ka-137 two different countermeasure treatments:

Case Source Behavior
Player-bought GUER Ka-137 Client_BuildUnit.sqf:690-703 After the normal air CM strip, the player drone receives CMFlareLauncher plus a tier-sized manual magazine from WFBE_C_GUER_KA137_FLARE_MAGS.
AI GUER air-defense Ka-137 Server_GuerAirDef.sqf:77-132,384-385,469-470 The server rolls WFBE_C_GUER_KA137_FLARES_MIN..MAX (default 5..20), mounts the manual launcher/magazine, then publishes the rolled integer as FlareCount for auto-CM.

Related constants live in Init_CommonConstants.sqf:120-122,212-225:

  • WFBE_C_GUER_KA137_TYPE
  • WFBE_C_GUER_KA137_FLARE_LAUNCHER
  • WFBE_C_GUER_KA137_FLARE_MAGS
  • WFBE_C_GUER_KA137_SWARM*
  • WFBE_C_GUER_KA137_FLARES*

The AI path logs GUERAIRDEF|KA137_FLARES and GUERAIRDEF|KA137_SWARM, so soak/RPT reviewers can distinguish flare-stock rolls from ordinary CM behavior.

IRS Is Separate

IRS uses the same engine event name (incomingMissile) but is not part of the CM flare budget:

  • IRS_OnIncomingMissile.sqf checks irLock, per-vehicle wfbe_irs_flares, WFBE_IRS_FLARE_DELAY, and the player preference WFBE_AUTO_IRSMOKE.
  • IRS_HandleMissile.sqf waits for the missile to enter the IRS detection range, looks for nearby SmokeShellVehicle objects, then attempts a deflection using the vehicle's <type>_IRS table.
  • IRS_ShowWarning.sqf is a player-facing title warning loop while a projectile exists.

Use IRS IR-smoke missile countermeasure for the ground-vehicle table and upgrade-level behavior. Do not route aircraft flare bugs through IRS unless the bug is specifically the incomingMissile event ordering between systems.

Maintained Roots

The Build84 tree carries the CM and IRS file set in all maintained roots:

  • Missions/[55-2hc]warfarev2_073v48co.chernarus/Client/Module/CM/
  • Missions_Vanilla/[61-2hc]warfarev2_073v48co.takistan/Client/Module/CM/
  • Missions_Vanilla/[61-2hc]warfarev2_073v48co.zargabad/Client/Module/CM/
  • matching Common/Module/IRS/ directories for Chernarus, Takistan, and Zargabad.

Wiki evidence for this page was read from Chernarus source and existence-checked across the maintained Vanilla roots. No mission source, LoadoutManager output, package artifact, deploy, or live server state changed for this lane.

Edit Checklist

Before changing countermeasure behavior:

  1. Identify whether the target is vanilla CM, OA auto-CM, native OA manual flares, IRS smoke, or GUER Ka-137 stock.
  2. Check both gates: WFBE_C_MODULE_WFBE_FLARES and, for OA auto-CM, WFBE_C_MODULE_AUTO_CM_OA.
  3. If mode 1 is involved, check the side's WFBE_UP_FLARESCM upgrade state.
  4. For Ka-137 work, decide whether the subject is player-bought GUER drones or server-spawned GUER air-defense drones.
  5. Preserve FlareCount as an integer budget; do not convert partial AI Ka-137 stock to magazine count.
  6. Mirror maintained roots through the normal mission build/copy path if mission source changes are ever made.

Continue Reading

Older vanilla detail: Vehicle countermeasure flares and spoofing | Ground smoke: IRS IR-smoke missile countermeasure | Module map: Modules atlas

Sidebar

Clone this wiki locally