Use this file to discover all available pages before exploring further.
This guide covers how to create leader-civilization associations and work with age-specific content using the Civilization VII TypeScript Modding Tools.
In Civilization VII, the TypeScript Modding Tools primarily support associating existing game leaders with civilizations rather than creating entirely new leaders. The toolkit provides the LeaderUnlockBuilder class for this purpose.
import { ACTION_GROUP_BUNDLE, CivilizationUnlockBuilder, LeaderUnlockBuilder, Mod, AGE} from "civ7-modding-tools";const mod = new Mod({ id: 'my-leader-mod', version: '1.0',});// Define a leader-civilization unlock// This associates an existing game leader with your custom civilizationconst decebalusLeadsDacia = new LeaderUnlockBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, // Define the association leaderUnlock: { leaderType: 'LEADER_DECEBALUS', // An existing leader type: 'CIVILIZATION_DACIA', // Your custom civilization ageType: AGE.ANTIQUITY, }, // AI leader preference for this civilization leaderCivilizationBias: { bias: 10, // Higher bias = more likely to be chosen by AI }, // Tooltip text that appears in the leader selection screen localizations: [{ tooltip: `[B]Decebalus[/B] ruled [B]Dacia[/B].` }]});// Add to modmod.add([decebalusLeadsDacia]);
You can also define civilization transitions between Ages:
// Create a civilization unlock for Age transitionsconst daciaTransitionsToRome = new CivilizationUnlockBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_EXPLORATION, // Define which civilization transitions to what from: { civilizationType: 'CIVILIZATION_DACIA', ageType: AGE.ANTIQUITY, }, to: { civilizationType: 'CIVILIZATION_ROME', ageType: AGE.EXPLORATION, },});// Add to modmod.add([daciaTransitionsToRome]);
To create entirely new leaders (rather than just associating existing ones), you’ll need to use direct XML manipulation, as the toolkit doesn’t provide a dedicated LeaderBuilder class. Here’s how to approach this:
Create XML Files Directly: Define leaders using the database schema structure
Import XML Files: Use ImportFileBuilder to include your custom XML files
For example:
import { ACTION_GROUP_BUNDLE, ACTION_GROUP_ACTION, ImportFileBuilder, Mod} from "civ7-modding-tools";const mod = new Mod({ id: 'my-custom-leader-mod', version: '1.0',});// Create leader XML contentconst leaderXML = `<?xml version="1.0" encoding="utf-8"?><Database> {/*Define Leader Type*/} <Types> <Row Type="LEADER_YOUR_LEADER" Kind="KIND_LEADER"/> </Types> {/*Basic Leader Definition*/} <Leaders> <Row LeaderType="LEADER_YOUR_LEADER" Name="LOC_LEADER_YOUR_LEADER_NAME" InheritFrom="LEADER_DEFAULT" Description="LOC_LEADER_YOUR_LEADER_DESCRIPTION"/> </Leaders> {/*Leader Traits*/} <LeaderTraits> <Row LeaderType="LEADER_YOUR_LEADER" TraitType="TRAIT_LEADER_YOUR_ABILITY"/> </LeaderTraits></Database>`;// Import the leader XML fileconst leaderDefinition = new ImportFileBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, content: leaderXML, name: 'leaders/your_leader.xml', actionGroupActions: [ACTION_GROUP_ACTION.UPDATE_DATABASE]});// Add to modmod.add([leaderDefinition]);
Similar to civilizations, you can define how leaders transition between Ages:
import { ACTION_GROUP_BUNDLE, LeaderUnlockBuilder, Mod, AGE} from "civ7-modding-tools";const mod = new Mod({ id: 'my-leader-transition-mod', version: '1.0',});// Define how a leader should transform in a new Ageconst decebalusToTrajan = new LeaderUnlockBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_EXPLORATION, leaderUnlock: { leaderType: 'LEADER_TRAJAN', // New leader for new Age type: 'CIVILIZATION_ROME', // New civilization ageType: AGE.EXPLORATION, // New Age fromLeaderType: 'LEADER_DECEBALUS', // Previous leader fromAgeType: AGE.ANTIQUITY // Previous Age }, localizations: [{ tooltip: `As Rome conquered Dacia, [B]Trajan[/B] now rules the [B]Roman[/B] empire.` }]});// Add to modmod.add([decebalusToTrajan]);