Mission framework
Every βFind this objectβ / βDeliver these waresβ / βDefend this stationβ mission the player encounters in X4 is generated by a layered mission framework. The framework separates mission TEMPLATES (what to do) from mission COMPOSITION (which template to pick) from BEHAVIOR REUSE (shared phases). This overview maps the layers.
Vanilla scope:
- 37
gm_*.xmlfiles β base mission templates - 6
gmc_*.xmlfiles β mission catalogues / compositions - 67
rml_*.xmlfiles β reusable mission library - 7
story_*.xmlfiles β narrative content
Three layers
Section titled βThree layersβββββββββββββββββββββββββββββββββββββββββββββββββββ Layer 3: Story missions (story_*) ββ - Hand-authored narrative content ββ - Tied to specific characters, sectors βββββββββββββββββββ¬βββββββββββββββββββββββββββββββ β usesββββββββββββββββββββββββββββββββββββββββββββββββββ Layer 2: Generic Mission Catalogues (gmc_*) ββ - Compose templates into themed flows ββ - Examples: assisted_task, dynamic, mad_ ββ scientist βββββββββββββββββββ¬βββββββββββββββββββββββββββββββ β instantiatesββββββββββββββββββββββββββββββββββββββββββββββββββ Layer 1: Generic Missions (gm_*) ββ - Mission TEMPLATES ββ - Examples: gm_bringitems, gm_board_ship, ββ gm_buildstation, gm_patrol βββββββββββββββββββ¬βββββββββββββββββββββββββββββββ β usesββββββββββββββββββββββββββββββββββββββββββββββββββ Layer 0: Reusable Mission Library (rml_*) ββ - Shared phases / sub-objectives ββ - Examples: rml_find_object, rml_buildstationββββββββββββββββββββββββββββββββββββββββββββββββββLayer 1: Generic Missions (gm_*)
Section titled βLayer 1: Generic Missions (gm_*)βThe 37 gm_* files are mission templates. Each defines one βkindβ of mission:
| File | Mission type |
|---|---|
gm_bringitems.xml | Deliver wares to a station |
gm_board_ship.xml | Capture a ship via boarding |
gm_buildstation.xml | Build a station |
gm_destroy_objects.xml | Destroy components / objects |
gm_find_object.xml | Find a specific object |
gm_patrol.xml | Patrol a region |
gm_assassinate.xml | Kill a specific NPC |
gm_barterwares.xml | Trade wares between two stations |
gm_ambush.xml | Ambush a passing convoy |
| (and 28 more) | Various mission types |
Each gm_* script implements the full lifecycle: offer creation β player accept β objective setup β progress tracking β completion / failure β reward distribution.
A typical gm_* script is 1000-3000 lines. Larger ones (gm_buildstation ~5000+) handle complex multi-phase missions.
Layer 2: Generic Mission Catalogues (gmc_*)
Section titled βLayer 2: Generic Mission Catalogues (gmc_*)βThe 6 gmc_* files are mission composers β they pick which gm_* to instantiate based on context.
| File | Composition theme |
|---|---|
gmc_assisted_task.xml | Player-assisted task missions |
gmc_dynamic.xml | Dynamic encounter missions (deploy in space) |
gmc_improve_station_defences.xml | Faction-requested defence upgrades |
gmc_madscientist.xml | Mad scientist story content (interior dynamic interior) |
gmc_retrieve_dead_drop.xml | Black-market dead drops |
gmc_supervised_mining.xml | Mining supervision tasks |
Catalogues are the βWhere do missions come from?β layer. When the player approaches a station, the engine asks a catalogue βwhat mission do you have for me right now?β, and the catalogue picks a gm_* template and instantiates it with appropriate parameters.
Layer 0: Reusable Mission Library (rml_*)
Section titled βLayer 0: Reusable Mission Library (rml_*)βThe 67 rml_* files are shared phases / sub-objectives. Multiple gm_* missions reference the same rml_* for common functionality:
| File | Reusable functionality |
|---|---|
rml_find_object.xml | Find-an-object sub-objective (used by 5+ missions) |
rml_buildstation.xml | Build-a-station sub-objective |
rml_collect_crates.xml | Collect floating crates |
rml_deploy_in_sectors.xml | Deploy satellites/probes |
rml_trade_wares.xml | Trade ware exchanges |
rml_destroy_components.xml | Destroy sub-components |
rml_largesupply.xml | Large-scale supply runs |
rml_rescue_ship.xml | Rescue stranded ships |
| (and 59 more) | β¦ |
The naming is parallel: gm_bringitems (top-level mission) uses rml_bringitems (the actual delivery phase). The split lets one mission compose multiple rml_* phases β e.g. find-then-deliver-then-defend uses 3 different rml_*.
Layer 3: Story content (story_*)
Section titled βLayer 3: Story content (story_*)βThe 7 story_* files are hand-authored narrative content β main plot missions, DLC arcs. They use the same framework primitives but are not templated. Each story script is bespoke.
| File | Story arc |
|---|---|
story_buccaneers.xml | Pirate DLC arc |
story_diplomacy_intro.xml | Diplomacy system introduction |
story_paranid.xml | Paranid story |
story_research_welfare_1.xml | Research welfare story |
story_ventures.xml | Ventures DLC arc |
| (and 2 more) | DLC-specific |
Mission lifecycle (gm_* pattern)
Section titled βMission lifecycle (gm_* pattern)βEvery gm_* mission follows a similar lifecycle:
Offer creation - Catalogue picks gm_*, sets parameters - Creates a mission offer at the offering object β Player accept (event_mission_accepted) - Mission becomes "active" - .hasmission = true on the cue β Objective setup - Spawn target objects / NPCs - Create map markers / guidance β Progress tracking - Listen for completion events - Update objective state - Voice line / UI feedback β Completion / failure - Reward distribution (LIB_Reward_Balancing) - Cleanup spawned content - Faction relation hit (if applicable)Mission offer location
Section titled βMission offer locationβEach catalogue picks an OFFER LOCATION β typically:
- A specific NPC (faction representative, ship trader)
- A control panel (signal leak with mission type)
- A signal leak (random encounter)
The locationβs .offerlocations list tracks active offers. See Cue β Properties for .offerlocations accessor.
Why this matters for modders
Section titled βWhy this matters for moddersβAdding a new mission type
Section titled βAdding a new mission typeβIf your mod needs a new mission KIND not in vanilla:
- Write a new
gm_X.xml(consider patterns from existing gm_* files) - Reuse
rml_*for common sub-objectives - Either: (a) hand-add offers via your own cue, or (b) register with an existing
gmc_*catalogue - Implement reward via
LIB_Reward_Balancingfor vanilla-style economy
Reusing rml_*
Section titled βReusing rml_*βMost βprimitiveβ mission objectives (find, deliver, destroy, collect) are already in rml_*. Your custom mission should call into them via <run_actions ref=> rather than reimplementing.
Mission group categorisation
Section titled βMission group categorisationβMission group lets you bucket missions by theme. Custom missions should register a mission group for analytics + UI.
Signal leaks and offer-source distinction
Section titled βSignal leaks and offer-source distinctionβMany vanilla missions (gm_bringitems uses 5+ sites) check whether the offer object is a Signal leak vs a station, and apply different content per case. Custom missions should follow the same pattern.
Cross-references
Section titled βCross-referencesβ- Cue (lang) β
.hasmission/.missiontype/.objectiveaccessors - Mission group β categorisation
- Signal leak β common offer source
- Crate β
find_crate_slotused inrml_collect_crates
Related architectural overviews
Section titled βRelated architectural overviewsβ- Reward calculation β
LIB_Reward_Balancingmath - NPC orders β missions create orders for cooperating ships
- Mission framework reward β separate concern