From The Battle for Wesnoth Wiki
Revision as of 20:23, 23 July 2008 by Paŭlo (talk | contribs) (Optional parameters: Linkfix)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

!!!Work in progress!!!

NOTE: This document describes the new terrain macros currently in 1.5 SVN (which will become 1.5.1). For a deeper understanding of the terrain engine, have a look at [TerrainGraphicsTutorial] and [TerrainGraphicsReference].

General concepts

Optional parameters

There are several parameters in most macros that are not required. If they are not specified, they are assigned a default value, that may depend on the macro. Those parameters are:

  • PROB: The probability that this macro is executed. This is used to make random variations possible. The default value is 100 (i.e. the macro will apply always). See here on how to use it correctly: TerrainGraphicsTutorial#Cumulative_Probabilities
  • LAYER: Specifies the ordering of images. Images with a higher layer are always above images with a lower layer. The default value for base terrains is -1000, the one for transitions between base terrains is -500 and the one for overlay terrain is 0.
  • FLAG: Usually, each type of macro is only applied once, i.e. if there is already a base terrain/a base transition to the tile on the north/ overlay/ overlay transition on one tile, no rule after that will apply. Sometimes you might want to layer several graphics on top of each other, in which case you can specify another flag, as macros with different flags can apply to one tile.

For example:


The "PLF" suffix means that the macro takes the PROB, LAYER and FLAG parameters. A macro with a suffix like "PF" takes only the parameters PROB and FLAG, macros without suffix take none.

Simple tiles

These macros just draw an image onto a tile


Sets IMAGE as base terrain for a tile with TERRAIN. IMAGE should be a 72x72 image, parts that overlap the hex are cut off.

It's commonly used for "flat" terrains like grassland, water but also hills.


Sets IMAGE as an overlay for a tile with TERRAIN. The image is centeres on that tile and can overlap the hex.

It's used together with TERRAIN_BASE for terrains that have a height an can overlap each other depending on their position.


This macro is just a shorthand to place a village on a tile with TERRAIN. Otherwise is works just like OVERLAY.


The TERRAIN_BASE_RANDOM macro is a easy way to have several variants of the same terrain. It uses the images IMAGE.png, IMAGE2.png ... IMAGE9.png and places them with equal probabiltiy. You don't need ten images for every terrain, the macro will also handle all smaller numbers as long as they exist in the correct order (if they are not in order, i.e. IMAGE.png, IMAGE2.png, IMAGE8.png, they will still display, but not with equal probability). Each image is placed in the same way as in TERRAIN_BASE


Works like TERRAIN_BASE_RANDOM, but places images as the OVERLAY macro.


Works like OVERLAY_RANDOM, but with the same layer/flag as the VILLAGE macro.

Transitions and more complex terrains


Creates a "flat" transition between tiles with TERRAIN and ADJACENT. Depending on the number of ADJACENT tiles around the base tile, IMAGE is suffixed with -@R0-@R1-@R2-@R3, -@R0-@R1-@R2, -@R0-@R1 or -@R0. If images with more sides don't exist, the transition will be drawn using images with fewer sides (e.g. a 4-sided transition can also be drawn with one 3-sided and one 1-sided, two 2-sided or four 1-sided images).

Flags on the tiles will be set so that only one transition will be drawn per edge. So a X-Y transition on the south side of the X-tile will prevent a later Y-X transition on the north side of the Y-tile (unless you set a different flag on one of the transitions).

This page was last edited on 23 July 2008, at 20:23.