Documentation Coding Community Modding Documentation

Users who are viewing this thread

Aha, I found them lol. Under TaleWorlds.CampaignSystem there is a DefaultPolicies as well as DefaultClanPoliticsModel with some of the policy effects. So for example, if I wanted to add a new policy, I would add a new public static PolicyObject for myPolicy, override RegisterAll() to include myPolicy and register the object, then override the InitializeAll() to add myPolicy to the Policies list, correct? Or in this case, should I not be overriding and simply extend it? Not sure if the way the policies work if it only handles registering/initializing on a new campaign start.

I apologize if this is cluttering this thread, let me know if I need to post this somewhere else. Not sure where else we can ask modding questions as the documentation is very basic right now.
 
Hello, I'm trying to make a mod that will edit and add more policies to Kingdoms. So far, I haven't found any XML docs under ModuleData for any modules that would have that stuff so I'm guessing this will have to be a .dll mod. What method would I have to override in order to do this? Which .dll could I open up to see how the game currently does policies? The documentation is very basic right now so I have no idea what anything does when I open up a .dll aside from how to create a basic mod.
I think questions like these are best asked in a separate thread, you'll probably get better support by doing so as well.
 
I suggest in the sample documentation for basic C# project setup that you don't have them include ALL the TaleWorlds dlls by default but only the ones they will actually be using. Second and more importantly, in the documentation tell them to set Copy Local to false for all the taleworld dlls. I've seen a few mods now with all those dlls in their local Win64 folder and it's not needed (and likely a source of some problems).
 
Hello, i'm kinda noob
<XmlNode>
<XmlName type="1" id="NPCCharacters" path="customcharacters"/>
</XmlNode>
what is type?
what is id? Name of xml?
what is path? if xml is in ModuleData then how path should look?
 
I don't know
I don't know
the name of the native XML file you want to change
the path is the name of your xml file that is changing the id.
Code:
        <XmlNode>               
            <XmlName type="1" id="NPCCharacters" path="Rigalebandits"/>
        </XmlNode>
This for exampkle a part of my ModuleData
 
obviously im too bad at xlms, but can you help me?
<Module>
<Name value="dniwe"/>
<Id value="dniwe"/>
<Version value="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 type="1" id="managed_core_parameters" path="dniwe1"/>
<IncludedGameTypes>
<GameType value = "Campaign"/>
<GameType value = "CampaignStoryMode"/>
<GameType value = "CustomGame"/>
</IncludedGameTypes>
</XmlNode>
</Xmls>
</Module>
<?xml version="1.0" encoding="utf-8"?>

<managed_core_parameters>
<managed_core_parameter id="BipedalCombatSpeedMinMultiplier" value="1.2"/>
<managed_core_parameter id="BipedalCombatSpeedMaxMultiplier" value="1.35"/>

<managed_core_parameter id="DamageInterruptAttackthresholdPierce" value="30"/>
<managed_core_parameter id="DamageInterruptAttackthresholdCut" value="30"/>
<managed_core_parameter id="DamageInterruptAttackthresholdBlunt" value="10"/>

<managed_core_parameter id="SwingHitWithArmDamageMultiplier" value="0.05" />
<managed_core_parameter id="ThrustHitWithArmDamageMultiplier" value="0.05" />
<managed_core_parameter id="NonTipThrustHitDamageMultiplier" value="0.05" />

<!-- stun calc related -->
<managed_core_parameter id="StunPeriodAttackerSwing" value="4.2"/>
<managed_core_parameter id="StunPeriodAttackerThrust" value="7.2"/>
<managed_core_parameter id="StunDefendWeaponWeightOffsetShield" value="0.5"/>
<managed_core_parameter id="StunDefendWeaponWeightMultiplierWeaponWeight" value="0.25"/>
<managed_core_parameter id="StunDefendWeaponWeightBonusTwoHanded" value="0.35"/>
<managed_core_parameter id="StunDefendWeaponWeightBonusPolearm" value="0.45"/>

<managed_core_parameter id="StunMomentumTransferFactor" value="0.007"/>

<managed_core_parameter id="StunDefendWeaponWeightParryMultiplier" value="0.2"/>
<managed_core_parameter id="StunDefendWeaponWeightBonusRightStance" value="0.15"/>

<managed_core_parameter id="StunDefendWeaponWeightBonusActiveBlocked" value="0.4"/>
<managed_core_parameter id="StunDefendWeaponWeightBonusChamberBlocked" value="0.4"/>
<managed_core_parameter id="StunPeriodAttackerFriendlyFire" value="0.4"/>
<managed_core_parameter id="StunPeriodMax" value="10.6"/>

