Designing Games with Xconq - Unit Types

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.)

UnitTypeProperty: `name-internal` str

Internally used type name.

- Unit Naming
- Availability
- Class-Restricted Unit Types
- Self-Unit Capable Units
- Limits on Unit Quantities
- Hit Points
- Experience
- Tech Levels vs Units
- Opinions
- Point Value
- Advanced Units

### 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`.

UnitTypeProperty: `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 in informational displays. Each element of list is either a string to add literally to the unit's description, or a symbol indicating the substitution of unit or unit type properties. The symbols are `name`, `position`, `side`, `side-adjective`, `side-name`, `type`. If `()`, then the instance will be described in a default fashion that is equivalent to a format of `(side " " type " " name)`. Defaults to `()`.

### Availability

It may be that a set of types is larger than strictly necessary for a particular game. You can make any type unavailable, which means that irrespective of any other controls, that type cannot come into play during a game. You can also make it available only for particular turns.

UnitTypeProperty: `available` n

If the value of this property is greater than 0, then this type is available in the game on or after turn n. If the value is less than 0, then the type is available, but only until turn -n. If the value is 0, then the type is never available. Defaults to `1`, which means that the type is always available.

If a type becomes unavailable and there are units of that type in play, then they will vanish immediately.

### 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`.

TableUU: `unit-control-chance-at` u1 u2 -> n%

TableUU: `unit-control-chance-adjacent` u1 u2 -> n%

TableUU: `unit-control-chance` u1 u2 -> n%

