Faction Def Mod Extension - Vanilla-Expanded/VanillaExpandedFramework GitHub Wiki
FactionDefExtension includes a lot of fields that you can add to tweak game factions
public bool hasCities = true;
public string settlementGenerationSymbol;
public string packAnimalTexNameSuffix;
public PawnKindDef strangerInBlackReplacement;
private string siegeParameterSet ="";
public SiegeParameterSetDef siegeParameterSetDef;
public List<StartingGoodwillByFaction> startingGoodwillByFactionDefs = new List<StartingGoodwillByFaction>();
public List<BiomeDef> allowedBiomes = new List<BiomeDef>();
public List<BiomeDef> disallowedBiomes = new List<BiomeDef>();
public List<Hilliness> requiredHillLevels;
public bool spawnOnCoastalTilesOnly;
public bool neverConnectToRoads;
public float minDistanceToOtherSettlements;
public bool excludeFromCommConsole;
public bool excludeFromQuests;
public List<RaidStrategyDef> allowedStrategies = new List<RaidStrategyDef>();
public ForcedFactionData forcedFactionData = new ForcedFactionData();
StartingGoodwillByFaction is a container class:
public FactionDef factionDef;
public IntRange startingGoodwill;
public int Min => startingGoodwill.min;
public int Max => startingGoodwill.max;
ForcedFactionData is also another container class:
// World generation
public int requiredFactionCountAtWorldGeneration = 0;
public bool preventRemovalAtWorldGeneration = false;
public bool displayMissingWarningIfNoFactionPresent = false;
public string factionDisabledAtWorldGenerationMessage = null;
// Existing games/faction discovery
public int requiredFactionCountDuringGameplay = 0;
public bool forceAddFactionIfMissing = false;
public bool forcePlayerToAddFactionIfMissing = false;
public string factionDiscoverySpecialMessage = null;
public string factionDiscoveryFailedMessage = null;
public float factionDiscoveryFactionCountFactor = 1f;
// 0 or negative values will force faction discovery to use the default value.
public int factionDiscoveryMinimumDistanceFromPlayer = -1;
Add the VEF.Factions.FactionDefExtension
Def Extension to the FactionDef
you want to customize, and specify optional parameters as desired:
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<!-- Specify optional parameters here -->
</li>
</modExtensions>
This allows you to set initial goodwill values and relations between your faction and any number of FactionDef
s.
Possible use cases include:
-
Faction_Kingdom
andFaction_Rebels
are mutual enemies, so even if both factions are friendly with the player, they should attack each other if their caravans happen to meet on the player colony map - Multiple factions of the same
Faction_Republic
type are mutual rivals - Different starting goodwill for different starting player factions/scenarios; for instance,
Faction_CatEmpire
is initially friendly withPlayerColony
,PlayerTribe
andFaction_CatPlayerColony
, but extremely hostile towardsFaction_MousePlayerColony
from another mod
To specify custom initial goodwill by faction type, add a startingGoodwillByFactionDefs
node, containing a list of FactionDef
s with their corresponding allowed starting goodwill ranges:
<FactionDef>
<defName>FactionA</defName>
<!-- Remaining XML nodes and tags omitted for clarity -->
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<startingGoodwillByFactionDefs>
<FactionB>-100~-80</FactionB> <!-- Faction A's starting goodwill with Faction B will be between -100 and -80 -->
<FactionC>-25~25</FactionC> <!-- Faction A's starting goodwill with Faction C will be between -25 and 25 -->
<FactionD>42~-69</FactionD> <!-- Faction A's starting goodwill with Faction D will be between 42 and 69 -->
</startingGoodwillByFactionDefs>
</li>
</modExtensions>
</FactionDef>
Upon initial world generation or when a new faction is added to an existing savegame, the game will iterate through every possible pair of relations between FactionA
and any other faction, and if the other faction's type matches FactionB
, FactionC
or FactionD
, it will set their starting relations with FactionA
to within the specified range allowed for each faction type.
Example 1
In the Mousekin Race mod, the following configuration makes Mousekin_FactionKingdom
factions:
- Neutral or mildly friendly to Mousekin settler and refugee starting players
- Hostile or neutral to other Mousekin Kingdoms (representing possible alliances or rivalries with other Kingdoms)
- Hostile to Independent/Rebel Mousekins
- Friendly to Mousekin Nomads
<FactionDef>
<defName>Mousekin_FactionKingdom</defName>
<!-- Remaining XML nodes and tags omitted for clarity -->
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<startingGoodwillByFactionDefs>
<Mousekin_PlayerFaction_Settlers>10~20</Mousekin_PlayerFaction_Settlers>
<Mousekin_PlayerFaction_Refugees>10~20</Mousekin_PlayerFaction_Refugees>
<Mousekin_FactionKingdom>-20~20</Mousekin_FactionKingdom>
<Mousekin_FactionIndyTown>-100~-80</Mousekin_FactionIndyTown>
<Mousekin_FactionNomad>30~40</Mousekin_FactionNomad>
</startingGoodwillByFactionDefs>
</li>
</modExtensions>
</FactionDef>
Example 2
If, for some reason, two or more factions both have startingGoodwillByFactionDefs
lists with entries that reference each other, the resulting mutual relation will be the worst possible of the specified ranges.
<FactionDef>
<defName>Faction_Foobar</defName>
<!-- Remaining XML nodes and tags omitted for clarity -->
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<startingGoodwillByFactionDefs>
<Faction_Wahoo>-90~-20</Faction_Wahoo>
</startingGoodwillByFactionDefs>
</li>
</modExtensions>
</FactionDef>
<FactionDef>
<defName>Faction_Wahoo</defName>
<!-- Remaining XML nodes and tags omitted for clarity -->
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<startingGoodwillByFactionDefs>
<Faction_Foobar>-75~-65</Faction_Foobar>
</startingGoodwillByFactionDefs>
</li>
</modExtensions>
</FactionDef>
In this case, the final mutual goodwill between the Foobar and the Wahoo factions will be a random value between -90 and -65
If your faction prefers to spawn its settlements in only some biomes, add an allowedBiomes
containing a list of BiomeDef
s:
<FactionDef>
<defName>FactionA</defName>
<!-- Remaining XML nodes and tags omitted for clarity -->
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<allowedBiomes>
<!-- List of allowed BiomeDefs -->
</allowedBiomes>
</li>
</modExtensions>
</FactionDef>
Conversely, if your faction can spawn in most biomes except for a few that they'd rather avoid, add an disallowedBiomes
containing a list of BiomeDef
s:
<FactionDef>
<defName>FactionA</defName>
<!-- Remaining XML nodes and tags omitted for clarity -->
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<disallowedBiomes>
<!-- List of disallowed BiomeDefs -->
</disallowedBiomes>
</li>
</modExtensions>
</FactionDef>
Example
In the Vanilla Factions Expanded: Vikings, the following configuration makes Viking factions prefer Ice Sheets, Sea Ice, Boreal Forests, Cold Bogs and Tundras:
<FactionDef ParentName="HumanFactionBase" Name="VFEV_VikingBase" Abstract="True">
<!-- Remaining XML nodes and tags omitted for clarity -->
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<allowedBiomes>
<li>IceSheet</li>
<li>SeaIce</li>
<li>BorealForest</li>
<li>ColdBog</li>
<li>Tundra</li>
</allowedBiomes>
</li>
</modExtensions>
</FactionDef>
In the Vanilla Factions Expanded: Insectoid mod, the following configuration makes Insectoid only use the custom raid strategy (and skip the vanilla ImmediateAttack, ImmediateAttackSapper…):
<FactionDef ParentName="FactionBase">
<!-- Remaining XML nodes and tags omitted for clarity -->
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<allowedStrategies>
<li>VFEI_ImmediateAttackInsect</li>
</allowedStrategies>
</li>
</modExtensions>
</FactionDef>
In the Reinforced Mechanoids 2 mod, the following configuration makes the ancient remnant faction spawn human-like, but without a faction leader. This will also hide the faction from the call list at the Comms console, as a faction requires an active leader to be called. That is however optional!
<FactionDef ParentName="FactionBase">
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<shouldHaveLeader>false</shouldHaveLeader>
<excludeFromCommConsole>true</excludeFromCommConsole>
</li>
</modExtensions>
</FactionDef>
In the Reinforced Mechanoids 2 mod, the following configuration makes it so the bases of the factions are never connected by a road on the world map:
<FactionDef ParentName="FactionBase">
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<neverConnectToRoads>true</neverConnectToRoads>
<minDistanceToOtherSettlements>30</minDistanceToOtherSettlements>
</li>
</modExtensions>
</FactionDef>
<neverConnectToRoads>true</neverConnectToRoads>
defines if faction bases should be connected to roads.
<minDistanceToOtherSettlements>30</minDistanceToOtherSettlements>
defines the min distance a base of this faction can be spawned from another factions bases. Here it is 30
world tiles.
For example, here is the extension for VFE Deserters
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<startingGoodwillByFactionDefs>
<VFEE_Deserters>100~-100</VFEE_Deserters>
</startingGoodwillByFactionDefs>
</li>
</modExtensions>
This is the extension for the Empire in VFE Empire
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<forcedFactionData>
<!-- World gen -->
<requiredFactionCountAtWorldGeneration>1</requiredFactionCountAtWorldGeneration>
<preventRemovalAtWorldGeneration>true</preventRemovalAtWorldGeneration>
<factionDisabledAtWorldGenerationMessage>VFEE.ForcedFaction.Empire.CannotDisable</factionDisabledAtWorldGenerationMessage>
<!-- Gameplay -->
<requiredFactionCountDuringGameplay>1</requiredFactionCountDuringGameplay>
<forcePlayerToAddFactionIfMissing>true</forcePlayerToAddFactionIfMissing>
<factionDiscoverySpecialMessage>VFEE.ForcedFaction.Empire.FactionDiscoveryMessage</factionDiscoverySpecialMessage>
</forcedFactionData>
</li>
</modExtensions>
Here is the hostile hybrids in VE genetics:
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<excludeFromQuests>true</excludeFromQuests>
</li>
</modExtensions>
And finally the Insect faction in VFE Insectoids 2
<modExtensions>
<li Class="VEF.Factions.FactionDefExtension">
<neverConnectToRoads>true</neverConnectToRoads>
<excludeFromCommConsole>true</excludeFromCommConsole>
</li>
</modExtensions>