Contribute on GitHub

Weapon Smithing & Crafting Pieces

Introduction

The Smithing screen allows for the creation of all melee and throwing weapons in the game (swords, daggers, throwing knives, throwing axes, maces, polearms, pikes, javelins).

Picture 1: Fine Steel Cavalry Broadsword being created on Smithing screen.

Adding Weapons to the Smithing System

To be able to create a weapon on the Smithing screen, all the individual weapon parts need to be exported to the game separately. You can find out how to export assets to the editor on ASSET MANAGEMENT. After the meshes are added to the editor, the mesh name and measurements specific to the added weapon part need to be put into the relevant XML document. Adding weapon parts is explained below by giving sword and dagger parts as examples (other weapon parts can be added to the editor using the same process).

Swords And Daggers

Five parts are needed to create a sword (similar to daggers). Those are the blade, guard, grip, pommel and optionally scabbard. All meshes’ pivot points need to be at the numeric centre of the object and the position of the object needs to be at the world origin (Picture 2, Picture 3). This way we can export all the parts in a single FBX file or export each part individually using separate FBX files. For example, we export all of the sword blades in a single FBX file. Other parts are also exported together to their respective FBX files (guards, grips, pommels, scabbards). (Picture 4)

Picture 2: Example, battania_grip_1 mesh in Blender viewport before exporting.

Picture 3: All weapon parts positioned neatly at the world origin.

Picture 4: Sword parts directory hierarchy.

CraftingPieces XmlNode Example

<CraftingPieces>
  <CraftingPiece id="empire_blade_3"
                 name="{=kuROzU1J}Simple Warsword Blade"
                 tier="1"
                 piece_type="Blade"
                 mesh="empire_blade_3"
                 culture="Culture.empire"
                 length="91.3"
                 weight="0.93"
                 is_default="true">
    <BuildData previous_piece_offset="-0.4" />
    <BladeData stack_amount="3"
               physics_material="metal_weapon"
               body_name="bo_sword_one_handed"
               holster_mesh="empire_blade_3_scabbard_3">
      <Thrust damage_type="Pierce"
              damage_factor="2.4" />
      <Swing damage_type="Cut"
             damage_factor="2.8" />
    </BladeData>
    <Flags>
      <Flag name="Civilian"
            type="ItemFlags" />
    </Flags>
    <Materials>
      <Material id="Iron2"
                count="3" />
    </Materials>
  </CraftingPiece>
</CraftingPieces>
CraftingPieces/CraftingPiece Node

When a crafting piece is created the following pieces of information should be defined.

CraftingPieces/CraftingPiece/BuildData Node
CraftingPieces/CraftingPiece/Materials/Material Node

Material sets the required number of materials needed to craft the piece. Materials are also used in the smelting formula. Results of the smelting can not be more than material count and can not result in materials that are not listed in the material list. (Current formula in Bannerlord generates 1 lesser quality material of the highest material defined) Multiple materials can be set for specific items. A sword guard might require 3 counts of Iron2 and 1 count of Iron4.

CraftingPieces/CraftingPiece/Flags/Flag Node

Flags are used for defining different properties that allow crafted items to have different features. There are two different variables when a flag needs to be set;

name: References to the “ItemFlags” or “WeaponFlags”.

type: “ItemFlags” or “WeaponFlags”. WeaponFlags is the default if omitted.

CraftingTemplates XmlNode Example