TableUU: `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 `non-unit`, then the destroyed unit just vanishes. The `wrecked-type` of a type must be a different type. Defaults to `non-unit`.

The transformation to the wrecked type does not change position or name. The transformed unit has full hp, supplies are conserved as much as possible (any excess is destroyed), tooling is preserved, and any unit plan is erased. It has the same number of parts, or as many as possible if that is fewer. It may be that the wrecked type is on terrain that it cannot survive on; in that case, it will be wrecked again, repeating until the unit either vanishes or is in a viable position, or this process has been repeated more times than the number of unit types (prevents infinite loops). Any excess occupants will be removed and either placed in another nearby unit or in the open, or will vanish if there is no other option.

UnitTypeProperty: `hp-recovery` n

This property is the number of 1/100 hp recovered per turn. Recovery happens automatically at the end of each turn. The amount n / 100 is recovered automatically each turn, while n mod 100 is the percent chance of recovering an additional 1 hit point.

UnitTypeProperty: `hp-to-recover` hp

This property is the minimum number of hp that the unit must have for hp recovery to work.

### Experience

UnitTypeProperty: `cxp-max` cxp

This property is the maximum combat experience this type of unit can have.

### Tech Levels vs Units

Before it can do anything with a type of unit, the side must have the appropriate tech level for that type, which is just a number ranging from 0 up to `tech-level-max`. Each type has a distinct tech level.

Tech levels always increase (since they represent abstract knowledge rather than physical plant). Tech can be transferred freely to any other side via the message `tech` [xref to messages].

For each unit type, the following parameters define the minimum tech levels at which sides can do various things.

UnitTypeProperty: `tech-to-see` tl

This property is the minimum tech level that a side must have before it can see a unit of this type.

UnitTypeProperty: `tech-to-own` tl

This property is the minimum tech level that a side must have in order to have a unit of this type.

UnitTypeProperty: `tech-from-ownership` tl

This property is the tech level that may be reached by acquiring a unit of this type. Since this is expressed as a minimum, multiple acquisitions have no additional effect.

UnitTypeProperty: `tech-to-use` tl

This property is the minimum tech level that a side must have in order to give actions to this type of unit.

UnitTypeProperty: `tech-to-build` tl

This property is the minimum tech level that a side must have in order to build this type of unit.

UnitTypeProperty: `tech-max` tl

This property is the absolute maximum tech level possible for this type.

TableUU: `tech-crossover` u1 u2 -> n%

This table is the minimum tech level for u2 that is guaranteed by a particular tech level for u1, expressed as a percentage of the `tech-max` for the types. For instance, if `tech-crossover` is 80, and the tech level for u1 is 10 out of a max of 20, and the max for u2 is also 20, then the side has a tech for u2 at least 8.

It is possible to gain some tech level just by being in the same game with a side that is more advanced.

UnitTypeProperty: `tech-leakage` .01tl

This property is the amount of tech level gain per turn that can happen to any side's tech level that is less than the max of all sides in the game. This only happens if at least one unit on the side has nonzero coverage of a unit on a more advanced side.

### Opinions

UnitTypeProperty: `opinion-min` n

UnitTypeProperty: `opinion-max` n

These properties are the bounds of the strength of a unit's opinion about the sides, both other sides and its own.

UnitTypeProperty: `courage-min` n

UnitTypeProperty: `courage-max` n

Morale is similar to opinion; it reflects the unit's opinion about itself.

UnitTypeProperty: `morale-max` n

This property is the maximum morale that the unit may have.

TableUT: `morale-terrain-effect` u t -> n

This table is the effect of the terrain at a unit's location on its morale.

UnitTypeProperty: `morale-recovery` .01n

This property is the amount of morale increase for a unit each turn, in 1/100ths of a point of morale. Defaults to `0`.

### Point Value

Point values provide an abstract way to characterize the overall importance of a unit type. Point values figure into some scorekeepers, and are used by AIs.

UnitTypeProperty: `point-value` n

This property is the "value" of a unit. Defaults to `1`.

### Advanced Units

Advanced units have an additional set of behaviors and functions; they are most like the cities in civilization-building games.

UnitTypeProperty: `advanced` t/f

This property is true if the type is an advanced type.

UnitProperty: `size` n

This property is the size of the advanced unit.

TableUA: `size-limit-without-advance` u a -> n

This table indicates the maximum size of a unit of type u if the advance a has not been achieved. Defaults to a large number.

TableUU: `size-limit-without-occupant` u1 u2 -> n

This table indicates the maximum size of a unit of type u1 if a unit of type u2 is not an occupant. Defaults to a large number.

TableUM: `unit-consumption-per-cp` u m -> n

TableUM: `unit-consumption-per-size` u m -> n

TableUM: `unit-consumption-to-grow` u m -> n

Advanced units may use cells around them for production.

UnitTypeProperty: `reach` n

This property is the radius out to which an advanced unit type may use the terrain for production.

UnitProperty: `reach` n

This property is the radius out to which an advanced unit may use the terrain for production. (This is always the same as the type property currently.)

UnitProperty: `size` n

This property is the size of the advanced unit.

UnitTypeProperty: `use-own-cell` t/f

If true, then the advanced unit type automatically uses the cell it is sitting on.

TableUA: `advance-add-maxcells` u a -> n

This is the number of additional cells that the unit can use for production if its side has the advance.

TableUA: `advance-mult-maxcells` u a -> n

This is the percentage multiplier for the additional cells that the unit can use for production if its side has the advance. Defaults to `100`.

TableUU: `occ-add-maxcells` u1 u2 -> n

This is the number of additional cells that each occupant of type u2 adds to a unit of type u1.

TableUU: `occ-multiply-maxcells` u1 u2 -> n

This is the percentage by which each occupant of type u2 multiples the production cells of a unit of type u1. Defaults to `100`.

UnitProperty: `usedcells` n

This is a cache of the number of cells used by an advanced unit.

UnitProperty: `maxcells` n

This is a cache of the maximum number of cells available to an advanced unit.

TableUA: `advance-add-production` u a -> n

This is the amount of additional production available to the unit if its side has the advance.

TableUA: `advance-multiply-production` u a -> n

This is the percentage by which an advance multiplies the production of the unit. Defaults to `100`.

TableUU: `occupant-add-production` u1 u2 -> n

This is the amount of additional production available to the unit of type u1 due to each occupant of type u2.

TableUU: `occupant-multiply-production` u1 u2 -> n

This is the percentage by which each occupant of type u2 multiplies the production of a unit of type u1. Defaults to `100`.

Materials produced by advanced units may be automatically converted into other types, in proportions decided by the player.

TableMM: `conversion` m1 m2 -> n

Values greater than zero in this table indicate that produced materials of type m1 can become materials of type m2.

TableMM: `conversion-default` m1 m2 -> n

This table is the default conversion rate of material of type m1 into a material of type m2.

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