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.
The 4 phases
Section titled βThe 4 phasesββββββββββββββββββββββββββββββββββββββββββ 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
Section titled βPhase transitionsβPhase transitions are driven by threshold checks + engine-side logic. The transitions:
| From | To | Trigger |
|---|---|---|
| (none) | pre | event_boarding_operation_created |
pre | approach | Threshold + OperationStarted |
approach | infiltration | Pods arrived AND insertion threshold met |
infiltration | internalfight | Marines 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>.
Marine flow
Section titled βMarine flowβ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.killedThe 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
Battle math (high level)
Section titled βBattle math (high level)βInternal fight outcome depends on:
| Side | Strength 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.
Special cases
Section titled βSpecial casesβPod destruction during approach
Section titled βPod destruction during approachβIf a pod is shot down (engine-side):
ApproachingBoardingPodDestroyedcue fires- Marines in that pod are lost (
.marines.killed) - If all pods destroyed: operation likely fails
Attacker destroyed
Section titled βAttacker destroyedβIf the attacking ship is destroyed before the op resolves:
AttackerDestroyedcue fires- Operation is cancelled (
event_boarding_operation_removedwith no ownership swap)
Boardee destroyed
Section titled βBoardee destroyedβ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)
Capturable filter
Section titled βCapturable filterβ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.
Vanilla file structure
Section titled βVanilla file structureβ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.
Cross-references
Section titled βCross-referencesβ- Boarding operation β runtime datatype and per-property reference
- Ship β boardable ships,
.iscapturableaccessor - NPC β marines and crew
- Faction β operation owner
- TransferShipOwnership library β what runs at conclusion
Why this matters for modders
Section titled βWhy this matters for moddersβCustom boarding outcomes
Section titled βCustom boarding outcomesβ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.
Tuning marine effectiveness
Section titled βTuning marine effectivenessβ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.
Adding boardable ships
Section titled βAdding boardable shipsβMake a ship boardable by:
- Setting
.iscapturable=trueon the macro - Ensuring
.canhaveattackablemodules=trueif you want module-level damage - Defining defence module slots (so the engine can simulate crew defence)
Custom boarding actions
Section titled βCustom boarding actionsβ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.
Related architectural overviews
Section titled βRelated architectural overviewsβ- 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