Skip to content

Commit 2045127

Browse files
authored
Merge pull request #129 from ardayildirim/master
Custom game modes docs update
2 parents 20da6e3 + 6c7d047 commit 2045127

3 files changed

Lines changed: 172 additions & 146 deletions

File tree

docs/content/english/Multiplayer/custom_game_mode.md

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ weight = 10
77
#### Prerequisites
88
To make a custom MP game mode, you first need to create your module’s folder under the `Modules` folder of your games installation. Inside your module’s folder, you need to create a `bin` folder for your DLL files and a `SubModule.xml` file for your module’s definition and additional data.
99

10-
For programming, you need to have .NET Framework development tools installed. To do that, download Visual Studio 2017 Community Edition and install .NET Framework 4.7.2 support. After that’s done, create a new Class Library project. For the client side, add references to DLLs located in the `Win64_Shipping_Client` folder of your Mount & Blade II: Bannerlord installation. For the server side, add references to DLLs located in the `Win64_Shipping_Server` folder of your Mount & Blade II: Dedicated Server installation.
10+
For programming, you need to have .NET Framework development tools installed. To do that, download Visual Studio 2022 Community Edition and install .NET 6 support. After that’s done, create a new Class Library project.\
11+
12+
For the client side, add references to DLLs located in the `Win64_Shipping_Client` folder of your Mount & Blade II: Bannerlord installation. \\
13+
For the server side, add references to DLLs located in the `Win64_Shipping_Server` folder of your Mount & Blade II: Dedicated Server installation.
1114

1215
Make sure the output directory of your project is:
1316

@@ -65,63 +68,68 @@ In the XML file, you can define the following so your game mode’s name show up
6568
Make sure IDs match up with the ones you defined in your code and module definition files.
6669

6770
#### GameMode Class
68-
To make the server start the mission with your game mode, you need to create a new class that inherits `MissionBasedMultiplayerGameMode`. In this class, override `StartMultiplayerGame` method like this:
71+
To make the server start the mission with your game mode, you need to create a new class that inherits `MissionBasedMultiplayerGameMode`. In this class, override `StartMultiplayerGame` method like this **for your client module**:
72+
73+
public override void StartMultiplayerGame(string scene) {
74+
MissionState.OpenNew("BountyMP", new MissionInitializerRecord(scene),
75+
missionController => {
76+
return new MissionBehavior[] {
77+
MissionLobbyComponent.CreateBehavior(),
78+
new MissionMultiplayerBountyMPClient(),
79+
new MultiplayerAchievementComponent(),
80+
new MultiplayerTimerComponent(),
81+
new MultiplayerMissionAgentVisualSpawnComponent(),
82+
new MissionLobbyEquipmentNetworkComponent(),
83+
new MultiplayerTeamSelectComponent(),
84+
new MissionHardBorderPlacer(),
85+
new MissionBoundaryPlacer(),
86+
new MissionBoundaryCrossingHandler(),
87+
new MultiplayerPollComponent(),
88+
new MultiplayerAdminComponent(),
89+
new MultiplayerGameNotificationsComponent(),
90+
new MissionOptionsComponent(),
91+
new MissionScoreboardComponent(new BountyMPScoreboardData()),
92+
new MissionMatchHistoryComponent(),
93+
new EquipmentControllerLeaveLogic(),
94+
new MissionRecentPlayersComponent(),
95+
new MultiplayerPreloadHelper(),
96+
};
97+
}
98+
);
99+
}
100+
101+
In this class, override StartMultiplayerGame method like this for your server module:
69102