</managed_core_parameters>
 
Last edited:
Hello, i'm kinda noob

what is type?
what is id? Name of xml?
what is path? if xml is in ModuleData then how path should look?
id : id identify the semantic of a xml file, it tells bannerlord which type of data this xml file contains
path : file path of the xml without ".xml" suffix, relative to "ModuleData" folder of your mod
 
I'd love to help contribute to the C# docs! In regards to that, is the end-result to take all the TaleWorlds assemblies and amass them into one spot or are only certain assemblies being documented?
 
FYI:
This section doesn't work correctly. Once all steps are completed, the module is not visible inside the SinglePlayer > Mods pane when its launched.
(EDIT: I've corrected the "SubModule.xml" - It wasn't clear through the instructions that this file must be named SubModule.xml. It's worth adding this line in).

There is also no additional information on:
  • Inherit from the MBSubModuleBase class. The following shouldbe added to the tutorial:

    Code:
    class MySubModule : MBSubModuleBase

  • Setup an override for the OnSubModuleLoad() inherited method.
    The remaining steps really should be broken down to show the following code, and explaining what each contains.

    Code:
    using TaleWorlds.Core;
    using TaleWorlds.Localization;
    using TaleWorlds.MountAndBlade;
    
    namespace ExampleMod
    {
    class MySubModule : MBSubModuleBase
    {
    protected override void OnSubModuleLoad()
    {
    Module.CurrentModule.AddInitialStateOption(new InitialStateOption("Message",
    new TextObject("Message", null),
    9990,
    () => { InformationManager.DisplayMessage(new InformationMessage("Hello World!")); },
    false));
    }
    }
    }
As someone who hasn't modded M&B before, or compiled a C# project for a game, it's not very clear for a "basic" tutorial as to what is required to get started.

Regarding the debugging, my VisualStudio does not have the option under the debug tab:
Select the Start external program option and then browse for Bannerlord.exe located in the bin\Win64_Shipping_Client directory in your game files (not your module directory).
(EDIT 2: I've started another mod after completing the ExampleMod basic tutorial and found that there are several project versions. It might be advisable to state that they must choose a blank project, with c# using .NET Framework.)
 
Last edited:
Quick question. Do you have any idea how to override already existing [ViewMethod("XXX")] 's which is inside the [ViewCreatorModule]?
For overriding Views they have an Override check but not for ViewMethods I assume. Or I'm just missing something.

--

Regarding the debugging, my VisualStudio does not have the option under the debug tab:
Select the Start external program option and then browse for Bannerlord.exe located in the bin\Win64_Shipping_Client directory in your game files (not your module directory).
At left, right-click to your solution, click properties, then find the Debug tab. Or, top debug tab, yourprojectname's properties, then same stuff.
 
So basically, I noticed that some XML files can't seem to be edited; namely SPKingdoms and SPClans. I've tried a few others that work fine but these two don't work. I tried everything, no hope. Then I realized I can ADD new entries, but I can't replace an already existing ID.

Anyone have any idea why? Is this a bug that will be fixed?
 
Good evening, I would like to ask if it was possible to create a Languages folder and which parameters should be taken into consideration.
I saw that the Localization section is still empty so I asked if there was any news about it.
 
FYI:
This section doesn't work correctly. Once all steps are completed, the module is not visible inside the SinglePlayer > Mods pane when its launched.
(EDIT: I've corrected the "SubModule.xml" - It wasn't clear through the instructions that this file must be named SubModule.xml. It's worth adding this line in).

As someone who hasn't modded M&B before, or compiled a C# project for a game, it's not very clear for a "basic" tutorial as to what is required to get started.

Regarding the debugging, my VisualStudio does not have the option under the debug tab:
Select the Start external program option and then browse for Bannerlord.exe located in the bin\Win64_Shipping_Client directory in your game files (not your module directory).
(EDIT 2: I've started another mod after completing the ExampleMod basic tutorial and found that there are several project versions. It might be advisable to state that they must choose a blank project, with c# using .NET Framework.)
The tutorial/documentation is not meant to teach you C#. You should have a basic understanding of C# before attempting to do the tutorial (this is mentioned).

Regarding the SubModule.xml needing to be named such, the tutorial says in step 4:
Create a new `SubModule.xml` file inside the folder you created in Step #2
This should have been quite clear, but I will add a note of this anyway since you are the 2nd person to have this issue.

Next, regarding debugging, the tutorial says:
Open your project properties and go to the `Debug` tab.
This is the Debug tab in project properties, not the Debug tab for the main window.

Again, please learn basic C# before attempting any of this. If you've never even compiled a C# project before, I don't think modding a game is a good place to start. Try something basic, such as a Console app and familiarize yourself with the language and IDE. Then try modding the game.
 
Quick question. Do you have any idea how to override already existing [ViewMethod("XXX")] 's which is inside the [ViewCreatorModule]?
For overriding Views they have an Override check but not for ViewMethods I assume. Or I'm just missing something.
You can try using reflection to modify the ViewCreatorManager._viewCreators dictionary. If it's a SandBox ViewMethod, you may need to modify the SandBoxViewCreator._viewCreators dictionary instead. I would do this in your OnSubModuleLoad() override. Let me know if this works for you, I'm curious as well.
 
You can try using reflection to modify the ViewCreatorManager._viewCreators dictionary. If it's a SandBox ViewMethod, you may need to modify the SandBoxViewCreator._viewCreators dictionary instead. I would do this in your OnSubModuleLoad() override. Let me know if this works for you, I'm curious as
Seems like its working but not actually working. I mean It's not crashing but I'm guessing that I'm not setting it properly since I'm not seeing any change at all.

Here is the code ( don't mind the ugly castings, its for test purpose )
C#:
Type type = typeof(SandBoxViewCreator);
FieldInfo info = type.GetField("_viewCreators", BindingFlags.NonPublic | BindingFlags.Static);
object value = info.GetValue(null);

((Dictionary<string, MethodInfo>)value).Remove("Village");
MethodInfo mInf = typeof(MissionOverride).GetMethod("OpenVillageMissionOverride");
((Dictionary<string, MethodInfo>)value).Add("Village", mInf);
info.SetValue(null, value);
Everything also looks fine on debugger as well, I'm not sure whats the issue.
 
The tutorial/documentation is not meant to teach you C#. You should have a basic understanding of C# before attempting to do the tutorial (this is mentioned).

Regarding the SubModule.xml needing to be named such, the tutorial says in step 4:

This should have been quite clear, but I will add a note of this anyway since you are the 2nd person to have this issue.

Next, regarding debugging, the tutorial says:

This is the Debug tab in project properties, not the Debug tab for the main window.

Again, please learn basic C# before attempting any of this. If you've never even compiled a C# project before, I don't think modding a game is a good place to start. Try something basic, such as a Console app and familiarize yourself with the language and IDE. Then try modding the game.

I have written an application in C# before which created and published powershell script files for execution. I haven't modded a game using C# before, so understanding its functionality and libraries isn't just common knowledge to me. Use of inheritance and override also hasn't been needed in what I've previously written.

You're going to have a lot of beginners asking how to mod, why not just simply make it easier and explain what it is that they're doing when assembling these things, rather than providing a basic framework and then saying "find your own way". A lot of people are going to get to a point where they simply cannot get it to work, and will just abort their ideas... that isn't really supporting a community now is it?

Like I said, I found my own way there... I've added you some feedback to prevent others coming back and finding the same issues I found, and just suggesting that you flesh out the examples so it can actually teach beginners how to start modding.
 
I have written an application in C# before which created and published powershell script files for execution. I haven't modded a game using C# before, so understanding its functionality and libraries isn't just common knowledge to me. Use of inheritance and override also hasn't been needed in what I've previously written.

You're going to have a lot of beginners asking how to mod, why not just simply make it easier and explain what it is that they're doing when assembling these things, rather than providing a basic framework and then saying "find your own way". A lot of people are going to get to a point where they simply cannot get it to work, and will just abort their ideas... that isn't really supporting a community now is it?

Like I said, I found my own way there... I've added you some feedback to prevent others coming back and finding the same issues I found, and just suggesting that you flesh out the examples so it can actually teach beginners how to start modding.
If you don't know what inheritance is, nor how to properly use it, you are going to have a hard time modding the game. There is no point in me writing a tutorial about inheritance (and other topics) when there are thousands of tutorials you can find by simply Googling the topic. My recommendation to you is to go through a proper C# beginner's guide first. This should only take you a couple of hours if you have any prior experience in OOP. Being capable of researching your own problems is something that will help you a lot in the long run.
 
Back
Top Bottom