Skip to content
Bannerlord Wiki
Share
Explore
Tutorials

icon picker
Custom Missions! (WIP)

Overview

-This tutorial includes everything:
Loading Custom Scenes
Loading Custom Mission Views
Loading Custom Mission Behaviors!


Mission Manager and ViewCreator


In order to launch scenes and load our views we need a and .
Create a .cs file called Managers and create a CustomMissionManager class that has a MissionManager Attribute
image.png

The attribute is points to an engine method which will compile all missions in the game so that they can be called. Now, we need to create a custom missing using a MissionMethod.

2. Inside the MissionManager, create a MissionMethod attribute and make a function which a Mission return type.
image.png

This will allow us to execute this method from anywhere in the game. Now let's add some code and return a MissionState method

3. We will now use MissionState's OpenNew method to create the Mission within the method we created.
image.png

Let me explain what is happening. So MissionState.OpenNew method takes a variety of parameters.The first parameter is the name of the that you want to load with it. I will explain this part later. The second part is a MissionInitializerRecord, in this record, you include the name of the scene file that you want to open. In this case we are opening the "empire_village_002" scene.The third part is where we load our mission behaviors. In this example. I am not using any but I will explain later on how to add.
This is refering to (Mission missionController) => new MissionBehaviour[] {} . The three trues you see refer to these fields, respectively:
addDefaultMissionBehaviours
needsMemoryCleanup
singlePlayerMission

What they do can be inferred by their name.
Ok, now our file should look like this:
image.png
Now, we can move on to creating custom MissionViews!

Mission Views


MissionViews are were input events, missionscreens, and other relevent stuff can be created and accessed. In order to add a MissionView to your Mission you need to use the .
Create a CustomViewCreator using the ViewCreatorModule attribute.
image.png

Now, we can add numerous amounts of views using the ViewMethod attribute. So, let's add a new MissionView by using the ViewMethod attribute like so:
image.png
As you can see, the parameter that the ViewMethod accepts is the same as the MissionView specified in the MissionState.OpenNew method. This is how we can refer to the view.

Now, we want to actually return a Mission view, we do list by returning a list of mission views like so:
image.png

As you can see, I am using my own missionView SceneEditorMissionView() and am adding it to the list. You can add as many as you want. A future tutorial will teach you how to create your own MissionView but for now you can simply leave this blank or use one the game provides.

Now, your code should look something like this:
image.png


Loading Custom Missions


It's great to have custom missions but how about loading them. To do this we need these things:
Custom GameState
Custom Handler
CustomMissionManagerHandler


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.