70103
public override void StartMultiplayerGame(string scene) {
71104
MissionState.OpenNew("BountyMP", new MissionInitializerRecord(scene),
72105
missionController => {
73-
if (GameNetwork.IsServer) {
74-
return new MissionBehavior[] {
75-
MissionLobbyComponent.CreateBehavior(),
76-
new MissionMultiplayerBountyMP(),
77-
new MissionMultiplayerBountyMPClient(),
78-
new MultiplayerTimerComponent(),
79-
new MultiplayerMissionAgentVisualSpawnComponent(),
80-
new SpawnComponent(new BountyMPSpawnFrameBehavior(), new BountyMPSpawningBehavior()),
81-
new MissionLobbyEquipmentNetworkComponent(),
82-
new MultiplayerTeamSelectComponent(),
83-
new MissionHardBorderPlacer(),
84-
new MissionBoundaryPlacer(),
85-
new MissionBoundaryCrossingHandler(),
86-
new MultiplayerPollComponent(),
87-
new MultiplayerAdminComponent(),
88-
new MultiplayerGameNotificationsComponent(),
89-
new MissionOptionsComponent(),
90-
new MissionScoreboardComponent(new BountyMPScoreboardData()),
91-
new MissionAgentPanicHandler(),
92-
new AgentHumanAILogic(),
93-
new EquipmentControllerLeaveLogic(),
94-
new MultiplayerPreloadHelper(),
95-
};
96-
} else {
97-
return new MissionBehavior[] {
98-
MissionLobbyComponent.CreateBehavior(),
99-
new MissionMultiplayerBountyMPClient(),
100-
new MultiplayerAchievementComponent(),
101-
new MultiplayerTimerComponent(),
102-
new MultiplayerMissionAgentVisualSpawnComponent(),
103-
new MissionLobbyEquipmentNetworkComponent(),
104-
new MultiplayerTeamSelectComponent(),
105-
new MissionHardBorderPlacer(),
106-
new MissionBoundaryPlacer(),
107-
new MissionBoundaryCrossingHandler(),
108-
new MultiplayerPollComponent(),
109-
new MultiplayerGameNotificationsComponent(),
110-
new MissionOptionsComponent(),
111-
new MissionScoreboardComponent(new BountyMPScoreboardData()),
112-
new MissionMatchHistoryComponent(),
113-
new EquipmentControllerLeaveLogic(),
114-
new MissionRecentPlayersComponent(),
115-
new MultiplayerPreloadHelper(),
116-
};
117-
}
106+
return new MissionBehavior[] {
107+
MissionLobbyComponent.CreateBehavior(),
108+
new MissionMultiplayerBountyMP(),
109+
new MissionMultiplayerBountyMPClient(),
110+
new MultiplayerTimerComponent(),
111+
new SpawnComponent(new BountyMPSpawnFrameBehavior(), new BountyMPSpawningBehavior()),
112+
new MissionLobbyEquipmentNetworkComponent(),
113+
new MultiplayerTeamSelectComponent(),
114+
new MissionHardBorderPlacer(),
115+
new MissionBoundaryPlacer(),
116+
new MissionBoundaryCrossingHandler(),
117+
new MultiplayerPollComponent(),
118+
new MultiplayerAdminComponent(),
119+
new MultiplayerGameNotificationsComponent(),
120+
new MissionOptionsComponent(),
121+
new MissionScoreboardComponent(new BountyMPScoreboardData()),
122+
new MissionAgentPanicHandler(),
123+
new AgentHumanAILogic(),
124+
new EquipmentControllerLeaveLogic(),
125+
new MultiplayerPreloadHelper(),
126+
};
118127
}
119128
);
120129
}
121130

122-
From this code, you can see that `GameNetwork` has a variable that you can use in all of your code to check if the running game instance is a server or a client. In this method, you can see that it is used to separate client behaviors from server behaviors. This way we make sure that correct `MissionBehaviors` are loaded for the correct type of the game. In other methods, `GameNetwork.IsClient` and `GameNetwork.IsServer` can be used to act differently on different events.
123131

124-
This method also shows how a mission runs at an overview. All mission behaviors are loaded one by one and they all handle different aspects of the game. Depending on your game mode, you might want all of these or only some of these at your mode. Also please note that there are dependencies between some of these behaviors, meaning that if one is not present, others might not work correctly. In this example, there are two mission behaviors that you are not going to get if you have created a clean project with the steps mentioned in the first section. These two behaviors are the ones the modder creates to add their own game logic. These are `MissionMultiplayerBountyMP` and `MissionMultiplayerBountyMPClient`. The former manages the game mode from the server while the latter manages the game mode from the client side. Make sure that all shared and important data is on your server and synchronized properly.
132+
This method shows how a mission runs at an overview. All mission behaviors are loaded one by one and they all handle different aspects of the game. Depending on your game mode, you might want all of these or only some of these at your mode. Also please note that there are dependencies between some of these behaviors, meaning that if one is not present, others might not work correctly. In this example, there are two mission behaviors that you are not going to get if you have created a clean project with the steps mentioned in the first section. These two behaviors are the ones the modder creates to add their own game logic. These are `MissionMultiplayerBountyMP` and `MissionMultiplayerBountyMPClient`. The former manages the game mode from the server while the latter manages the game mode from the client side. Make sure that all shared and important data is on your server and synchronized properly.
125133

126134
#### Mission Behaviors
127135
For all native game modes, the server side game mode logic class, `MissionMultiplayerBountyMP` in this example, inherits `MissionMultiplayerGameModeBase`. This class defines basic spawning and synchronization systems. Also for all native game modes, the client side game mode message handling logic class, `MissionMultiplayerBountyMPClient` in this example, inherits `MissionMultiplayerGameModeBaseClient`. There are several overrides available for this class that makes sure the registering and deregistering from message handlers happen at the correct time.

