We will create this tutorial in a way that everybody will be able to follow the steps and create good, custom maps. That includes that all the software used is freeware and I will put download links in the tutorial for easy access.
Programs And Tools:
Before starting, we need to download the required software.
- Python: Python.org
Download the version 2.7.6
- M&B Warband Module System: Forums.taleworlds.com
Download the M&B Warband Module System
- OPTIONAL: Notepad++ : Notepad-plus-plus.org
This is not required, but makes the editing of the code within the module system much easier. This is obviously based on personal preference, so you can choose for yourself if you want to use it or not.
Setting Up The Programs And Tools:
We could do this later, but it is much more convenient to do it all in the beginning.
Let's start with setting up Notepad++. I doubt I really have to explain much about that. Download the program, unzip the file, run the installer. The only thing you should mind here is that you really use the installer, and don't just run the program. It works to run the program, but that way you won't be able to open any files directly with it later.
Second, let's set up the Module System. During this intro, I will use the shortcut MS for this. Download and unzip the file. Now, take the entire module system, and move it to a convenient folder. In some downloads, there appears to be an error with the latest version of the module system, so you might be better off downloading the version 1.153 instead. Now go into the MS folder, and search for "module_info.py". Don't be scared by the amount of files in the MS, you will need less than a handful of those for the actual process of adding a map. Right click on the file "module_info.py", and either click on "Edit with IDLE" or on "Edit with Notepad++". In the rest of the tutorial, I will only say "edit this file" to state that you are supposed to open it in either notepad++ or idle.
Now, this is a quite short document. The first two lines are only for your information, so don't edit them. The line we need to edit is the third (starting with export_dir). This line defines the folder your modifications will be saved in. Now, if you want to add a map to your normal Native module, change the path within the " " to the path of your Native folder. This could look somewhat like that:
export_dir = "C:/Program Files/Mount&Blade/Modules/Native/"
The line below that is not relevant. None of the lines starting with # are relevant in fact. They are all just information, not actual codes.
Now it is time to set up Python. Download the file, and install it. It is easiest to just install it in its default path C:\Python27. Now, you don't have to do much more but to ensure everything works out smoothly, it would be adviced for you to add it to the environmental variables. That isn't as hard as it sounds. I don't know how this works on Windows 8, but on Windows XP, and Windows 7 it works as follos:
Right click on "My Computer" and choose "Properties". There click on "Advanced" tab and select "Environmental Variables". Look for the section "Path" in the small window on the bottom of the window, edit that one, and add ";C:\Python27\" in the end. Make sure not to change any the other files, and check whether the ";" is already there before or not. If it is there, you do not need to add it.
Now we're set, and can start making our map!
First of all, start the Warband launcher, select the correct mod, and click on "Configure". Now go to "Advanced", and tick the "Enable Edit Mode" to activate it. Click on "OK" and start the game. If you are following this tutorial while actually trying the things, I would advice you to start the game in Windowed (this can be adjusted in the launcher as well).
If you want to edit a default map, you can ignore the following step. If you want to actually add an additional map, you should follow the next step. Start the Singleplayer Campaign - just load some character you have or create a new game. On the bottom left of your screen, to the left of "Camp", there is now a buttom that only appears in edit mode: "Terrain". This enters the terrain editor, and that is exactly what we want to do! So click on that, and you will be taken to the editor. Here you can create the general terrain you want your map to be set in. You have the possibility to set things such as river, water depth, vegetation, terrain, valley, map size, and more. Adjust the map the way you want your future map to be, and click on "Generate Terrain" to preview your final terrain, and click on "Copy" on the top.
One thing you need to be careful about here: If you want a completely plain map, without any random grass you can't remove being generated around the map, choose "Snow". You will be able to edit that later in the regular editor.
A casual sized, completely plain, map code is below. Feel free to use it.
Now we have already generated the basic setup for our map. The next step is to add the map to the module system, and with that to the game. If you want to edit an original map, you can also ignore this step. Your map is obviously already added to the game, and you can just jump to editing it. If you want to add a completely new map though, it is important you follow the following steps closely.
For those who edited an original map, the following might be interesting. If you, for some reason, want to edit the terrain of one of the original maps, here is which code belongs to which map:
("multi_scene_3", "Hailes Castle"), #Castle 1
("multi_scene_4", "Ruined Fort"),
("multi_scene_5", "Scene 5"), #not ready yet
("multi_scene_6", "Scene 6"), #not ready yet
("multi_scene_7", "Field by the River"),
("multi_scene_8", "Rudkhan Castle"), #Castle 2
("multi_scene_9", "Snowy Village"),
("multi_scene_10", "Turin Castle"), #Castle 3
("multi_scene_11", "Nord Town"),
("multi_scene_16", "Port Assault"),
("multi_scene_17", "Brunwud Castle"), #Castle 4
("multi_scene_18", "Battle on Ice"),
("multi_scene_19", "Mahdaar Castle"), #Castle 5
("multi_scene_20", "Jameyyed Castle"), #Castle 6
("multi_scene_21", "The Arena"),
("multi_scene_22", "Forest Hideout"),
("multi_scene_12", "Random Plains (Medium)"),
("multi_scene_13", "Random Plains (Large)"),
("multi_scene_14", "Random Steppe (Medium)"),
("multi_scene_15", "Random Steppe (Large)"),
Now back to adding a custom map:
1.) Open "module_scenes.py" in either IDLE or Notepad++. Press Ctrl + F and search for "multiplayer_maps_end". You need to put the code for your map before that, given that this obviously sets the end of the scenes. Copy paste one of the codes, and edit it as shown in the following example:
The blue part is the part you need to copy, the red part is the part you customize (this will be the code for your map), the black part marks the end of the part of the code.
("multi_scene_18",sf_generate|sf_muddy_water,"none", "none", (0,0),(100,100),-100,"0x00000000b00037630002308c00000c9400005d4c00000f3a", ,,"outer_terrain_plain"), ("your_map_name",sf_generate,"none", "none", (0,0),(100,100),-100,"0x00000001300389800003a4ea000058340000637a0000399b", ,,"outer_terrain_plain"), ("multiplayer_maps_end",sf_generate,"none", "none", (0,0),(100,100),-100,"0x00000001300389800003a4ea000058340000637a0000399b", ,,"outer_terrain_plain"),
You can now clearly see the long number in the end of every part of the code. Replace this number with the code we generated previously in the Terrain Editor. Save and exit "module_scenes.py".
2.) Open "module_scripts.py", and press Ctrl + F to search for "scn_multi_scene_1". You will see that right above these lines you can see the lines:
(this_or_next|eq, ":game_type", multiplayer_game_type_deathmatch),
(this_or_next|eq, ":game_type", multiplayer_game_type_duel), (eq, ":game_type", multiplayer_game_type_team_deathmatch),
In this step we will add the map to the game types. You can very easily determine where to add your map for which game. Here is how it works: add your map in the bottom of the list for every game type you want it to be played in in the future: simply copy paste the last line and edit it as shown in the following example:
The blue part is the part you need to copy, the red part is the part you customize (this will be the code for your map), the black part marks the end of this part of the code. Make sure to increase the number at the end of every game type by one. It might look like this after.
(troop_set_slot, "trp_multiplayer_data", multi_data_maps_for_game_type_begin + 13, "scn_random_multi_steppe_large"),
(troop_set_slot, "trp_multiplayer_data", multi_data_maps_for_game_type_begin + 14, "scn_your_map_name"),
(assign, ":num_maps", 15),
Save and exit "module_scripts.py".
3.) Open "module_strings.py" in either IDLE or Notepad++, and search for "multi_scene_end". Copy one of the lines from above, and paste it right before the "multi_scene_end". We will now modify this pasted line to give your future map a name. It might look something like this:
The blue part is the part you should copy, the red part the part that leads the code to your map. Use the name you gave the map in the previous codes here. The green part is the name the map will be displayed with in the admin panel of the game.
("multi_scene_15", "Random Steppe (Large)"),
Save and exit "module_strings.py".
4.) Now the last step of adding your map to the game: Run "build_module.bat". Give it time to generate the module. If you have done everything correctly, it will run without any errors. If you encounter any errors, feel free to ask me for advice. Often times you can easily fix it yourself, or search for the error on Google.
5.) If you want to add it to a module, you are done now. If you want your map to be online on a server, you need to take the created .txt files (found in the folder you directed your module system to after successfully running build_module.bat) and upload those to the server\Modules\Native. In a next step, upload your map to server\Modules\Native\Sceneobj. Obviously, you can replace "Native" with any module you prefer, as long as the server recognizes it.
Congratulations, you have now generated your map and added it to your module/server. You can now proceed to build your custom map. A few pieces of advice here, concerning the editor:
1.) To get into the editor, start the game with edit mode enabled, select Multiplayer, Host A Game, and load your map. Now click on Ctrl + E to get into the edit mode. If you haven't loaded a character, it teleports you to the outer edge of the map. This can be avoided simply by spawning and walking to the place you want to enter the edit mode in.
2.) The Interface: On the left side you can basically control everything. On top you have the different modes you can edit in, below that a list of all objects added to the map, and below that all objects available to be added.
3.) The Controls:
Left Click: Select
Right Click: Place
W - A - S - D: Move around
B: Change item size
Y - Z - X: Turn in the direction of the axis
G: Move item around
U: Turn item
R: Reset item in original position