Documentation Coding Community Modding Documentation

Users who are viewing this thread

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.
Try it with ViewCreatorManager._viewCreators instead. It seems that the ViewCreatorManager is the only one that adds the behaviors. If this doesn't work, try it with both.
 
Try it with ViewCreatorManager._viewCreators instead. It seems that the ViewCreatorManager is the only one that adds the behaviors. If this doesn't work, try it with both.
This works like charm. Eh, it introduced new errors but that's something else :smile:
Although I must admit, this logic is strange, I wasn't expecting ViewCreatorManager to do that work while SandboxViewCreator in the module. Regardless of that, thanks for the help
 
Hey, I get this error couldn't understand why it happens. I followed tutorial and repeated over and over again for few times and all say the same:

System.IO.FileNotFoundException: ''file:///X:\Program Files (x86)\Steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\ExampleMod.dll'


Can you guys help?
 
Hey, I get this error couldn't understand why it happens. I followed tutorial and repeated over and over again for few times and all say the same:

System.IO.FileNotFoundException: ''file:///X:\Program Files (x86)\Steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\ExampleMod.dll'


Can you guys help?
There isn't a file in that location. Also, the path to your DLL should be Modules\ExampleMod\bin\Win64_Shipping_Client\ExampleMod.dll (relative to your game files). Please verify that your files are in the correct path and that your SubModule.xml file matches what is provided in the tutorial.
 
There isn't a file in that location. Also, the path to your DLL should be Modules\ExampleMod\bin\Win64_Shipping_Client\ExampleMod.dll (relative to your game files). Please verify that your files are in the correct path and that your SubModule.xml file matches what is provided in the tutorial.

Thanks I handled it! ^^
 
Docs are great, good to see. May I suggest, for those C# noobs, run through the official unity C# tutorials. It's a couple of hours of watching and it is specific to unity but it covers so many things that you absolutely need to know with C#. WATCH THEM ALL!!

 
EDIT: It works now but ill keep this here if anyway else wants to see the code
Game crashed upon running the Basic C# Mod.
C#:
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;

namespace ExampleMod
{
    public 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));
        }
    }
}
The code compiled and was enabled on the mods screen on the launcher. It went to the loading screen and then said "Application Crash"

EDIT: Note the xml is a copy paste from the tutorial and also the ExampleMod.dll file is in the Modules\ExampleMod\bin folder
EDIT2: My problem was that i did not create the Win64_Shipping_Client folder
 
Last edited:
Hey I am not sure if this should be include in the community documentation but right now skills are unimplemented for troops.

You can test this out yourself by:
*on 1/3 easiest damage settings
*I removed all equipment sets except for the last one which spawns with stones and a hammer.

Looters at 10 skill for everything: deal 3-4 damage throwing stones, 7-9 damage with hammers
Looters at 400 skill for everything : deal 3-4 damage throwing stones, 7-9 damage with hammers
Looters at 2000 skill for everything: deal 3-4 damage throwing stones, 7-9 damage with hammers

It can be noted that Athletics did have an effect, 400 skill looters were fast, 2000 skill looters were very fast

Anyhow, perhaps some "unimplemented" section could be added that details various effects that are unimplemented. this might save some people time. I have already wasted at least 4 hours trying to get my mod (Stats Actually Matter) to work for troops only to find out that is impossible. Any mod that changes troop stats is also a waste of time.
 
I would especially like to see specific tutorials that cover different parts of the game in the documentation. Most mods will likely be some combination of the same feature builds.
  • Adding new weapons/armour
  • Adjusting attributes of existing weapons/armour
  • Adding in-game menu elements
  • Adding conversation points with npcs
  • Adding quests
  • Modifying map elements
 
I'd like to add a few points to that list.
  • Hooking into specific events (e.g., after battle, at midnight, when entering a town, every frame, every five seconds).
  • Iterating over existing entities (e.g., towns, troops, parties, NPCs, items, quests, settlement improvements, perks).
  • Using existing functions (e.g., upgrade troops, buy/sell item, transfer units, change ownership, change relationship).
 
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.

That is only half true. A person could recite chapter and verse from the Gang of Four and still not understand how Tale is executing dependency injection (hopefully at program root). Build your own behaviors, delegates, etc. but they still need to be properly injected. I’m not trying to slap you down, but it isnt so cut and dry as your message’s tone.
 
Thank you so much for your effort!!

Just curious, how do you know the logic of the code? Do you have the original code or you decompiled all the dlls?

Thanks!

-zycooper
 
That is only half true. A person could recite chapter and verse from the Gang of Four and still not understand how Tale is executing dependency injection (hopefully at program root).
I'm not sure what you mean in there. That's what Ster is saying already. You can't learn much by looking at existing code. You need to know the basics of C# first, and then some more advanced concepts like injection, reflection etc. And then you can check the code and see what exactly is happening and why exactly it's happening. But there is no point of writing a tutorial about these concepts since the web is already have hundreds of articles about that.
You can, however, ask "Hey where can I access X's values if I have only YMissionLogic file." since it's not common knowledge or anything documented officially, only other modders can help you. Or they can simply create a document like Ster and others are working on right now. To make these questions less often and document more efficient/helpful
 
I'm not sure what you mean in there. That's what Ster is saying already. You can't learn much by looking at existing code. You need to know the basics of C# first, and then some more advanced concepts like injection, reflection etc. And then you can check the code and see what exactly is happening and why exactly it's happening. But there is no point of writing a tutorial about these concepts since the web is already have hundreds of articles about that.
You can, however, ask "Hey where can I access X's values if I have only YMissionLogic file." since it's not common knowledge or anything documented officially, only other modders can help you. Or they can simply create a document like Ster and others are working on right now. To make these questions less often and document more efficient/helpful

