Modpack UI icon

This page partially describes the contents of a ruleset collection. It is intended as developer reference and for people wanting to create/compile alternative rulesets for Freeciv.

The anatomy of a units ruleset fileEdit


The units.ruleset file contains all the information about unit types in the game. In addition to unit type entries there is some generic information about how units gain veterancy and how it affects them. Starting from Freeciv version 2.2 there are also unit class entries. Each unit type belongs to some unit class.

Configurable Unit Type FlagsEdit

Configurable Unit Type Flags are available starting from version 2.2

; Names for custom unit type flags.
names = "Airbase"
; Airbase - can build airbases. See airbase definition in terrain.ruleset

This is list of custom unit type flags this ruleset uses. Custom unit type flags have no internal meaning to Freeciv, but ruleset can give them to units and have unit with such flag as requirement for effects or base building. Default ruleset has one such flag, Airbase. Workers and Engineers have Airbase flag and building Airbase requires it.

Veteran SystemEdit

Veteran system entries are quite well documented in default ruleset.

Note that individual unit types can have "NoVeteran" flag preventing it from becoming veteran no matter what generic veteran system definitions say. In default ruleset Settlers, Workers and Engineers all have "NoVeteran" flag, so changing veteran_work_raise_chance affects nothing.

Unit ClassesEdit

Unit classes are new concept in version 2.2

There can be maximum of 32 different unit classes. Do not add them without proper consideration if separate class is really needed. Considering all the cross-referencing from other ruleset files, big number of different unit class can prove difficult to maintain. For example typical effects.ruleset has effects with UnitClass requirements. If you want same effect to affect several classes, you need to provide separate effect for each.

name          = _("Sea")
move_type     = "Sea"
min_speed     = 2
hp_loss_pct   = 0
hut_behavior  = "Normal"
flags         = "TerrainSpeed", "DamageSlows"

Possible values for move_type are "Land", "Sea", "Both" and "Air". The terrain.ruleset defines exact limitations where units of this class can move, but move_type must be compatible with that. "Land" units cannot move at any oceanic terrain. "Sea" units can move only at oceanic terrains. "Air" units still have some special rules that makes them different from "Both". In theory you can have "Both" units that terrain.ruleset restricts to land terrains only, but you should not do that. AI does not use "Both" units. In default ruleset, Helicopters are "Both" units.

Some units are slowed down when damaged. No matter how much damage they have, speed never drops below min_speed. Neither do terrain slow units below min_speed.

Some units lose hitpoints when ever they end turn and are not in city, native base, or transport. hp_loss_pct tells how many percents of units total hitpoints is lost each turn. In default ruleset helicopters have non-zero hp_loss_pct.

hut_behavior controls what happens when unit enters tile with hut (minor tribe village). "Normal" means that hut disappears with random effect. "Nothing" means that nothing happens, hut even remains for other units to come. "Frighten" means that hut just disappear without any other effects. In default ruleset airplanes and missiles "Frighten"

Unit Class FlagsEdit

  • TerrainSpeed - Unit is not moving at constant speed, but terrain affects it. This includes effects from roads and railroads. In default ruleset all but flying units have this flag.
  • TerrainDefense - Units gain defense bonus from terrain.
  • DamageSlows - Unit is slowed down when damaged. In default ruleset land and sea units have this flag and flying units do not.
  • CanOccupyCity - Units of this class can occupy empty enemy cities. Note that particular unit type must be also military unit in order to occupy cities. In default ruleset land units and helicopters have this flag.
  • Missile - Unit disappears after it has attacked even if it was victorious. In default ruleset missiles have this flag
  • RoadNative - Even if particular base terrain is listed as non-native for this unit class, tiles with road are still considered native. That is, units can move anywhere where is road. In default ruleset we have no such units as all land units can move at all land terrains anyway. Removed in 2.5 Add native_to unit classes to terrain.ruleset road definitions instead.
  • RiverNative - Even if particular base terrain is listed as non-native for this unit class, tiles with river are still considered native. That is, units can move anywhere where is river.
  • BuildAnywhere - Units can be built even if city is located in non-native terrain for unit. In default ruleset land units have this flag so theoretical ocean cities can build them. Most definitely sea units do not have this flag.
  • Unreachable - By default other units cannot attack units of this class. Only those unit types listing this class in its targets can attack. In default ruleset airplanes and missiles have this flag and Fighters list them as targets.
  • CollectRansom - When unit of this class kills lone barbarian leader, player gains money. In default ruleset land units and helicopters have this flag.
  • ZOC - Units of this class are subject to Zone of Control rules. There is also unit type flag IgZOC that can be used to override this. In default ruleset land units class has this flag, but some individual unit types override it with IgZOC.
  • CanFortify - Units of this class can fortify in land squares. In default ruleset land units have this flag, flying units cannot fortify even when over land.
  • CanPillage - Units of this class can destroy tile improvements. In default ruleset land units have this flag.
  • DoesntOccupyTile - Even if enemy unit of this class is on tile, cities can still work it. In default ruleset air and missile units have this flag.
  • AttackNonNative - New in 2.5 Unit can attack units on non-native tiles. Unit type flag "Only_Native_Attack" can override this.
  • AttFromNonNative - New in 2.5 Unit can attack from non-native tile. Unit can be in such a tile in transport or in city. In default ruleset sea units have this flag so they can attack out from harbour cities. Unit type flag Marines works the same way, so use it if you want only some units of the class to be able to attack from non-native tiles.