<CraftingTemplates>

  <CraftingTemplate id="OneHandedSword"
                    item_modifier_group="sword"
                    item_holsters="sword_left_hip_3:sword_left_hip:sword_left_hip_2:sword_back"
                    piece_type_to_scale_holster_with="Blade"
                    hidden_piece_types_on_holster="Blade"
                    default_item_holster_position_offset="0,0,-0.1">
    <PieceDatas>
      <PieceData piece_type="Handle"
                 build_order="0" />
      <PieceData piece_type="Guard"
                 build_order="1" />
      <PieceData piece_type="Blade"
                 build_order="2" />
      <PieceData piece_type="Pommel"
                 build_order="-1" />
    </PieceDatas>
    <WeaponDescriptions>
      <WeaponDescription id="OneHandedSword" />
    </WeaponDescriptions>
    <StatsData>
      <StatData stat_type="Weight"
                max_value="7.0" />
      <StatData stat_type="WeaponReach"
                max_value="300" />
      <StatData stat_type="ThrustSpeed"
                max_value="200" />
      <StatData stat_type="SwingSpeed"
                max_value="200" />
      <StatData stat_type="ThrustDamage"
                max_value="500" />
      <StatData stat_type="SwingDamage"
                max_value="500" />
      <StatData stat_type="Handling"
                max_value="200" />
      <!--<StatData stat_type="FollowUp" max_value="200" />-->
    </StatsData>
    <UsablePieces>
      <UsablePiece piece_id="empire_blade_1" />
      <UsablePiece piece_id="empire_noble_blade_1" />
      <UsablePiece piece_id="empire_noble_blade_2" />
      <UsablePiece piece_id="mp_vlandian_arming_sword_blade"
                   mp_piece="true" />
      <UsablePiece piece_id="mp_vlandian_arming_sword_guard"
                   mp_piece="true" />
    </UsablePieces>
  </CraftingTemplate>
</CraftingTemplates>
CraftingTemplates/CraftingTemplate Node

When generating a crafting template the following values must be defined.

For example both two handed maces and maces fall under the mace category here.

item_modifier_group="mace"
CraftingTemplates/CraftingTemplate/PieceDatas/PieceData Node

Defines which type of pieces can be used with the template and in which order they will be assembled.

CraftingTemplates/CraftingTemplate/WeaponDescriptions/WeaponDescription Node

A WeaponDescription is simply the primary usage or one of the alternative usages of a weapon. They are defined in weapon_descriptions.xml and referenced in the template.

CraftingTemplates/CraftingTemplate/StatsData Node

This is used for defining which basic stats for the weapon will be shown on the inventory or the crafting screen.

An example is given below;

<StatsData usage_data="Javelin">
    <StatData stat_type="Weight"
        max_value="7.0" />
    <StatData stat_type="WeaponReach"
        max_value="300" />
    <StatData stat_type="MissileDamage"
        max_value="500" />
    <StatData stat_type="MissileSpeed"
        max_value="200" />
    <StatData stat_type="Accuracy"
        max_value="100" />
    <StatData stat_type="StackAmount"
        max_value="5" />
</StatsData>
CraftingTemplates/CraftingTemplate/StatsData/StatData Node
CraftingTemplates/CraftingTemplate/UsablePieces/UsablePiece Node

Example: In order to enable spear_blade_7 as a javelin part, it must be listed under the “javelin” id. The same piece must also be listed on the weapon_descriptions.xml under the related part.

<UsablePiece piece_id="spear_blade_7" />

WeaponDescriptions XmlNode Example

<WeaponDescriptions>
  <WeaponDescription id="OneHandedSword"
                     weapon_class="OneHandedSword"
                     item_usage_features="onehanded:block:shield:swing:thrust">
    <WeaponFlags>
      <WeaponFlag value="MeleeWeapon"/>
    </WeaponFlags>
    <AvailablePieces>
      <AvailablePiece id="empire_blade_1"/>
      <AvailablePiece id="empire_noble_blade_1"/>
      <AvailablePiece id="empire_noble_blade_2"/>
      ...
    </AvailablePieces>
  </WeaponDescription>
</WeaponDescriptions>
WeaponDescriptions/WeaponDescription Node

A Weapon description is used for defining different usages and features. Defined parts listed under the crafting templates nodes must also be listed under the weapon_descriptions.xml to be used.

An example is listed below;

item_usage_features="onehanded:block:shield:swing:thrust">
WeaponDescriptions/WeaponDescription/WeaponFlags/WeaponFlag Node

Default WeaponFlags used for all weapons for the description.