docs/content/russian/Multiplayer/custom_game_mode.md

Lines changed: 57 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ weight = 10
77
#### Prerequisites
88
To make a custom MP game mode, you first need to create your module’s folder under the `Modules` folder of your games installation. Inside your module’s folder, you need to create a `bin` folder for your DLL files and a `SubModule.xml` file for your module’s definition and additional data.
99

10-
For programming, you need to have .NET Framework development tools installed. To do that, download Visual Studio 2017 Community Edition and install .NET Framework 4.7.2 support. After that’s done, create a new Class Library project. For the client side, add references to DLLs located in the `Win64_Shipping_Client` folder of your Mount & Blade II: Bannerlord installation. For the server side, add references to DLLs located in the `Win64_Shipping_Server` folder of your Mount & Blade II: Dedicated Server installation.
10+
For programming, you need to have .NET Framework development tools installed. To do that, download Visual Studio 2022 Community Edition and install .NET 6 support. After that’s done, create a new Class Library project.\
11+
12+
For the client side, add references to DLLs located in the `Win64_Shipping_Client` folder of your Mount & Blade II: Bannerlord installation. \\
13+
For the server side, add references to DLLs located in the `Win64_Shipping_Server` folder of your Mount & Blade II: Dedicated Server installation.
1114

1215
Make sure the output directory of your project is:
1316

@@ -65,63 +68,68 @@ In the XML file, you can define the following so your game mode’s name show up
6568
Make sure IDs match up with the ones you defined in your code and module definition files.
6669

6770
#### GameMode Class
68-
To make the server start the mission with your game mode, you need to create a new class that inherits `MissionBasedMultiplayerGameMode`. In this class, override `StartMultiplayerGame` method like this:
71+
To make the server start the mission with your game mode, you need to create a new class that inherits `MissionBasedMultiplayerGameMode`. In this class, override `StartMultiplayerGame` method like this **for your client module**:
72+
73+
public override void StartMultiplayerGame(string scene) {
74+
MissionState.OpenNew("BountyMP", new MissionInitializerRecord(scene),
75+
missionController => {
76+
return new MissionBehavior[] {
77+
MissionLobbyComponent.CreateBehavior(),
78+
new MissionMultiplayerBountyMPClient(),
79+
new MultiplayerAchievementComponent(),
80+
new MultiplayerTimerComponent(),
81+
new MultiplayerMissionAgentVisualSpawnComponent(),
82+
new MissionLobbyEquipmentNetworkComponent(),
83+
new MultiplayerTeamSelectComponent(),
84+
new MissionHardBorderPlacer(),
85+
new MissionBoundaryPlacer(),
86+
new MissionBoundaryCrossingHandler(),
87+
new MultiplayerPollComponent(),
88+
new MultiplayerAdminComponent(),
89+
new MultiplayerGameNotificationsComponent(),
90+
new MissionOptionsComponent(),
91+
new MissionScoreboardComponent(new BountyMPScoreboardData()),
92+
new MissionMatchHistoryComponent(),
93+
new EquipmentControllerLeaveLogic(),
94+
new MissionRecentPlayersComponent(),
95+
new MultiplayerPreloadHelper(),
96+
};
97+
}
98+
);
99+
}
100+
101+
In this class, override StartMultiplayerGame method like this for your server module:
69102

