Difference between revisions of "TerrainMacros"

From The Battle for Wesnoth Wiki
m (Optional parameters: Linkfix)
(Optional parameters: fix redlink)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
!!!Work in progress!!!
 
!!!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].
+
NOTE: This document describes the terrain macros that were new in 1.5 SVN (which became 1.5.1). For a deeper understanding of the terrain engine, have a look at [[TerrainGraphicsWML]], [[MultiHexTutorial]], and [[TerrainGraphicsReference]].
  
 
==General concepts==
 
==General concepts==
Line 9: Line 9:
 
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:
 
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]]
+
* 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: [http://web.archive.org/web/20170323180423/http://wiki.wesnoth.org/TerrainGraphicsTutorial#Cumulative_Probabilities 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.
 
* 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.
 
* 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.

Latest revision as of 17:20, 5 August 2021

!!!Work in progress!!!

NOTE: This document describes the terrain macros that were new in 1.5 SVN (which became 1.5.1). For a deeper understanding of the terrain engine, have a look at TerrainGraphicsWML, MultiHexTutorial, 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:

MACRO_PLF TERRAIN1 ... TERRAIN{n} PROB LAYER FLAG IMAGE

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

TERRAIN_BASE TERRAIN [PROB] [LAYER] [FLAG] IMAGE

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.

OVERLAY TERRAIN [PROB] [LAYER] [FLAG] IMAGE

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.

VILLAGE TERRAIN [PROB] IMAGE

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

TERRAIN_BASE_RANDOM TERRAIN [LAYER] [FLAG] IMAGE

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

OVERLAY_RANDOM TERRAIN [LAYER] [FLAG] IMAGE

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

VILLAGE_RANDOM TERRAIN IMAGE

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

Transitions and more complex terrains

TRANSITION_BASE TERRAIN ADJACENT [PROB] [LAYER] [FLAG] IMAGE

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 5 August 2021, at 17:20.