WeaponDescriptions/WeaponDescription/AvailablePieces/AvailablePiece Node

List of available pieces.

Example: Adding crafting pieces to existing weapon templates via XML & XSLT

Example case: We have created 8 crafting pieces suitable for one handed swords with the following mesh names in the .fbx files:

We have also created 4 crafting pieces suitable for two handed swords:

We haven’t yet created our new module which is why we launched the Mount & Blade II: Bannerlord Modding Kit, opened the Editor, clicked on File->Create New Module, gave our module a name “OurModule” and clicked “Create”.

We have then added all of the meshes and materials to our module with the help of the editor. This requires more than just adding the source files to the AssetSources\element folder. The files then need to be exported to the game via the Resource browser and the module published.

Now, we want to do the necessary steps for these crafting pieces to appear in-game. We need to create a new XML file within our module:

We also need to modify the native Crafting_templates.xml and Weapon_descriptions.xml via XSLT. That’s why we need to create these 2 files within our module:

SubModule.xml

We also need to add the new XML & XSL files to our SubModule.xml:

<Xmls>
    <XmlNode>
        <XmlName id="CraftingPieces" path="custom_crafting_pieces"/>
        <IncludedGameTypes>
            <GameType value="Campaign"/>
            <GameType value="CampaignStoryMode"/>
        </IncludedGameTypes>
    </XmlNode>
    <XmlNode>                
        <XmlName id="CraftingTemplates" path="crafting_templates"/>
        <IncludedGameTypes>
            <GameType value="Campaign"/>
            <GameType value="CampaignStoryMode"/>
        </IncludedGameTypes>
    </XmlNode>
    <XmlNode>                
        <XmlName id="WeaponDescriptions" path="weapon_descriptions"/>
        <IncludedGameTypes>
            <GameType value="Campaign"/>
            <GameType value="CampaignStoryMode"/>
        </IncludedGameTypes>
    </XmlNode>              
</Xmls>
Custom_crafting_pieces.xml

Within the Custom_crafting_pieces.xml, we’ll add the 12 crafting pieces. We’ll also define all of the required properties of these pieces as explained in this document above.

