<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<refentry id="cfed.6">
<refentryinfo>
  <date>November 22 2003</date>
  <author>
    <firstname>Jens</firstname>
    <surname>Granseuer</surname>
    <address><email>jensgr@gmx.net</email></address>
  </author>
</refentryinfo>

<refmeta>
  <refentrytitle>cfed</refentrytitle>
  <manvolnum>6</manvolnum>
</refmeta>

<refnamediv>
  <refname>cfed</refname>
  <refpurpose>a level compiler for Crimson Fields</refpurpose>
</refnamediv>

<refsynopsisdiv>
  <cmdsynopsis>
    <command>cfed</command>
    <arg choice="plain"><replaceable>mapsource</replaceable></arg>
    <arg choice="plain">--tiles <replaceable>tileset</replaceable></arg>
    <arg choice="plain">--units <replaceable>unitset</replaceable></arg>
  </cmdsynopsis>

  <cmdsynopsis>
    <command>cfed</command>
    <group choice="req">
      <arg choice="plain">--help</arg>
      <arg choice="plain">--version</arg>
    </group>
  </cmdsynopsis>
</refsynopsisdiv>

<refsect1><title>Description</title>
  <para><command>cfed</command> is the <application>Crimson
  Fields</application> level compiler.</para>

  <para>It creates a <filename>*.lev</filename> file out of a source file
  <filename>*.src</filename>. You can use any standard text editor to
  create the level source files (for the syntax of those files, see
  <link linkend="format">File Format</link> below).
  <command>cfed</command> reads the input file and creates the level file,
  which is named after the <emphasis>title</emphasis> given in the mission
  description, to the current directory. You can also have a look at the
  existing levels for more hints.</para>
</refsect1>

<refsect1><title>Options</title>
  <variablelist>
    <varlistentry>
      <term><option>--help</option></term>
      <listitem>
        <para>Print a usage message on standard output and exit.</para>
      </listitem>
    </varlistentry>

    <varlistentry>
      <term><option>--tiles</option> <replaceable>tileset</replaceable></term>
      <listitem>
        <para>Use the tile definitions from <replaceable>tileset</replaceable>
         when compiling the map.</para>
      </listitem>
    </varlistentry>

    <varlistentry>
      <term><option>--units</option> <replaceable>unitset</replaceable></term>
      <listitem>
        <para>Use the unit definitions from <replaceable>unitset</replaceable>
        when compiling the map.</para>
      </listitem>
    </varlistentry>

    <varlistentry>
      <term><option>--version</option></term>
      <listitem>
        <para>Print version information on standard output and
        exit.</para>
      </listitem>
    </varlistentry>
  </variablelist>
</refsect1>

