Name

cfed — a level compiler for Crimson Fields

Synopsis

cfed mapsource --tiles tileset --units unitset [-o outfile]

cfed { --help | --version }

Description

cfed is the Crimson Fields level compiler.

It creates a *.lev file out of a source file *.src. You can use any standard text editor to create the level source files (for the syntax of those files, see File Format below). cfed reads the input file and creates the level file. If the name of the ouput file is not given on the command line, it is created in the same location as the source file with the .src suffix substituted by .lev.

Options

--help

Print a usage message on standard output and exit.

--tiles tileset

Use the tile definitions from tileset when compiling the map.

--units unitset

Use the unit definitions from unitset when compiling the map.

--version

Print version information on standard output and exit.

-o

Set the name and path of the converted level file.

File Format

A level source file consists of sections. A section is started by the section name in square brackets, i.e. the line

[unit]

starts a unit section. Lines in a section are usually composed like this:

qualifier = value

The only exceptions to this are the map and messages sections. Lines starting with # are considered comments. The following sections exist:

mission

This section defines some global mission parameters like map size or the graphics set to use. The mission section is mandatory and must appear before the map section in the file. Valid qualifiers are

name

index of a message containing the mission title. This name will be used when presenting the list of available maps to the player. (maximum length 30 characters, mandatory)

mapwidth

[10-200] (mandatory)

mapheight

[10-200] (mandatory)

nextmap

the name of another map (without path and file ending). After the current map has been completed, this new map will be loaded automatically. This tag is only valid for campaign maps.

info

index of the information message that is to be shown when a player requests level information. This message can contain the level name, author, revision, etc.

campaign

indicates whether the map is part of a campaign [0|1]. Default is 0 (not part of a campaign). See also campaignname and campaigninfo.

campaignname

index of the campaign name. It should be set only when the map actually is the first of a campaign. See also campaign and campaigninfo. (mandatory and valid only for the introductory map of a campaign)

campaigninfo

index of the information message for the campaign. This info is displayed when starting a new campaign and should contain a short outline of the background story. It is useful only when the map actually is the first of a campaign. See also campaign and campaignname.

players

selects whether the map is intended for play against another human being (2) or against the computer (1). This is for informational purposes only and defaults to 2.

music

name of a soundtrack (either MIDI or Ogg Vorbis) excluding the file type suffix to be played during this map. If the setting is missing, the default track for Crimson Fields will be played.

tileset

tileset file to be used. A tileset contains the map graphics and terrain definitions. The filename must be given without the .tiles suffix. If omitted, the tile set defaults to 'default'.

unitset

unit set file to be used. A unit set contains the unit graphics and definitions. The filename must be given without the .units suffix. If omitted, the unit set defaults to 'default'.

map

The map section defines the actual map layout. It is a rectangle of the size specified in the mission section, consisting of various symbols which describe a certain map tile type. The map section is mandatory and may not contain comments. The following symbols exist.

.

plains

*

forest

%

mountains

=

shallow water

~

water

-

deep water

#

swamp

"

cliff

0

headquarters, neutral entrance, east

1

headquarters, yellow entrance, east

2

headquarters, blue entrance, east

3

depot, neutral entrance, north

4

depot, yellow entrance, north

5

depot, blue entrance, north

6

factory, neutral entrance, north

7

factory, yellow entrance, north

8

factory, blue entrance, north

9

factory, neutral entrance, east

J

factory, yellow entrance, east

L

factory, blue entrance, east

A

city, yellow

B

city, blue

C

city, neutral

D

headquarters, yellow entrance, west

E

headquarters, blue entrance, west

F

headquarters, neutral entrance, west

G

headquarters, yellow entrance, north

H

headquarters, blue entrance, north

I

headquarters, neutral entrance, north

>

headquarters, east

<

headquarters, west

^

headquarters, north

v

headquarters, south

\

road, se-nw

|

road, s-n

/

road, sw-ne

y

road, sw-n-ne

Y

road, se-n-nw

X

road, s-se-nw-n

x

road, s-sw-n-ne

o

road, sw-nw-ne-se

k

road, sw-s-ne

K

road, s-se-nw

(

road, n-se

)

road, n-sw

]

road, nw-s