<?xml version="1.0" encoding="utf-8"?>
<CraftingPieces>
  <!-- #Blades -->
  <CraftingPiece id="yourforumusername_blade_1"
                 name="{=}Cool Blade 1"
                 tier="1"
                 piece_type="Blade"
                 mesh="yourforumusername_blade_1"
                 culture="Culture.battania"
                 length="80.8"
                 weight="0.81">
    <BladeData physics_material="metal_weapon"
               body_name="bo_sword_one_handed"
               holster_mesh="yourforumusername_blade_scabbard_1">
      <Thrust damage_type="Pierce"
              damage_factor="3.1" />
      <Swing damage_type="Cut"
             damage_factor="4.1" />
    </BladeData>
    <Flags>
      <Flag name="Civilian"
            type="ItemFlags" />
    </Flags>
    <Materials>
      <Material id="Iron6"
                count="2" />
    </Materials>
  </CraftingPiece>
  <CraftingPiece id="yourforumusername_blade_2"
                 name="{=}Cool Blade 2"
                 tier="1"
                 piece_type="Blade"
                 mesh="yourforumusername_blade_2"
                 culture="Culture.battania"
                 length="80.8"
                 weight="1.5">
    <BladeData physics_material="metal_weapon"
               body_name="bo_sword_one_handed"
               holster_mesh="yourforumusername_blade_scabbard_2">
      <Thrust damage_type="Pierce"
              damage_factor="2.2" />
      <Swing damage_type="Cut"
             damage_factor="3.1" />
    </BladeData>
    <Flags>
      <Flag name="Civilian"
            type="ItemFlags" />
    </Flags>
    <Materials>
      <Material id="Iron3"
                count="3" />
    </Materials>
  </CraftingPiece>
  <CraftingPiece id="yourforumusername_blade_3"
                 name="{=}Cool Blade 3"
                 tier="2"
                 piece_type="Blade"
                 mesh="yourforumusername_blade_3"
                 culture="Culture.battania"
                 length="80.8"
                 weight="1.5">
    <BladeData physics_material="metal_weapon"
               body_name="bo_sword_one_handed"
               holster_mesh="yourforumusername_blade_scabbard_3">
      <Thrust damage_type="Pierce"
              damage_factor="2.2" />
      <Swing damage_type="Cut"
             damage_factor="3.1" />
    </BladeData>
    <Flags>
      <Flag name="Civilian"
            type="ItemFlags" />
    </Flags>
    <Materials>
      <Material id="Iron3"
                count="3" />
    </Materials>
  </CraftingPiece>
  <!-- #Guards -->
  <CraftingPiece id="yourforumusername_guard_1"
                 name="{=}Cool Guard 1"
                 tier="1"
                 piece_type="Guard"
                 mesh="yourforumusername_guard_1"
                 culture="Culture.battania"
                 length="5.3"
                 weight="0.097">
    <BuildData next_piece_offset="1.8" />
    <StatContributions armor_bonus="3" />
    <Materials>
      <Material id="Iron5"
                count="1" />
    </Materials>
  </CraftingPiece>
  <CraftingPiece id="yourforumusername_guard_2"
                 name="{=}Cool Guard 2"
                 tier="1"
                 piece_type="Guard"
                 mesh="yourforumusername_guard_2"
                 culture="Culture.battania"
                 length="5.7"
                 weight="0.300">
    <BuildData next_piece_offset="1.8" />
    <StatContributions armor_bonus="3" />
    <Materials>
      <Material id="Iron1"
                count="1" />
    </Materials>
  </CraftingPiece>
  <CraftingPiece id="yourforumusername_guard_3"
                 name="{=}Cool Guard 3"
                 tier="1"
                 piece_type="Guard"
                 mesh="yourforumusername_guard_3"
                 culture="Culture.battania"
                 length="2.6"
                 weight="0.086">
    <BuildData next_piece_offset="0.3" />
    <StatContributions armor_bonus="1" />
    <Materials>
      <Material id="Iron1"
                count="1" />
    </Materials>
  </CraftingPiece>
  <!-- #Grips -->
  <CraftingPiece id="yourforumusername_grip_1"
                 name="{=}Cool Grip 1"
                 tier="1"
                 piece_type="Handle"
                 mesh="yourforumusername_grip_1"
                 culture="Culture.battania"
                 length="19.17"
                 weight="0.225"
                 item_holster_pos_shift="0,0,-0.03">
    <BuildData piece_offset="-1.88"
               previous_piece_offset="0.1"
               next_piece_offset="0.1" />
    <Materials>
      <Material id="Iron5"
                count="2" />
    </Materials>
  </CraftingPiece>
  <CraftingPiece id="yourforumusername_grip_2"
                 name="{=}Cool Grip 2"
                 tier="1"
                 piece_type="Handle"
                 mesh="yourforumusername_grip_2"
                 culture="Culture.aserai"
                 length="19.855"
                 weight="0.165">
    <BuildData piece_offset="-2.18"
               previous_piece_offset="0.2"
               next_piece_offset="0.2" />
    <Materials>
      <Material id="Iron2"
                count="3" />
    </Materials>
  </CraftingPiece>
  <CraftingPiece id="yourforumusername_grip_3"
                 name="{=}Cool Grip 3"
                 tier="2"
                 piece_type="Handle"
                 mesh="yourforumusername_grip_3"
                 culture="Culture.sturgia"
                 length="29.4"
                 weight="0.1">
    <BuildData piece_offset="-9.9"
               next_piece_offset="0.1"
               previous_piece_offset="0.3" />
    <Materials>
      <Material id="Iron2"
                count="2" />
    </Materials>
  </CraftingPiece>
  <!-- #Pommels -->
  <CraftingPiece id="yourforumusername_pommel_1"
                 name="{=}Cool Pommel 1"
                 tier="1"
                 piece_type="Pommel"
                 mesh="yourforumusername_pommel_1"
                 culture="Culture.battania"
                 length="2.5"
                 weight="0.14">
    <Materials>
      <Material id="Iron5"
                count="1" />
    </Materials>
  </CraftingPiece>
  <CraftingPiece id="yourforumusername_pommel_2"
                 name="{=}Cool Pommel 2"
                 tier="1"
                 piece_type="Pommel"
                 mesh="yourforumusername_pommel_2"
                 culture="Culture.battania"
                 length="4.027"
                 weight="0.12">
    <Materials>
      <Material id="Iron2"
                count="1" />
    </Materials>
  </CraftingPiece>
  <CraftingPiece id="yourforumusername_pommel_3"
                 name="{=}Cool Pommel 3"
                 tier="2"
                 piece_type="Pommel"
                 mesh="yourforumusername_pommel_3"
                 culture="Culture.sturgia"
                 length="3.76"
                 weight="0.15">
    <Materials>
      <Material id="Iron2"
                count="1" />
    </Materials>
  </CraftingPiece>
