Go to the first, previous, next, last section, table of contents.

Unit Types

Form: unit-type symbol properties...

This form defines a new type of unit. The symbol is required and must be previously undefined. The bindings in properties are then added to the type one by one. If no other name properties are defined, the symbol may be displayed to players (see above). You can define no more than 126 types of units.

The symbol here becomes the unit type's "internal type name" which is guaranteed unique. To make synonyms for the internal type name, use define.

GlobalVariable: u*

This variable evaluates to a list of all unit types, listed in the order that they were defined. This list always reflects the list of types at the moment it is evaluated.

GlobalVariable: non-unit

This variable evaluates to a value that is NOT a unit type. This is needed in several places to enable/disable features. Use of this in any other way is an error, and may or may not be detected before it causes a crash. (Although described as a variable, its value cannot be changed.)

Unit Naming

UnitTypeProperty: namer namer-id

This property is the namer that will be used to generate names for units, if the unit's side does not have a namer, or the unit is independent and not in any country. Defaults to 0, which leaves the unit unnamed.

UnitTypeProperty: assign-number t/f

This property is true if the unit should have a serial number assigned to it by the side it belongs to. Serial numbers are maintained for each type on each side separately, start at 1 for the first unit of the type, and increase by one each time. Defaults to true.

TypeProperty: description-format list...

This property defines the different ways in which an instance or instances of this type may be described textually. This information may be used in narrative descriptions and by some interfaces. If (), then the instance will be described in some default fashion, such as "the <side> <ordinal> <type>". If (name), then the unit will be identified only by name. Defaults to ().

Class-Restricted Unit Types

Sometimes the designer will want to make different sides have different types of units. Although this can be done by setting up scenarios appropriately, that won't close all the loopholes that might allow a side to get units that should only ever belong to another side.

The first step is to define a class for each side. For instance, a side named "Rome" might have a class "Roman", while the sides named "Aedui" and "Parisii" could both be in the class "barbarian".

UnitTypeProperty: possible-sides exp

This property restricts the unit type to only be usable by a side meeting the conditions of exp. If exp is a string, it restricts the unit type to only be usable by a side whose class includes a matching string. This may also be a boolean expression. Independent units belong to a side whose class is "independent". The default of "" allows the unit to belong to any side.

Self-Unit Capable Units

The self-unit can be any type, including one that cannot act; for instance, a capital city could be the self-unit, thus making its defense all-important for a player.

GlobalVariable: self-required t/f

This variable is true if each side is required to have a self-unit at all times. However, if no unit of a suitable type is available when the game begins, then none will be required. Defaults to false.

UnitTypeProperty: can-be-self t/f

This property says that the type of unit can represent the side directly. Defaults to false.

UnitTypeProperty: self-changeable t/f

This property is true if the player can choose to change a self-unit of this type at any time. Otherwise the self-unit can be changed only if the current one dies. Defaults to false.

UnitTypeProperty: self-resurrects t/f

This property is true if when the self-unit dies, another unit of an allowable type becomes the self-unit automatically. Defaults to false.

Observe that these parameters can be used to develop various forms of backup, so that a player can start out as a capital city, resurrect as a town, change self to one of several towns, then lose when all the towns are lost.

UnitTypeProperty: direct-control t/f

This property is true if a unit of this type can be controlled by its side automatically. If false, then it must be within range of a unit that can control it, and is itself under control by the side. Defaults to true.

Table: unit-control-chance-at u1 u2 -> n%

Table: unit-control-chance-adjacent u1 u2 -> n%

Table: unit-control-chance u1 u2 -> n%

Table: unit-control-range u1 u2 -> dist

This table gives the maximum distance from self-unit u1 at which units of type u2 can be controlled directly. Units further away always act on their own. If this value is < 0, then u1 can never directly control any other u2 on the side. Defaults to infinity.

Limits on Unit Quantities

The effect of these is to prevent any extra units from being created or from going over to a side, regardless of the reason. This happens by either preventing player actions that would result in exceeding a limit (such as when building units), or by making the unit vanish instantly (such as when capturing a unit).

GlobalVariable: units-in-game-max n

This variable is the maximum number of all types of units, on all sides, including independents, that may exist at any time, including initially. Defaults to -1, which means that there is no limit.

GlobalVariable: units-per-side-max n

This variable is the maximum number of units (of all types together) that any side may have, at any time. Events that would cause the limit to be exceeded, such as capturing a unit, result in either the unit vanishing or becoming independent. Defaults to -1, which means that there is no limit.

There is no limit on the number of units that may be independent.

UnitTypeProperty: type-in-game-max n

This property is the maximum total of the given type, for all sides together. Defaults to -1, which means that there is no limit.

