Skip to main content

Wesnoth terrain

How are maps created? How are terrains organized? These questions are no way different from asking how GNU/Linux works. The brief explanation is, it is very complicated!


Conceptually it works like this:


Terrains are defined in terrain.cfg. They get assigned ID, name, char, etc.


A snippet of terrain.cfg



# Terrain configuration file. Defines how the terrain _work_ in the game. How
# the terrains _look_ is defined in terrain_graphics.cfg .

# NOTE: terrain id's are used implicitly by the in-game help:
# each "[terrain] id=some_id" corresponds to "[section] id=terrain_some_id"
# or "[topic] id=terrain_some_id" identifying its description in [help]

[terrain]
symbol_image=void
id=shroud
name= _ "Shroud"
char=" "
[/terrain]

[terrain]
symbol_image=fog
id=fog
name= _ "Fog"
char="~"
[/terrain]

[terrain]
symbol_image=ocean
id=deep_water
name= _ "Deep Water"
char=s
submerge=0.5
unit_height_adjust=-3
[/terrain]

[terrain]
symbol_image=coast
id=shallow_water
name= _ "Shallow Water"
char=c
submerge=0.4
unit_height_adjust=-4
[/terrain]

--snip--

In terrain-graphics.cfg the char gets assigned to the actual gfx files and given rules for how it is to be placed, layered, transitioned, etc. A normal type terrain gets a base image assigned and optionally several alternative tiles which will be distributed according to a given percentage. Then, it will be fed into the macro responsible for layering and transitioning against other terrains. Multihex terrains use their own custom macros to be assembled and placed (either on top of other terrains or with no background). Castles have their own macros, some terrains are also drawn using the castle macro.


A snippet of terrain-graphics.cfg



# The following flags are defined to have a meaning
#
# * base : the corresponding tile has already graphics for the terrain
# base. No other one should be added.
# * transition-$direction : the corresponding tile already has the transition
# in the given direction (or should not have one). No other one should be
# added.
# * keep-of-$castle : castle being a tile letter. The corresponding tile is the
# keep correspoding to the given castle tile

# The following should be kept on top of the file {terrain-graphics}
#-----------------------------------------------------------------
# Forest< ->Castle|Encampment special cases
#-----------------------------------------------------------------

#define FORESTADJCASTLEA FID ID PROB TILE
[terrain_graphics]
map="
1
* 1
2
* *
*"

[tile]
pos=1
type={ID}
[/tile]

[tile]
pos=2
type={FID}
no_flag="overlay"
set_flag="overlay"
[/tile]

probability={PROB}
rotations=n,ne,se,s,sw,nw

[image]
name={TILE}
position=vertical
base=90,144
[/image]

[/terrain_graphics]
#enddef

--snip--

All sorts of stuff like rotation, precedence, mutual-exclusiveness, ordering, layering, positioning, etc. are the macro’s area of responsibility. You have total control of the game’s interface using the right macro. Ayin made a very powerfull and flexible system, but very complex indeed!


Thanks to freim for the help.

Comments

Popular posts from this blog

Architecture Complexity

Here are the items to consider: Coding to an interface Service Oriented Architecture Automated Testing Domain Driven Design Custom Data Access Layer Layered architecture Complexity is relatively equal the number of lines of code. Note that complexity is not bad. It must be justified.

Repair Windows 7 System Files

8 out of 10 average PC users have their box’s system files altered by malwares, viruses, etc. We usually reinstall the OS if the antivirus and anti malware software did not perform their job well. Here’s one way to fix the corrupted system files without the need of restarting your Windows 7 box. 1. Run the Command Prompt as Administrator 2. Type the following command C:\Windows\system32\> sfc /scannow 3. After the verification phase, you will receive a message about your system files’ integrity Windows Resource Protection did not find any integrity violations.

Android Studio:Unknown Host Error

After installing Android Studio, I got the following error: Unknown host 'services.gradle.org'. Please ensure the host name is correct. If you are behind an HTTP proxy, please configure the proxy settings either in Android Studio or Gradle. Consult IDE log for more details (Help | Show Log) Solution File --> Settings --> HTTP Proxy --> Auto-detect proxy settings