</CraftingPieces>
Crafting_templates.xsl

Now, we need to add the crafting pieces to the Crafting_templates.xsl:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <xsl:output omit-xml-declaration="yes"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="CraftingTemplate[@id='OneHandedSword']/UsablePieces/UsablePiece[1]">
        <UsablePiece piece_id="yourforumusername_blade_1"/>
        <UsablePiece piece_id="yourforumusername_blade_2"/>
        <UsablePiece piece_id="yourforumusername_guard_1"/>
        <UsablePiece piece_id="yourforumusername_guard_2"/>
        <UsablePiece piece_id="yourforumusername_grip_1"/>
        <UsablePiece piece_id="yourforumusername_grip_2"/>
        <UsablePiece piece_id="yourforumusername_pommel_1"/>
        <UsablePiece piece_id="yourforumusername_pommel_2"/>
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

<xsl:template match="CraftingTemplate[@id='TwoHandedSword']/UsablePieces/UsablePiece[1]">
        <UsablePiece piece_id="yourforumusername_blade_3"/>
        <UsablePiece piece_id="yourforumusername_guard_3"/>
        <UsablePiece piece_id="yourforumusername_grip_3"/>
        <UsablePiece piece_id="yourforumusername_pommel_3"/>
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
</xsl:stylesheet>

The above XSLT code modifies the two native crafting templates “OneHandedSword” and “TwoHandedSword”. The use of XSLT is required in order to modify the existing templates. If we were to add a new template, for example “Firearms”, the use of XSLT wouldn’t be required. Instead, we could simply create a new custom_crafting_templates.xml and add the new template there.

Weapon_descriptions.xsl

We also need to modify the Weapon_descriptions.xsl with the following:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
    <xsl:output omit-xml-declaration="yes"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
    <xsl:template match="WeaponDescription[@id='OneHandedSword']/AvailablePieces/AvailablePiece[1]">
        <AvailablePiece id="yourforumusername_blade_1"/>
        <AvailablePiece id="yourforumusername_blade_2"/>
        <AvailablePiece id="yourforumusername_guard_1"/>
        <AvailablePiece id="yourforumusername_guard_2"/>
        <AvailablePiece id="yourforumusername_grip_1"/>
        <AvailablePiece id="yourforumusername_grip_2"/>
        <AvailablePiece id="yourforumusername_pommel_1"/>
        <AvailablePiece id="yourforumusername_pommel_2"/>
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

<xsl:template match="WeaponDescription[@id='TwoHandedSword']/AvailablePieces/AvailablePiece[1]">
        <AvailablePiece id="yourforumusername_blade_3"/>
        <AvailablePiece id="yourforumusername_guard_3"/>
        <AvailablePiece id="yourforumusername_grip_3"/>
        <AvailablePiece id="yourforumusername_pommel_3"/>
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    
</xsl:stylesheet>

That’s it. Our crafting pieces will now show up on the crafting screen in-game.

Example Mod Download

If you would like to download the example module presented above click here.