Mount & Blade II: Bannerlord

In this article I will describe a detailed, step by step way to quickly add many items to an armoury. It may seem overkill for few items, but for anything over 50 items this will be godsend, I promise.
Our goal is to add new Aserai Helmets to Aserai armouries. Currently, there's only one way to put items to the armoury.

-----

0. Setup
I recommend using a text file such as Sublime Text for it's ability to:
- find strings with Regular Expressions
- select and write in multiple rows.
However nothing is stopping you from using other text editor with similar functionality, or doing everything by hand.

1. Get item IDs
Let's say we have the following item definition XML:
<?xml version="1.0" encoding="utf-8"?>
<Items>
<Item id="aserai_helmet" name="Aserai Helmet" subtype="head_armor" mesh="aserai_helmet_model" culture="Culture.aserai" weight="3" difficulty="0" appearance="1" value="45000" Type="HeadArmor">
<ItemComponent>
<Armor head_armor="0" has_gender_variations="true" hair_cover_type="all" modifier_group="plate" material_type="Plate" beard_cover_type="all" />
</ItemComponent>
<Flags Civilian="true" />
</Item>
<Item id="aserai_helmet_2" name="Aserai Helmet Two" subtype="head_armor" mesh="aserai_helmet_2_model" culture="Culture.aserai" weight="3" difficulty="0" appearance="1" value="45000" Type="HeadArmor">
<ItemComponent>
<Armor head_armor="0" has_gender_variations="true" hair_cover_type="all" modifier_group="plate" material_type="Plate" beard_cover_type="all" />
</ItemComponent>
<Flags Civilian="true" />
</Item>
</Items>

This kind of XML file is likely placed in ModuleData directory of your mod. Use the following regular expression to extract all item IDs:
(id="[\w]+")
In Sublime Text, press Ctrl+F (to open "find" panel) and then Alt+R (to enable RegEx). Paste the above RegEx. Press "Find All" button to the right. Press Ctrl+C and create a new file. Paste the IDs there.
Press Ctrl+Shift+F, disable RegEx if it's enabled (Alt+R). Fill the fields like this (exactly as it says):
Find: id
Where: <current file>
Replace: name
Press Replace button to the right. Accept.

2. Create your armoury XML
After you packaged your mod for release, make sure it has a directory tree like this:
Modules\VsRoyalArmoryRewritten\bin\Win64_Shipping_Client\Mods
Create a new file in this directory with any name you wish. It has to have .xml extension. In this example we will name it AseraiHelmet.xml.
Fill your XML like this:
<Settings>
<Aserai>

</Aserai>
</Settings>

You can also replace Aserai with Any - it will result in these items appearing in every armoury in the game.

3. Add items
Between <Aserai> and </Aserai>, paste your item IDs so it looks like this:

<Settings>
<Aserai>
name="aserai_helmet"
name="aserai_helmet_2"
</Aserai>
</Settings>

Select the two newly added name="..."  entries and press Ctrl+Shift+L. Press Home (on your keyboard) to move to beginning of each line. Begin typing:
<Item

Press End (on your keyboard). Begin typing again:
minCount="1" maxCount="4" />

If everything went well, it should now look like this:
<Settings>
 <Aserai>
<Item name="aserai_helmet" minCount="1" maxCount="4" />
<Item name="aserai_helmet_2" minCount="1" maxCount="4" />
</Aserai>
</Settings>


Save the file and check in-game. The Aserai armouries should have both items available for sale.

Article information

Added on

Edited on

Written by

noafk9

0 comments