Faction goals
Above Faction economy (which manages day-to-day stations and freighters) sits a higher layer: faction goals. This is where vanilla decides βshould Argon invade Boron space?β or βshould Teladi run plunder operations?β β strategic, multi-stage actions that take time to play out.
Vanilla implements goals across 4 factiongoal_*.xml files (Hold / Invade / Plunder / Patrol) plus 4 factionsubgoal_*.xml files (BuildStation / DefendArea / PrepareStagingArea / Recon). The whole system is tied together by a two-tier evaluation pattern.
The two tiers
Section titled βThe two tiersββββββββββββββββββββββββββββββββββββββββββββββ Per-faction tick βββββββββββββββββββ¬ββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββ Tier 1: PriorityGoals ββ - Must-run goals ββ - Examples: Hold_Space ββ - Run regardless of competing options βββββββββββββββββββ¬ββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββ Tier 2: EvaluatedGoals ββ - Compete for execution ββ - Examples: Invade / Plunder / Patrol ββ - Faction picks best based on weight βββββββββββββββββββ¬ββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββ Selected goal runs ββ - Drives subgoals (Recon, BuildStation, ββ DefendArea, PrepareStagingArea) βββββββββββββββββββββββββββββββββββββββββββββThe distinction:
- PriorityGoals ALWAYS execute their evaluation/action loop if their conditions are met. They donβt compete.
- EvaluatedGoals evaluate their weight per tick; the faction picks the highest-weight option to actually run.
This lets vanilla express both βArgon must defend its space at all timesβ (Hold = PriorityGoal) and βArgon picks ONE strategic operation per tickβ (Invade vs Plunder vs Patrol = EvaluatedGoals).
Goal contract
Section titled βGoal contractβEvery goal β priority or evaluated β exposes the same contract:
| Cue / phase | Purpose |
|---|---|
Start | Initial setup when goal first becomes active |
Init | Per-cycle initialization |
Evaluate | Returns a EvaluationResult indicating fitness |
Cleanup | Cleanup when goal ends |
Update_Sub_Goal | Propagate state to active subgoals |
EvaluationResult enum values (used by Evaluate):
successβ goal achievedfailureβ goal can no longer proceedcancelβ caller-initiated stopinprogressβ still workingpartialβ partial success, continuepriorityβ promote to high-priority status
Each goalβs Evaluate returns one of these, and the parent (PriorityGoals or EvaluatedGoals dispatcher) decides next action based on the result.
The 4 vanilla goals
Section titled βThe 4 vanilla goalsβHold_Space (PriorityGoal)
Section titled βHold_Space (PriorityGoal)βfactiongoal_hold_space.xml β defends faction territory. Runs always for any active faction. Triggers subgoals (DefendArea, PrepareStagingArea) to respond to threats.
Invade_Space (EvaluatedGoal)
Section titled βInvade_Space (EvaluatedGoal)βfactiongoal_invade_space.xml β picks an enemy sector to invade, sets up staging, executes the invasion. Highly involved: 4-phase state machine (prepare β beachhead β retreat β handoff), uses Recon subgoal to scout.
Plunder (EvaluatedGoal)
Section titled βPlunder (EvaluatedGoal)βfactiongoal_plunder.xml β sends raiders to disrupt enemy trade. Has its own broker pattern: NPC factions outsource plunder targets to specific ship missions. 375 lines.
Patrol (PatrolCoordinationService)
Section titled βPatrol (PatrolCoordinationService)βfactiongoal_patrolcoordinationservice.xml β galaxy-wide combat coordination. Maintains a master list of distress calls, evaluates response weights, dispatches patrol ships.
The 4 vanilla subgoals
Section titled βThe 4 vanilla subgoalsβSubgoals are reusable building blocks that any goal can invoke:
| Subgoal | Purpose |
|---|---|
BuildStation (factionsubgoal_buildstation.xml) | Build a station as part of a larger plan |
Recon (factionsubgoal_recon.xml) | Scout a sector for intel |
DefendArea (factionsubgoal_defendarea.xml) | Defend a specific area |
PrepareStagingArea (factionsubgoal_preparestagingarea.xml) | Pre-position assets for upcoming operations |
Subgoals follow the same contract as goals (Start / Init / Evaluate / Cleanup / Update_Sub_Goal). The composability is the point β Invade_Space uses Recon + PrepareStagingArea; Hold_Space uses DefendArea. Same subgoal, different parents.
Registry pattern
Section titled βRegistry patternβEach faction has a FactionGoals registry containing all active goals + subgoals:
FactionGoals (per-faction global table)βββ [active goal] Hold_Space (PriorityGoal)β βββ DefendArea subgoal for Argon Primeβββ [active goal] Invade_Space (EvaluatedGoal)β βββ Recon subgoal scouting Boron territoryβ βββ PrepareStagingArea subgoal in adjacent clusterβββ ...The registry is the source of truth for βwhatβs this faction doing right nowβ. Modders extending faction behaviour add to this registry.
Why this matters for modders
Section titled βWhy this matters for moddersβAdding a custom goal
Section titled βAdding a custom goalβA custom goal (priority OR evaluated) needs:
- New
factiongoal_X.xmlfile mirroring vanilla structure - Registration in the FactionGoals registry on faction init
- Implementation of the 5-cue contract (Start / Init / Evaluate / Cleanup / Update_Sub_Goal)
- Tested EvaluationResult values
Reusing subgoals
Section titled βReusing subgoalsβThe 4 vanilla subgoals are well-tested. A custom goal that needs βbuild a stationβ should call BuildStation rather than inlining the logic. Subgoals were designed for reuse.
Donβt touch subgoals
Section titled βDonβt touch subgoalsβx4_md_subgoal_recon_stable β Vanilla subgoals are battle-tested. DA mods (and other major mods) deliberately donβt modify subgoals because theyβre a βstable foundation for custom faction AIβ. Build on them, donβt fork them.
Performance
Section titled βPerformanceβEach goalβs Evaluate runs per faction per tick. With ~12 active factions Γ 4 evaluated goals = 48 evaluations per tick. Heavy evaluation logic (galaxy-wide scans) adds up. Vanilla goals cache aggressively.
Cross-cluster operations
Section titled βCross-cluster operationsβInvade_Space and Hold_Space frequently use $LocalClusters + $AdjacentClusters patterns to operate across cluster boundaries. Custom goals targeting cross-cluster strategy should mirror this β see factiongoal_hold_space.xml:136-152.
Cross-references
Section titled βCross-referencesβ- Faction economy β the layer BELOW goals (day-to-day stations)
- Faction (game) β owner of goals
- Sector (game) β goals operate on sectors
- Cluster (game) β cross-cluster operations use
$LocalClusters/$AdjacentClusterspatterns
Related architectural overviews
Section titled βRelated architectural overviewsβ- Faction economy β child system
- Patrol coordination β overlapping with Patrol goal
- Mission framework β goals can spawn missions via the framework