70103
public override void StartMultiplayerGame(string scene) {
71104
MissionState.OpenNew("BountyMP", new MissionInitializerRecord(scene),
72105
missionController => {
73-
if (GameNetwork.IsServer) {
74-
return new MissionBehavior[] {
75-
MissionLobbyComponent.CreateBehavior(),
76-
new MissionMultiplayerBountyMP(),
77-
new MissionMultiplayerBountyMPClient(),
78-
new MultiplayerTimerComponent(),
79-
new MultiplayerMissionAgentVisualSpawnComponent(),
80-
new SpawnComponent(new BountyMPSpawnFrameBehavior(), new BountyMPSpawningBehavior()),
81-
new MissionLobbyEquipmentNetworkComponent(),
82-
new MultiplayerTeamSelectComponent(),
83-
new MissionHardBorderPlacer(),
84-
new MissionBoundaryPlacer(),
85-
new MissionBoundaryCrossingHandler(),
86-
new MultiplayerPollComponent(),
87-
new MultiplayerAdminComponent(),
88-
new MultiplayerGameNotificationsComponent(),
89-
new MissionOptionsComponent(),
90-
new MissionScoreboardComponent(new BountyMPScoreboardData()),
91-
new MissionAgentPanicHandler(),
92-
new AgentHumanAILogic(),
93-
new EquipmentControllerLeaveLogic(),
94-
new MultiplayerPreloadHelper(),
95-
};
96-
} else {
97-
return new MissionBehavior[] {
98-
MissionLobbyComponent.CreateBehavior(),
99-
new MissionMultiplayerBountyMPClient(),
100-
new MultiplayerAchievementComponent(),
101-
new MultiplayerTimerComponent(),
102-
new MultiplayerMissionAgentVisualSpawnComponent(),
103-
new MissionLobbyEquipmentNetworkComponent(),
104-
new MultiplayerTeamSelectComponent(),
105-
new MissionHardBorderPlacer(),
106-
new MissionBoundaryPlacer(),
107-
new MissionBoundaryCrossingHandler(),
108-
new MultiplayerPollComponent(),
109-
new MultiplayerGameNotificationsComponent(),
110-
new MissionOptionsComponent(),
111-
new MissionScoreboardComponent(new BountyMPScoreboardData()),
112-
new MissionMatchHistoryComponent(),
113-
new EquipmentControllerLeaveLogic(),
114-
new MissionRecentPlayersComponent(),
115-
new MultiplayerPreloadHelper(),
116-
};
117-
}
106+
return new MissionBehavior[] {
107+
MissionLobbyComponent.CreateBehavior(),
108+
new MissionMultiplayerBountyMP(),
109+
new MissionMultiplayerBountyMPClient(),
110+
new MultiplayerTimerComponent(),
111+
new SpawnComponent(new BountyMPSpawnFrameBehavior(), new BountyMPSpawningBehavior()),
112+
new MissionLobbyEquipmentNetworkComponent(),
113+
new MultiplayerTeamSelectComponent(),
114+
new MissionHardBorderPlacer(),
115+
new MissionBoundaryPlacer(),
116+
new MissionBoundaryCrossingHandler(),
117+
new MultiplayerPollComponent(),
118+
new MultiplayerAdminComponent(),
119+
new MultiplayerGameNotificationsComponent(),
120+
new MissionOptionsComponent(),
121+
new MissionScoreboardComponent(new BountyMPScoreboardData()),
122+
new MissionAgentPanicHandler(),
123+
new AgentHumanAILogic(),
124+
new EquipmentControllerLeaveLogic(),
125+
new MultiplayerPreloadHelper(),
126+
};
118127
}
119128
);
120129
}
121130

122-
From this code, you can see that `GameNetwork` has a variable that you can use in all of your code to check if the running game instance is a server or a client. In this method, you can see that it is used to separate client behaviors from server behaviors. This way we make sure that correct `MissionBehaviors` are loaded for the correct type of the game. In other methods, `GameNetwork.IsClient` and `GameNetwork.IsServer` can be used to act differently on different events.
123131

124-
This method also shows how a mission runs at an overview. All mission behaviors are loaded one by one and they all handle different aspects of the game. Depending on your game mode, you might want all of these or only some of these at your mode. Also please note that there are dependencies between some of these behaviors, meaning that if one is not present, others might not work correctly. In this example, there are two mission behaviors that you are not going to get if you have created a clean project with the steps mentioned in the first section. These two behaviors are the ones the modder creates to add their own game logic. These are `MissionMultiplayerBountyMP` and `MissionMultiplayerBountyMPClient`. The former manages the game mode from the server while the latter manages the game mode from the client side. Make sure that all shared and important data is on your server and synchronized properly.
132+
This method shows how a mission runs at an overview. All mission behaviors are loaded one by one and they all handle different aspects of the game. Depending on your game mode, you might want all of these or only some of these at your mode. Also please note that there are dependencies between some of these behaviors, meaning that if one is not present, others might not work correctly. In this example, there are two mission behaviors that you are not going to get if you have created a clean project with the steps mentioned in the first section. These two behaviors are the ones the modder creates to add their own game logic. These are `MissionMultiplayerBountyMP` and `MissionMultiplayerBountyMPClient`. The former manages the game mode from the server while the latter manages the game mode from the client side. Make sure that all shared and important data is on your server and synchronized properly.
125133

126134
#### Mission Behaviors
127135
For all native game modes, the server side game mode logic class, `MissionMultiplayerBountyMP` in this example, inherits `MissionMultiplayerGameModeBase`. This class defines basic spawning and synchronization systems. Also for all native game modes, the client side game mode message handling logic class, `MissionMultiplayerBountyMPClient` in this example, inherits `MissionMultiplayerGameModeBaseClient`. There are several overrides available for this class that makes sure the registering and deregistering from message handlers happen at the correct time.

0 commit comments

Comments
 (0)