Skip to content

Boarding

Boarding is X4’s most elaborate single-operation system β€” 2749 lines of MD in boarding.xml, a 4-phase state machine, marine accounting, pod lifecycle, threshold mechanics, and ownership transfer. This overview connects the dots from β€œplayer clicks Board” to β€œship changes faction”.

For the runtime data type and per-property reference, see Boarding operation.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ pre β”‚
β”‚ - Marines being selected by attacker β”‚
β”‚ - Boardingapproachthreshold check β”‚
β”‚ - Pods not yet launched β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
↓ threshold met
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ approach β”‚
β”‚ - Pods launched, flying to boardee β”‚
β”‚ - Aiscript on each pod handles β”‚
β”‚ flight + defence-evasion β”‚
β”‚ - Insertion threshold check β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
↓ threshold met
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ infiltration β”‚
β”‚ - Marines inserting through hull β”‚
β”‚ - Boardingresistance vs β”‚
β”‚ boardingstrength clash β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
↓ inserted
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ internalfight β”‚
β”‚ - Marines vs crew interior battle β”‚
β”‚ - Result determines ownership swap β”‚
β”‚ - .marines.killed accumulates β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
↓ resolution
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (removed) β”‚
β”‚ - Operation concluded β”‚
β”‚ - event_boarding_operation_removed β”‚
β”‚ - Ownership swapped (or not) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Phase transitions are driven by threshold checks + engine-side logic. The transitions:

FromToTrigger
(none)preevent_boarding_operation_created
preapproachThreshold + OperationStarted
approachinfiltrationPods arrived AND insertion threshold met
infiltrationinternalfightMarines successfully entered
internalfight(removed)Crew defeated OR all marines killed OR boardee destroyed

The Phase_Pre_Approach_Check_Conditions cue evaluates conditions every second during pre; once thresholds are met, vanilla advances via <set_boarding_phase>.

A marine’s journey through a boarding operation:

pre phase
↓
Marine assigned to operation
(from attacker ship's .people.marine)
↓
approach phase
↓
Marine in pod, flying to boardee
↓
Pod arrives β†’ infiltration phase
↓
Marine attempts insertion
- Success: enters internalfight
- Failure: killed
↓
internalfight phase
↓
Marine fights interior crew
- Survives + crew defeated: marines stay (attacker keeps them)
- Killed: added to .marines.killed

The boarding operation tracks marines in three buckets via the Boarding operation datatype:

  • .marines.infiltrating β€” currently inserting
  • .marines.fighting β€” in the internal fight
  • .marines.killed β€” dead during the op

Internal fight outcome depends on:

SideStrength source
Attacker.boardingstrength β€” marine skill * count
Defender.boardingresistance β€” base + crew skill + pilot

The fight resolves stochastically per tick β€” engine compares strengths, applies losses, and either resolves quickly (huge imbalance) or grinds (close fight). When defender’s resistance hits zero, the boardee changes ownership.

If a pod is shot down (engine-side):

  • ApproachingBoardingPodDestroyed cue fires
  • Marines in that pod are lost (.marines.killed)
  • If all pods destroyed: operation likely fails

If the attacking ship is destroyed before the op resolves:

  • AttackerDestroyed cue fires
  • Operation is cancelled (event_boarding_operation_removed with no ownership swap)

If the boardee is destroyed mid-op:

  • Operation removed
  • Marines who hadn’t yet inserted are lost
  • No ownership change (you can’t board a wreck)

Some ships can’t be boarded β€” .iscapturable=false. Vanilla filters include:

  • Most Khaak ships
  • Story-critical ships
  • Lasertowers

Modders adding boardable ships must set .iscapturable=true on the macro.

boarding.xml (2749 lines) is organised by cue purpose:

boarding.xml
β”œβ”€β”€ OperationCreated (entry point β€” fires on event_boarding_operation_created)
β”‚ β”œβ”€β”€ ChangePhase (phase transition handler)
β”‚ β”œβ”€β”€ ApproachingBoardingPod* (pod lifecycle)
β”‚ β”œβ”€β”€ AttackerDestroyed
β”‚ └── OperationStarted
β”œβ”€β”€ Phase_Pre_Approach
β”‚ β”œβ”€β”€ Phase_Pre_Approach_Check_Conditions (1s heartbeat)
β”‚ └── Phase_Pre_Approach_Damage_Speak (voice line)
β”œβ”€β”€ Phase_Approach
β”‚ β”œβ”€β”€ Phase_Approach_Player_Ship_Handler (player-side UX)
β”‚ β”œβ”€β”€ Phase_Approach_Player_Launch
β”‚ └── ... (NPC equivalents)
β”œβ”€β”€ Phase_Infiltration (similar split)
└── Phase_InternalFight (similar split)

The player-side and NPC-side flows are largely separate cues β€” different UX. Player gets UI prompts, voice lines, camera framing; NPC just runs the math.

If your mod wants to react to boarding (e.g. β€œgive the player a bonus for capturing capital ships”), use event_boarding_operation_removed. Determine outcome by checking event.object.boardee.trueowner == event.object.owner β€” see Boarding operation β†’ Examples.

Marine skill matters. The marine officer skill multiplies all marine effectiveness during the internal fight. Mods adding NPCs should consider whether they have marine officers.

Make a ship boardable by:

  1. Setting .iscapturable=true on the macro
  2. Ensuring .canhaveattackablemodules=true if you want module-level damage
  3. Defining defence module slots (so the engine can simulate crew defence)

Modders adding new boarding-style operations (e.g. β€œhijack via signal leak”) can use the operation datatype as a template β€” <start_boarding_operation> accepts a custom operation parameter set.

  • Marine recruitment β€” how marines enter the player’s ships in the first place
  • Defence response to boarding β€” how the defending faction reacts (relations hit, patrol response)
  • Faction economy β€” separate but adjacent system