[

road, ne-s

n

road, sw-se

u

road, nw-ne

T

road, n-s-se

U

road, n-s-sw

V

road, n-s-ne

W

road, n-s-nw

!

bridge, n-s

`

bridge, sw-ne

 '

bridge, se-nw

a

fence, se-nw end

b

fence, nw-se end

c

fence, ne-sw end

d

fence, sw-ne end

e

fence, n-s

f

fence, sw-ne

g

fence, nw-se

h

fence, nw-s

i

fence, ne-s

j

fence, sw-n

l

fence, se-n

m

fence, nw-ne

p

fence, sw-se

There is also an alternative format. If the section is called map-raw instead, the map is defined by giving the hexagon identifiers directly, using the comma as a tile separator. This approach requires intimate knowledge of the tileset used and may break the map if the tileset changes. The format has been created because there are now more tiles than can be represented with single ASCII characters.

player

This can be used to set some player definitions. There may be a maximum of two player sections in a file. The first section encountered corresponds to the first player, the next to the second. Valid qualifiers are

name

index of a message containing the player name (mandatory, maximum length 20 characters)

briefing

index of the player's briefing message. The briefing can be reviewed during the game by choosing the Briefing item from the Game Menu. It is also recommended to create a message event to tell the players about their objectives on the first turn (see event and messages sections below). If omitted defaults to -1, meaning that no briefing is available.

fcolor

foreground color to use for this player in the format r,g,b, e.g. 255,0,0 for red. The default player colors match the default unit set, but different sets may use different color schemes (also see bcolor).

bcolor

background color to use for this player in the format r,g,b, e.g. 0,0,255 for blue. The default player colors match the default unit set, but different sets may use different color schemes (also see fcolor).

unit

Each of these sections creates a unit on the map. Loaded transporter units must be specified before any units they carry. Valid qualifiers for units are

xpos, ypos

location of the unit on the map. If there is a building at the given location, the unit will be put in. It is also possible to let units begin inside a transport. In that case you have to make sure, however, that in the level file the transport is declared before the carried unit. (mandatory)

id

unique unit identifier [0-10000]. (mandatory)

type

unit type definition to use for this unit. Known definitions for the default unit set are Infantry, Medium Tanks, Heavy Tanks, Anti-Aircraft Tanks, Anti-Aircraft Guns, Artillery, Mines, Patrol Boats, Fighter Squadron, Personnel Carriers, Troopships, Transport Planes, Scouts, Interceptors, Bunkers, Torpedo Boats, Bomber Wing, Hovercraft, Gunships, Troop Train, Rail Guns, Armoured Train, Submarines, and Aircraft Carriers. (mandatory)

player

unit controller [1|2]. (mandatory)

size

number of vehicles for this unit [1-6]. Defaults to 6 (undamaged).

xp

experience level this unit starts at [0-6]. Defaults to 0 (Rookie, no experience).

face

direction the unit is heading [0-5]. Directions are numbered clockwise from North (0) to Northwest (5). Defaults are North (0) for units controlled by player 1, and South (3) for the second player.

crystals

amount of crystals the unit carries. This may only be given for transports and defaults to 0.

building

A building section is required to actually create a building (sometimes also called a shop) on the map that units can enter. This is not automatically done by placing the symbol for a building entrance in the map section.

xpos, ypos

location of the building entrance on the map. (mandatory)

id

unique building identifier [0-10000]. (mandatory)

player

building controller [1|2|0]. Units starting in unaligned buildings are automatically tagged unaligned as well. (mandatory)

type

type of building. Units can be repaired in buildings of type Workshop. New units can be produced in buildings of type Factory. A building may have multiple types. Defaults to Depot, meaning no special attributes. In addition to these attributes, a shop which produces crystals is (automatically) called a Mine.

name

index of a message containing the shop name (mandatory, maximum length 30 characters)

mining

amount of crystals produced each turn [0-1000]. Defaults to 0. If given, implies type Mine.

capacity

maximum amount of crystals [0-10000]. Defaults to 1000.

crystals

amount of crystals in stock [0-capacity]. Defaults to 0.

factory

name of a unit type definition that can be built here. If given, implies type = factory. Multiple factory lines may be given for a shop.

minweight

weight of the smallest unit allowed to enter the building [0-99]. Defaults to 0.

maxweight

weight of the heaviest unit allowed to enter the building [0-99]. Defaults to 99.

event

Events provide a way to interact with players during a game. They can cause actions like points being awarded or messages being displayed under certain conditions. The event type defines what happens, the event trigger controls when (or if) the event is executed.

Event Types

createunit

create a unit somewhere on the map.

manipulateevent

modify event internals. Currently this can be used to dynamically enable or disable an event.

message

display a message.

mining

set the amount of crystals for a building.

nextmap

change the setting for the next map to be played. Can be used to create dynamic campaigns.

research

make a new unit type available for production in a factory.

score

award points to a player.

Event Triggers

handicap

the event is executed if the set handicap matches the current game settings. Usually such an event is triggered immediately on the first turn or not at all. You can, however, combine multiple events (e.g. a handicap and a turn trigger) to change the default behaviour.

havebuilding

the event is executed when the player controls a certain building on a specified turn.

haveunit

the event is executed when the player controls a certain unit on a specified turn.

turn

the event is unconditionally executed on the specified turn.

unitdestroyed

the event is executed when a specified unit is destroyed or captured by the enemy.

unitposition

the event is executed when a specified unit ends its move on a certain target hex.

The following list contains generic qualifiers which are valid for all event types.

Qualifiers

id

unique event identifier [0-200]. (mandatory)

type

event type (mandatory, see below).

trigger

event trigger (mandatory). This describes the circumstances under which the event is executed (see below).

message

index of a message to be displayed when the event occurs.

title

title of the message window. Only useful when a message is shown.

depend

identifier of another event. This makes the current event depend on the given event. Prior to event execution, the trigger conditions for both events are checked, and the event is activated only if both are successful. Mutual, circular, and transitive dependencies are supported.

In addition there are special qualifiers which can only be used with certain event types or triggers. All of these are mandatory if nothing else is stated.

action (manipulateevent, mining)

For manipulateevent this defines how to handle the specified flags. A value of 0 will set, 1 will clear, and 2 will toggle the flags. For mining 0 will set the crystal storage to an absolute amount, 1 will modify the current amount by the given number, 2 will set the mining rate, i.e. the amount mined each turn, and 3 will change the current mining rate by the given value. Minimum mining rate is 0, maximum is 200.

building (mining, research)

Identifier of the building referenced in the event.

crystals (mining)

Amount of crystals. The action flag controls how this number is actually interpreted.

event (manipulateevent)

Identifier of the event to be modified.

flags (manipulateevent)

Event flags to be modified. Currently the only legal value for this is 1, the disable flag, which can be used to deactivate an event. Disabled events won't be triggered even if their trigger conditions are met.

map (nextmap)

For this event you must create a message in the messages section which contains the name of the map to be loaded (excluding file path and suffix). The event then needs to know the message identifier.

othermsg (score)

For score events, one often wants to show a message not only to the player who benefits from the event but also to his opponent. Instead of creating a separate message event with inverted trigger conditions you can use this qualifier and othertitle to do just that (optional).

othertitle (score)

Index of the message title for the other player (optional, see othermsg)

success (score)

Amount of success points the player receives when the event occurs. Any player with a success score of 100 or more wins the game.

unit (createunit, research)

Name of a unit type specification to build or make available, respectively.

tbuilding (havebuilding)

Identifier of the building to be controlled.

thandicap (handicap)

Handicap setting to trigger the event [1 (none)|2 (player 1 handicapped)|4 (player 2 handicapped)]. You can add up the numbers to trigger on more than one setting.

towner (havebuilding, haveunit, unitdestroyed)

The event will only occur if the new owner of the building or unit is the same as the player specified here [1|2]. For the unitdestroyed trigger it is only required if tunit is -1. In this case you can select the player whose units have to be destroyed to activate the event. This setting may be omitted and defaults to the player not owning the event otherwise. You must supply this key for the other two trigger types.

tturn (havebuilding, haveunit, turn)

Turn on which the event conditions should be checked. For turn the event will always be executed on this turn. (mandatory only for turn. If omitted for the other triggers, the condition will be checked each turn.)

tunit (haveunit, unitdestroyed, unitposition)

Identifier of the unit to be targeted. For unitdestroyed and unitposition this may take a value of -1 which will activate the event when all enemy units have been destroyed or any unit controlled by this player has reached the destination hex, respectively.

txpos, typos (unitposition)

Coordinates of the target hex

xpos, ypos (createunit)

hex to create the unit on. The unit will only be created if the target hex is empty at creation time or there is a shop or a valid transporter which is controlled by the player for whom the event is set up.

messages

The messages section contains all text messages that may possibly be displayed in the course of a mission. The format of this section differs from that of the other sections. Here is an excerpt from an imaginary level file.

[messages(en)]
This is a message.
% this line separates messages
This is the second message.
% separator lines can be used for comments
This is the third message,
containing a line break.
[/messages] this marks the end of the messages section
  

The two characters in brackets identify the language messages in this section are written in. There is one messages section for each language the mission supports. The (en) in the section title shows that this section contains English messages. All messages must be encoded in UTF-8.

Example

### This is a simple example mission file

[mission]
# mission title is "The Great Example"
name = 5
mapwidth = 11
mapheight = 10
# the first message in the [messages] section
# will be used as level information
info = 0
# we use the default tileset and unit set so we could
# omit the next two lines
tileset = default
unitset = default

[map]
***...***..
**...****.=
*<^1n]*..==
**v..(..==~
***...].=~~
#=#.==!====
======(]...
%*.=...E^>.
%%..%...v..
%%%%.%...**


### first player - The Good
[player]
name = 6
# second message is briefing for this player
briefing = 1

### second player - The Bad
[player]
name = 7
# third message is briefing for this player
briefing = 2


### units for player 1

[unit]
# this unit will start in the building
xpos = 3
ypos = 2
player = 1
id = 0
type = Infantry

[unit]
xpos = 5
ypos = 4
player = 1
id = 1
type = Medium Tanks

[unit]
xpos = 6
ypos = 3
player = 1
id = 2
type = Medium Tanks

[unit]
xpos = 3
ypos = 2
player = 1
id = 3
type = Scouts


### units for player 2

[unit]
xpos = 7
ypos = 7
player = 2
id = 10
type = Anti-Aircraft Tanks

[unit]
xpos = 6
ypos = 6
player = 2
id = 11
type = Personnel Carriers

[unit]
xpos = 7
ypos = 6
player = 2
id = 12
type = Infantry

[unit]
xpos = 7
ypos = 7
player = 2
id = 13
type = Heavy Tanks


### buildings

# HQ of the Good
[building]
name = 8
xpos = 3
ypos = 2
id = 0
player = 1
# can repair units here
type = workshop
crystals = 25

# HQ of the Bad
[building]
name = 9
xpos = 7
ypos = 7
id = 1
player = 2
# can repair and build units
type = workshop
type = factory
# the following units can be built
factory = personnel carriers
factory = anti-aircraft guns
factory = bomber wing
crystals = 25

### events

# player 1 wins if he conquers
# the enemy building at any time...
[event]
type = score
id = 0
player = 1
trigger = havebuilding
tbuilding = 1
towner = 1
# the next line could be left out
tturn = -1
success = 100
message = 3
title = 4

# ...or destroys all enemy units
[event]
type = score
id = 1
player = 1
trigger = unitdestroyed
tunit = -1
success = 100


# player 2 wins if he conquers
# the enemy building at any time...
[event]
type = score
id = 2
player = 2
trigger = havebuilding
tbuilding = 0
towner = 2
success = 100
message = 3
title = 4

# ...or destroys all enemy units as well
[event]
type = score
id = 3
player = 2
trigger = unitdestroyed
tunit = -1
success = 100

# display briefings on first turn
#
[event]
type = message
id = 4
player = 1
trigger = turn
tturn = 1
title = 5
message = 1

[event]
type = message
id = 5
player = 2
trigger = turn
tturn = 1
title = 5
message = 2

# we want to support difficulty levels (handicaps)
#
# if player 1 is handicapped we allocate some more
# crystals to players 2's factory
[event]
type = mining
id = 6
player = 2
trigger = handicap
# 1 is no handicap, 2 is player 1, 4 is player 2
thandicap = 2
building = 1
action = 1
crystals = 35

# if player 2 is handicapped player 1 gets another tank
[event]
type = createunit
id = 7
player = 1
trigger = handicap
thandicap = 4
unit = Medium Tanks
xpos = 3
ypos = 2

### english messages

[messages(en)]
The Great Example
Revision 5 (16-04-2004)
by Jens Granseuer <jensgr@gmx.net>
%
This is a nice introductory message, so that player 1 knows what he is expected to do. Word wraps are done automatically, so don't include line breaks if you don't want them. So, Player 1, let's take them apart:

Either conquer the enemy headquarters or destroy all their troops.
%
This should present the situation to player 2.

You are being attacked. Defend yourself. The attack is considered repelled if you gain control of the enemy headquarters or the entire attacking army is no more.
%
This is the success message for conquering the enemy headquarters.
Congratulations!
%
Hip! Hip! Hurrah!
%
The Great Example
%
The Good
%
The Bad
%
HQ of the Good
%
HQ of the Bad
[/messages]

Notes

The file format of level files (source and data) is subject to change without notice. If you get an error "File not of the required type", it mostly should be sufficient to feed the appropriate source file to cfed again to create a valid level file. However, no promises are being made. You have been warned!

cfed will eventually be phased out in favour of CoMET, the graphical map editor for crimson.

See Also

crimson(6), bi2cf(6)

Copyright

Copyright © 2000-2004 Jens Granseuer

This software is distributed under the terms of the GNU General Public License (GPL).