Viliam Búr

2008/07/27

Water Battle Map for Wesnoth, Published

In previous article we have designed a map for water battle, called "2p_Pool.map". Now we will specify that players can only recruit Merfolk and Naga units. And then we will publish the map on the Wesnoth add-on server, so that other people can download it and play against each other online.

In map editor we can only place terrains and starting positions. For anything else we must create a configuration file. It is a text file. And by "text file" I mean text file created with plain text editor such as Notepad or KWrite. Not Word document, nor RTF document, just good old "*.txt" file. And it looks like this:

[multiplayer]

 id=multiplayer_2p_Pool
 name= _ "2p - Pool"
 description= _ "Fight in water between merfolk and nagas."
 map_data="{@campaigns/Examples_by_Viliam/maps/multiplayer/2p_Pool.map}"

 {DEFAULT_SCHEDULE}
 {DEFAULT_MUSIC_PLAYLIST}

 [side]
  side=1
  controller=human

  team_name=west
  user_team_name= _ "teamname^West"

  canrecruit=yes
  recruit=Merman Fighter,Merman Hunter,Mermaid Initiate

 [/side]

 [side]
  side=2
  controller=human

  team_name=east
  user_team_name= _ "teamname^East"

  canrecruit=yes
  recruit=Naga Fighter,Saurian Augur,Saurian Skirmisher

 [/side]

[/multiplayer]

Do not be afraid. It is easy to understand, when you try. The configuration file is basicly a list of "keyword=value" pairs. Sometimes they are surrounded by marks like "[multiplayer]" and "[/multiplayer]", or "[side]" and "[/side]". You can learn their meanings (keep a cheat sheet at hand), or just copy this example and try to change the ones you understand.

The "[multiplayer]" and "[/multiplayer]" marks mean "this is the beginning / the end of multiplayer scenario description". The "id" is an internal scenario identifier; it means that nobody will read this text, but it has to be different from the "id"s of other scenarios. The "name" is a name under which the scenario will appear in a map list. Tradition says that the name should also show how many players can play the scenario, therefore "2p - Pool". The "description" will appear when you move the mouse cursor above the map preview. The "map_data" is a link to map file created in map editor.

(C) 2008 Viliam Búr viliambur.blogspot.com

The symbols "{DEFAULT_SCHEDULE}" and "{DEFAULT_MUSIC_PLAYLIST}" are just shortcuts (called macros) for something more complicated. This means that we will use standard day/night schedule, and standard music playlist. We have no reason to change this now.

The "[side]" and "[/side]" marks mean "this is the beginning / the end of side description". We have two sides, and we have put two starting positions in the map. The "side" is just an order of side, 1 or 2. The "controller" means that this side can be played by human player (but we can choose computer player instead). The "team_name" is a team identifier; the "user_team_name" is how the team name will be displayed to player, so that s/he knows s/he will play for the West team or the East team. The "canrecruit" says that players can recruit units at keeps. And the "recruit" is a comma-separated list of recruitable units. (You will find the units in "data/core/units" directory, where "data" means "C:\Program Files\Wesnoth 1.4.4\data" or something similar. Look at the text files and find the "id".)

The symbol "_" before some texts means that these texts are translatable to other languages. We will not do it now, but it is a good habit to write the "_" symbol before all strings which will be displayed to player. The part of texts before symbol "^" in translated strings will not be displayed; it is just a hint for translators.

Now we need to put the map file "2p_Pool.map" and the scenario configuration file "2p_Pool.cfg" somewhere where the game finds them, and make them link to each other correctly. Because I want to publish my examples in one package, I have created a directory "userdata/data/campaigns/Examples_by_Viliam". (This is not a campaign, but the game add-on server supports campaigns, so we are going to cheat a little.) Inside this directory I put the map file as "maps/multiplayer/2p_Pool.map" and the scenario file as "scenarios/multiplayer/2p_Pool.cfg". Please note how the "map_data" value in scenario configuration file points to the map file. If you want to use different directories, you have to change the link.

To make this package visible to game, we need another configuration file "userdata/data/campaigns/Examples_by_Viliam.cfg". It will be like this:

#ifdef MULTIPLAYER
{@campaigns/Examples_by_Viliam/scenarios/multiplayer}
#endif

The package configuration file will include the subdirectory "scenarios/multiplayer" if the game is in the multiplayer mode. No need to waste memory if the player is doing something different. And we will need a publishing file "userdata/data/campaigns/Examples_by_Viliam.pbl" like this:

title="Examples by Viliam"
version="0.0.1"
author="Viliam Bur"
passphrase="i_will_not_show_you_my_password__make_your_own"
description="WML examples. I hope this works..."