UnitTypeProperty: type-per-side-max n

This property is the maximum number of units of the given type allowed to each side. Defaults to -1, which means that there is no limit.

Hit Points

A unit's hit points determine how healthy it is. If a unit's hp goes below 1, it is either wrecked, meaning that it changes to a new type wrecked-type or else it vanishes, meaning that it is completely cleared from the world.

UnitTypeProperty: hp-max n

This property is the maximum number of hit points for (each part of) a unit. Completed units start with this many hit points. Defaults to 1.

UnitTypeProperty: parts-max n

This property declares that a unit is really an aggregate of n smaller identical units. Defaults to 1.

UnitTypeProperty: wrecked-type unit-type

This property is the type of unit that a unit with 0 hp will become. For instance, a destroyed "fort" might become a "rubble pile" unit. If its value is cdesign_42.html#SEC200">Opinions

  • Point Value

    Unit Naming

    UnitTypeProperty: namer namer-id

    This property is the namer that will be used to generate names for units, if the unit's side does not have a namer, or the unit is independent and not in any country. Defaults to 0, which leaves the unit unnamed.

    UnitTypeProperty: assign-number t/f

    This property is true if the unit should have a serial number assigned to it by the side it belongs to. Serial numbers are maintained for each type on each side separately, start at 1 for the first unit of the type, and increase by one each time. Defaults to true.

    TypeProperty: description-format list...

    This property defines the different ways in which an instance or instances of this type may be described textually. This information may be used in narrative descriptions and by some interfaces. If (), then the instance will be described in some default fashion, such as "the <side> <ordinal> <type>". If (name), then the unit will be identified only by name. Defaults to ().

    Class-Restricted Unit Types

    Sometimes the designer will want to make different sides have different types of units. Although this can be done by setting up scenarios appropriately, that won't close all the loopholes that might allow a side to get units that should only ever belong to another side.

    The first step is to define a class for each side. For instance, a side named "Rome" might have a class "Roman", while the sides named "Aedui" and "Parisii" could both be in the class "barbarian".

    UnitTypeProperty: possible-sides exp

    This property restricts the unit type to only be usable by a side meeting the conditions of exp. If exp is a string, it restricts the unit type to only be usable by a side whose class includes a matching string. This may also be a boolean expression. Independent units belong to a side whose class is "independent". The default of "" allows the unit to belong to any side.

    Self-Unit Capable Units

    The self-unit can be any type, including one that cannot act; for instance, a capital city could be the self-unit, thus making its defense all-important for a player.

    GlobalVariable: self-required t/f

    This variable is true if each side is required to have a self-unit at all times. However, if no unit of a suitable type is available when the game begins, then none will be required. Defaults to false.

    UnitTypeProperty: can-be-self t/f

    This property says that the type of unit can represent the side directly. Defaults to false.

    UnitTypeProperty: self-changeable t/f

    This property is true if the player can choose to change a self-unit of this type at any time. Otherwise the self-unit can be changed only if the current one dies. Defaults to false.

    UnitTypeProperty: self-resurrects t/f

    This property is true if when the self-unit dies, another unit of an allowable type becomes the self-unit automatically. Defaults to false.

    Observe that these parameters can be used to develop various forms of backup, so that a player can start out as a capital city, resurrect as a town, change self to one of several towns, then lose when all the towns are lost.

    UnitTypeProperty: direct-control t/f

    This property is true if a unit of this type can be controlled by its side automatically. If false, then it must be within range of a unit that can control it, and is itself under control by the side. Defaults to true.

    Table: unit-control-chance-at u1 u2 -> n%

    Table: unit-control-chance-adjacent u1 u2 -> n%

    Table: unit-control-chance u1 u2 -> n%

    Table: unit-control-range u1 u2 -> dist

    This table gives the maximum distance from self-unit u1 at which units of type u2 can be controlled directly. Units further away always act on their own. If this value is < 0, then u1 can never directly control any other u2 on the side. Defaults to infinity.

    Limits on Unit Quantities

    The effect of these is to prevent any extra units from being created or from going over to a side, regardless of the reason. This happens by either preventing player actions that would result in exceeding a limit (such as when building units), or by making the unit vanish instantly (such as when capturing a unit).

    GlobalVariable: units-in-game-max n

    This variable is the maximum number of all types of units, on all sides, including independents, that may exist at any time, including initially. Defaults to -1, which means that there is no limit.

    GlobalVariable: units-per-side-max n

    This variable is the maximum number of units (of all types together) that any side may have, at any time. Events that would cause the limit to be exceeded, such as capturing a unit, result in either the unit vanishing or becoming independent. Defaults to -1, which means that there is no limit.

    <