Beginner Course – Phase 1: Editing Troop Trees
Lesson 2: Creating and Modifying a Troop
Objective:
By the end of this lesson, you will be able to:
-
Duplicate an existing troop definition safely.
-
Assign a unique id to avoid conflicts.
-
Customize skills, equipment, name, and upgrade paths.
-
Add your custom troop to the existing troop tree.
-
Prepare the file for testing in-game.
!!Always Make a Backup First!!
Before you edit any game file:
-
Navigate to:
Mount & Blade II Bannerlord\Modules\SandBoxCore\ModuleData\
Find spnpccharacters.xml. -
Copy and paste it somewhere else outside the game folders as a backup:
spnpccharacters_backup.xml
Choose a Template Troop
Start by opening spnpccharacters.xml in your text editor (Notepad++ or VS Code).
Use the search function (Ctrl + F) to locate a basic troop. For example:
​
id="imperial_recruit"
This will bring you to the full <NPCCharacter> block. Read it carefully and identify:
-
The troop's name
-
Skills
-
Equipment
-
Upgrade targets
This unit will serve as your base template.
Copy the whole troop information, starting from <NpcCharacter... until </NPCCharacter>
Paste it right below the one you copied from (imperial recruit) for easy reference.
Change the ID
As we learend previously, the id is its unqiue indentifier and ensures that it is a unique troop
and not a duplicate. Make a unique exclusive id for it. (not found in any other part of the game). For this exercise use the following:
mymod_imperial_recruit_v2
Change the Name
Update the name attribute to reflect your new troop. You can use localization syntax or plain text:
​
name="{=MyRecruitNameID}Imperial Recruit Veteran"
Or just:
​
name="Imperial Recruit Veteran"
If you use the {=...} format, ensure the key (MyRecruitName) is unique.
Adjust Attributes
Example edits:
​
level="11" ← Higher tier than original
occupation "Soldier" ← Keep this for regular troops culture="Culture.empire" ← Keep or change if you want it tied to a different faction
is_basic_troop="false" ← This is no longer the base recruit
Edit Skills
Modify the skills to reflect the troop’s purpose:
​
<skills>
<skill id="OneHanded" value="30" />
<skill id="Polearm" value="10" />
<skill id="Athletics" value="25" />
</skills>
A troop with stronger skills than the original should also have a higher level and better gear.
Edit Equipment
Adjust the <Equipments> section with new gear:
​
<Equipments>
<EquipmentRoster>
<equipment slot="Item0" id="Item.empire_sword_1_t2" /> <equipment slot="Head" id="Item.leather_cap" />
<equipment slot="Body" id="Item.studded_leather" /> <equipment slot="Leg" id="Item.empire_horseman_boots" />
</EquipmentRoster>
</Equipments>
You can find valid item IDs by browsing Items folder or copying from other troops. Inside the items folder will will find the equipment itens divided into:
. arm_armors.xml
. body_armors.xml
. head_armors.xml
. horses_and_others.xml
. legs_armors.xml
. shields.xml
. shoulder_armors.xml
. weapons.xml
use those to retrieve your tems to copy/paste on your custom troops. COPY THE IDS ONLY!
Set or Remove Upgrade Targets
If this is a mid-tier troop, you should give it an upgrade target.
​
<upgrade_targets>
<upgrade_target id="NPCCharacter.imperial_legionary" /> </upgrade_targets>
If it's a final-tier unit, simply remove the entire <upgrade_targets> block.
Update the Parent Troop’s Upgrade Targets
This is how you insert your troop into the troop tree.
Find the troop you want to upgrade into your custom troop. For example, if your new unit is a stronger recruit, go to:
​
id="imperial_recruit"
Then edit its upgrade_targets like this:
​
<upgrade_targets>
<upgrade_target id="NPCCharacter.imperial_infantryman" />
<upgrade_target id="NPCCharacter.mymod_imperial_recruit_v2" />
</upgrade_targets>
Now your new troop will show up as an upgrade option in-game.
XML Example:
(some equipment roster entrances have bee removed for the sake of this example)
<NPCCharacter
id="imperial_recruit"
default_group="Infantry"
level="6"
name="{=s3IJIFUw}Imperial Recruit"
occupation="Soldier"
is_basic_troop="true"
culture="Culture.empire">
<face>
<face_key_template
value="BodyProperty.fighter_empire" />
</face>
<skills>
<skill
id="Athletics"
value="20" />
<skill
id="Riding"
value="0" />
<skill
id="OneHanded"
value="20" />
<skill
id="TwoHanded"
value="10" />
<skill
id="Polearm"
value="20" />
<skill
id="Bow"
value="5" />
<skill
id="Crossbow"
value="5" />
<skill
id="Throwing"
value="10" />
</skills>
<upgrade_targets>
<upgrade_target
id="NPCCharacter.imperial_infantryman" />
<upgrade_target
id="NPCCharacter.imperial_archer" />
</upgrade_targets>
<Equipments>
<EquipmentRoster>
<equipment
slot="Item0"
id="Item.peasant_pitchfork_2_t1" />
<equipment
slot="Head"
id="Item.leather_cap" />
<equipment
slot="Body"
id="Item.tunic_with_shoulder_pads" />
<equipment
slot="Leg"
id="Item.empire_horseman_boots" />
</EquipmentRoster>
<EquipmentSet
id="empire_troop_civilian_template_t1"
civilian="true" />
</Equipments>
</NPCCharacter>
Example modified troop
<NPCCharacter
id="mymod_imperial_footman_trainee"
name="Imperial Footman Trainee"
level="9"
occupation="Soldier"
culture="Culture.empire">
<face>
<face_key_template value="BodyProperty.fighter_empire" />
</face>
<skills>
<skill id="OneHanded" value="30" />
<skill id="Polearm" value="15" />
<skill id="Athletics" value="25" />
<skill id="Throwing" value="10" />
</skills>
<upgrade_targets>
<upgrade_target id="NPCCharacter.imperial_infantryman" />
</upgrade_targets>
<Equipments>
<EquipmentRoster>
<equipment slot="Item0" id="Item.empire_sword_1_t2" />
<equipment slot="Head" id="Item.leather_cap" />
<equipment slot="Body" id="Item.studded_leather" />
<equipment slot="Leg" id="Item.empire_horseman_boots" />
<equipment slot="Gloves" id="Item.leather_gloves" />
</EquipmentRoster>
</Equipments>
</NPCCharacter>
Save and Validate
-
Save the XML file.
-
Use an online validator like xmlvalidation.com to paste the content and check for syntax errors.
-
Fix issues like:
-
Missing closing tags (</NPCCharacter>)
-
Invalid quotes
-
Mismatched tags
Test in Game
-
Enable Cheats:
-
Navigate to Documents\Mount and Blade II Bannerlord\Configs.
-
Open engine_config.txt.
-
Change cheat_mode=0 to cheat_mode=1.
Launch the game and start a sandbox campaign. -
Open the party screen and search for your new troop
-
(Add those troops to your party
-
Check:
-
Name
-
Skills
-
Equipment
-
Whether they can be upgraded correctly. Open and search for it inside the encyclopedia
-
Optional: Updating the Recruit’s Upgrade Targets
To make this new troop selectable in-game, edit the original imperial_recruit block to reference it:
​
<upgrade_targets>
<upgrade_target id="NPCCharacter.mymod_imperial_footman_trainee" />
<upgrade_target id="NPCCharacter.imperial_archer" />
</upgrade_targets>
This replaces the previous melee path with your custom unit while keeping the ranged branch.
Click to watch the basic troop edition video

Basic Troop Edition
Summary – Lesson 2: Creating and Modifying a Troop
In this lesson, you learned how to create a new troop for Bannerlord by duplicating and editing an existing troop entry in the spnpccharacters.xml file.
Key Concepts:
-
Safe Duplication:
You start by copying a complete <NPCCharacter> block as a template. -
Unique ID:
Every troop must have a unique id. This is critical to prevent conflicts and game errors. -
Custom Name and Attributes:
You can give your troop a new name, adjust its level, and set its culture, occupation, and is_basic_troop status based on your design goals. -
Skills and Equipment:
Troop performance is controlled by its skills and the gear it spawns with under <Equipments>. These should match the role and tier of the unit. -
Upgrade Paths:
Use <upgrade_targets> to define which troop(s) your new unit can upgrade into. This determines how it fits into the troop tree. -
Integrating into the Tree:
To make your new unit appear in the game, you must edit the previous troop (e.g., imperial_recruit) and add your unit's id to its <upgrade_targets>. -
Testing:
You validate your XML for errors, then use Bannerlord’s cheat console to spawn your troop and confirm its appearance, equipment, and upgrade path.
Exercises – Creating and Modifying a Troop
Now it is time to put your knowledge in practice by duplicating and editing existing troops entries in the spnpccharacters.xml file.
Exercise 1: Duplicate a Basic Troop
​
-
Open the spnpccharacters.xml file from one of the vanilla modules.
-
Find a basic troop (e.g., imperial_infantry_recruit).
-
Duplicate the entire <NPCCharacter> entry and place the copy just below the original.
-
Change the id to something like custom_infantry_recruit.
-
Edit the name, occupation, and default_group to give it a unique identity (e.g., make it a desert soldier)
Exercise 2: Modify Troop Equipment
-
In your duplicated troop, find the equipment you want to copy from any other troop and paste correctly inside the <Equipmentrosters> section.
-
Replace existing weapons or armor with different items from the game (you can find any reference items inside sandboxcore/items/ weapons.xml and shields.xml).
-
For example, give your new recruit a short bow instead of a sword and shield.
-
Test in-game to see if the equipment updates correctly.
Exercise 3: Change Troop Skills and Attributes
-
In the same duplicated troop entry, edit the <skills> sections.
-
Increase riding, archery, or any relevant skill depending on your troop concept.
-
Optional: Increase the troop level to reflect the new stats.
Exercise 4: Create a New Troop Line
-
Create two new troops: custom_infantry_soldier, and custom_infantry_veteran.
-
Connect them through the <upgrade_targets> field so that each one upgrades into the next. Connect the also the custom_infantry_soldier to the imperial_recruit to make it upgradable from it.
-
Make sure to balance their stats, equipment, and skills across the progression.
-
Test in-game to ensure the upgrade path works correctly.