Unit TypesEdit

name          = _("Warriors")
class         = "Land"
tech_req      = "None"
obsolete_by   = "Pikemen"
graphic       = "u.warriors"
graphic_alt   = "-"
sound_move    = "m_warriors"
sound_move_alt = "m_generic"
sound_fight   = "f_warriors"
sound_fight_alt = "f_generic"
build_cost    = 10
pop_cost      = 0
attack        = 1
defense       = 1
hitpoints     = 10
firepower     = 1
move_rate     = 1
vision_radius_sq = 2
transport_cap = 0
fuel          = 0
uk_happy      = 1
uk_shield     = 1
uk_food       = 0
uk_gold       = 0
flags         = ""
roles         = "DefendOk", "FirstBuild"
helptext      = _("\
This unit may be built from the start of the game.  It is the\
 weakest unit.\

class refers to unit class this unit type belongs to. In 2.2 this is one of the classes defined earlier in the units.ruleset. In 2.1 this is one of the predefined classes: "Missile", "Land", "Sea", "Helicopter", "Air" or "Nuclear".

tech_req is name of the tech that is required in order to build this unit. These are defined in Techs.ruleset. Special value "None" means that unit can be built without knowing any tech.

impr_req required city improvement, name from buildings.ruleset

obsolete_by is name of the another unit type to which this unit type upgrades to.

convert_to is name of another unit type that this unit can be converted to. New in 2.3

convert_time is number of movement points it takes to convert to convert_to unit. New in 2.5

graphic is graphic tag for this unit. Tileset should provide graphics for matching this tag.

graphic_alt is used as fallback tag if primary tag is not found from tileset.

sound_move, sound_move_alt, sound_fight and sound_fight_alt Sound tags similar to graphic tags.

build_cost is how much production is needed in order to build this unit.

pop_cost is how much city size will shrink once unit is finished. In default ruleset only Settlers have population cost.

attack is attack strength of unit.

defense is defense strength of unit.

hitpoints is number of hitpoints units of this type have when they are in full health.

firepower is unit firepower.

move_rate is unit speed. Here it is in full move points, not in 1/3 points.

vision_radius_sq is how far unit sees. This is given as vision_radius_square in order to be able to see circular areas instead of square area.

transport_cap tells how many other units this unit type can transport.

cargo is new optional field in 2.2, applicable only for units that have transport_cap > 0. It is list of different unit classes this unit type can transport. In default ruleset Carrier has cargo = "Air", "Missile", "Helicopter". In 2.1 unit type flags define what other units unit can transport.

fuel is number of turns that unit can live without refueling. Value 0 means that unit never needs to refuel. Value 1 means that unit needs to refuel every turn or to crash. Value other than zero should be given only to air units, it does not work correctly with other kind of units.

uk_happy is how much unit causes unhappiness when aggressive.

uk_shield is unit upkeep in shields / turn.

uk_food is unit upkeep in food / turn.

uk_gold is unit upkeep in gold / turn.

city_size is new optional field in 2.2. Cities built by this unit will initially be of given size. Default is 1.

targets is new optional field in 2.2. This is list of unit classes unit type can attack against even if those classes have "Unreachable" flag set. All unit types can attack classes without "Unreachable" flag even if class is not mentioned in targets.

helptext is shown in inline help in addition to automatically generated help.

Unit Type FlagsEdit

  • TradeRoute - Unit can establish trade routes
  • HelpWonder - Unit can be disbanded in city building Wonder to get full unit production cost towards finishing wonder
  • IgZOC - Ignores Zone of Control restrictions even if unit class has ZOC flag
  • NonMil - Can enforce martial law. Can occupy empty enemy cities, if unit class is capable to that. In 2.1, units of classes Land and Helicopter can occupy. In 2.2, unit class must have flag CanOccupy.
  • IgTer - Regardless of terrain, move speed is at least same as would be using roads. Takes advantage of railroads.
  • OneAttack - Unit can attack only once in a turn even if its move_rate is more than one.
  • Pikemen - Unit gets double defense power against units flagged as Horse.
  • Horse - Units flagged as Pikemen get double defense against these units.
  • IgWall - Defender's Defend_Bonus effects are ignored when this unit attacks. In default rules only buildings City Walls and Great Wall give Defend_Bonus effect against Land units. Units of other classes ignore those effects and so do Land units with IgWall.
  • FieldUnit - Unit is considered aggressive - causing unhappiness - even if it's within home borders (and inside cities when server setting 'happyborders' is off)
  • AEGIS - Unit defensepower is multiplied by 5 when attacker is air unit. In 2.1 units from classes Air, Helicopter, Missile or Nuclear are considered air units. In 2.2, units with unit class flag AirUnit are considered air units.
  • Marines - Unit can attack directly from non-native terrain. Typically this means that unit is in transport.
  • Partial_Invis - Other players can see this unit only if they have unit or city center in adjacent tile.
  • Settlers - Unit can irrigate, mine and build roads and railroads (when tech is known). In 2.1 they also can build Fortresses. In 2.2 this is controlled by base definitions in terrain.ruleset.
  • Diplomat - Can establish embassies, steal random technologies, bribe enemy units, start revolution in enemy city, sabotage production, investigate cities. If unit does not have also Spy flag, it is always destroyed after mission.
  • Trireme - Unit should stay adjacent to Land squares. In 2.1 unit can move away from coast, but might be lost if ends turn not adjacent to land. In 2.2 unit cannot move away from land at all.
  • Nuclear - Can only be built when Enable_Nuke effect is active. When this unit attacks, all units (including friendly ones) within 3x3 square area are destroyed. Size of the attacked city is halved. Attack might cause fallout to surrounding squares.
  • Spy - This flag works correctly only if unit has also Diplomat flag. Can poison water, select what technology to steal, select what to sabotage, sabotage enemy units. This unit might survive mission.
  • Paratroopers - Unit can paradrop to native terrain. Paradrop can be initiated from city or base. In 2.1 paradrop is possible from Airbase. In 2.2 paradrop is possible from base with flag ParadropFrom.
  • Airbase - In 2.1 means that unit can build airbases. In 2.2 has no hardcoded meaning. Default rules mark Settlers, Worker and Engineer unit with this flag and base Airbase has building requirement UnitFlag Airbase
  • Cities - Can found new city. Unit is destroyed in the process.
  • No_Land_Attack - This flag affects Sea moving units only. Usually they can attack non-native terrains (shore bombardment), but units with this flag cannot. Replaced with Only_Native_Attack in 2.5
  • Only_Native_Attack - This can be used to override AttackNonNative unit class flag for specific unit types. Units with this flag cannot attack against units on non-native tiles. New in 2.5
  • AddToCity - Unit can inrease city size by population cost. Unit is destroyed in the process. City size cannot be increased if city is already larger than limit defined in cities.ruleset
  • Fanatic - If effect Fanatics is active for player, units of this type have no upkeep cost. (According to some documentation, effect needs to be active in order to build these units. Looking at the source code this seems not to be true)
  • GameLoss - If player loses unit of this type, he loses whole game.
  • Unique - Player can have only one unit of this type at a time.
  • Unbribable - Unit cannot be bribed.
  • Undisbandable - Player cannot disband this unit.
  • SuperSpy - This unit always wins against regular Diplomat and Spy units.
  • NoHome - Unit has no home city assigned. This means that no city is paying upkeep for it and it cannot be killed by conquering its home city.
  • NoVeteran - Unit cannot gain veteran levels. It is always in the lowest defined level.
  • Bombarder - Unit uses bombard attack.
  • CityBuster - Unit's firepower is doubled when it attacks against city
  • NoBuild - Unit cannot be built in cities. These units can only be available from start, appear from huts, appear as barbarians, or be created via scenario scripting.
  • BadWallAttacker - If defender has Defend_Bonus effect when this unit attacks, firepower is considered to be 1.
  • BadCityDefender - When this unit is defender against attack to city, attacker firepower is doubled and this unit is considered to have firepower of one. Default rules use this flag for all ships. Note that native/non-native terrain does not affect defense capabilities.
  • Helicopter New in 2.2 When units flagged as Fighter attack this unit, defender's firepower is considered to be 1 and defense value is halved.
  • AirUnit - New in 2.2
  • Fighter - Good at attacking against helicopters. In 2.1 units of class Helicopter are considered helicopters. In 2.2 units with unit type flag Helicopter are considered helicopters. In 2.1 Fighter is also able to attack against air units (similar to listing air units class in targets in 2.2)
  • BarbarianOnly - New in 2.2 - Unit can be built only by barbarian players. For other players this is similar to NoBuild
  • Missile - Removed in 2.2 - Unit is destroyed after it attacks even if it is victorious. In 2.2 this is unit class flag.
  • Carrier - Removed in 2.2 - Unit can transport units of classes Air, Missile, Helicopter and Nuclear, and no Land units. Unit is Land unit transport if it does not have this flag or Missile_Carrier flag. In 2.2 this implementation is replaced by unit type field cargo.
  • Missile_Carrier - Removed in 2.2 - Unit can transport units of classes Missile and Nuclear, but no others. See also Carrier.
  • Shield2Gold - New in 2.2 - unit upkeep can be switch from shield upkeep to gold upkeep

Unit Type RolesEdit

Unit type can have multiple roles it fits in to.
























See also Edit

Editing Rulesets
Editing BuildingsEditing CitiesEditing EffectsEditing GameEditing Governments
Editing NationsEditing StylesEditing TechsEditing TerrainEditing Units
Community content is available under CC-BY-SA unless otherwise noted.