<refsect1 id="format"><title id="format.title">File Format</title>
  <para>A level source file consists of sections. A section is started
  by the section name in square brackets, i.e. the line</para>
  <para><computeroutput>[unit]</computeroutput></para>
  <para>starts a unit section. Lines in a section are usually composed
  like this:</para>
  <para><computeroutput>qualifier = value</computeroutput></para>
  <para>The only exceptions to this are the <emphasis>map</emphasis> and
  <emphasis>messages</emphasis> sections. Lines starting with
  <computeroutput>#</computeroutput> are considered comments. The
  following sections exist:</para>

  <refsect2><title>mission</title>
    <para>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</para>

  <variablelist>
    <varlistentry>
      <term>title</term><listitem>
        <para>mission title (maximum length 29 characters, mandatory)</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>mapwidth</term>
      <listitem><para>[10-200] (mandatory)</para></listitem>
    </varlistentry>
    <varlistentry>
      <term>mapheight</term>
      <listitem><para>[10-200] (mandatory)</para></listitem>
    </varlistentry>
    <varlistentry>
      <term>nextmap</term><listitem>
        <para>index of a message containing the name of another map
        (without path and file ending). After the current map has been
        completed, this new map will be loaded automatically. If this tag
        is omitted, the game will return to the main menu after the
        current map.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>info</term><listitem>
        <para>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.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>password</term><listitem>
        <para>A level may be protected by a password. This can be used
        in campaign games to play maps in a specific order. The password
        will not be checked if the map is loaded via the
        <emphasis>nextmap</emphasis> flag above. Level passwords must have
        exactly seven characters. All protected maps should tell the
        player about the access code in the level information message.
        </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>players</term><listitem>
        <para>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.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>tileset</term><listitem>
        <para>tileset file to be used. A tileset contains the map
        graphics and terrain definitions. The filename must be given
        without the <filename>.tiles</filename> suffix. If omitted, the
        tile set defaults to 'default'.</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>unitset</term><listitem>
        <para>unit set file to be used. A unit set contains the unit
        graphics and definitions. The filename must be given without the
        <filename>.units</filename> suffix. If omitted, the unit set
        defaults to 'default'.</para>
      </listitem>
    </varlistentry>
  </variablelist>
  </refsect2>

  <refsect2><title>map</title>
  <para>The map section defines the actual map layout. It is a rectangle
  of the size specified in the <emphasis>mission</emphasis> 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.</para>

  <variablelist>
  <varlistentry><term>.</term><listitem><para>plains</para></listitem></varlistentry>
  <varlistentry><term>*</term><listitem><para>forest</para></listitem></varlistentry>
  <varlistentry><term>%</term><listitem><para>mountains</para></listitem></varlistentry>
  <varlistentry><term>=</term><listitem><para>shallow water</para></listitem></varlistentry>
  <varlistentry><term>~</term><listitem><para>water</para></listitem></varlistentry>
  <varlistentry><term>-</term><listitem><para>deep water</para></listitem></varlistentry>
  <varlistentry><term>#</term><listitem><para>swamp</para></listitem></varlistentry>
  <varlistentry><term>&quot;</term><listitem><para>cliff</para></listitem></varlistentry>
  <varlistentry><term>0</term><listitem><para>headquarters, neutral entrance, east</para></listitem></varlistentry>
  <varlistentry><term>1</term><listitem><para>headquarters, yellow entrance, east</para></listitem></varlistentry>
  <varlistentry><term>2</term><listitem><para>headquarters, blue entrance, east</para></listitem></varlistentry>
  <varlistentry><term>3</term><listitem><para>depot, neutral entrance, north</para></listitem></varlistentry>
  <varlistentry><term>4</term><listitem><para>depot, yellow entrance, north</para></listitem></varlistentry>
  <varlistentry><term>5</term><listitem><para>depot, blue entrance, north</para></listitem></varlistentry>
  <varlistentry><term>6</term><listitem><para>factory, neutral entrance, north</para></listitem></varlistentry>
  <varlistentry><term>7</term><listitem><para>factory, yellow entrance, north</para></listitem></varlistentry>
  <varlistentry><term>8</term><listitem><para>factory, blue entrance, north</para></listitem></varlistentry>
  <varlistentry><term>9</term><listitem><para>factory, neutral entrance, east</para></listitem></varlistentry>
  <varlistentry><term>J</term><listitem><para>factory, yellow entrance, east</para></listitem></varlistentry>
  <varlistentry><term>L</term><listitem><para>factory, blue entrance, east</para></listitem></varlistentry>
  <varlistentry><term>A</term><listitem><para>city, yellow</para></listitem></varlistentry>
  <varlistentry><term>B</term><listitem><para>city, blue</para></listitem></varlistentry>
  <varlistentry><term>C</term><listitem><para>city, neutral</para></listitem></varlistentry>
  <varlistentry><term>D</term><listitem><para>headquarters, yellow entrance, west</para></listitem></varlistentry>
  <varlistentry><term>E</term><listitem><para>headquarters, blue entrance, west</para></listitem></varlistentry>
  <varlistentry><term>F</term><listitem><para>headquarters, neutral entrance, west</para></listitem></varlistentry>
  <varlistentry><term>G</term><listitem><para>headquarters, yellow entrance, north</para></listitem></varlistentry>
  <varlistentry><term>H</term><listitem><para>headquarters, blue entrance, north</para></listitem></varlistentry>
  <varlistentry><term>I</term><listitem><para>headquarters, neutral entrance, north</para></listitem></varlistentry>
  <varlistentry><term>&gt;</term><listitem><para>headquarters, east</para></listitem></varlistentry>
  <varlistentry><term>&lt;</term><listitem><para>headquarters, west</para></listitem></varlistentry>
  <varlistentry><term>^</term><listitem><para>headquarters, north</para></listitem></varlistentry>
  <varlistentry><term>v</term><listitem><para>headquarters, south</para></listitem></varlistentry>
  <varlistentry><term>\</term><listitem><para>road, se-nw</para></listitem></varlistentry>
  <varlistentry><term>|</term><listitem><para>road, s-n</para></listitem></varlistentry>
  <varlistentry><term>/</term><listitem><para>road, sw-ne</para></listitem></varlistentry>
  <varlistentry><term>y</term><listitem><para>road, sw-n-ne</para></listitem></varlistentry>
  <varlistentry><term>Y</term><listitem><para>road, se-n-nw</para></listitem></varlistentry>
  <varlistentry><term>X</term><listitem><para>road, s-se-nw-n</para></listitem></varlistentry>
  <varlistentry><term>x</term><listitem><para>road, s-sw-n-ne</para></listitem></varlistentry>
  <varlistentry><term>o</term><listitem><para>road, sw-nw-ne-se</para></listitem></varlistentry>
  <varlistentry><term>k</term><listitem><para>road, sw-s-ne</para></listitem></varlistentry>
  <varlistentry><term>K</term><listitem><para>road, s-se-nw</para></listitem></varlistentry>
  <varlistentry><term>(</term><listitem><para>road, n-se</para></listitem></varlistentry>
  <varlistentry><term>)</term><listitem><para>road, n-sw</para></listitem></varlistentry>
  <varlistentry><term>]</term><listitem><para>road, nw-s</para></listitem></varlistentry>
  <varlistentry><term>[</term><listitem><para>road, ne-s</para></listitem></varlistentry>
  <varlistentry><term>n</term><listitem><para>road, sw-se</para></listitem></varlistentry>
  <varlistentry><term>u</term><listitem><para>road, nw-ne</para></listitem></varlistentry>
  <varlistentry><term>T</term><listitem><para>road, n-s-se</para></listitem></varlistentry>
  <varlistentry><term>U</term><listitem><para>road, n-s-sw</para></listitem></varlistentry>
  <varlistentry><term>V</term><listitem><para>road, n-s-ne</para></listitem></varlistentry>
  <varlistentry><term>W</term><listitem><para>road, n-s-nw</para></listitem></varlistentry>
  <varlistentry><term>!</term><listitem><para>bridge, n-s</para></listitem></varlistentry>
  <varlistentry><term>`</term><listitem><para>bridge, sw-ne</para></listitem></varlistentry>
  <varlistentry><term>&nbsp;'</term><listitem><para>bridge, se-nw</para></listitem></varlistentry>
  <varlistentry><term>a</term><listitem><para>fence, se-nw end</para></listitem></varlistentry>
  <varlistentry><term>b</term><listitem><para>fence, nw-se end</para></listitem></varlistentry>
  <varlistentry><term>c</term><listitem><para>fence, ne-sw end</para></listitem></varlistentry>
  <varlistentry><term>d</term><listitem><para>fence, sw-ne end</para></listitem></varlistentry>
  <varlistentry><term>e</term><listitem><para>fence, n-s</para></listitem></varlistentry>
  <varlistentry><term>f</term><listitem><para>fence, sw-ne</para></listitem></varlistentry>
  <varlistentry><term>g</term><listitem><para>fence, nw-se</para></listitem></varlistentry>
  <varlistentry><term>h</term><listitem><para>fence, nw-s</para></listitem></varlistentry>
  <varlistentry><term>i</term><listitem><para>fence, ne-s</para></listitem></varlistentry>
  <varlistentry><term>j</term><listitem><para>fence, sw-n</para></listitem></varlistentry>
  <varlistentry><term>l</term><listitem><para>fence, se-n</para></listitem></varlistentry>
  <varlistentry><term>m</term><listitem><para>fence, nw-ne</para></listitem></varlistentry>
  <varlistentry><term>p</term><listitem><para>fence, sw-se</para></listitem></varlistentry>
  </variablelist>
  <para>There is also an alternative format. If the section is called
  <emphasis>map-raw</emphasis> 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.</para>
  </refsect2>

  <refsect2><title>player</title>
  <para>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</para>

  <variablelist>
    <varlistentry><term>name</term><listitem>
      <para>player name. If omitted this defaults to 'Player 1' or
      'Player 2', depending on the position in the file. (maximum length
      15 characters)</para>
    </listitem></varlistentry>
    <varlistentry><term>briefing</term><listitem>
      <para>index of the player's briefing message. The briefing can be
      reviewed during the game by choosing the
      <guimenuitem>Briefing</guimenuitem> item from the
      <guimenu>Game</guimenu> Menu. It is also recommended to create a
      <emphasis>message</emphasis> event to tell the players about their
      objectives on the first turn (see <emphasis>event</emphasis> and
      <emphasis>messages</emphasis> sections below). If omitted defaults to
      -1, meaning that no briefing is available.</para>
    </listitem></varlistentry>
  </variablelist>
  </refsect2>

  <refsect2><title>unit</title>
  <para>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</para>

  <variablelist>
    <varlistentry><term>xpos</term><term>ypos</term><listitem>
      <para>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)</para>
    </listitem></varlistentry>
    <varlistentry><term>id</term><listitem>
      <para>unique unit identifier [0-10000]. (mandatory)</para>
    </listitem></varlistentry>
    <varlistentry><term>type</term><listitem>
      <para>unit type definition to use for this unit. Known definitions
      for the default unit set are <emphasis>Infantry</emphasis>,
      <emphasis>Medium Tanks</emphasis>, <emphasis>Heavy Tanks</emphasis>,
      <emphasis>Anti-Aircraft Tanks</emphasis>, <emphasis>Anti-Aircraft Guns</emphasis>,
      <emphasis>Artillery</emphasis>, <emphasis>Mines</emphasis>,
      <emphasis>Patrol Boats</emphasis>, <emphasis>Fighter Squadron</emphasis>,
      <emphasis>Personnel Carriers</emphasis>, <emphasis>Troopships</emphasis>,
      <emphasis>Transport Planes</emphasis>, <emphasis>Scouts</emphasis>,
      <emphasis>Interceptors</emphasis>, <emphasis>Bunkers</emphasis>,
      <emphasis>Torpedo Boats</emphasis>, <emphasis>Bomber Wing</emphasis>,
      <emphasis>Hovercraft</emphasis>, <emphasis>Gunships</emphasis>,
      <emphasis>Troop Train</emphasis>, <emphasis>Rail Guns</emphasis>,
      <emphasis>Armoured Train</emphasis>, <emphasis>Submarines</emphasis>,
      and <emphasis>Aircraft Carriers</emphasis>. (mandatory)</para>
    </listitem></varlistentry>
    <varlistentry><term>player</term><listitem>
      <para>unit controller [1|2]. (mandatory)</para>
    </listitem></varlistentry>
    <varlistentry><term>face</term><listitem>
      <para>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.</para>
    </listitem></varlistentry>
    <varlistentry><term>crystals</term><listitem>
      <para>amount of crystals the unit carries. This may only be given
      for transports and defaults to 0.</para>
    </listitem></varlistentry>
  </variablelist>
  </refsect2>

  <refsect2><title>building</title>
  <para>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.</para>

  <variablelist>
    <varlistentry><term>xpos</term><term>ypos</term><listitem>
      <para>location of the building entrance on the map. (mandatory)</para>
    </listitem></varlistentry>
    <varlistentry><term>id</term><listitem>
      <para>unique building identifier [0-10000]. (mandatory)</para>
    </listitem></varlistentry>
    <varlistentry><term>player</term><listitem>
      <para>building controller [1|2|0]. Units starting in unaligned
      buildings are automatically tagged unaligned as well. (mandatory)
      </para>
    </listitem></varlistentry>
    <varlistentry><term>type</term><listitem>
      <para>type of building. Units can be repaired in buildings of type
      <emphasis>Workshop</emphasis>. New units can be produced in buildings
      of type <emphasis>Factory</emphasis>. A building may have multiple types.
      Defaults to <emphasis>Depot</emphasis>, meaning no special attributes.
      In addition to these attributes, a shop which produces crystals is
      (automatically) called a <emphasis>Mine</emphasis>.
      </para>
    </listitem></varlistentry>
    <varlistentry><term>name</term><listitem>
      <para>building name (maximum length 20 characters). Default value
      corresponds to building type.</para>
    </listitem></varlistentry>
    <varlistentry><term>mining</term><listitem>
      <para>amount of crystals produced each turn [0-1000]. Defaults to
      0. If given, implies type <emphasis>Mine</emphasis>.</para>
    </listitem></varlistentry>
    <varlistentry><term>capacity</term><listitem>
      <para>maximum amount of crystals [0-10000]. Defaults to 1000.</para>
    </listitem></varlistentry>
    <varlistentry><term>crystals</term><listitem>
      <para>amount of crystals in stock [0-capacity]. Defaults to 0.</para>
    </listitem></varlistentry>
    <varlistentry><term>factory</term><listitem>
      <para>name of a unit type definition that can be built here. If
      given, implies <computeroutput>type = factory</computeroutput>.
      Multiple <emphasis>factory</emphasis> lines may be given for a shop.</para>
    </listitem></varlistentry>
    <varlistentry><term>minweight</term><listitem>
      <para>weight of the smallest unit allowed to enter the building
      [0-99]. Defaults to 0.</para>
    </listitem></varlistentry>
    <varlistentry><term>maxweight</term><listitem>
      <para>weight of the heaviest unit allowed to enter the building
      [0-99]. Defaults to 99.</para>
    </listitem></varlistentry>
  </variablelist>
  </refsect2>

  <refsect2><title>event</title>
  <para>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 <firstterm>event type</firstterm> defines
  what happens, the <firstterm>event trigger</firstterm> controls when
  (or if) the event is executed.</para> 

  <para><variablelist>
    <title>Event Types</title>
    <varlistentry><term>createunit</term><listitem>
      <para>create a unit in a building. The unit will only be created if
      the specified building is controlled by the player for whom the
      event is set up.</para>
    </listitem></varlistentry>
    <varlistentry><term>manipulateevent</term><listitem>
      <para>modify event internals. Currently this can be used to
      dynamically enable or disable an event.</para>
    </listitem></varlistentry>
    <varlistentry><term>message</term><listitem>
      <para>display a message.</para>
    </listitem></varlistentry>
    <varlistentry><term>mining</term><listitem>
      <para>set the amount of crystals for a building.</para>
    </listitem></varlistentry>
    <varlistentry><term>nextmap</term><listitem>
      <para>change the setting for the next map to be played. Can be used
      to create dynamic campaigns.</para>
    </listitem></varlistentry>
    <varlistentry><term>research</term><listitem>
      <para>make a new unit type available for production in a factory.</para>
    </listitem></varlistentry>
    <varlistentry><term>score</term><listitem>
      <para>award points to a player.</para>
    </listitem></varlistentry>
  </variablelist></para>

  <para><variablelist>
    <title>Event Triggers</title>
    <varlistentry><term>havebuilding</term><listitem>
      <para>the event is executed when the player controls a certain
      building on a specified turn.</para>
    </listitem></varlistentry>
    <varlistentry><term>haveunit</term><listitem>
      <para>the event is executed when the player controls a certain unit
      on a specified turn.</para>
    </listitem></varlistentry>
    <varlistentry><term>turn</term><listitem>
      <para>the event is unconditionally executed on the specified turn.</para>
    </listitem></varlistentry>
    <varlistentry><term>unitdestroyed</term><listitem>
      <para>the event is executed when a specified unit is destroyed or
      captured by the enemy.</para>
    </listitem></varlistentry>
    <varlistentry><term>unitposition</term><listitem>
      <para>the event is executed when a specified unit ends its move on
      a certain target hex.</para>
    </listitem></varlistentry>
  </variablelist></para>

  <para>The following list contains generic qualifiers which are valid
  for all event types.</para>

  <para><variablelist>
    <title>Qualifiers</title>
    <varlistentry><term>id</term><listitem>
      <para>unique event identifier [0-200]. (mandatory)</para>
    </listitem></varlistentry>
    <varlistentry><term>type</term><listitem>
      <para>event type (mandatory, see below).</para>
    </listitem></varlistentry>
    <varlistentry><term>trigger</term><listitem>
      <para>event trigger (mandatory). This describes the circumstances
      under which the event is executed (see below).</para>
    </listitem></varlistentry>
    <varlistentry><term>message</term><listitem>
      <para>index of a message to be displayed when the event occurs.</para>
    </listitem></varlistentry>
    <varlistentry><term>title</term><listitem>
      <para>title of the message window. Only useful when a message is shown.</para>
    </listitem></varlistentry>
    <varlistentry><term>depend</term><listitem>
      <para>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.</para>
    </listitem></varlistentry>
  </variablelist></para>

  <para>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.</para>

  <variablelist>
    <varlistentry><term>action (manipulateevent, mining)</term><listitem>
      <para>For <emphasis>manipulateevent</emphasis> this defines how to
      handle the specified flags. A value of 0 will set, 1 will clear,
      and 2 will toggle the flags. For <emphasis>mining</emphasis> 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.</para>
    </listitem></varlistentry>
    <varlistentry><term>building (createunit, mining, research)</term><listitem>
      <para>Identifier of the building referenced in the event.</para>
    </listitem></varlistentry>
    <varlistentry><term>crystals (mining)</term><listitem>
      <para>Amount of crystals. The <emphasis>action</emphasis> flag controls
      how this number is actually interpreted.</para>
    </listitem></varlistentry>
    <varlistentry><term>event (manipulateevent)</term><listitem>
      <para>Identifier of the event to be modified.</para>
    </listitem></varlistentry>
    <varlistentry><term>flags (manipulateevent)</term><listitem>
      <para>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.</para>
    </listitem></varlistentry>
    <varlistentry><term>map (nextmap)</term><listitem>
      <para>For this event you must create a message in the
      <emphasis>messages</emphasis> 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.</para>
    </listitem></varlistentry>
    <varlistentry><term>success (score)</term><listitem>
      <para>Amount of success points the player receives when the event
      occurs. Any player with a success score of 100 or more wins the
      game.</para>
    </listitem></varlistentry>
    <varlistentry><term>unit (createunit, research)</term><listitem>
      <para>Name of a unit type specification to build or make
      available, respectively.</para>
    </listitem></varlistentry>
    <varlistentry><term>tbuilding (havebuilding)</term><listitem>
      <para>Identifier of the building to be controlled.</para>
    </listitem></varlistentry>
    <varlistentry><term>towner (havebuilding, haveunit, unitdestroyed)</term><listitem>
      <para>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
      <emphasis>unitdestroyed</emphasis> trigger it is only required if
      <emphasis>tunit</emphasis> 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.</para>
    </listitem></varlistentry>
    <varlistentry><term>tturn (havebuilding, haveunit, turn)</term><listitem>
      <para>Turn on which the event conditions should be checked. For
      <emphasis>turn</emphasis> the event will always be executed on this
      turn. (mandatory only for <emphasis>turn</emphasis>. If omitted for the
      other triggers, the condition will be checked each turn.)</para>
    </listitem></varlistentry>
    <varlistentry><term>tunit (haveunit, unitdestroyed, unitposition)</term><listitem>
      <para>Identifier of the unit to be targeted. For
      <emphasis>unitdestroyed</emphasis> and <emphasis>unitposition</emphasis>
      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.</para>
    </listitem></varlistentry>
    <varlistentry><term>txpos</term><term>typos (unitposition)</term><listitem>
      <para>Coordinates of the target hex</para>
    </listitem></varlistentry>
  </variablelist>
  </refsect2>

  <refsect2><title>messages</title>
  <para>The <emphasis>messages</emphasis> 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.</para>

  <programlisting>
[messages]
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.
%% this marks the end of the messages section
  </programlisting>

  <para>A single message may be up to 1800 characters long.</para>
  </refsect2>
</refsect1>

<refsect1><title>Example</title>
<programlisting>
### This is a simple example mission file

[mission]
title = Example
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]
***...***..
**...****.=
*&lt;^1n]*..==
**v..(..==~
***...].=~~
#=#.==!====
======(]...
%*.=...E^&gt;.
%%..%...v..
%%%%.%...**


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

### second player
[player]
name = The Bad
# 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

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

[building]
name = HQ of the Bad
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


### messages

[messages]
The Great Example
Revision 3 (27-09-2002)
by Jens Granseuer &lt;jensgr@gmx.net&gt;
%
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
%%
</programlisting>
</refsect1>

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

  <para><command>cfed</command> will eventually be phased out in favour
  of <command>CoMET</command>, the graphical map editor for
  <command>crimson</command>.</para>
</refsect1>

<refsect1><title>See Also</title>
  <para>
    <citerefentry><refentrytitle>crimson</refentrytitle><manvolnum>6</manvolnum></citerefentry>,
    <citerefentry><refentrytitle>bi2cf</refentrytitle><manvolnum>6</manvolnum></citerefentry>
  </para>
</refsect1>

<refsect1><title>Copyright</title>
  <para>Copyright &copy; 2000-2003 Jens Granseuer</para>
  <para>This software is distributed under the terms of the
  <ulink url="http://www.gnu.org/copyleft/gpl.html">GNU General Public
  License</ulink> (GPL).</para>
</refsect1>
</refentry>

