BL Coding Help initializing a battle of my own

Users who are viewing this thread


Hello everyone,
I need to initialize a field battle within my campaign and, while searching for how native starts its battles I found how it started its custom battle. It uses the function "OpenCustomBattleMission" which can be found in the class "BannerlordMissions". This is the function which is called when you press start custom battle.

It receives a scene, a character (in my case the player character), two custom battle parties, among other variables and uses them to create a Mission using the function "MissionState.OpenNew".
My idea was to use this function to create a a battle, by giving it the arguments it needed and ended up with the following code:

I have checked every argument and everything seems to be fine and it even starts the Mission. However, when it starts trying to spawn the agents during the loading screen it crashes with the following error and stack call:



I've been trying to understand this error and correct it for some days now without success. Another modder noticed that the error might be coming from the fact that it is using the class "SandBoxAgentStatCalculateModel" instead of the "CustomBattleAgentStatCalculateModel". I don't understand if the problem actually comes from this but, even if it does, I don't understand how I am supposed to enforce the use of "CustomBattleAgentStatCalculateModel".

I was wondering if anyone has ever found this problem and, if so, How did you overcome it? Are there any mods which managed to successfully create a battle?

Thank you in advance.
Top Bottom