Skip to content

Countermeasure

A Countermeasure is a missile-defeating effect — vanilla treats it as a flare-style consumable launched by a Ship to confuse incoming guided Missiles. The engine exposes class.countermeasure to scripts but provides no dedicated countermeasure datatype. The interaction between missiles and countermeasures lives at the macro level via explosive.countermeasureresistance.{macro}.

No inheritance beyond standard object. Countermeasures are class.countermeasure with no class-specific accessors. Effectiveness is determined by the macro definition and the targeted missile’s resistance.

Minimal vanilla MD usage. Like Checkpoint and Bomb, vanilla MD does not reference class.countermeasure directly — the system is handled engine-side at the AI / projectile level.

No countermeasure-specific properties. Standard object accessors apply.

The missile-side explosive datatype defines:

.countermeasureresistance.{$macro}
→ 0..1 (or %) — how strongly this missile resists the specified countermeasure macro

This is the bridge. When a countermeasure macro is launched, the engine queries each in-range targeting missile for .countermeasureresistance.{countermeasureMacro} and:

  • 0 → countermeasure fully effective, missile breaks lock
  • 1 → countermeasure ineffective, missile keeps lock

Modders adding new countermeasures define the macro and add per-missile resistance values; the engine handles the rest.

Inventory-side — give the player countermeasure stock

Section titled “Inventory-side — give the player countermeasure stock”
<add_ammo
object="player.ship"
macro="ware.eq_arg_countermeasure_01.objectmacro"
amount="50"/>

Same deployable-style pattern as Satellite / Mine / Missile. Countermeasures live in ammostorage.{macro}.

<find_object name="$CMs"
space="$Sector"
class="class.countermeasure"
multiple="true"/>

In practice, countermeasures are brief — they pop, decoy missiles for a few seconds, then despawn.

Standard object events. No event_countermeasure_X family.

EventWhenNotes
event_object_destroyedCountermeasure despawnedFilter on class.countermeasure
  • countermeasureresistance is per-pair (countermeasure macro × missile macro). Adding a new countermeasure requires defining resistance for each missile type, or accepting the default (zero resistance — countermeasure fully effective).
  • Countermeasures are launched, not “fired”. They appear from the deploying ship and are destructible objects until they despawn. Don’t expect them to be class.missile.
  • No vanilla MD references class.countermeasure. Like Bomb, the system is engine-driven; mods that add custom flare logic interact via macros, not via MD scripting of the runtime object.
  • .istargetable on the countermeasure object is the engine flag for “can a missile target this”. Used by the diversion logic. Don’t set it directly.
  • Player countermeasure deployment uses ammostorage. add_ammo macro=, not inventory or cargo. Same as all deployables.
  • Missile vs countermeasure interaction: Architectural overview Countermeasure system — how countermeasureresistance.{macro} drives the engine’s miss-rate calculation.
  • Adding a custom countermeasure: Architectural overview Custom countermeasure mods — macro definition + per-missile resistance entries.
  • Missile — what countermeasures defeat. The .countermeasureresistance.{macro} is on the missile side.
  • Ship — what launches countermeasures from ammostorage.
  • Wareware.eq_arg_countermeasure_* are the inventory items.
  • Explosive — abstract parent of missile; .countermeasureresistance lives there.