Okay, so here's how I managed to add working custom text lines for the wanderers, the method will probably work for any text you want to add to the game through an xml file. Be aware that it requires a bit of coding (although you can just copy and paste the code I'll give you below and just change some names so it fits your mod).
First of all, if you don't know how to set up your environment to program code for bannerlord, watch the first two videos of this playlist and follow what they do:
https://www.youtube.com/watch?v=IotGd1MgZQw&list=PL-eEdYu_CymFEGjndmZRmM-gSg8AK66L_
Next, you'll have to add the code in the .cs file (the file the guy in the video names Main):
//CODE STARTS HERE
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TaleWorlds.Core; //if any of this 4 lines is red, you haven't added it as a refference
using TaleWorlds.MountAndBlade; //go to Project > Add Refference...
using TaleWorlds.CampaignSystem; //click on browse
using TaleWorlds.Library; //navigate to your bannerlord game folder /bin/Win64_Shipping_Client
//select the dll files with the same names as this lines and click add
namespace MoreWanderers //This should be changed to the name of your mod. NO SPACES
{
public class MoreWanderersSubModule : MBSubModuleBase //MoreWanderersSubModule can be called also like your mod + SubModule like me or you can
{ //call it Main like in the videos I linked
//LoadXMLFiles will use CampaignGameStarter to load any text strings we want from any number of xml files.
private void LoadXMLFiles(CampaignGameStarter gameInitializer)
{
gameInitializer.LoadGameTexts(BasePath.Name + "Modules/zMoreWanderers/ModuleData/wanderer_strings_morewanderers.xml");
//between the "" you have to write the path to the xml file with the strings
}
//That's it. You don't need to change anything else beyond this line.
//OnGameLoaded gets called every time we load a game
public override void OnGameLoaded(Game game, object initializerObject)
{
CampaignGameStarter gameInitializer = (CampaignGameStarter)initializerObject;
this.LoadXMLFiles(gameInitializer);
}
//OnNewGameCreated gets called every time we start a new campaign
public override void OnNewGameCreated(Game game, object initializerObject)
{
CampaignGameStarter gameInitializer = (CampaignGameStarter)initializerObject;
this.LoadXMLFiles(gameInitializer);
}
}
}
//CODE ENDS HERE, COPY ALL OF IT
After you are done with the code, the only thing left is propperly linking the xmls and dlls with the SubModule.xml
Mine looks like this:
<Module>
<Name value="More Wanderers"/><!-- This is the name of the mod in the launcher -->
<Id value="zMoreWanderers"/><!-- This is the name of the mod folder -->
<Version value="v1.0.0"/>
<SingleplayerModule value="true"/>
<MultiplayerModule value="false"/>
<DependedModules>
<DependedModule Id="Native"/>
<DependedModule Id="SandBoxCore"/>
<DependedModule Id="Sandbox"/>
<DependedModule Id="StoryMode" />
</DependedModules>
<SubModules>
<SubModule>
<Name value="MoreWanderers"/><!-- This is the name next to namespace in the code -->
<DLLName value="MoreWanderers.dll"/><!--This is the name of your dll-->
<SubModuleClassType value="MoreWanderers.MoreWanderersSubModule"/><!--This is the name next to namespace . the name next to class -->
<Tags>
<Tag key="DedicatedServerType" value="none" />
<Tag key="IsNoRenderModeElement" value="false" />
</Tags>
</SubModule>
</SubModules>
<Xmls>
<XmlNode>
<XmlName id="NPCCharacters" path="spspecialcharacters_morewanderers"/><!-- This is the name of the wanderer characteristics xml -->
<IncludedGameTypes>
<GameType value = "Campaign"/>
<GameType value = "CampaignStoryMode"/>
</IncludedGameTypes>
</XmlNode>
</Xmls>
</Module>
Change only the lines with my comments between <!-- --> if you don't know how to code and everything will be okay!
I hope everyone can understand this! I explained in the most layman terms I had so that anyone can do it / understand it regardless of their coding knowledge.
That said, if you find this overwhelming and are thinking of not modding anymore, remember the modding tools are not out yet so when TW releases them it will get much much easier!
I hope everyone has a fine day at home! Stay healthy and keep modding!
Bleinz-
1 comment