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.

Moving on

So I bought my self a 2.5″ hard drive enclosure for about 750 bucks. I wish I have my own tools for constructing a device as such. Instead of going for a 2GB USB flash drive, I chose to salvage the 30GB hard drive of an incapacitated laptop. Cool isn’t it? Though relatively slower than a typical USB flash drive, the storage capacity outweighs it. [To God] Thanks for being there always.

Bin to hex converter in 16-bit DOS assembly

Just a quick code like putting your keyboard where your brain is. There should be another way of doing this. I hate this code. start: xor al, al xor bl, bl xor cl, cl mov dl, 4 ; use dl as counter input: mov ah, 00 int 16h cmp ah, 1ch je exit cmp al, '0' jb input cmp al, '1' ja input convert: mov cl, dl dec cl ; dl - 1 sub al, 30h ; get original value shl al, cl ; place in the appropriate bit position or bl, al ; save in bl dec dl ; prepare for the next bit jnz input ; must be 4 bits cmp bl, 9 ja letter jbe number letter: add bl, 37h ; because 'A' - 37h is 0Ah jmp here number: add bl, 30h ; because '0' - 30h is 00h here: call display jmp start display: mov ah, 02h ...