Anyone able to tell me why my simple mod doesnt work?

Users who are viewing this thread

Whall

Recruit
Any idea why my submodule is causing weapons to be tagged with multiple copies of the same type? For example a couch lance will have 2 in game tags of couch lance and 2 tags of twohanded.

I have disabled all mods, started a new game, replaced all info on the custom modules with unmodded game data (instead of custom weapons, it actually loads the vanilla weapons). The only thing active is this submodule and it messes up lots of weapon tags.

Code:
<?xml version="1.0" encoding="utf-8"?>
 <Module>
     <Name value="Thamaskene Glaive"/>
     <Id value="Thamaskene Glaive"/>
     <Version value="v1.0.0"/>
     <SingleplayerModule value="true"/>
     <MultiplayerModule value="false"/>
     <DependedModules>
         <DependedModule Id="Native"/>
         <DependedModule Id="SandBoxCore"/>
         <DependedModule Id="Sandbox"/>
         <DependedModule Id="CustomBattle"/>
         <DependedModule Id="StoryMode" />
    </DependedModules>
    <SubModules/>
    <Xmls>
        <XmlNode>               
            <XmlName id="Items" path="customitems"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
        <XmlNode>               
            <XmlName id="CraftingTemplates" path="customcraftingtemplates"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
        <XmlNode>               
            <XmlName id="WeaponDescriptions" path="customweapondescriptions"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
        <XmlNode>               
            <XmlName id="CraftingPieces" path="customcraftingpieces"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
    </Xmls>
</Module>
 
Last edited:
Any idea why my submodule is causing weapons to be tagged with multiple copies of the same type? For example a couch lance will have 2 in game tags of couch lance and 2 tags of twohanded.

I have disabled all mods, started a new game, replaced all info on the custom modules with unmodded game data (instead of custom weapons, it actually loads the vanilla weapons). The only thing active is this submodule and it messes up lots of weapon tags.

Code:
<?xml version="1.0" encoding="utf-8"?>
 <Module>
     <Name value="Thamaskene Glaive"/>
     <Id value="Thamaskene Glaive"/>
     <Version value="v1.0.0"/>
     <SingleplayerModule value="true"/>
     <MultiplayerModule value="false"/>
     <DependedModules>
         <DependedModule Id="Native"/>
         <DependedModule Id="SandBoxCore"/>
         <DependedModule Id="Sandbox"/>
         <DependedModule Id="CustomBattle"/>
         <DependedModule Id="StoryMode" />
    </DependedModules>
    <SubModules/>
    <Xmls>
        <XmlNode>           
            <XmlName id="Items" path="customitems"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
        <XmlNode>           
            <XmlName id="CraftingTemplates" path="customcraftingtemplates"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
        <XmlNode>           
            <XmlName id="WeaponDescriptions" path="customweapondescriptions"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
        <XmlNode>           
            <XmlName id="CraftingPieces" path="customcraftingpieces"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
    </Xmls>
</Module>
SubModule.xml expects an xml to add new custom elements. You are adding vanilla weapons to BL’s existing vanilla weapons. If you want to over-ride BL’s original weapons (as opposed to just adding to them), you also need to use xslt to remove those you are overriding.

The settlements example xslt wipes out everything in vanilla settlements.xml. To understand how to over-ride individual elements (albeit troops rather than weapons) with xslt you could look here
https://forums.taleworlds.com/index...r-troop-override-question.454053/post-9828306
 
Last edited:
SubModule.xml expects an xml to add new custom elements. You are adding vanilla weapons to BL’s existing vanilla weapons. If you want to over-ride BL’s original weapons (as opposed to just adding to them), you also need to use xslt to remove those you are overriding.

The settlements example xslt wipes out everything in vanilla settlements.xml. To understand how to over-ride individual elements (albeit troops rather than weapons) with xslt you could look here
https://forums.taleworlds.com/index...r-troop-override-question.454053/post-9828306
Hey thanks for the reply. Sorry I am new to modding. Just to clarify, if I am trying to add a single weapon without removing or changing any existing weapons, is the above mention still the solution?