I don’t believe the original question asked for a tutorial for making any basic c# program. I think he was asking for a tutorial on the high level architecture. That‘s not actually just a rehash of the code classes—something that DocFX would generate for you automatically with source access. It’s also not just self-documenting code—just reading the source from a decompiler. There is also the overall design—the game design and the software design. For example, tale is clearly not using ECS, they are using an agent framework. I’m not suggesting anyone needs to write something fully iaw IEEE 1016-2009, but it makes navigating the file structure and source much faster for someone new to the code. The fact that Tale doesn’t seem to follow consistent standards among their own team makes such a description all the more important.
 
Last edited:
No, he kinda asked for a super detailed tutorial, step by step explaining every single line.
I can understand that its strange/confusing for some people with less on-hands experience but its not realistic to expect that much detail from the community document, especially in this EA phase. If one follows the basics of C#, and then going into more advanced topics later on even he/she can see that Taleworlds is actually doing something unusual in the overall architecture they have. But right now we are saying that based on what we are seeing. We can say "Hey this is an unusual engine, I'm not used to this weird architecture" but then Taleworlds can easily say "Well you are not supposed to decompile my code anyway?" Because they said "It will be moddable" - by assuming that they will provide some endpoints etc. They didn't say "You can decompile and reassemble every single piece of game - excluding RGL"

Of course, it does help to know all those standards or basics of game design. I agree with you on that. Modding is in essence, hacking the game functionality to make it more fun. At least in the current state, that's what we have. Because we don't have any official information from Taleworlds. And for that purpose, one shouldn't expect every detail to be on there.
 
No, he kinda asked for a super detailed tutorial, step by step explaining every single line.
I can understand that its strange/confusing for some people with less on-hands experience but its not realistic to expect that much detail from the community document, especially in this EA phase. If one follows the basics of C#, and then going into more advanced topics later on even he/she can see that Taleworlds is actually doing something unusual in the overall architecture they have. But right now we are saying that based on what we are seeing. We can say "Hey this is an unusual engine, I'm not used to this weird architecture" but then Taleworlds can easily say "Well you are not supposed to decompile my code anyway?" Because they said "It will be moddable" - by assuming that they will provide some endpoints etc. They didn't say "You can decompile and reassemble every single piece of game - excluding RGL"

Of course, it does help to know all those standards or basics of game design. I agree with you on that. Modding is in essence, hacking the game functionality to make it more fun. At least in the current state, that's what we have. Because we don't have any official information from Taleworlds. And for that purpose, one shouldn't expect every detail to be on there.

Accepted. Every design is unusual. There are, however, similar ways of solving problems. Assuming tale is professional, he should be able grok how those parts fit together—as you wrote.

With a little more mentoring added and a verification, tutorials like this one and this one need to be in this guide.

My curiosity is peaked that, for some reason, Tale used different solutions to solve the same problem in different parts of the code... instead of DRY. Notice how static dictionary data is loaded, parsed and processed into game objects differently depending on the files. If a modder changes or adds an XML, they might expect theses processes (merges, etc.) to behave consistently. However, in at least one case, document names are literals in a bespoke load method.

Even class and method fields don’t use consistent name standards.

Literals are used inside functions. In some cases a class or method constant is set and then unused... let alone not being established in config data.

It’s all the more baffling because everything that helps a modder helps a dev team member and tale more.

Certainly no one is perfect, but we can generalize on the whole. Take a look at Rimworld as a counterpoint. It has it’s own design decisions and issues, but those compromises are apparent and consistently executed in the source.
 
Last edited:
Thank you for reply! I'm really curious about how they make this document. If they decompile the dlls and the code doesn't have clean comments, it's a real tough job to do.

I'm a .Net developer and the thing I don't want to touch is legacy code without comments and document.
Yeah there are no comments and the code is decompiled so it's probably a lot less readable than the actual source code (I hope!)

I have been just reading over the decompiled code in order to get my head around it. Last night I started my own auto-docs just for my own benefit, maybe you guys could benefit too? https://bldocs.brookesy.dev/api/index.html

I'm using DocFX to generate the docs, and just copying class files into my DocFX project as I find ones that seem worth documenting.

@Ster could you use that in your docs? I don't have a pretty domain to host it on. It's also up on github: https://github.com/AbrahamBrookes/BannerlordCommunityAPI
 
Last edited:
Yeah there are no comments and the code is decompiled so it's probably a lot less readable than the actual source code (I hope!)

I have been just reading over the decompiled code in order to get my head around it. Last night I started my own auto-docs just for my own benefit, maybe you guys could benefit too? https://bldocs.brookesy.dev/api/index.html

I'm using DocFX to generate the docs, and just copying class files into my DocFX project as I find ones that seem worth documenting.

@Ster could you use that in your docs? I don't have a pretty domain to host it on. It's also up on github: https://github.com/AbrahamBrookes/BannerlordCommunityAPI
Very cool!

While I don't think that I would be able to use DocFX for the community docs, I could use some help with descriptions/overviews of important classes. I am writing my own solution to automate building the docs, which will allow for much more freedom in the overall design/implementation. I just need to do a few more things before I can make this new version public. After this is done, I will be restructuring the current documentation to use a more consistent format.
 
Back
Top Bottom