[RimWorld Modding] Civilized Nation - Mod Faction XML Patching

RimWorld126 views2 min readby ShakecatazUpdated 19 JanView on Steam ↗

Selecting a FactionDef

Either create your own FactionDef or find a FactionDef by using Steam Workshop.

Steam Workshop mods for RimWorld can be found by looking at the long number string at the end of the Workshop page URL:
http s:// steamcommunity .com/sharedfiles/ filedetails/ ?id =3646229944

This number string "3646229944" will then be used in the folder structure as follows:
SteamLibrary/steamapps/workshop/content/294100/3646229944

Navigate to any FactionDef entry in the relevant XML file within the mod folder and find the field:
<defName>SomeDefName</defName>

You only need to find the exact defName used in the mod.

Writing the XML Patch

Now that you have a defName you have all you need to write an XML patch for Civilized Nation. Let's say your defName is <defName>ExampleDef</defName>.

You will want to make a generic mod folder, about.xml and preview.png for your mod. Look for a tutorial on setting up a basic RimWorld mod. It will explain it in far better detail than I. After setting up your mod folder, create or navigate to your Patches folder and create a new xml document.

The typical patch looks like this:

<Patch> <Operation Class="PatchOperationAddModExtension"> <xpath>/Defs/FactionDef[defName="ExampleDef"]</xpath> <value> <li Class="CivilizedNation.FactionDefModExtension"> <era>X1</era> <flavor>Y1</flavor> <allowForShadow>false</allowForShadow> <allowForAI>true</allowForAI> <defaultProgression>true</defaultProgression> </li> </value> </Operation> <Operation Class="PatchOperationAddModExtension"> <xpath>/Defs/FactionDef[defName="AnotherDef"]</xpath> <value> <li Class="CivilizedNation.FactionDefModExtension"> <era>X2</era> <flavor>Y2</flavor> <allowForShadow>false</allowForShadow> <allowForAI>true</allowForAI> <defaultProgression>false</defaultProgression> <nextDefName>ThirdExample</nextDefName> </li> </value> </Operation> </Patch>
The only relevant data you are in charge of for making a patch are five things:
What is inside the quotes after defName
What is within the <era></era> field
What is within the <flavor></flavor> field
What is within the <defaultProgression></defaultProgression> field
What is within the <nextDefName></nextDefName> field IF defaultProgression is false

allowForShadow is always false.
allowForAI is always true.
If the faction is a unique xenotype or direction over progression is desired then defaultProgression can be set to false. If so, the defName provided in the nextDefName field will be selected automatically as the upgrade faction upon advancing eras.

How the Patch is Used by the Mod

Once your patch is active Civilized Nation will recognize it as a potential faction for its era and flavor.

When the AI advances era the current era and flavor are used to determine candidates for the next era. All factions within the next era with the same flavor have the potential to be used for the faction's next stage.

The same holds true for the player's faction.

As such, if the player or AI is a "Rough Neolithic" faction and you patched VE Vikings as a Rough Medieval faction, then there is a chance (or if Vikings is the only option, guarantee) that the player or AI faction will be a VE Vikings faction.

If the player or AI is a "Civil Neolithic" and you patched VE Medieval as a Civil Medieval faction, then the AI or player faction could manifest as a VE Medieval faction.

Civilized Nation is designed to parse an unlimited number of factions. Your patch is all that is needed.

Mod link

This guide was created by its original author on the Steam Community. Are you the author and want it removed? Request removal.