The weapon that I am trying to add is using 3 existing crafting pieces with the 4th piece being an reskin of existing piece, using all existing assets. I copied and existing craftingpiece, changed the mesh to an existing mesh, and renamed the piece. Maybe there is a better way to create the mod, than the way I am trying?

I created a customitems, customcraftingpieces, customcraftingtemplates, and customweapondesription. I named and added the skinned part to everything. Built the weapon in customitems. But I have 2 problems.

The original problem with the submodule messing up weapon tags. My second problem is my 4 customxmls. If I attempt to add only my custom data it crashes on launch. If I copy the existing items, craftingpieces, craftingtemplates, and weapondesription with my data added to them it doesn't crash. But it doesn't seem like I should need to include all existing data in the mod.
 
I have narrowed down my second problem. My submodule trying to load this below, causes the game to crash.
Code:
        <XmlNode>               
            <XmlName id="CraftingTemplates" path="customcraftingtemplates2"/>
            <IncludedGameTypes>
                <GameType value = "Campaign"/>
                <GameType value = "CampaignStoryMode"/>
                <GameType value = "CustomGame"/>
            </IncludedGameTypes>
        </XmlNode>
 
You only need to include your additional items, if they are complete elements such as everything between the opening <Item and closing </Item>. However, they must be included in the correct formats - xmls don’t forgive errors or omissions. Check your rgl.log in C:\ProgramData\Mount and Blade II Bannerlord\logs just in case it gives a clue as to the error. They generally aren’t very helpful.

CraftingTemplates need an xslt override as you will be adding your UsablePieces inside existing vanilla CraftingTemplates such as OneHandedSword. Unless you make a new CraftingTemplate only for your weapon - say id=“my_onehanded_sword” (ids must be unique).
 
Last edited:
Ok thanks for the help. I might have problems down the road but I have managed to get it to work. I created a customitems.xml that added my item and custompieces.xml that added my reskinned piece. With those 2 I only had to add the piece or item like this.
Code:
<?xml version="1.0" encoding="utf-8"?>
<Items>
    <CraftedItem
        id="khuzait_polearm_3_t5"
        name="{=6hwZw00p}Thamaskene Glaive"
        crafting_template="TwoHandedPolearm"
        culture="Culture.khuzait"
        modifier_group="polearm">
        <Pieces>
            <Piece
                id="spear_blade_46"
                Type="Blade"
                scale_factor="98" />
            <Piece
                id="spear_guard_4"
                Type="Guard"
                scale_factor="106" />
            <Piece
                id="spear_handle_15"
                Type="Handle"
                scale_factor="98" />
            <Piece
                id="spear_pommel_9"
                Type="Pommel"
                scale_factor="110" />
        </Pieces>
    </CraftedItem>
</Items>

But for the customweapontemplate.xml and customweapondescription.xml I had create a copy of the existing weapontemplate.xml and copy of the existing weapondescription.xml. Then i had to add my usablepiece to the complete list. (So on these 2 xmls, it wasnt enough to only add my usablepiece, I had to include it with ALL usablepieces.

So do I need an xslt to override the entire 2 list except for my new usablepiece, correct?
 
Is this what it is supposed to look like or does every vanilla template need to be listed on here? Also would the 2 xslts just go in the moduledata folder with everything else?
Code:
<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="craftingtemplates"/>
</xsl:stylesheet>
 
Is this what it is supposed to look like or does every vanilla template need to be listed on here? Also would the 2 xslts just go in the moduledata folder with everything else?
Code:
<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="craftingtemplates"/>
</xsl:stylesheet>
Almost. AFAIK it should be:

<xsl:template match=“CraftingTemplate”/>

The match is to each CraftingTemplate within CraftingTemplates, so, singular as opposed to plural and ids are case sensitive so can’t just be lower case letters.

That should delete all vanilla CraftingTemplates, so, you’d need to reinstate those unchanged, which is fairly heavy handed. Once you’ve got it to work, you might consider a more targeted xslt. Something like the following xslt should only delete the vanilla CraftingTemplate for TwoHandedPolearm
XML:
<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='TwoHandedPolearm']"/>



</xsl:stylesheet>

Xslt are also capable of editing sub-elements, but they don’t always work in the context of Bannerlord’s codebase.
 
Last edited:
Back
Top Bottom