Missions
A mission in X4 is anything the player accepts that produces an objective marker, tracks progress, and pays out at completion. Vanilla has six distinct categories of mission, each with its own code path. They share a common event API (event_mission_aborted, create_mission action, .hasmission accessor) but the rest of their lifecycle differs.
The six categories
Section titled βThe six categoriesβ| Category | Code lives in | Examples | Page |
|---|---|---|---|
| Story | story_*.xml | Paranid story, Buccaneers (Pirate), Welfare research | Story missions |
| Generic (BBS-style) | gm_*.xml + gmc_*.xml + rml_*.xml | Find object, board ship, deliver wares, escort | Generic missions |
| Faction subscription | x4ep1_*_subscriptions.xml | War subs, Trade subs, Pirate subs, Mentor subs | Subscription missions |
| Plot | plot.xml | Claim plot of space (sector ownership) | Plot missions |
| Tutorial | tutorial_*.xml | Flight basics, mining, stations | Tutorial missions |
| Reusable phases | rml_*.xml | Building blocks reused by gm_/story_/subscription | See Generic missions |
For the layered architecture of how gm_*/gmc_*/rml_* compose, see Architectural overview: Mission framework.
The shared lifecycle
Section titled βThe shared lifecycleβWhatever the category, a mission follows the same 5-step flow:
Offer creation β create_mission (action) β sets up the offer βPlayer discovers β event_player_discovered_mission_offer βPlayer accepts β event_briefing_started + accept (LIB c_mission_accept) βProgress tracking β custom per-mission cues, sub-objectives βResolution β completion (reward) / event_mission_aborted (cleanup)Each category implements the middle three steps differently, but create_mission and event_mission_aborted are universal β see Mission events for the full event catalog.
Decision matrix β which category for your mod?
Section titled βDecision matrix β which category for your mod?β| You want to addβ¦ | Use category |
|---|---|
| Hand-authored narrative for a faction | Story |
| Repeatable BBS-style player-pick missions | Generic |
| Faction-loyalty repeating offers | Subscription |
| Sector-ownership / claim-territory | Plot |
| Player onboarding for a feature | Tutorial |
| Sub-objective reused across mission types | Reusable phases (rml_) |
Key common gotchas
Section titled βKey common gotchasβ- β
create_missionrequires an offer source (.offerlocationshost) β not all objects can offer - β
event_mission_abortedfires for BOTH player-cancelled AND system-cancelled β distinguish viaevent.param - β Mission rewards must route through
LIB_Reward_Balancingfor economy-consistent payouts - β Map markers /
NewTargetGuidance need explicit cleanup on abort β they donβt auto-remove
Cross-references
Section titled βCross-referencesβ- Architectural overview: Mission framework β the layered composition
- Architectural overview: Reward calculation β
LIB_Reward_Balancing - Cue β
.hasmission/.missioncueaccessors - Mission group β categorisation taxonomy
- Mission events β full event + action catalog
Pick the right category before you start writing. Adding a faction subscription mission as a gm_* template wonβt give you the loyalty-tier UI the player expects from subscriptions.