Now when we start the game and select the "Add-ons" menu, there will be a list of downloadable packages, and also an option to publish this package. I did it... so if anything in this tutorial was not clear, you can just download "Examples by Viliam" and look at the files on your own disk.

If you have any questions about this example, or if you found it useful, please write me a comment here. If you have more questions about creating Wesnoth content, please register into Wesnoth forum and ask there. There are many people in the forum willing to help, if you behave politely and try to search the web page before asking.

Related articles:

Labels:

2008/07/26

Water Battle Map for Wesnoth

Do you know Battle for Wesnoth? It is a turn-based strategy game with a fantasy theme. You can freely download it from the website and start playing right now. (Really, do it! Then return to read the rest of this article.) There is even more. You can create your own maps, design your own military units, and write your own stories; and then you can share them on the Internet. Let's try it now!

This is my first Wesnoth map. I started playing the game a few years ago, in 2003. Then, there was only one campaign with maybe 5 or 10 scenarios, which were followed by a message saying "To be continued..." or something like this. Yeah, those old times... ;-) Do not worry, today all official campaigns in game are completed and tested. So I was a few years contemplating an idea of making my own campaign, but there was always something else to do (for example translating the game to Slovak language). But now I decided that I am going to learn WML (Wesnoth markup language, this game has its own scripting language) and make a few maps, maybe even a full campaign. And while I am doing this, I will turn all my gained knowledge into web tutorials, so that more people can try it and contribute to the game. So this is the first map, hopefully many more will follow.

When you install the game, a map editor is also installed. You can find it (on Windows) in Start menu, as "Wesnoth | Map Editor". Start it!

The maps in Wesnoth consist of hexagonal pieces of terrain (called hexes). When playing game, the borders of hexagons blend to look nicer, more realistic. But in map editor I prefer them visibly separated. The border between hexes can be emphasised by menu option "Settings | Settings | Show Grid". You can also turn on/off the grid using a toolbar button. Now the edges are clearly visible, but in the game they will look normally. There is a similar option in game settings too.

To change map dimensions, select the menu option "Edit | Change map size". Do not worry about setting them right, you can change the dimensions later.

When you move the mouse cursor above the map, you can see two small hexagonal pictures above the selected hex. These are the selected terrains associated with left and right mouse buttons. On the lower right part of editor you can click on various terrains; when you click with left or right mouse button, you associate the terrain with this button. This means that clicking this button on the map will draw this terrain on the selected hex. The terrains in palette are divided into groups, so you can choose if you want to see all terrains or just water terrains, for example.

Most of battles in Wesnoth happen on the ground; the second most frequent place is underground. There are some flying or swimming units, but most units can only walk, so the maps reflect this. You know what? This is not fair! Let's make a map full of water, where the Merfolk and Nagas can enjoy their great water battles. We can use water villages, and water castles...

(C) 2008 Viliam Búr viliambur.blogspot.com

...and then I added some grassland around the lake, patches of swamp, and bridges across, because the big blue area was kind of boring. There are not many different water terrains. We could add new terrains, but not now. Let's keep it simple. It is the first map.

When the map is finished, the last necessary step is to place starting locations. (There is a toolbar button for this. When you are finished, there is another toolbar button to return the terrain painting mode.) Make one starting position for player 1, and another for player 2. The starting location is a place where the leader of this side will appear at the beginning of the game. It is usually in a keep, otherwise s/he would not be able to recruit units. I decided to give each side two castles and put the leader between them. The reasons for this will be explained in another article; now just consider it a harmless whim.

Map Editor screenshot

When everything is ready, we can save the map as "2p_Pool.map" and quit the map editor. The "2p" at the beginning means that it is a multiplayer map for 2 players. By the way, you should sometimes save your map during editing, because you know, bugs exist, and editor may unfortunately crash or freeze, losing your work.

So where is my map saved and how can I play it?

You can play the map by starting Wesnoth, selecting "Multiplayer | Local game" and finding your map in the list of maps. Maps created in map editor are automatically included in the game. You cannot play this map over internet yet, because it does not exist on the opponent's computer. We will get to publishing later. But now you can test the map against the computer, or just let two computer players fight against each other.

All files you create for Wesnoth should be placed in your "userdata" directory. The exact location depends on your operating system and version of Wesnoth; on Windows it is like "C:\Program Files\Wesnoth 1.4.4\userdata". From now on I will just write "userdata" and you will know what I mean. So the maps created in map editor are saved in directory "userdata/editor/maps", unless specified otherwise.

There are some things left to do. For example I want to allow recruiting only Merfolk and Naga units. But these things cannot be done in the map editor, where we can only place terrains and starting positions.

Labels:

Site Map

Welcome, this is my English blog. There are not many pages yet. Hopefully there will be more later. If the pages become too many, here is a list to find what you want: