Gamedev:UnitDefs: Difference between revisions

From Spring
Jump to navigationJump to search
fixed problems caused by changing the template.
Flozi (talk | contribs)
m →Categories: A warning about null categories leading to untargetable units
 
(111 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[Gamedev:Main|Development]] < [[Gamedev:Main]] < {{FULLPAGENAME}}
==Location==
==Location==
UnitDef files are .lua files stored in the <code>Units/</code> directory of a Spring Game.
UnitDef files are .lua files stored in the <code>Units/</code> directory of a Spring Game.
Line 6: Line 8:


==Source==
==Source==
The engine source code which loads the tags from these files is viewable here:{{sourcelink|file=rts/Sim/Units/UnitDef.cpp}}
The engine source code which loads the tags from these files is viewable here:
 
* {{sourcelink|file=rts/Sim/Units/UnitDef.cpp}}
 


The engine source which reads the [[#sounds]] subtable can be found here:


The engine source which reads the [[#sounds]] subtable can be found here:{{sourcelink|file=rts/Sim/Units/UnitDefHandler.cpp}}
* {{sourcelink|file=rts/Sim/Units/UnitDefHandler.cpp}}


==Data Types==
==Data Types==
Tags may be one of the following data types:
{{DataTypes}}
* <code>int</code> - An integer number
* <code>float</code> - A number with decimals.
* <code>bool</code> - A value which can be <code>true</code> or <code>false</code>.
* <code>string</code> - Text, or more precisely a string of alphanumeric characters.
* <code>float[3]</code> - A vector, with three <code>float</code> components, representing x, y and z axes (y is 'up').


==Details==
==Details==
Line 31: Line 32:
|type = string
|type = string
|default = ""
|default = ""
|lua = humanName
|description = This is simply the name of the unit as it appears to the player.}}
|description = This is simply the name of the unit as it appears to the player.}}


Line 37: Line 39:
|type = string
|type = string
|default = name
|default = name
|description = This is the tooltip description of the unit seen by the player. It defaults to the <code>name</code> of the unit.}}
|lua = tooltip
|description = This is the tooltip description of the unit seen by the player. It defaults to the {{taglink|name}} of the unit.}}


{{tag
{{tag
Line 43: Line 46:
|type = string
|type = string
|default = ""
|default = ""
|description = The filename of the image to be used as the build picture.}}
|lua = buildPicName
|description = The filename of the image to be used as the build picture, assumes <code>Unitpics/</code> directory (see [[Gamedev:Buildpics]]).}}


{{tag
{{tag
Line 49: Line 53:
|type = string
|type = string
|default = ""
|default = ""
|lua = modelname
|description = The filename of the 3D model file for this unit, assumes <code>Objects3D/</code> directory.}}
|description = The filename of the 3D model file for this unit, assumes <code>Objects3D/</code> directory.}}


Line 55: Line 60:
|type = string
|type = string
|default = unitName + ".cob"
|default = unitName + ".cob"
|lua = scriptName
|description = The filename of the animation script file for this unit, assumes <code>Scripts/</code> directory. Default assumes .cob file but [[Animation-LuaScripting | LUS]] should be preferred.}}
|description = The filename of the animation script file for this unit, assumes <code>Scripts/</code> directory. Default assumes .cob file but [[Animation-LuaScripting | LUS]] should be preferred.}}


Line 61: Line 67:
|type = float
|type = float
|default = 0.0
|default = 0.0
|lua = health
|description = The base 'hitpoints' the unit will have.}}
|description = The base 'hitpoints' the unit will have.}}


Line 85: Line 92:
|type = float
|type = float
|default = 1.0
|default = 1.0
|lua = metalCost
|description = The amount of metal resource the unit costs to build. Cannot be below <code>1.0</code>.}}
|description = The amount of metal resource the unit costs to build. Cannot be below <code>1.0</code>.}}


Line 91: Line 99:
|type = float
|type = float
|default = 0.0
|default = 0.0
|lua = energyCost
|description = The amount of energy resource the unit costs to build.}}
|description = The amount of energy resource the unit costs to build.}}


Line 97: Line 106:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The time taken to build the unit, in conjunction with the <code>workerTime</code> of the constructor. Effectively, ''Time to build = unit <code>buildTime</code> / constructor <code>workerTime</code>''. Defaults to <code>0.0</code> but cannot actually be below <code>1.0</code>.}}
|description = The time taken to build the unit, in conjunction with the {{taglink|workerTime}} of the constructor. In [[Gamedev:UnitsOfMeasurement#Time|Resource Frames]], <code>Time to build = (buildTime / workerTime)</code>. Defaults to <code>0.0</code> but cannot actually be below <code>1.0</code>.}}


{{tag
{{tag
Line 127: Line 136:
|type = float
|type = float
|default = 1e20
|default = 1e20
|description = The maximum cumulative speed at which this unit can be repaired.}}
|description = The maximum cumulative speed at which this unit type can repair a single target.}}


{{tag
{{tag
Line 133: Line 142:
|type = string
|type = string
|default = "default"
|default = "default"
|description = The name of the radar icon type this unit should use. See [[Icontypes.lua]].}}
|description = The name of the radar icon type this unit should use (see [[Icontypes.lua]]).}}


{{tag
{{tag
Line 139: Line 148:
|type = string
|type = string
|default = ""
|default = ""
|description = The name of the feature this unit should leave behind as a wreck when it dies (See [[Units-FeatureDefs]]).}}
|lua = wreckName
|description = The name of the feature this unit should leave behind as a wreck when it dies (see [[Gamedev:FeatureDefs]]).}}


{{tag
{{tag
Line 145: Line 155:
|type = string
|type = string
|default = ""
|default = ""
|description = The name of the weapon this unit should explode as when it is killed (See [[Units-WeaponDefs]]).}}
|description = The name of the weapon this unit should explode as when it is killed (see [[Gamedev:WeaponDefs]]).}}


{{tag
{{tag
Line 151: Line 161:
|type = string
|type = string
|default = ""
|default = ""
|description = The name of the weapon this unit should explode as when it self destructs (See [[Units-WeaponDefs]]). Also used as the <code>kamikaze</code> weapon.}}
|description = The name of the weapon this unit should explode as when it self destructs (see [[Gamedev:WeaponDefs]]). Also used as the {{taglink|kamikaze}} weapon.}}


===Resources===
===Resources===
{{tag
|name = harvestStorage
|type = float
|default = 0.0
|special = {{new|97.0; ATTENTION: unfinished implementation, can be set in UnitDefs but it can't be read in-game}}
|description = How much of the metal resource a unit can store when used as an engine-assisted resource 'harvester'. See also [[Lua_SyncedRead#Unit_Informations|Spring.GetUnitHarvestStorage]] and [[Lua_SyncedCtrl#Unit_Resourcing|Spring.SetUnitHarvestStorage]] callouts.}}
{{tag
{{tag
|name = metalStorage
|name = metalStorage
Line 171: Line 188:
|default = 0.0
|default = 0.0
|description = The amount of the metal resource the unit extracts from the ground. The amount extracted depends on the metal map defined in the map itself. Works only for structures.}}
|description = The amount of the metal resource the unit extracts from the ground. The amount extracted depends on the metal map defined in the map itself. Works only for structures.}}
{{tag
|name = extractSquare
|type = bool
|default = false
|description = Is the metal extractors extraction area circular or square?}}


{{tag
{{tag
Line 182: Line 193:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The amount of the energy resource the unit generates which is dependant on the map wind. Works only for structures.}}
|description = The maximum amount of the energy resource the unit generates which is dependant on the map wind. Works only for structures. If wind speed is higher than this, the unit will still only produce this much. If wind speed is less, it will produce as much as windspeed is.}}


{{tag
{{tag
Line 194: Line 205:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The amount of the metal resource the unit consumes per game 'tick'.}}
|lua = metalUpkeep
|description = The amount of the metal resource the unit consumes per game 'tick' when activated.}}


{{tag
{{tag
Line 200: Line 212:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The amount of the energy resource the unit consumes per game 'tick'.}}
|lua = energyUpkeep
|description = The amount of the energy resource the unit consumes per game 'tick' when activated.}}


{{tag
{{tag
Line 222: Line 235:
===Sensors===
===Sensors===
{{tag
{{tag
|name = onoffable
|name = onOffable
|type = bool
|type = bool
|default = false
|default = false
Line 237: Line 250:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The radius of the units sight (LOS is circular in Spring)}}
|lua = losRadius
|description = The radius of the units sight (LOS is circular in Spring).
}}


{{tag
{{tag
Line 243: Line 258:
|type = float
|type = float
|default = 1.5 * sightDistance
|default = 1.5 * sightDistance
|lua = airLosRadius
|description = How far away the unit can see aircraft (and some FX).}}
|description = How far away the unit can see aircraft (and some FX).}}


Line 249: Line 265:
|type = float
|type = float
|default = 20.0
|default = 20.0
|special={{new|83.0}}
|lua = losHeight
|special = {{new|83.0}}
|description = How high up the unit is the point used to calculate it's LOS vs. the terrain?}}
|description = How high up the unit is the point used to calculate it's LOS vs. the terrain?}}


Line 256: Line 273:
|type = float
|type = float
|default = 20.0
|default = 20.0
|special={{new|83.0}}
|lua = radarHeight
|special = {{new|83.0}}
|description = How high up the unit is the point used to calculate it's radar vs. the terrain?}}
|description = How high up the unit is the point used to calculate it's radar vs. the terrain?}}


Line 263: Line 281:
|type = int
|type = int
|default = 0
|default = 0
|lua = radarRadius
|description = The radius of the units radar.}}
|description = The radius of the units radar.}}


Line 269: Line 288:
|type = int
|type = int
|default = 0
|default = 0
|lua = sonarRadius
|description = The radius of the units sonar.}}
|description = The radius of the units sonar.}}


Line 275: Line 295:
|type = int
|type = int
|default = 0
|default = 0
|lua = jammerRadius
|description = The radius of the units radar jamming.}}
|description = The radius of the units radar jamming.}}


{{tag
{{tag
|name = sonarDistance
|name = sonarDistanceJam
|type = int
|type = int
|default = 0
|default = 0
|lua = sonarJamRadius
|description = The radius of the units sonar jamming.}}
|description = The radius of the units sonar jamming.}}


Line 299: Line 321:
|type = int
|type = int
|default = 0
|default = 0
|lua = seismicRadius
|description = The radius of the unit's seismic (movement) sensor.}}
|description = The radius of the unit's seismic (movement) sensor.}}


Line 304: Line 327:
|name = seismicSignature
|name = seismicSignature
|type = float
|type = float
|default = 0 for units with <code>floater</code>, <code>canHover</code> or <code>canFly</code>, otherwise sqrt(mass / 100.0)
|default = 0 for units with {{taglink|floater}}, {{taglink|canHover}} or {{taglink|canFly}}, otherwise sqrt(mass / 100.0)
|description = How fast the seismic ring expands in [[Units-UnitsOfMeasurement | elmos per frame]]. Each ping always lasts 15 [[frames]], so this also determines the maximum radius of the seismic ring.}}
|description = How fast the seismic ring expands in [[elmo]]s per frame. Each ping always lasts 15 [[frames]], so this also determines the maximum radius of the seismic ring.}}


====Cloaking====
====Cloaking====
For units with [[Units-UnitDefs#Commands|canCloak]] set to <code>true</code>:
For units with {{taglink|canCloak|true}}:
{{tag
{{tag
|name = cloakCost
|name = cloakCost
Line 325: Line 348:
|type = bool
|type = bool
|default = false
|default = false
|lua = startCloaked
|description = Is the unit cloaked as soon as it is created?}}
|description = Is the unit cloaked as soon as it is created?}}


Line 337: Line 361:
|type = bool
|type = bool
|default = true
|default = true
|description = Does <code>minCloakDistance</code> apply in 3D or only 2D? i.e. can aircraft flying above the unit decloak it?}}
|description = Does {{taglink|minCloakDistance}} apply in 3D or only 2D? i.e. can aircraft flying above the unit decloak it?}}


{{tag
{{tag
Line 343: Line 367:
|type = bool
|type = bool
|default = true
|default = true
|description = Does the unit deloak when it fires a weapon?}}
|description = Does the unit decloak when it fires a weapon?}}


{{tag
{{tag
Line 356: Line 380:
|type = bool
|type = bool
|default = false
|default = false
|description = Can the unit be issued Move orders?}}
|description = Can the unit be issued Move orders?
}}


{{tag
{{tag
Line 362: Line 387:
|type = bool
|type = bool
|default = true
|default = true
|description = Can the unit be issued Attack orders?}}
|description = Can the unit be issued Attack orders?
}}


{{tag
{{tag
Line 368: Line 394:
|type = bool
|type = bool
|default = true
|default = true
|description = Can the unit be issued Fight orders?}}
|description = Can the unit be issued Fight orders?
}}


{{tag
{{tag
Line 374: Line 401:
|type = bool
|type = bool
|default = true
|default = true
|description = Can the unit be issued Patrol orders?}}
|description = Can the unit be issued Patrol orders?
}}


{{tag
{{tag
Line 380: Line 408:
|type = bool
|type = bool
|default = true
|default = true
|description = Can the unit be issued Guard orders?}}
|description = Can the unit be issued Guard orders?
}}


{{tag
{{tag
Line 387: Line 416:
| default = false
| default = false
| description =
| description =
Can the unit be issued Cloak orders?}}
Can the unit be issued Cloak orders?
}}


{{tag
{{tag
Line 393: Line 423:
|type = bool
|type = bool
|default = true
|default = true
|description = Can the unit be issued Repeat orders?}}
|description = Can the unit be issued Repeat orders?
}}


{{tag
{{tag
Line 399: Line 430:
|type = bool
|type = bool
|default = true
|default = true
|description = Can the unit be issued a self destruct order?}}
|lua = canSelfD
|description = Can the unit be issued a self destruct order?
}}


{{tag
{{tag
|name = moveState
|name = moveState
|type = int
|type = int
|default = -1 for mobile units, <code>1</code> for structures
|default = -1 for mobile units, 1 for structures
|description = The initial movement state for the unit. Can be <code>-1</code> - Inherits from factory, <code>0</code> - Hold Position, <code>1</code> - Manoeuvre or <code>2</code> - Roam.}}
|description = The initial movement state for the unit. Can be {{value|-1}} - Inherits from factory, {{value|0}} - Hold Position, {{value|1}} - Manoeuvre or {{value|2}} - Roam.
}}


{{tag
{{tag
|name = fireState
|name = fireState
|type = int
|type = int
|default = -1 for units without <code>noAutoFire</code>, <code>2</code> otherwise
|default = -1 for units with {{taglink|noAutoFire|false}}, 2 otherwise
|description = The initial firing state for the unit. Can be <code>-1</code> - Inherits from factory, <code>0</code> - Hold Fire, <code>1</code> - Return Fire or <code>2</code> - Fire At Will.}}
|description = The initial firing state for the unit. Can be {{value|-1}} - Inherits from factory, {{value|0}} - Hold Fire, {{value|1}} - Return Fire or {{value|2}} - Fire At Will. Since 104.0 there is an additional value {{value|3}} - Fire At Neutral.
}}


{{tag
{{tag
Line 417: Line 452:
|type = bool
|type = bool
|default = false
|default = false
|description = Controls whether or not the unit has a fire state button.}}
|lua = canFireControl
|description = Controls whether or not the unit has a fire state button.
}}


{{tag
{{tag
Line 423: Line 460:
|type = bool
|type = bool
|default = false
|default = false
|description = Can the unit be issued ManualFire commands? A ManualFire command will fire any weapons with the <code>commandfire</code> tag (See [[Units-WeaponDefs]]).}}
|description = description = Can the unit be issued ManualFire commands? A ManualFire command will fire any weapons with the {{xtaglink|Gamedev:WeaponDefs|commandfire}} tag.
}}


====Builder Commands====
====Builder Commands====
Line 429: Line 467:
|name = canRestore
|name = canRestore
|type = bool
|type = bool
|default = builder
|default = builder && {{taglink|terraformSpeed}} > 0
|description = Can the unit be issued restore terrain commands? For builders only.}}
|description = Can the unit be issued restore terrain commands? For builders only.
}}


{{tag
{{tag
|name = canRepair
|name = canRepair
|type = bool
|type = bool
|default = builder
|default = builder && {{taglink|repairSpeed}} > 0
|description = Can the unit be issued repair commands? For builders only.}}
|description = Can the unit be issued repair commands? For builders only.
}}


{{tag
{{tag
|name = canReclaim
|name = canReclaim
|type = bool
|type = bool
|default = builder
|default = builder && {{taglink|reclaimSpeed}} > 0
|description = Can the unit be issued reclaim commands? For builders only.}}
|description = Can the unit be issued reclaim commands? For builders only.
}}


{{tag
{{tag
|name = canResurrect
|name = canResurrect
|type = bool
|type = bool
|default = false
|default = builder && {{taglink|resurrectSpeed}} > 0
|description = Can the unit be issued resurrection commands? For builders only.}}
|description = Can the unit be issued resurrection commands? For builders only.
}}


{{tag
{{tag
|name = canCapture
|name = canCapture
|type = bool
|type = bool
|default = false
|default = builder && {{taglink|captureSpeed}} > 0
|description = Can the unit be issued capture commands? For builders only.}}
|description = Can the unit be issued capture commands? For builders only.
}}


===Builder===
===Builder===
Line 461: Line 504:
|type = bool
|type = bool
|default = false
|default = false
|lua = isBuilder
|description = Is the unit a builder?}}
|description = Is the unit a builder?}}


Line 473: Line 517:
|type = bool
|type = bool
|default = false
|default = false
|description = Does the builders <code>buildDistance</code> apply in all 3 dimensions or only 2?}}
|description = Does the builders {{taglink|buildDistance}} apply in all 3 dimensions or only 2?}}


{{tag
{{tag
Line 479: Line 523:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How fast the builder builds, used in conjunction with the <code>buildTime</code> of the unit being built. Effectively, ''Time to build = unit <code>buildTime</code> / constructor <code>workerTime</code>''. If this value is <= <code>0.0</code> then <code>builder</code> is set to false.}}
|lua = buildSpeed
|description = How fast the builder builds, used in conjunction with the {{taglink|buildTime}} of the unit being built. Effectively, <code>Time to build = buildTime / workerTime</code>. If this value is <= <code>0.0</code> then {{taglink|builder}} is set to false.}}


{{tag
{{tag
Line 539: Line 584:
|type = float[3]
|type = float[3]
|default = {0.2, 0.7, 0.2} aka green
|default = {0.2, 0.7, 0.2} aka green
|description = The RGB colour of a builders' emitted nano particles if <code>showNanoSpray</code> is <code>true</code>. Also controls the RBG colour of a unit's own nanoframe if <code>showNanoFrame</code> is <code>true</code>.}}
|description = The RGB colour of a builders' emitted nano particles if {{taglink|showNanoSpray|true}}. Also controls the RBG colour of a unit's own nanoframe if {{taglink|showNanoFrame|true}}.}}


{{tag
{{tag
|name = fullHealthFactory
|name = fullHealthFactory
|type = bool
|type = bool
|default = false
|defaul[[elmo]]s
|description = If <code>true</code>, units are repaired before they are allowed to leave the factory i.e. units from this factory will be healed back to 100% health if they are damaged during construction.}}
|description = If <code>true</code>, units are repaired before they are allowed to leave the factory i.e. units from this factory will be healed back to 100% health if they are damaged during construction.}}


Line 551: Line 596:
|type = bool
|type = bool
|default = false
|default = false
|special = Removed in 101.0 in favour of more flexible lua custom commands
|description = Is this unit an airbase? Aircraft may land and repair on units which are airbases.}}
|description = Is this unit an airbase? Aircraft may land and repair on units which are airbases.}}


Line 559: Line 605:
|default = 1
|default = 1
|description =  
|description =  
How wide the unit is in footprint units, left to right. 1 footprint unit = 16 [[elmos]]. Cannot be below <code>1</code>. For mobile units this should be the same as the <code>footprintX</code> of its <code>movementClass</code>. Also used for obstacle avoidance.}}
How wide the unit is in footprint units, left to right. 1 footprint unit = 16 [[elmo]]s. Cannot be below <code>1</code>. For mobile units this should be the same as the {{xtaglink|Movedefs.lua|footprintX}} of its {{taglink|movementClass}}. Also used for obstacle avoidance.
}}


{{tag
{{tag
Line 566: Line 613:
|default = 1
|default = 1
|description =  
|description =  
How wide the unit is in footprint units, top to bottom. 1 footprint unit = 16 [[elmos]]. Cannot be below <code>1</code>. For mobile units this should be the same as the <code>footprintZ</code> of its <code>movementClass</code>. Also used for obstacle avoidance.}}
How wide the unit is in footprint units, top to bottom. 1 footprint unit = 16 [[elmo]]s. Cannot be below <code>1</code>. For mobile units this should be the same as the {{xtaglink|Movedefs.lua|footprintZ}} of its {{taglink|movementClass}}. Also used for obstacle avoidance.
}}


{{tag
{{tag
Line 576: Line 624:
:: <code>y</code> - 'Yard' - Always open, unblocking,  
:: <code>y</code> - 'Yard' - Always open, unblocking,  
:: <code>c</code> - 'Construction' - Open and unblocking only while constructing (for factories, controlled via <code>COB.YARD_OPEN</code> see [[Animation-LuaCallouts#Other]]),  
:: <code>c</code> - 'Construction' - Open and unblocking only while constructing (for factories, controlled via <code>COB.YARD_OPEN</code> see [[Animation-LuaCallouts#Other]]),  
:: <code>g</code> - 'Geothermal' - Flags that the unit must be placed over a <code>geoThermal</code> feature, does not actually count as a square (See [[Units-FeatureDefs]]),  
:: <code>i</code> - 'Inversed Construction' - Closed and blocking only while constructing (for factories, controlled via <code>COB.YARD_OPEN</code> see [[Animation-LuaCallouts#Other]]) ({{new|89.0}}),
:: <code>g</code> - 'Geothermal' - Flags that the unit must be placed over a {{xtaglink|Gamedev:FeatureDefs|geoThermal}} feature, does not actually count as a square,
:: <code>h</code> - 'High Resolution' - Indicates that the yardmap will use double resolution with four times as many characters. Must be the '''first''' character, and does not count as a square itself ({{new|93.0}}),
::<code>o</code> - 'Obstacle' - Always closed, blocking, all other chars are treated the same way.
::<code>o</code> - 'Obstacle' - Always closed, blocking, all other chars are treated the same way.
: Tip: 'Draw' out the yardmap over multiple lines then replace newlines with spaces (currently newlines are treated as <code>o</code>).}}
: Tip: 'Draw' out the yardmap over multiple lines. As of <span class=warning>89.0</span> all whitespace characters are ignored, including newlines.
}}
 
{{tag
|name = buildingMask
|type = int
|default = 1
|description = [http://en.wikipedia.org/wiki/Mask_(computing) Bitmask] representing the types of ground that this structure can be built on. Each digit of binary that is set to one means that a ground square with the corresponding digit set via [[Lua_SyncedCtrl#Ground|Spring.SetSquareBuildingMask]] can be built on.
}}


{{tag
{{tag
Line 584: Line 642:
|type = bool
|type = bool
|default = false
|default = false
|description = For structures. Does the constructor have to level the ground underneath the build area before beginning to build the structure?}}
|description = For structures. Does the constructor have to level the ground underneath the build area before beginning to build the structure?
}}


{{tag
{{tag
Line 590: Line 649:
|type = string
|type = string
|default = ""
|default = ""
|description = The name of the movement type a mobile, non aircraft, unit should use. See [[Movedefs.lua]]. Other tag usage should be consistent with this i.e. <code>canHover = true</code> IFF using a <code>HOVER</code> based movetype.}}
|lua = moveDef.name
|description = The name of the movement type a mobile, non aircraft, unit should use. See [[Movedefs.lua]].
}}


{{tag
{{tag
Line 596: Line 657:
|type = bool
|type = bool
|default = false
|default = false
|description = Is the unit a hovercraft? Hovercraft can cross water of any depth without a speed penalty. Hover's must also have <code>HOVER</code> within the name of their <code>movementClass</code> (see [[Movedefs.lua]]).}}
|special = <span class="warning">Removed in 95.0</span>
|description = Is the unit a hovercraft? Hovercraft can cross water of any depth without a speed penalty. Hover's must also have <code>HOVER</code> within the name of their {{taglink|movementClass}} (see [[Movedefs.lua]]).
}}


{{tag
{{tag
|name = floater
|name = floater
|type = bool
|type = bool
|default = true if the unit has the <code>waterline</code> tag, <code>false</code> otherwise
|default = false if a {{taglink|moveClass}} is defined, if not true if {{taglink|waterline|true}}, false otherwise
|description = When a mobile unit is crossing water, or a structure is placed on water, does it float on top of the water or crawl / lay on the sea bed?}}
|description = When a mobile unit is crossing water, or a structure is placed on water, does it float on top of the water or crawl / lay on the sea bed?
}}


{{tag
{{tag
Line 608: Line 672:
|type = bool
|type = bool
|default = false
|default = false
|description = Does the unit follow the terrain or always remain upright? Generally used for walkers.}}
|description = Does the unit follow the terrain or always remain upright? Generally used for walkers.
}}


{{tag
{{tag
Line 614: Line 679:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The maximum slope a building can be placed on. Mobile unit's use the <code>maxSlope</code> set in their <code>movementClass</code> (see [[Movedefs.lua]]). The value is in degrees and is clamped between <code>0.0</code> and <code>89.0</code>. This value is converted to a "maximum allowed height difference" (call it M), which involves a hard-coded constant. When a building gets placed, the height of each of its footprint squares is compared to a reference height (calculated for the build position). If the difference exceeds M for any square, that build position is rejected.}}
|lua = maxHeightDif
|description = The maximum slope a building can be placed on. Mobile unit's use the {{xtaglink|Movedefs.lua|maxSlope}} set in their {{taglink|movementClass}}. The value is in degrees and is clamped between <code>0.0</code> and <code>89.0</code>. This value is converted to a "maximum allowed height difference" (call it M), which involves a hard-coded constant. When a building gets placed, the height of each of its footprint squares is compared to a reference height (calculated for the build position). If the difference exceeds M for any square, that build position is rejected. The value readable from lua has been changed from that in the unitdef and reflects the internal engine value.
}}


{{tag
{{tag
Line 620: Line 687:
|type = float
|type = float
|default = -10e6
|default = -10e6
|description = The minimum depth of water a building can be placed on. Mobile unit's use the <code>minWaterDepth</code> set in their <code>movementClass</code> (see [[Movedefs.lua]]).}}
|description = The minimum depth of water a building can be placed on. Mobile unit's use the {{xtaglink|Movedefs.lua|minWaterDepth}} set in their {{taglink|movementClass}}.
}}


{{tag
{{tag
Line 626: Line 694:
|type = float
|type = float
|default = 10e6
|default = 10e6
|description = The maximum depth of water a building can be placed on. Mobile unit's use the <code>maxWaterDepth</code> set in their <code>movementClass</code> (see [[Movedefs.lua]]).}}
|description = The maximum depth of water a building can be placed on. Mobile unit's use the {{xtaglink|Movedefs.lua|maxWaterDepth}} set in their {{taglink|movementClass}}.
}}


{{tag
{{tag
Line 632: Line 701:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How low in the water does a ship sit? Higher values means the ship is lower in the water.}}
|description = How low in the water does a ship sit? Higher values means the ship is lower in the water.
}}


{{tag
{{tag
Line 638: Line 708:
|type = float
|type = float
|default = 1.0
|default = 1.0
|description = The minimum net impact speed that will cause a unit to be damaged by collisions with another unit.}}
|description = The minimum net impact speed that will cause a unit to be damaged by collisions with another unit.
}}


{{tag
{{tag
Line 644: Line 715:
|type = bool
|type = bool
|default = false
|default = false
|description = Can the unit be pushed around by other units? Turning it on doesn't remove all pushing but is a marked improvement.}}
|description = Can the unit be pushed around by other units? Turning it on doesn't remove all pushing but is a marked improvement.
}}


{{tag
{{tag
Line 650: Line 722:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The maximum speed attainable by the unit in [[Units-UnitsOfMeasurement | elmos per frame]]. If the value is -ve, the absolute value is used.}}
|lua = speed
|description = The maximum speed attainable by the unit in [[elmo]]s per frame. If the value is -ve, the absolute value is used.
}}


{{tag
{{tag
Line 656: Line 730:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The maximum speed attainable by the unit in reverse in [[Units-UnitsOfMeasurement | elmos per frame]]. If the value is -ve, the absolute value is used.}}
|lua = rSpeed
|special = {{new|99.0}}
|description = The maximum speed attainable by the unit in reverse in [[elmo]]s per frame. If the value is -ve, the absolute value is used.
}}


{{tag
{{tag
Line 662: Line 739:
|type = float
|type = float
|default = 0.5
|default = 0.5
|description = The acceleration of the unit, in [[Units-UnitsOfMeasurement | elmos per frame<sup>2</sup>]]. If the value is -ve, the absolute value is used.}}
|lua = maxAcc
|description = The acceleration of the unit, in [[elmo]]s per frame<sup>2</sup>. If the value is -ve, the absolute value is used.
}}


{{tag
{{tag
|name = brakeRate
|name = brakeRate
|type = float
|type = float
|default = 3.0 * acceleration
|default = acceleration
|description = The deceleration of the unit, in [[Units-UnitsOfMeasurement | elmos per frame<sup>2</sup>]]. If the value is -ve, the absolute value is used. For units with <code>canFly</code> this is multiplied by <code>0.1</code>.}}
|lua = maxDec
|description = The deceleration of the unit, in [[elmo]]s per frame<sup>2</sup>. If the value is -ve, the absolute value is used. For units with {{taglink|canFly|true}} this is multiplied by <code>0.1</code>. Prior to 95.0 this was scaled by 0.1 for aircraft and the default was 3x acceleration.
}}
 
{{tag
|name = myGravity
|type = float
|default = 0.4
|description = As Spring aircraft are slower than real aircraft this tag allows to lower gravity to compensate. Multiplies against map gravity for aircraft, replaces map gravity for ground vehicles if non-zero.
}}


{{tag
{{tag
Line 674: Line 762:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How fast the unit can turn. ''degrees per seconds = 0.16 * <code>turnRate</code>''}}
|description = How fast the unit can turn. <code>degrees per seconds = 0.16 * turnRate</code>.
}}


{{tag
{{tag
Line 680: Line 769:
|type = bool
|type = bool
|default = true
|default = true
|description = Does the unit turn on the spot (like a person or tank) or must it be moving forwards to turn (like a car).}}
|description = Does the unit turn on the spot (like a person or tank) or must it be moving forwards to turn (like a car).
}}


{{tag
{{tag
|name = turnInPlaceSpeedLimit
|name = turnInPlaceSpeedLimit
|type = float
|type = float
|default = A complex formula based on <code>turnRate</code> and <code>maxVelocity</code>
|default = A complex formula based on {{taglink|turnRate}} and {{taglink|maxVelocity}}
|description = For units with <code>turnInPlace = false</code>, this defines the minimum speed it will slow down to (the speed at which the turn is actually performed can be higher depending on the angular difference and <code>turnRate</code>).}}
|description = For units with {{taglink|turnInPlace|false}}, this defines the minimum speed it will slow down to (the speed at which the turn is actually performed can be higher depending on the angular difference and {{taglink|turnRate}}).
}}


{{tag
{{tag
Line 693: Line 784:
| default = 0.0
| default = 0.0
| special = {{new|86.0}}
| special = {{new|86.0}}
| description = For units with <code>turnInPlace = true</code>, defines the maximum angle (in degrees) of a turn above which it starts to brake.}}
| description = For units with {{taglink|turnInPlace|true}}, defines the maximum angle (in degrees) of a turn above which it starts to brake.
}}


{{tag
{{tag
Line 699: Line 791:
|type = bool
|type = bool
|default = true
|default = true
|description =Does the unit block the movement of other units? (Mines, i.e. non-mobile units with the <code>kamikaze</code> tag default to <code>false</code>)}}
|description = Does the unit block the movement of other units? (Mines, i.e. non-mobile units with the {{taglink|kamikaze}} tag default to <code>false</code>).
}}


{{tag
{{tag
Line 706: Line 799:
|default = mass
|default = mass
|special = {{new|85.0}}
|special = {{new|85.0}}
|description = How resistant is the unit to being crushed? Any [[Movedefs.lua|'''MoveClass''']] with a <code>crushStrength</code> greater than this will crush the unit - if and only if this has been enabled via [[Lua_SyncedCtrl#Unit_Control|Spring.SetUnitBlocking]].}}
|description = How resistant is the unit to being crushed? Any [[Movedefs.lua|'''MoveClass''']] with a {{xtaglink|Movedefs.lua|crushStrength}} greater than this will crush the unit - IFF this has been enabled via [[Lua_SyncedCtrl#Unit_Control|Spring.SetUnitBlocking]] and the collider impulse exceeds that of the colidee.
}}


===Flanking===
===Flanking===
For a deeper explanation of these tags, see [[Units:FlankingBonus]].
{{tag
{{tag
|name = flankingBonusMode
|name = flankingBonusMode
|type = int
|type = int
|default = flankingBonus.defaultMode set in [[Modrules.lua]]
|default = flankingBonus.defaultMode set in [[Modrules.lua]]
|description = The mode of operation of Spring's inbuilt flanking system. Can be <code>0</code> - No flanking bonus. Mode <code>1</code> builds up the ability to move over time, and swings to face attacks, but does not respect the way the unit is facing. Mode <code>2</code> also can swing, but moves with the unit as it turns. Mode <code>3</code> stays with the unit as it turns and otherwise doesn't move, the ideal mode to simulate something such as tank armour.}}
|description = The mode of operation of Spring's inbuilt flanking system. Can be <code>0</code> - No flanking bonus. Mode <code>1</code> builds up the ability to move over time, and swings to face attacks, but does not respect the way the unit is facing. Mode <code>2</code> also can swing, but moves with the unit as it turns. Mode <code>3</code> stays with the unit as it turns and otherwise doesn't move, the ideal mode to simulate something such as tank armour.
}}


{{tag
{{tag
Line 721: Line 814:
|type = float[3]
|type = float[3]
|default = {0.0, 0.0, 1.0}
|default = {0.0, 0.0, 1.0}
|description = This is the direction vector where the armour is facing; i.e. where the least damage is applied. The default is straight forwards.}}
|description = This is the direction vector where the armour is facing; i.e. where the least damage is applied. The default is straight forwards.
}}


{{tag
{{tag
Line 727: Line 821:
|type = float
|type = float
|default = 1.9
|default = 1.9
|description = The maximum multiplier to the damage dealt, when a unit is hit from the opposite direction to <code>flankingBonusDir</code>.}}
|description = The maximum multiplier to the damage dealt, when a unit is hit from the opposite direction to {{taglink|flankingBonusDir}}.
}}


{{tag
{{tag
Line 733: Line 828:
|type = float
|type = float
|default = 0.9
|default = 0.9
|description = The minimum multiplier to the damage dealt, when a unit is hit from the opposite direction to <code>flankingBonusDir</code>.}}
|description = The minimum multiplier to the damage dealt, when a unit is hit from the same direction as {{taglink|flankingBonusDir}}.
}}


{{tag
{{tag
Line 739: Line 835:
|type = float
|type = float
|default = 0.01
|default = 0.01
|description = This defines the ability of <code>flankingBonusDir</code> to move over time. Its value is added to the mobility every [[SlowUpdate]]. When the unit is attacked, the build up mobility value is multiplied by a vector facing the attack, which is added to <code>flankingBonusDir</code>.}}
|description = This defines the ability of {{taglink|flankingBonusDir}} to move over time. Its value is added to the mobility every [[SlowUpdate]]. When the unit is attacked, the build up mobility value is multiplied by a vector facing the attack, which is added to {{taglink|flankingBonusDir}}.
}}


===Aircraft===
===Aircraft===
Line 746: Line 843:
|type = bool
|type = bool
|default = false
|default = false
|description = Can the unit fly, i.e. is it an aircraft?}}
|description = Can the unit fly, i.e. is it an aircraft?
}}


{{tag
{{tag
Line 752: Line 850:
|type = bool
|type = bool
|default = false
|default = false
|description = Can the aircraft land underwater?}}
|description = Can the aircraft land underwater?
}}


{{tag
{{tag
Line 758: Line 857:
|type = bool
|type = bool
|default = true
|default = true
|description = Controls the take-off behaviour of aircraft with <code>hoverAttack</code>. <code>true</code> means planes start matching their factory's heading right after taking off from the pad, <code>false</code> means they maintain the heading of the pad until reaching <code>cruiseAlt</code>.}}
|description = Controls the take-off behaviour of aircraft with {{taglink|hoverAttack|true}}. <code>true</code> means planes start matching their heading right after taking off from the pad, <code>false</code> means they maintain the heading of the pad until reaching {{taglink|cruiseAlt}}.
}}


{{tag
{{tag
Line 764: Line 864:
|type = bool
|type = bool
|default = true
|default = true
|description = Does the unit collide with other aircraft, or can it occupy the same space?}}
|description = Does the unit collide with other aircraft, or can it occupy the same space?
}}


{{tag
{{tag
Line 770: Line 871:
|type = bool
|type = bool
|default = false
|default = false
|description = Controls whether the aircraft flys and attacks like a fighter/bomber or a helicopter/gunship.}}
|description = Controls whether the aircraft flys and attacks like a fighter/bomber or a helicopter/gunship.
}}


{{tag
{{tag
Line 776: Line 878:
|type = bool
|type = bool
|default = true
|default = true
|description = For aircraft with <code>hoverAttack = true</code>, controls if the unit strafes side to side while attacking or remains stationary.}}
|description = For aircraft with {{taglink|hoverAttack|true}}, controls if the unit strafes side to side while attacking or remains stationary.
}}


{{tag
{{tag
Line 782: Line 885:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The altitude in [[elmos]] which the unit attempts to fly at while cruising.}}
|lua = wantedHeight
|description = The altitude in [[elmo]]s which the unit attempts to fly at while cruising.
}}


{{tag
{{tag
Line 788: Line 893:
|type = float
|type = float
|default = -1.0
|default = -1.0
|description = For aircraft with <code>hoverAttack = true</code>, less then <code>0</code> means it can land and >= <code>0</code> indicates how much the unit will move during hovering on the spot.}}
|lua = dlHoverFactor
|description = For aircraft with {{taglink|hoverAttack|true}}, less then <code>0</code> means it can land and >= <code>0</code> indicates how much the unit will move during hovering on the spot.
}}


{{tag
{{tag
Line 794: Line 901:
|type = bool
|type = bool
|default = true
|default = true
|description = For aircraft with <code>hoverAttack = true</code>, controls whether or not the unit banks when moving turning.}}
|description = For aircraft with {{taglink|hoverAttack|true}}, controls whether or not the unit banks when moving turning.
}}


{{tag
{{tag
Line 800: Line 908:
|type = bool
|type = bool
|default = true
|default = true
|description = Does the aircraft follow the real map terrain or the special smoothed out navigation mesh generated by Spring specifically for aircraft?}}
|description = Does the aircraft follow the real map terrain or the special smoothed out navigation mesh generated by Spring specifically for aircraft?} Can become problematic for construction aircrafts, building in canyons.
}}


{{tag
{{tag
Line 806: Line 915:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The maximum flight time in seconds before aircraft must return to an airbase to refuel.}}
|special = Removed in 101.0 in favour of more flexible lua custom commands
|description = The maximum flight time in seconds before aircraft must return to an airbase to refuel.
}}


{{tag
{{tag
Line 812: Line 923:
|type = float
|type = float
|default = 5.0
|default = 5.0
|description = The time in seconds required to refuel the aircraft at an airbase.}}
|special = Removed in 101.0 in favour of more flexible lua custom commands
|description = The time in seconds required to refuel the aircraft at an airbase.
}}


{{tag
{{tag
Line 818: Line 931:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The minimum <code>workerTime</code> an airbase must have to repair / refuel this aircraft.}}
|special = Removed in 101.0 in favour of more flexible lua custom commands
|description = The minimum {{taglink|workerTime}} an airbase must have to repair / refuel this aircraft.
}}


{{tag
{{tag
Line 824: Line 939:
|type = bool
|type = bool
|default = false
|default = false
|description = Can the aircraft perform an [http://en.wikipedia.org/wiki/Immelmann_turn Immelmann turn]?}}
|description = Can the aircraft perform an [http://en.wikipedia.org/wiki/Immelmann_turn Immelmann turn]?
}}


====Advanced Air Tags====
====Advanced Air Tags====
The following set of tags are not well understood and using non-default values can lead to undesired flight behaviours.
The following set of tags are not well understood and using non-default values can lead to undesired flight behaviours.<br /><br />
{{tag
{{tag
|name = wingDrag
|name = wingDrag
|type = float
|type = float
|default = 0.07
|default = 0.07
|description = The drag caused by the aircraft's wing. Clamped between <code>0.0</code> and <code>1.0</code>.}}
|description = The drag caused by the aircraft's wing. Clamped between <code>0.0</code> and <code>1.0</code>.
}}


{{tag
{{tag
Line 838: Line 955:
|type = float
|type = float
|default = 0.08
|default = 0.08
|description = The angle between the front and the wing plane.}}
|description = The angle between the front and the wing plane.
}}


{{tag
{{tag
Line 844: Line 962:
|type = float
|type = float
|default = 0.1
|default = 0.1
|description = Fudge factor for lining up speed and front of plane.}}
|description = How far nose can be unaligned to speed vector before accelleration is applied.
}}


{{tag
{{tag
Line 850: Line 969:
|type = float
|type = float
|default = 0.07
|default = 0.07
|description = Fudge factor for lining up speed and front of plane.}}
|description = Rate for the nose to align to new (true) direction change. Values above 0.1 may lead to cumulative speedup issues.
 
}}
{{tag
|name = myGravity
|type = float
|default = 0.4
|description = As Spring aircraft are slower than real aircraft this tag allows to lower gravity to compensate. Multiplies against map gravity.}}


{{tag
{{tag
Line 862: Line 976:
|type = float
|type = float
|default = 0.005
|default = 0.005
|description = The drag used when crashing. Clamped between <code>0.0</code> and <code>1.0</code>.}}
|description = The drag used when crashing. Clamped between <code>0.0</code> and <code>1.0</code>.
}}


{{tag
{{tag
Line 868: Line 983:
|type = float
|type = float
|default = 0.8
|default = 0.8
|description = The maximum roll (z-axis rotation) the aircraft can achieve.}}
|description = The maximum roll (z-axis rotation) the aircraft can achieve.
}}


{{tag
{{tag
Line 874: Line 990:
|type = float
|type = float
|default = 0.45
|default = 0.45
|description = The maximum pitch (x-axis rotation) the aircraft tries to keep.}}
|description = The maximum pitch (x-axis rotation) the aircraft tries to keep.
}}


{{tag
{{tag
Line 880: Line 997:
|type = float
|type = float
|default = 500.0
|default = 500.0
|description = Hint to Spring unit AI about the required turning radius.}}
|description = Hint to Spring unit AI about the required turning radius.
}}


{{tag
{{tag
Line 886: Line 1,004:
|type = float
|type = float
|default = 3.0
|default = 3.0
|description = The speed of takeoff and landing, at least for gunships (<code>hoverAttack = true</code>)}}
|description = The speed of takeoff and landing, at least for gunships ({{taglink|hoverAttack|true}}).
}}


{{tag
{{tag
Line 892: Line 1,011:
|type = float
|type = float
|default = 0.015
|default = 0.015
|description =  The maximum turn speed around the roll (z) axis.}}
|description =  The maximum turn speed around the roll (z) axis.
}}


{{tag
{{tag
Line 898: Line 1,018:
|type = float
|type = float
|default = 0.01
|default = 0.01
|description = The maximum turn speed around the pitch (x) axis.}}
|description = The maximum turn speed around the pitch (x) axis.
}}


{{tag
{{tag
Line 904: Line 1,025:
|type = float
|type = float
|default = 0.004
|default = 0.004
|description = The maximum turn speed around the yaw (y) axis.}}
|description = The maximum turn speed around the yaw (y) axis.
}}


{{tag
{{tag
Line 910: Line 1,032:
|type = float
|type = float
|default = 0.065
|default = 0.065
|description = The maximum acceleration or 'engine power' of the aircraft.}}
|description = The maximum acceleration or 'engine power' of the aircraft.
}}
 
{{tag
|name = attackSafetyDistance
|type = float
|default = 0
| special = Exists only in version 99.0
|description = Fighters abort dive toward target if within attackSafetyDistance and try to climb back to normal altitude while still moving toward target. It's disabled by default. Set to half of the minimum weapon range to avoid collisions, enemy fire, AOE damage. If set to greater than the weapon range, the unit will fly over the target like a bomber. This tag was removed in version 100.0 and changed to a [[Lua_MoveCtrl#MoveType-Controlling|Spring.SetMoveTypeData]] key.
}}


====Flares====
====Flares====
The following set of tags are rarely used and are hardcoded to only work vs. missile weapons. The texture is hardcoded to be <code>flareprojectiletexture</code> defined in [[Resources.lua]].
The following set of tags are rarely used and are hardcoded to only work vs. missile weapons. The texture is hardcoded to be <code>flareprojectiletexture</code> defined in [[Resources.lua]].<br /><br />
{{tag
{{tag
|name = canDropFlare
|name = canDropFlare
|type = bool
|type = bool
|default = false
|default = false
|description = Can this aircraft drop flares to distract missile weapons?}}
|description = Can this aircraft drop flares to distract missile weapons?
}}


{{tag
{{tag
Line 924: Line 1,056:
|type = float
|type = float
|default = 5.0
|default = 5.0
|description = The time in seconds between successive flare drops.}}
|lua = flareReloadTime
|description = The time in seconds between successive flare drops.
}}


{{tag
{{tag
Line 930: Line 1,064:
|type = float
|type = float
|default = 0.3
|default = 0.3
|description = The delay between detecting an incoming missile and launching flares. Multiplied by a random number between 1 and 16.}}
|description = The delay between detecting an incoming missile and launching flares. Multiplied by a random number between 1 and 16.
}}


{{tag
{{tag
Line 936: Line 1,071:
|type = float
|type = float
|default = 0.5
|default = 0.5
|description = The probability that an incoming missile will target the flare instead of the aircraft.}}
|description = The probability that an incoming missile will target the flare instead of the aircraft.
}}


{{tag
{{tag
Line 942: Line 1,078:
|type = float[3]
|type = float[3]
|default = {0.0, 0.0, 0.0}
|default = {0.0, 0.0, 0.0}
|description = The direction vector which flares are emitted in.}}
|description = The direction vector which flares are emitted in.
}}


{{tag
{{tag
Line 948: Line 1,085:
|type = int
|type = int
|default = 3
|default = 3
|description = The lifetime of a dropped flare in [[frames]].}}
|description = The lifetime of a dropped flare in [[frames]].
}}


{{tag
{{tag
Line 954: Line 1,092:
|type = int
|type = int
|default = 4
|default = 4
|description = How many flares are dropped at once?}}
|description = How many flares are dropped at once?
}}


{{tag
{{tag
Line 960: Line 1,099:
|type = int
|type = int
|default = 0
|default = 0
|description = The delay in [[frames]] between the release of each individual flare in a burst.}}
|description = The delay in [[frames]] between the release of each individual flare in a burst.
}}


===Transports===
===Transports===
Line 967: Line 1,107:
|type = int
|type = int
|default = 0
|default = 0
|description = The size of units that the transport can pick up, in terms of the passengers <code>footprintX</code>.}}
|description = The size of units that the transport can pick up, in terms of the passengers {{taglink|footprintX}}.}}


{{tag
{{tag
Line 973: Line 1,113:
|type = int
|type = int
|default = 0
|default = 0
|description = The smallest size of unit that the transport can pick up, in terms of the passengers <code>footprintX</code>.}}
|description = The smallest size of unit that the transport can pick up, in terms of the passengers {{taglink|footprintX}}.}}


{{tag
{{tag
Line 979: Line 1,119:
|type = int
|type = int
|default = 0
|default = 0
|description = The total number of units that the transport can pick up, with each unit multiplied by it's <code>footprintX</code> size. If this tag is not present, then any AttachUnit and DropUnit call in the animation script will be ignored (See [[Animation-LuaCallouts#Other]])}}
|description = The total number of units that the transport can pick up, with each unit multiplied by it's {{taglink|footprintX}} size. Prior to 101.0 if this tag is not present, then any Script.AttachUnit and Script.DropUnit call in the animation script will be ignored (See [[Animation-LuaCallouts#Other]]), in successive versions all units can use [[Lua_SyncedCtrl#Unit_Control|Spring.UnitAttach]] et al regardless of this tag.}}


{{tag
{{tag
Line 985: Line 1,125:
|type = float
|type = float
|default = 100000.0
|default = 100000.0
|description = The total cumulative <code>mass</code> of passengers the transport can carry.}}
|description = The total cumulative {{taglink|mass}} of passengers the transport can carry.}}


{{tag
{{tag
Line 991: Line 1,131:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = The total minimum <code>mass</code> passenger the transport can carry.}}
|description = The minimum {{taglink|mass}} passenger the transport can carry.}}


{{tag
{{tag
Line 997: Line 1,137:
|type = float
|type = float
|default = 220.0
|default = 220.0
|description = How far away in [[elmos]] can the transporter pick up and drop units?}}
|description = How far away in [[elmo]]s can the transporter pick up and drop units?}}


{{tag
{{tag
|name = unloadSpread
|name = unloadSpread
|type = float
|type = float
|default = 1.0
|default = 5.0
|description = How spread out the passengers are when unloaded. Is multiplied by the passengers radius.}}
|description = How spread out the passengers are when unloaded. Is multiplied by the passengers radius.}}


Line 1,026: Line 1,166:
|name = cantBeTransported
|name = cantBeTransported
|type = bool
|type = bool
|default = false</code> for mobile units <code>true</code> for structures
|default = false for mobile units, true for structures
|description = Controls if a unit is transportable at all or not. If <code>false</code> it is overridden by [[Modrules.lua]] <code>transportability</code> subtable tags.}}
|description = Controls if a unit is transportable at all or not. If <code>false</code> it is overridden by [[Modrules.lua]] <code>transportability</code> subtable tags.}}


Line 1,045: Line 1,185:
|type = float
|type = float
|default = 0.2
|default = 0.2
|description = For air transports with <code>transportUnloadMethod = 1</code>. The speed in [[elmos]] per second which units will fall at when released from the transport.}}
|description = For air transports with {{taglink|transportUnloadMethod|1}}. The speed in [[elmo]]s per second which units will fall at when released from the transport.}}


{{tag
{{tag
Line 1,051: Line 1,191:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = Allows you to override <code>fallSpeed</code> for an individual passenger.}}
|description = Allows you to override {{taglink|fallSpeed}} for an individual passenger.}}


===Categories===
===Categories===
For a deeper explanation of these tags, see [[Unit_Categories]].
{{tag
{{tag
|name = category
|name = category
|type = string
|type = string
|default = ""
|default = ""
|description = The category tag is a string of separate words, each representing a category of units. There are a maximum of 32 categories. The primary purpose of categories is weapon targeting (See [[#weapons]]).}}
|description = The category tag is a string of separate words, each representing a category of units. There is a maximum of 32 categories. The primary purpose of categories is weapon targeting (See [[#weapons]]). Be aware that if no category is set, by default the unit will not be targetable due to {{taglink|onlyTargetCategory}} defaulting to a null string also.}}


{{tag
{{tag
Line 1,065: Line 1,204:
|type = string
|type = string
|default = ""
|default = ""
|description = The unit will still target enemies with a matching <code>category</code>, but will not chase after it if it moves out of weapon range.}}
|description = The unit will still target enemies with a matching {{taglink|category}}, but will not chase after it if it moves out of weapon range.}}


===Decals===
===Decals===
Line 1,084: Line 1,223:
|type = float
|type = float
|default = 32.0
|default = 32.0
|description = The width of the track decal left on the ground, in [[elmos]].}}
|description = The width of the track decal left on the ground, in [[elmo]]s.}}


{{tag
{{tag
Line 1,090: Line 1,229:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How far back in [[elmos]] the track should be drawn from the centre of the unit.}}
|description = How far back in [[elmo]]s the track should be drawn from the centre of the unit.}}


{{tag
{{tag
Line 1,135: Line 1,274:


===Collision Volumes===
===Collision Volumes===
For a deeper explanation of these tags, see [[Unit_collision_volumes | Unit Collision Volumes]].
For a deeper explanation of these tags, see [[Gamedev:CollisionVolumes]]. Note that all collision checks first do a pre-check with the unit ''radius'' before doing the colvol checks. Ergo the unit ''radius'' must be larger or equal to the colvol!
 
 
{{tag
{{tag
|name = modelCenterOffset
|name = usePieceCollisionVolumes
|type = float[3]
|type = bool
|default = {0.0, 0.0, 0.0}
|default = false
|description = How far from the model's defined centre should the centre of the unit be?}}
|lua = collisionVolume.defaultToPieceTree
|description = When turned on the model and UnitDef collision volumes are ignored and Spring generates a bounding box volume for each piece of the unit model. These volumes can be manipulated or replaced by [[Lua_SyncedCtrl#Unit_Control | Spring.SetUnitPieceCollisionVolumeData]]. Increases the performance cost of collision calculations.}}


{{tag
{{tag
|name = usePieceCollisionVolumes
|name = useFootPrintCollisionVolume
|type = bool
|type = bool
|default = false
|default = false
|description = When turned on the model and unitDef collision volumes are ignored and Spring generates a bounding box volume for each piece of the unit model. These volumes can be manipulated or replaced by [[Lua_SyncedCtrl#Unit_Control | Spring.SetUnitPieceCollisionVolumeData]]. Increases the performance cost of collision calculations.}}
|special = {{new|92.0}}
|lua = .collisionVolume.defaultToFootprint
|description = Replaces any defined collision volume with a box with dimensions equal to the object's footprint (this also overrides any custom scaling and/or offsets).
}}
 
 
The following three tags can instead be replaced with a [[#collisionVolume]] subtable:


{{tag
{{tag
|name = collisionVolumeType
|name = collisionVolumeType
|type = string
|type = string
|default = ""
|default = "s"
|description = What shape should the unit's collision volume be? Can be <code>box</code>, <code>ellipsoid</code> or a cylinder aligned to an axis; <code>cylX</code>, <code>cylY</code>, <code>cylZ</code>.}}
|lua = collisionVolume.type
|description = What shape should the unit's collision volume be? Can be {{value|"box"}}, {{value|"sphere}} or a cylinder aligned to an axis; {{value|"cylX"}}, {{value|"cylY"}}, {{value|"cylZ"}}.}}


{{tag
{{tag
Line 1,158: Line 1,307:
|type = float[3]
|type = float[3]
|default = {0.0, 0.0, 0.0}
|default = {0.0, 0.0, 0.0}
|description = The length of the collision volume in each of the three axes.}}
|lua = collisionVolume.scale{X{{pipe}}Y{{pipe}}Z}
|description = The lengths of the collision volume in each of the three axes. Note that non-spherical ellipsoids and elliptical cylinders are not supported.}}


{{tag
{{tag
Line 1,164: Line 1,314:
|type = float[3]
|type = float[3]
|default = {0.0, 0.0, 0.0}
|default = {0.0, 0.0, 0.0}
|lua = collisionVolume.offset{X{{pipe}}Y{{pipe}}Z}
|description = The offset from the unit centre to the hit volume centre in each axis.}}
|description = The offset from the unit centre to the hit volume centre in each axis.}}
The following tags have now been removed from the engine:


{{tag
{{tag
Line 1,170: Line 1,324:
|type = int
|type = int
|default = 0
|default = 0
|special = <span class="warning">Removed in 90.0 (Now always continuous)</span>
|description = The type of test used to detect collisions. Can be <code>0</code> (discrete) or <code>1</code> (continuous). Use the latter for catching high speed projectiles which may otherwise 'skip through' small collision volumes, but beware of the increased performance cost.}}
|description = The type of test used to detect collisions. Can be <code>0</code> (discrete) or <code>1</code> (continuous). Use the latter for catching high speed projectiles which may otherwise 'skip through' small collision volumes, but beware of the increased performance cost.}}
{{tag
|name = modelCenterOffset
|type = float[3]
|default = {0.0, 0.0, 0.0}
|special = <span class="warning">Removed in 89.0 (Now set via lua)</span>
|description = How far from the model's defined centre should the centre of the unit be?}}
===Selection Volumes===
Introduced in 104.0, units may now have custom selection volumes in exactly the same way as collision volumes were already defined.
{{tag
|name = usePieceSelectionVolumes
|type = bool
|default = false
|special = {{new|104.0}}
|lua = .selectionVolume.defaultToPieceTree
|description = When turned on the model and UnitDef selection volumes are ignored and Spring generates a bounding box volume for each piece of the unit model (the same volumes are used for collision and selection). These volumes can be manipulated or replaced by [[Lua_SyncedCtrl#Unit_Control | Spring.SetUnitPieceColisionVolumeData]]. Increases the performance cost of selection calculations.}}
{{tag
|name = useFootPrintSelectionVolume
|type = bool
|default = false
|special = {{new|104.0}}
|lua = .selectionVolume.defaultToFootprint
|description = Replaces any defined selection volume with a box with dimensions equal to the object's footprint (this also overrides any custom scaling and/or offsets).
}}
The following three tags can instead be replaced with a [[#selectionVolume]] subtable:
{{tag
|name = selectionVolumeType
|type = string
|default = "s"
|special = {{new|104.0}}
|lua = collisionVolume.type
|description = What shape should the unit's selection volume be? Can be {{value|"box"}}, {{value|"sphere}} or a cylinder aligned to an axis; {{value|"cylX"}}, {{value|"cylY"}}, {{value|"cylZ"}}.}}
{{tag
|name = selectionVolumeScales
|type = float[3]
|default = {0.0, 0.0, 0.0}
|special = {{new|104.0}}
|lua = .selectionVolume.scale{X{{pipe}}Y{{pipe}}Z}
|description = The lengths of the selection volume in each of the three axes. Note that non-spherical ellipsoids and elliptical cylinders are not supported.}}
{{tag
|name = selectionVolumeOffsets
|type = float[3]
|default = {0.0, 0.0, 0.0}
|special = {{new|104.0}}
|lua = .selectionVolume.offset{X{{pipe}}Y{{pipe}}Z}
|description = The offset from the unit centre to the selection volume centre in each axis.}}


===Attack Behaviours===
===Attack Behaviours===
Line 1,177: Line 1,387:
|type = int
|type = int
|default = 0
|default = 0
|lua = highTrajectoryType
|description = Can the unit fire it's (ballistic) weapons in a high trajectory arc? Can be <code>0</code> - Low trajectory only, <code>1</code> - High trajectory only, or <code>2</code> - Toggle button.}}
|description = Can the unit fire it's (ballistic) weapons in a high trajectory arc? Can be <code>0</code> - Low trajectory only, <code>1</code> - High trajectory only, or <code>2</code> - Toggle button.}}


Line 1,183: Line 1,394:
|type = bool
|type = bool
|default = false
|default = false
|lua = canKamikaze
|description = Does the unit attack its target by blowing itself up?}}
|description = Does the unit attack its target by blowing itself up?}}


Line 1,189: Line 1,401:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How close to the target, in [[elmos]], the unit must get before detonating. Measured in 3D, not 2D.}}
|lua = kamikazeDist
|description = How close to the target, in [[elmo]]s, the unit must get before detonating. Measured in 3D, not 2D.}}


{{tag
{{tag
Line 1,195: Line 1,408:
|type = bool
|type = bool
|default = false
|default = false
|description = Does the target unit have to be in LOS when detonating or only within <code>kamikazeDistance</code>.}}
|description = Does the target unit have to be in LOS when detonating or only within {{taglink|kamikazeDistance}}.}}


{{tag
{{tag
Line 1,208: Line 1,421:
|type = string
|type = string
|default = ""
|default = ""
|description = The unitdef name (not human <code>name</code>) which this unit is a decoy for.}}
|description = The UnitDef name (not human {{taglink|name}}) which this unit is a decoy for.}}


{{tag
{{tag
Line 1,214: Line 1,427:
|type = int
|type = int
|default = 5
|default = 5
|lua = selfDCountdown
|description = The length in seconds taken between issuing self destruct order and the unit exploding.}}
|description = The length in seconds taken between issuing self destruct order and the unit exploding.}}


Line 1,220: Line 1,434:
|type = float
|type = float
|default = 1.0
|default = 1.0
|lua = armoredMultiple
|description = The multiplier applied to weapon damage when the units ARMORED status (See [[Lua_ConstCOB]]) is turned on.}}
|description = The multiplier applied to weapon damage when the units ARMORED status (See [[Lua_ConstCOB]]) is turned on.}}


Line 1,226: Line 1,441:
|type = bool
|type = bool
|default = false
|default = false
|lua = targFac
|description = Does the unit upgrade the targeting so that units shoot accurately at enemy units which are in radar but not in LOS.}}
|description = Does the unit upgrade the targeting so that units shoot accurately at enemy units which are in radar but not in LOS.}}


Line 1,232: Line 1,448:
|type = bool
|type = bool
|default = false
|default = false
|description = Does the unit immediately die into it's <code>corpse</code> feature when built? Used mainly for making walls.}}
|description = Does the unit immediately die into it's {{taglink|corpse}} feature when built? Used mainly for making walls.}}


{{tag
{{tag
Line 1,244: Line 1,460:
|type = bool
|type = bool
|default = false
|default = false
|description = Should the unit display it's controlling player as its name instead of <code>name</code>. Generally used for commander or hero units.}}
|description = Should the unit display it's controlling player as its name instead of {{taglink|name}}. Generally used for commander or hero units.}}


{{tag
{{tag
Line 1,256: Line 1,472:
|type = int
|type = int
|default = MAX_UNITS
|default = MAX_UNITS
|lua = maxThisUnit
|description = How many of this unit type may a player control at once? Defaults to being the maximum amount of units controllable. Is overridden by lobby unit restrictions.}}
|description = How many of this unit type may a player control at once? Defaults to being the maximum amount of units controllable. Is overridden by lobby unit restrictions.}}


Line 1,261: Line 1,478:
|name = power
|name = power
|type = float
|type = float
|default = buildCostMetal + (buildCostEnergy / 60.0)
|default = {{taglink|buildCostMetal}} + ({{taglink|buildCostEnergy}} / 60.0)
|description = The relative power of the unit. Used in weapon targeting priority and experience gain calculations.}}
|description = The relative power of the unit. Used in weapon targeting priority and experience gain calculations.}}


==Sub Tables==
==Sub Tables==
===collisionVolume===
The <code>collisionVolume</code> subtable of a UnitDef replaces the older individual {{taglink|collisionVolumeType}}, {{taglink|collisionVolumeScales}} and {{taglink|collisionVolumeOffsets}} tags.
{{tag
|name = type
|type = string
|default = "s"
|lua = .collisionVolume.type
|description = What shape should the unit's collision volume be? Can be {{value|"box"}}, {{value|"sphere"}} or a {{value|"cylinder"}}.}}
{{tag
|name = axis
|type = string
|default = "z"
|description = Which axis does the unit's collision volume lie along? Can be {{value|"x"}}, {{value|"y"}} or {{value|"z"}}.}}
{{tag
|name = scales
|type = float[3]
|default = {0.0, 0.0, 0.0}
|lua = .collisionVolume.scale{X{{pipe}}Y{{pipe}}Z}
|description = The lengths of the collision volume in each of the three axes. Note that non-spherical ellipsoids and elliptical cylinders are not supported.}}
{{tag
|name = offsets
|type = float[3]
|default = {0.0, 0.0, 0.0}
|lua = .collisionVolume.offset{X{{pipe}}Y{{pipe}}Z}
|description = The offset from the unit centre to the hit volume centre in each axis.}}
===selectionVolume===
The <code>selectionVolume</code> subtable of a UnitDef can replace the individual {{taglink|selectionVolumeType}}, {{taglink|selectionVolumeScales}} and {{taglink|selectionVolumeOffsets}} tags.
{{tag
|name = type
|type = string
|default = "s"
|lua = .selectionVolume.type
|description = What shape should the unit's selection volume be? Can be {{value|"box"}}, {{value|"sphere"}} or a {{value|"cylinder"}}.}}
{{tag
|name = axis
|type = string
|default = "z"
|description = Which axis does the unit's selection volume lie along? Can be {{value|"x"}}, {{value|"y"}} or {{value|"z"}}.}}
{{tag
|name = scales
|type = float[3]
|default = {0.0, 0.0, 0.0}
|lua = .selectionVolume.scale{X{{pipe}}Y{{pipe}}Z}
|description = The lengths of the selection volume in each of the three axes. Note that non-spherical ellipsoids and elliptical cylinders are not supported.}}
{{tag
|name = offsets
|type = float[3]
|default = {0.0, 0.0, 0.0}
|lua = .selectionVolume.offset{X{{pipe}}Y{{pipe}}Z}
|description = The offset from the unit centre to the selection volume centre in each axis.}}


===weapons===
===weapons===
Line 1,275: Line 1,552:
|type = string
|type = string
|default = ""
|default = ""
|description = The <code>weaponName</code> of the weapon (See [[Units-WeaponDefs]]). If using the [[weapondefs_post.lua]] provided by [[springcontent.sdz]], you may include the WeaponDef tables within the UnitDef as the <code>weaponDefs</code> subtable, and refer to them with <code>def</code> rather than <code>name</code>. This can be a useful way to organise definitions if units do not generally share weapons.}}
|description = The <code>weaponName</code> of the weapon (See [[Gamedev:WeaponDefs]]). If using the [[weapondefs_post.lua]] provided by [[springcontent.sdz]], you may include the WeaponDef tables within the UnitDef as the <code>weaponDefs</code> subtable, and refer to them with <code>def</code> rather than <code>name</code>. This can be a useful way to organise definitions if units do not generally share weapons.}}


{{tag
{{tag
Line 1,281: Line 1,558:
|type = string
|type = string
|default = ""
|default = ""
|description = A string of unit <code>category</code> entries which this weapon prefers to avoid targeting. i.e. given two units which ''can'' be targeted, any unit whose <code>category</code> matches any entry in this tag, will be targeted last. (See [[#Categories]])}}
|description = A string of unit {{taglink|category}} entries which this weapon prefers to avoid targeting. i.e. given two units which ''can'' be targeted, any unit whose {{taglink|category}} matches any entry in this tag, will be targeted last. (See [[#Categories]])}}


{{tag
{{tag
Line 1,287: Line 1,564:
|type = string
|type = string
|default = ""
|default = ""
|description = A string of unit <code>category</code> entries which this weapon can target. i.e. any unit whose <code>category</code> does not match any entry in this tag, cannot be targeted by this weapon. (See [[#Categories]])}}
|description = A string of unit {{taglink|category}} entries which this weapon can target. i.e. any unit whose {{taglink|category}} does not match any entry in this tag, cannot be targeted by this weapon. (See [[#Categories]])}}


{{tag
{{tag
Line 1,298: Line 1,575:
|name = mainDir
|name = mainDir
|type = float[3]
|type = float[3]
|default = {1.0, 0.0, 0.0} i.e. forwards
|default = {0.0, 0.0, 1.0} i.e. forwards
|description = A vector representing the firing direction of this weapon if it has a limited firing arc. Used in conjunction with <code>maxAngleDif</code> (See [[Units:WeaponMainDir]]).}}
|description = A vector representing the firing direction of this weapon if it has a limited firing arc. Used in conjunction with {{taglink|maxAngleDif}} (See [[Gamedev:WeaponMainDir]]).}}


{{tag
{{tag
|name = maxAngleDif
|name = maxAngleDif
|type = float
|type = float
|default = 180.0
|default = 360.0
|description = How wide this weapons limited firing arc is in degrees. Symmetrical about <code>mainDir</code> i.e. <code>180.0</code> is 90 degree freedom either way (See [[Units:WeaponMainDir]]).}}
|description = How wide this weapons limited firing arc is in degrees. Symmetrical about {{taglink|mainDir}} i.e. <code>180.0</code> is 90 degree freedom either way (See [[Gamedev:WeaponMainDir]]).}}


{{tag
{{tag
Line 1,311: Line 1,588:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How much fuel in seconds is deducted from the units initial <code>maxFuel</code> when this weapon fires.}}
|description = How much fuel in seconds is deducted from the units initial {{taglink|maxFuel}} when this weapon fires.}}


===buildOptions===
===buildOptions===
The <code>buildOptions</code> subtable of a UnitDef tells Spring which other units the unit can build (in the case of a builder) or produce (in the case of a factory).
The <code>buildOptions</code> subtable of a UnitDef tells Spring which other units the unit can build (in the case of a builder) or produce (in the case of a factory).
It is a simple array (number indexed table) of <code>unitName</code>s (not the human readable <code>name</code>!).
It is a simple array (number indexed table) of <code>unitName</code>s (not the human readable {{taglink|name}}!).


There are no additional tags specific to this subtable.
There are no additional tags specific to this subtable.
Line 1,381: Line 1,658:
The events called by the engine are as follows:
The events called by the engine are as follows:


* '''<code>ok</code>'''
{{ItemType
: Unit is issued a command.
|name = ok
|description = Unit is issued a command.
}}


* '''<code>select</code>'''
{{ItemType
: Unit is selected by the player.
|name = select
|description = Unit is selected by the player.
}}


* '''<code>arrived</code>
{{ItemType
: Unit has arrived at its destination. Mobile ground units only.
|name = arrived
|description = Unit has arrived at its destination. Mobile ground units only.
}}


* '''<code>build</code>'''
{{ItemType
: Unit begins building. Called for both factories and mobile construction units.
|name = build
|description = Unit begins building. Called for both factories and mobile construction units.
}}


* '''<code>activate</code>'''
{{ItemType
: Unit is activated, i.e. Is turned on. Also called when a mobile ground unit starts moving.
|name = activate
|description = Unit is activated, i.e. Is turned on. Also called when a mobile ground unit starts moving.
}}


* '''<code>deactivate</code>'''
{{ItemType
: Unit deactivates, i.e. Is turned off.
|name = deactivate
|description = Unit deactivates, i.e. Is turned off.
}}


* '''<code>cant</code>'''
{{ItemType
: Unit cannot carry out this order. Loaded but not currently called by the engine.
|name = cant
|description = Unit cannot carry out this order. Loaded but not currently called by the engine.
}}


* '''<code>underattack</code>'''
{{ItemType
: Unit gets attacked. Loaded but not currently called by the engine.
|name = underattack
|description = Unit gets attacked. Loaded but not currently called by the engine.
}}


===customParams===
===customParams===
Line 1,411: Line 1,704:


==Examples==
==Examples==
[http://imolarpg.dyndns.org/trac/balatest/browser/trunk/units 'Balanced Annihilation' UnitDefs]
MC:L implements OO with inheritance (base classes in [http://sourceforge.net/p/mwspring/code/HEAD/tree/Gamedata/unitdefs_pre.lua#l36 unitdefs_pre.lua])
 
[http://trac.caspring.org/browser/trunk/mods/ca/units 'Complete Annihilation' UnitDefs]
 
[http://code.google.com/p/conflictterra/source/browse/#svn%2Fgames%2FCT%2Funits 'Conflict Terra' UnitDefs]
 
[https://code.google.com/p/evolutionrts/source/browse/#svn%2Ftrunk%2Fevolutiondev.sdd%2FUnits 'Evolution RTS' UnitDefs]
 
[http://code.google.com/p/springtutorialgame/source/browse/#svn%2Ftrunk%2FSpringTutorialGame.sdd%2FUnits 'Spring Tutorial Game' UnitDefs]


[http://code.google.com/p/zero-k/source/browse/trunk#trunk%2Fmods%2Fzk%2Funits 'ZeroK' UnitDefs]


{{ExampleRepoLinks
|path = units/
|entity = UnitDefs
}}


[[Category: Unit_development]]
[[Category: Game Dev]]
[[Category: Game development]]

Latest revision as of 12:16, 8 April 2025

Development < Gamedev:Main < Gamedev:UnitDefs

Location

UnitDef files are .lua files stored in the Units/ directory of a Spring Game.

Purpose

UnitDef files have one purpose; to define the properties of units. They are the main description file for what attributes your unit should have and how it should behave.

Source

The engine source code which loads the tags from these files is viewable here:


The engine source which reads the #sounds subtable can be found here:

Data Types

int
An integer number. eg. 5
float
A number with decimals. eg 1.023
bool
A value which can be true or false. eg true
string
Text, or more precisely a string of alphanumeric characters. eg "string of characters"
rgb
Three float components, representing red, green and blue components, ranged from 0.0 to 1.0. eg {0.0, 0.0, 0.0}
float3
Three float components, eg {0.0, 0.0, 0.0}
float4
Four float components, eg {0.0, 0.0, 0.0, 0.0}

Details

There follows a comprehensive (certain deprecated tags are not present) list of the tags available, their data type, default value and a brief description of what they do. Bear in mind that the source code linked above is the ultimate reference when dealing with these tags.

In lua tables keys (i.e. the tags) should be lower case, here they are represented in camelCase for readability. In your files you may use the lowerkeys function on your final table to ensure the keys are properly cased.

It is usual to name the returned UnitDef table the internal unitName desired for the unit.

General

string name  default: "" lua: humanName 

This is simply the name of the unit as it appears to the player.

string description  default: name lua: tooltip 

This is the tooltip description of the unit seen by the player. It defaults to the name of the unit.

string buildPic  default: "" lua: buildPicName 

The filename of the image to be used as the build picture, assumes Unitpics/ directory (see Gamedev:Buildpics).

string objectName  default: "" lua: modelname 

The filename of the 3D model file for this unit, assumes Objects3D/ directory.

string script  default: unitName + ".cob" lua: scriptName 

The filename of the animation script file for this unit, assumes Scripts/ directory. Default assumes .cob file but LUS should be preferred.

float maxDamage  default: 0.0 lua: health 

The base 'hitpoints' the unit will have.

float autoHeal  default: 0.0 

How much health the unit will regain every second.

float idleAutoHeal  default: 10.0 

How much health the unit will regain every second whilst it is idle.

int idleTime  default: 600 

The time in frames taken until a unit is considered to be idle.

float buildCostMetal  default: 1.0 lua: metalCost 

The amount of metal resource the unit costs to build. Cannot be below 1.0.

float buildCostEnergy  default: 0.0 lua: energyCost 

The amount of energy resource the unit costs to build.

float buildTime  default: 0.0 

The time taken to build the unit, in conjunction with the workerTime of the constructor. In Resource Frames, Time to build = (buildTime / workerTime). Defaults to 0.0 but cannot actually be below 1.0.

float mass  default: buildCostMetal 

The mass of the unit, used in weapon impulse calculations. Cannot be less than 1.0.

bool reclaimable  default: true 

Can the unit be reclaimed by a builder?

bool capturable  default: true 

Can a unit be stolen by a builder using the capture command?

bool repairable  default: true 

Can the unit be repaired by a builder?

float maxRepairSpeed  default: 1e20 

The maximum cumulative speed at which this unit type can repair a single target.

string iconType  default: "default" 

The name of the radar icon type this unit should use (see Icontypes.lua).

string corpse  default: "" lua: wreckName 

The name of the feature this unit should leave behind as a wreck when it dies (see Gamedev:FeatureDefs).

string explodeAs  default: "" 

The name of the weapon this unit should explode as when it is killed (see Gamedev:WeaponDefs).

string selfDestructAs  default: "" 

The name of the weapon this unit should explode as when it self destructs (see Gamedev:WeaponDefs). Also used as the kamikaze weapon.

Resources

float harvestStorage  default: 0.0 New in version 97.0; ATTENTION: unfinished implementation, can be set in UnitDefs but it can't be read in-game

How much of the metal resource a unit can store when used as an engine-assisted resource 'harvester'. See also Spring.GetUnitHarvestStorage and Spring.SetUnitHarvestStorage callouts.

float metalStorage  default: 0.0 

The amount of the metal resource storage the unit contributes.

float energyStorage  default: 0.0 

The amount of the energy resource storage the unit contributes.

float extractsMetal  default: 0.0 

The amount of the metal resource the unit extracts from the ground. The amount extracted depends on the metal map defined in the map itself. Works only for structures.

float windGenerator  default: 0.0 

The maximum amount of the energy resource the unit generates which is dependant on the map wind. Works only for structures. If wind speed is higher than this, the unit will still only produce this much. If wind speed is less, it will produce as much as windspeed is.

float tidalGenerator  default: 0.0 

The amount of the energy resource the unit generates which is dependant on the maps tidal power. Clearly, this only works on water structures.

float metalUse  default: 0.0 lua: metalUpkeep 

The amount of the metal resource the unit consumes per game 'tick' when activated.

float energyUse  default: 0.0 lua: energyUpkeep 

The amount of the energy resource the unit consumes per game 'tick' when activated.

float metalMake  default: 0.0 

The amount of the metal resource the unit generates unconditionally per game 'tick'.

float energyMake  default: 0.0 

The amount of the energy resource the unit generates unconditionally per game 'tick'.

float makesMetal  default: 0.0 

The amount of the energy resource the unit turns into the metal resource per game 'tick'.

Sensors

bool onOffable  default: false 

Does the unit have an on/off button? Currently the activation status tied to this button also turns sensors (other than LOS) on and off.

bool activateWhenBuilt  default: false 

Should the unit's activation status be on or off when it is created?

float sightDistance  default: 0.0 lua: losRadius 

The radius of the units sight (LOS is circular in Spring).

float airSightDistance  default: 1.5 * sightDistance lua: airLosRadius 

How far away the unit can see aircraft (and some FX).

float losEmitHeight  default: 20.0 lua: losHeight New in version 83.0

How high up the unit is the point used to calculate it's LOS vs. the terrain?

float radarEmitHeight  default: 20.0 lua: radarHeight New in version 83.0

How high up the unit is the point used to calculate it's radar vs. the terrain?

int radarDistance  default: 0 lua: radarRadius 

The radius of the units radar.

int sonarDistance  default: 0 lua: sonarRadius 

The radius of the units sonar.

int radarDistanceJam  default: 0 lua: jammerRadius 

The radius of the units radar jamming.

int sonarDistanceJam  default: 0 lua: sonarJamRadius 

The radius of the units sonar jamming.

bool stealth  default: false 

Is the unit undetectable by radar?

bool sonarStealth  default: false 

Is the unit undetectable by sonar?

int seismicDistance  default: 0 lua: seismicRadius 

The radius of the unit's seismic (movement) sensor.

float seismicSignature  default: 0 for units with floater, canHover or canFly, otherwise sqrt(mass / 100.0) 

How fast the seismic ring expands in elmos per frame. Each ping always lasts 15 frames, so this also determines the maximum radius of the seismic ring.

Cloaking

For units with canCloak = true: float cloakCost  default: 0.0 

The energy cost per tick to cloak the unit while it is stationary.

float cloakCostMoving  default: cloakCost 

The energy cost per tick to cloak the unit while it is moving.

bool initCloaked  default: false lua: startCloaked 

Is the unit cloaked as soon as it is created?

float minCloakDistance  default: 0.0 

The minimum distance (radius) which the unit must be from any enemy units to remain cloaked.

bool decloakSpherical  default: true 

Does minCloakDistance apply in 3D or only 2D? i.e. can aircraft flying above the unit decloak it?

bool decloakOnFire  default: true 

Does the unit decloak when it fires a weapon?

int cloakTimeout  default: 128 

The minimum time, in frames, between a decloak and subsequent re-cloak.

Commands

bool canMove  default: false 

Can the unit be issued Move orders?

bool canAttack  default: true 

Can the unit be issued Attack orders?

bool canFight  default: true 

Can the unit be issued Fight orders?

bool canPatrol  default: true 

Can the unit be issued Patrol orders?

bool canGuard  default: true 

Can the unit be issued Guard orders?

bool canCloak  default: false 

Can the unit be issued Cloak orders?

bool canRepeat  default: true 

Can the unit be issued Repeat orders?

bool canSelfDestruct  default: true lua: canSelfD 

Can the unit be issued a self destruct order?

int moveState  default: -1 for mobile units, 1 for structures 

The initial movement state for the unit. Can be -1 - Inherits from factory, 0 - Hold Position, 1 - Manoeuvre or 2 - Roam.

int fireState  default: -1 for units with noAutoFire = false, 2 otherwise 

The initial firing state for the unit. Can be -1 - Inherits from factory, 0 - Hold Fire, 1 - Return Fire or 2 - Fire At Will. Since 104.0 there is an additional value 3 - Fire At Neutral.

bool noAutoFire  default: false lua: canFireControl 

Controls whether or not the unit has a fire state button.

bool canManualFire  default: false 

description = Can the unit be issued ManualFire commands? A ManualFire command will fire any weapons with the commandfire tag.

Builder Commands

bool canRestore  default: builder && terraformSpeed > 0 

Can the unit be issued restore terrain commands? For builders only.

bool canRepair  default: builder && repairSpeed > 0 

Can the unit be issued repair commands? For builders only.

bool canReclaim  default: builder && reclaimSpeed > 0 

Can the unit be issued reclaim commands? For builders only.

bool canResurrect  default: builder && resurrectSpeed > 0 

Can the unit be issued resurrection commands? For builders only.

bool canCapture  default: builder && captureSpeed > 0 

Can the unit be issued capture commands? For builders only.

Builder

bool builder  default: false lua: isBuilder 

Is the unit a builder?

float buildDistance  default: 128.0 

How far away from itself the unit can build, measured to the centre of the unit being built. The minimum value is 38.0.

bool buildRange3D  default: false 

Does the builders buildDistance apply in all 3 dimensions or only 2?

float workerTime  default: 0.0 lua: buildSpeed 

How fast the builder builds, used in conjunction with the buildTime of the unit being built. Effectively, Time to build = buildTime / workerTime. If this value is <= 0.0 then builder is set to false.

float repairSpeed  default: workerTime 

How fast the builder can repair other units.

float reclaimSpeed  default: workerTime 

How fast the builder can reclaim other units and features.

float resurrectSpeed  default: workerTime 

How fast the builder can resurrect corpse features back into living units.

float captureSpeed  default: workerTime 

How fast the builder can capture other units.

float terraformSpeed  default: workerTime 

How fast the builder levels and restores terrain.

bool canAssist  default: builder 

Can the builder assist other constructions?

bool canBeAssisted  default: true 

Can the builder be assisted by other builders?

bool canSelfRepair  default: false 

Can the builder repair itself?

bool showNanoSpray  default: true 

Does the builder emit OTA-style nanospray whilst constructing?

float[3] nanoColor  default: {0.2, 0.7, 0.2} aka green 

The RGB colour of a builders' emitted nano particles if showNanoSpray = true. Also controls the RBG colour of a unit's own nanoframe if showNanoFrame = true.

bool fullHealthFactory  default: ? 

If true, units are repaired before they are allowed to leave the factory i.e. units from this factory will be healed back to 100% health if they are damaged during construction.

bool isAirbase  default: false Removed in 101.0 in favour of more flexible lua custom commands

Is this unit an airbase? Aircraft may land and repair on units which are airbases.

Movement & Placement

int footprintX  default: 1 

How wide the unit is in footprint units, left to right. 1 footprint unit = 16 elmos. Cannot be below 1. For mobile units this should be the same as the footprintX of its movementClass. Also used for obstacle avoidance.

int footprintZ  default: 1 

How wide the unit is in footprint units, top to bottom. 1 footprint unit = 16 elmos. Cannot be below 1. For mobile units this should be the same as the footprintZ of its movementClass. Also used for obstacle avoidance.

string yardmap  default: "" 

Used to determine a structure from a mobile unit. A string of characters which defines in detail each 'footprint square' of the structure. Each footprint square may be:
y - 'Yard' - Always open, unblocking,
c - 'Construction' - Open and unblocking only while constructing (for factories, controlled via COB.YARD_OPEN see Animation-LuaCallouts#Other),
i - 'Inversed Construction' - Closed and blocking only while constructing (for factories, controlled via COB.YARD_OPEN see Animation-LuaCallouts#Other) (New in version 89.0),
g - 'Geothermal' - Flags that the unit must be placed over a geoThermal feature, does not actually count as a square,
h - 'High Resolution' - Indicates that the yardmap will use double resolution with four times as many characters. Must be the first character, and does not count as a square itself (New in version 93.0),
o - 'Obstacle' - Always closed, blocking, all other chars are treated the same way.
Tip: 'Draw' out the yardmap over multiple lines. As of 89.0 all whitespace characters are ignored, including newlines.

int buildingMask  default: 1 

Bitmask representing the types of ground that this structure can be built on. Each digit of binary that is set to one means that a ground square with the corresponding digit set via Spring.SetSquareBuildingMask can be built on.

bool levelGround  default: false 

For structures. Does the constructor have to level the ground underneath the build area before beginning to build the structure?

string movementClass  default: "" lua: moveDef.name 

The name of the movement type a mobile, non aircraft, unit should use. See Movedefs.lua.

bool canHover  default: false Removed in 95.0

Is the unit a hovercraft? Hovercraft can cross water of any depth without a speed penalty. Hover's must also have HOVER within the name of their movementClass (see Movedefs.lua).

bool floater  default: false if a moveClass is defined, if not true if waterline = true, false otherwise 

When a mobile unit is crossing water, or a structure is placed on water, does it float on top of the water or crawl / lay on the sea bed?

bool upright  default: false 

Does the unit follow the terrain or always remain upright? Generally used for walkers.

float maxSlope  default: 0.0 lua: maxHeightDif 

The maximum slope a building can be placed on. Mobile unit's use the maxSlope set in their movementClass. The value is in degrees and is clamped between 0.0 and 89.0. This value is converted to a "maximum allowed height difference" (call it M), which involves a hard-coded constant. When a building gets placed, the height of each of its footprint squares is compared to a reference height (calculated for the build position). If the difference exceeds M for any square, that build position is rejected. The value readable from lua has been changed from that in the unitdef and reflects the internal engine value.

float minWaterDepth  default: -10e6 

The minimum depth of water a building can be placed on. Mobile unit's use the minWaterDepth set in their movementClass.

float maxWaterDepth  default: 10e6 

The maximum depth of water a building can be placed on. Mobile unit's use the maxWaterDepth set in their movementClass.

float waterline  default: 0.0 

How low in the water does a ship sit? Higher values means the ship is lower in the water.

float minCollisionSpeed  default: 1.0 

The minimum net impact speed that will cause a unit to be damaged by collisions with another unit.

bool pushResistant  default: false 

Can the unit be pushed around by other units? Turning it on doesn't remove all pushing but is a marked improvement.

float maxVelocity  default: 0.0 lua: speed 

The maximum speed attainable by the unit in elmos per frame. If the value is -ve, the absolute value is used.

float maxReverseVelocity  default: 0.0 lua: rSpeed New in version 99.0

The maximum speed attainable by the unit in reverse in elmos per frame. If the value is -ve, the absolute value is used.

float acceleration  default: 0.5 lua: maxAcc 

The acceleration of the unit, in elmos per frame2. If the value is -ve, the absolute value is used.

float brakeRate  default: acceleration lua: maxDec 

The deceleration of the unit, in elmos per frame2. If the value is -ve, the absolute value is used. For units with canFly = true this is multiplied by 0.1. Prior to 95.0 this was scaled by 0.1 for aircraft and the default was 3x acceleration.

float myGravity  default: 0.4 

As Spring aircraft are slower than real aircraft this tag allows to lower gravity to compensate. Multiplies against map gravity for aircraft, replaces map gravity for ground vehicles if non-zero.

float turnRate  default: 0.0 

How fast the unit can turn. degrees per seconds = 0.16 * turnRate.

bool turnInPlace  default: true 

Does the unit turn on the spot (like a person or tank) or must it be moving forwards to turn (like a car).

float turnInPlaceSpeedLimit  default: A complex formula based on turnRate and maxVelocity 

For units with turnInPlace = false, this defines the minimum speed it will slow down to (the speed at which the turn is actually performed can be higher depending on the angular difference and turnRate).

float turnInPlaceAngleLimit  default: 0.0 New in version 86.0

For units with turnInPlace = true, defines the maximum angle (in degrees) of a turn above which it starts to brake.

bool blocking  default: true 

Does the unit block the movement of other units? (Mines, i.e. non-mobile units with the kamikaze tag default to false).

float crushResistance  default: mass New in version 85.0

How resistant is the unit to being crushed? Any MoveClass with a crushStrength greater than this will crush the unit - IFF this has been enabled via Spring.SetUnitBlocking and the collider impulse exceeds that of the colidee.

Flanking

int flankingBonusMode  default: flankingBonus.defaultMode set in Modrules.lua 

The mode of operation of Spring's inbuilt flanking system. Can be 0 - No flanking bonus. Mode 1 builds up the ability to move over time, and swings to face attacks, but does not respect the way the unit is facing. Mode 2 also can swing, but moves with the unit as it turns. Mode 3 stays with the unit as it turns and otherwise doesn't move, the ideal mode to simulate something such as tank armour.

float[3] flankingBonusDir  default: {0.0, 0.0, 1.0} 

This is the direction vector where the armour is facing; i.e. where the least damage is applied. The default is straight forwards.

float flankingBonusMax  default: 1.9 

The maximum multiplier to the damage dealt, when a unit is hit from the opposite direction to flankingBonusDir.

float flankingBonusMin  default: 0.9 

The minimum multiplier to the damage dealt, when a unit is hit from the same direction as flankingBonusDir.

float flankingBonusMobilityAdd  default: 0.01 

This defines the ability of flankingBonusDir to move over time. Its value is added to the mobility every SlowUpdate. When the unit is attacked, the build up mobility value is multiplied by a vector facing the attack, which is added to flankingBonusDir.

Aircraft

bool canFly  default: false 

Can the unit fly, i.e. is it an aircraft?

bool canSubmerge  default: false 

Can the aircraft land underwater?

bool factoryHeadingTakeoff  default: true 

Controls the take-off behaviour of aircraft with hoverAttack = true. true means planes start matching their heading right after taking off from the pad, false means they maintain the heading of the pad until reaching cruiseAlt.

bool collide  default: true 

Does the unit collide with other aircraft, or can it occupy the same space?

bool hoverAttack  default: false 

Controls whether the aircraft flys and attacks like a fighter/bomber or a helicopter/gunship.

bool airStrafe  default: true 

For aircraft with hoverAttack = true, controls if the unit strafes side to side while attacking or remains stationary.

float cruiseAlt  default: 0.0 lua: wantedHeight 

The altitude in elmos which the unit attempts to fly at while cruising.

float airHoverFactor  default: -1.0 lua: dlHoverFactor 

For aircraft with hoverAttack = true, less then 0 means it can land and >= 0 indicates how much the unit will move during hovering on the spot.

bool bankingAllowed  default: true 

For aircraft with hoverAttack = true, controls whether or not the unit banks when moving turning.

bool useSmoothMesh  default: true 

Does the aircraft follow the real map terrain or the special smoothed out navigation mesh generated by Spring specifically for aircraft?} Can become problematic for construction aircrafts, building in canyons.

float maxFuel  default: 0.0 Removed in 101.0 in favour of more flexible lua custom commands

The maximum flight time in seconds before aircraft must return to an airbase to refuel.

float refuelTime  default: 5.0 Removed in 101.0 in favour of more flexible lua custom commands

The time in seconds required to refuel the aircraft at an airbase.

float minAirbasePower  default: 0.0 Removed in 101.0 in favour of more flexible lua custom commands

The minimum workerTime an airbase must have to repair / refuel this aircraft.

bool canLoopbackAttack  default: false 

Can the aircraft perform an Immelmann turn?

Advanced Air Tags

The following set of tags are not well understood and using non-default values can lead to undesired flight behaviours.

float wingDrag  default: 0.07 

The drag caused by the aircraft's wing. Clamped between 0.0 and 1.0.

float wingAngle  default: 0.08 

The angle between the front and the wing plane.

float frontToSpeed  default: 0.1 

How far nose can be unaligned to speed vector before accelleration is applied.

float speedToFront  default: 0.07 

Rate for the nose to align to new (true) direction change. Values above 0.1 may lead to cumulative speedup issues.

float crashDrag  default: 0.005 

The drag used when crashing. Clamped between 0.0 and 1.0.

float maxBank  default: 0.8 

The maximum roll (z-axis rotation) the aircraft can achieve.

float maxPitch  default: 0.45 

The maximum pitch (x-axis rotation) the aircraft tries to keep.

float turnRadius  default: 500.0 

Hint to Spring unit AI about the required turning radius.

float verticalSpeed  default: 3.0 

The speed of takeoff and landing, at least for gunships (hoverAttack = true).

float maxAileron  default: 0.015 

The maximum turn speed around the roll (z) axis.

float maxElevator  default: 0.01 

The maximum turn speed around the pitch (x) axis.

float maxRudder  default: 0.004 

The maximum turn speed around the yaw (y) axis.

float maxAcc  default: 0.065 

The maximum acceleration or 'engine power' of the aircraft.

float attackSafetyDistance  default: 0 Exists only in version 99.0

Fighters abort dive toward target if within attackSafetyDistance and try to climb back to normal altitude while still moving toward target. It's disabled by default. Set to half of the minimum weapon range to avoid collisions, enemy fire, AOE damage. If set to greater than the weapon range, the unit will fly over the target like a bomber. This tag was removed in version 100.0 and changed to a Spring.SetMoveTypeData key.

Flares

The following set of tags are rarely used and are hardcoded to only work vs. missile weapons. The texture is hardcoded to be flareprojectiletexture defined in Resources.lua.

bool canDropFlare  default: false 

Can this aircraft drop flares to distract missile weapons?

float flareReload  default: 5.0 lua: flareReloadTime 

The time in seconds between successive flare drops.

float flareDelay  default: 0.3 

The delay between detecting an incoming missile and launching flares. Multiplied by a random number between 1 and 16.

float flareEfficiency  default: 0.5 

The probability that an incoming missile will target the flare instead of the aircraft.

float[3] flareDropVector  default: {0.0, 0.0, 0.0} 

The direction vector which flares are emitted in.

int flareTime  default: 3 

The lifetime of a dropped flare in frames.

int flareSalvoSize  default: 4 

How many flares are dropped at once?

int flareSalvoDelay  default: 0 

The delay in frames between the release of each individual flare in a burst.

Transports

int transportSize  default: 0 

The size of units that the transport can pick up, in terms of the passengers footprintX.

int minTransportSize  default: 0 

The smallest size of unit that the transport can pick up, in terms of the passengers footprintX.

int transportCapacity  default: 0 

The total number of units that the transport can pick up, with each unit multiplied by it's footprintX size. Prior to 101.0 if this tag is not present, then any Script.AttachUnit and Script.DropUnit call in the animation script will be ignored (See Animation-LuaCallouts#Other), in successive versions all units can use Spring.UnitAttach et al regardless of this tag.

float transportMass  default: 100000.0 

The total cumulative mass of passengers the transport can carry.

float minTransportMass  default: 0.0 

The minimum mass passenger the transport can carry.

float loadingRadius  default: 220.0 

How far away in elmos can the transporter pick up and drop units?

float unloadSpread  default: 5.0 

How spread out the passengers are when unloaded. Is multiplied by the passengers radius.

bool isFirePlatform  default: false 

Can transported units still aim and shoot while loaded by this transport?

bool holdSteady  default: false 

If true - passengers are slaved to orientation of transporter attachment piece, if false - passengers are slaved to orientation of transporter body.

bool releaseHeld  default: false 

Does the transporter unload it's passengers when it dies?

bool cantBeTransported  default: false for mobile units, true for structures 

Controls if a unit is transportable at all or not. If false it is overridden by Modrules.lua transportability subtable tags.

bool transportByEnemy  default: true 

Controls if a unit can be transported by an enemy transport. i.e. can it be kidnapped.

int transportUnloadMethod  default: 0 

For air transports. Can be 0 - Land to unload individually, 1 - Flyover drop (i.e. Parachute), or 2 - Land and flood unload all passengers. Can be used on ground transports with mixed results.

float fallSpeed  default: 0.2 

For air transports with transportUnloadMethod = 1. The speed in elmos per second which units will fall at when released from the transport.

float unitFallSpeed  default: 0.0 

Allows you to override fallSpeed for an individual passenger.

Categories

string category  default: "" 

The category tag is a string of separate words, each representing a category of units. There is a maximum of 32 categories. The primary purpose of categories is weapon targeting (See #weapons). Be aware that if no category is set, by default the unit will not be targetable due to onlyTargetCategory defaulting to a null string also.

string noChaseCategory  default: "" 

The unit will still target enemies with a matching category, but will not chase after it if it moves out of weapon range.

Decals

bool leaveTracks  default: false 

Does the unit leave a track mark decal behind it when it moves? For mobile units.

string trackType  default: "stdTank" 

The filename of the image, without extension, assumed to be in Bitmaps/Tracks/, to be used as the track decal. The red channel of the image controls the brightness and the green channel the alpha (how visible it is) of the track. Blue channel is unused.

float trackWidth  default: 32.0 

The width of the track decal left on the ground, in elmos.

float trackOffset  default: 0.0 

How far back in elmos the track should be drawn from the centre of the unit.

float trackStrength  default: 32.0 

How visible or 'deep' the track mark should be. Also used to determine how long the decal should last.

float trackStretch  default: 1.0 

How much the track is stretched in the forward direction compared to the sides (i.e. used to change aspect ratio).

bool useBuildingGroundDecal  default: false 

For structures, do they display a ground decal on the terrain under their model?

string buildingGroundDecalType  default: "" 

The filename of the image to be used as ground decal. Assumed to be in Unittextures/.

int buildingGroundDecalSizeX  default: 4 

How wide the decal is left to right, in footprint units.

int buildingGroundDecalSizeY  default: 4 

How wide the decal is top to bottom, in footprint units.

float buildingGroundDecalDecaySpeed  default: 0.1 

A measure of how quickly the decal should fade out if the structure dies. Essentially this value is multiplied by the time since death and subtracted from the original alpha until the decal is fully transparent.

Collision Volumes

For a deeper explanation of these tags, see Gamedev:CollisionVolumes. Note that all collision checks first do a pre-check with the unit radius before doing the colvol checks. Ergo the unit radius must be larger or equal to the colvol!


bool usePieceCollisionVolumes  default: false lua: collisionVolume.defaultToPieceTree 

When turned on the model and UnitDef collision volumes are ignored and Spring generates a bounding box volume for each piece of the unit model. These volumes can be manipulated or replaced by Spring.SetUnitPieceCollisionVolumeData. Increases the performance cost of collision calculations.

bool useFootPrintCollisionVolume  default: false lua: .collisionVolume.defaultToFootprint New in version 92.0

Replaces any defined collision volume with a box with dimensions equal to the object's footprint (this also overrides any custom scaling and/or offsets).


The following three tags can instead be replaced with a #collisionVolume subtable:

string collisionVolumeType  default: "s" lua: collisionVolume.type 

What shape should the unit's collision volume be? Can be "box", "sphere or a cylinder aligned to an axis; "cylX", "cylY", "cylZ".

float[3] collisionVolumeScales  default: {0.0, 0.0, 0.0} lua: collisionVolume.scale{X|Y|Z} 

The lengths of the collision volume in each of the three axes. Note that non-spherical ellipsoids and elliptical cylinders are not supported.

float[3] collisionVolumeOffsets  default: {0.0, 0.0, 0.0} lua: collisionVolume.offset{X|Y|Z} 

The offset from the unit centre to the hit volume centre in each axis.


The following tags have now been removed from the engine:

int collisionVolumeTest  default: 0 Removed in 90.0 (Now always continuous)

The type of test used to detect collisions. Can be 0 (discrete) or 1 (continuous). Use the latter for catching high speed projectiles which may otherwise 'skip through' small collision volumes, but beware of the increased performance cost.

float[3] modelCenterOffset  default: {0.0, 0.0, 0.0} Removed in 89.0 (Now set via lua)

How far from the model's defined centre should the centre of the unit be?

Selection Volumes

Introduced in 104.0, units may now have custom selection volumes in exactly the same way as collision volumes were already defined.


bool usePieceSelectionVolumes  default: false lua: .selectionVolume.defaultToPieceTree New in version 104.0

When turned on the model and UnitDef selection volumes are ignored and Spring generates a bounding box volume for each piece of the unit model (the same volumes are used for collision and selection). These volumes can be manipulated or replaced by Spring.SetUnitPieceColisionVolumeData. Increases the performance cost of selection calculations.

bool useFootPrintSelectionVolume  default: false lua: .selectionVolume.defaultToFootprint New in version 104.0

Replaces any defined selection volume with a box with dimensions equal to the object's footprint (this also overrides any custom scaling and/or offsets).


The following three tags can instead be replaced with a #selectionVolume subtable:

string selectionVolumeType  default: "s" lua: collisionVolume.type New in version 104.0

What shape should the unit's selection volume be? Can be "box", "sphere or a cylinder aligned to an axis; "cylX", "cylY", "cylZ".

float[3] selectionVolumeScales  default: {0.0, 0.0, 0.0} lua: .selectionVolume.scale{X|Y|Z} New in version 104.0

The lengths of the selection volume in each of the three axes. Note that non-spherical ellipsoids and elliptical cylinders are not supported.

float[3] selectionVolumeOffsets  default: {0.0, 0.0, 0.0} lua: .selectionVolume.offset{X|Y|Z} New in version 104.0

The offset from the unit centre to the selection volume centre in each axis.

Attack Behaviours

int highTrajectory  default: 0 lua: highTrajectoryType 

Can the unit fire it's (ballistic) weapons in a high trajectory arc? Can be 0 - Low trajectory only, 1 - High trajectory only, or 2 - Toggle button.

bool kamikaze  default: false lua: canKamikaze 

Does the unit attack its target by blowing itself up?

float kamikazeDistance  default: 0.0 lua: kamikazeDist 

How close to the target, in elmos, the unit must get before detonating. Measured in 3D, not 2D.

bool kamikazeUseLOS  default: false 

Does the target unit have to be in LOS when detonating or only within kamikazeDistance.

bool strafeToAttack  default: false 

Should the unit move sideways when it can't shoot?

Other

string decoyFor  default: "" 

The UnitDef name (not human name) which this unit is a decoy for.

int selfDestructCountdown  default: 5 lua: selfDCountdown 

The length in seconds taken between issuing self destruct order and the unit exploding.

float damageModifier  default: 1.0 lua: armoredMultiple 

The multiplier applied to weapon damage when the units ARMORED status (See Lua_ConstCOB) is turned on.

bool isTargetingUpgrade  default: false lua: targFac 

Does the unit upgrade the targeting so that units shoot accurately at enemy units which are in radar but not in LOS.

bool isFeature  default: false 

Does the unit immediately die into it's corpse feature when built? Used mainly for making walls.

bool hideDamage  default: false 

Should the units current health be invisible to enemy players?

bool showPlayerName  default: false 

Should the unit display it's controlling player as its name instead of name. Generally used for commander or hero units.

bool showNanoFrame  default: true 

Does the unit show an OTA-style nanoframe whilst being constructed?

int unitRestricted  default: MAX_UNITS lua: maxThisUnit 

How many of this unit type may a player control at once? Defaults to being the maximum amount of units controllable. Is overridden by lobby unit restrictions.

float power  default: buildCostMetal + (buildCostEnergy / 60.0) 

The relative power of the unit. Used in weapon targeting priority and experience gain calculations.

Sub Tables

collisionVolume

The collisionVolume subtable of a UnitDef replaces the older individual collisionVolumeType, collisionVolumeScales and collisionVolumeOffsets tags.

string type  default: "s" lua: .collisionVolume.type 

What shape should the unit's collision volume be? Can be "box", "sphere" or a "cylinder".

string axis  default: "z" 

Which axis does the unit's collision volume lie along? Can be "x", "y" or "z".

float[3] scales  default: {0.0, 0.0, 0.0} lua: .collisionVolume.scale{X|Y|Z} 

The lengths of the collision volume in each of the three axes. Note that non-spherical ellipsoids and elliptical cylinders are not supported.

float[3] offsets  default: {0.0, 0.0, 0.0} lua: .collisionVolume.offset{X|Y|Z} 

The offset from the unit centre to the hit volume centre in each axis.

selectionVolume

The selectionVolume subtable of a UnitDef can replace the individual selectionVolumeType, selectionVolumeScales and selectionVolumeOffsets tags.

string type  default: "s" lua: .selectionVolume.type 

What shape should the unit's selection volume be? Can be "box", "sphere" or a "cylinder".

string axis  default: "z" 

Which axis does the unit's selection volume lie along? Can be "x", "y" or "z".

float[3] scales  default: {0.0, 0.0, 0.0} lua: .selectionVolume.scale{X|Y|Z} 

The lengths of the selection volume in each of the three axes. Note that non-spherical ellipsoids and elliptical cylinders are not supported.

float[3] offsets  default: {0.0, 0.0, 0.0} lua: .selectionVolume.offset{X|Y|Z} 

The offset from the unit centre to the selection volume centre in each axis.

weapons

The weapons subtable of a UnitDef tells Spring which weapons the unit has. It is a simple array (number indexed table) of weaponNames (not the human readable name!).

The following additional tags are associated with this subtable:

string name  default: "" 

The weaponName of the weapon (See Gamedev:WeaponDefs). If using the weapondefs_post.lua provided by springcontent.sdz, you may include the WeaponDef tables within the UnitDef as the weaponDefs subtable, and refer to them with def rather than name. This can be a useful way to organise definitions if units do not generally share weapons.

string badTargetCategory  default: "" 

A string of unit category entries which this weapon prefers to avoid targeting. i.e. given two units which can be targeted, any unit whose category matches any entry in this tag, will be targeted last. (See #Categories)

string onlyTargetCategory  default: "" 

A string of unit category entries which this weapon can target. i.e. any unit whose category does not match any entry in this tag, cannot be targeted by this weapon. (See #Categories)

int slaveTo  default: 0 

The number of the weapon which this weapon is slaved to. A slaved weapon can only target what it's master is targeting. Weapon numbers start at 1 and correspond to the index of the weapon within the subtable.

float[3] mainDir  default: {0.0, 0.0, 1.0} i.e. forwards 

A vector representing the firing direction of this weapon if it has a limited firing arc. Used in conjunction with maxAngleDif (See Gamedev:WeaponMainDir).

float maxAngleDif  default: 360.0 

How wide this weapons limited firing arc is in degrees. Symmetrical about mainDir i.e. 180.0 is 90 degree freedom either way (See Gamedev:WeaponMainDir).

float fuelUsage  default: 0.0 

How much fuel in seconds is deducted from the units initial maxFuel when this weapon fires.

buildOptions

The buildOptions subtable of a UnitDef tells Spring which other units the unit can build (in the case of a builder) or produce (in the case of a factory). It is a simple array (number indexed table) of unitNames (not the human readable name!).

There are no additional tags specific to this subtable.

SFXTypes

The SFXTypes subtable of a UnitDef tells Spring which CEG effects are associated with the unit. It consists of two further subtables, with no additional tags specific to them.

explosionGenerators

The explosionGenerators subtable of SFXTypes tells Spring which CEGs the unit's script can call, via the EmitSFX() callout (See Animation-LuaCallouts#Effects). It is a simple array (number indexed table) of CEG names, prefaced by the string "custom:".

pieceExplosionGenerators

New in version 83.0

The pieceExplosionGenerators subtable of SFXTypes tells Spring which CEGs the unit's script can pick at random to attach to a flying unit piece, created from the Explode() callout (See Animation-LuaCallouts#Effects). It is a simple array (number indexed table) of CEG names, with no prefix.

Forum thread (with examples): pieceExplosionGenerators

sounds

The sounds subtable of a UnitDef tells Spring which sound files to play when the unit triggers various events.

Files are assumed to be in the Sounds/ directory; accepted formats are .wav and .ogg, the former being assumed if no extension is given.

Sounds can be defined in one of three ways:

  1. Each event can be used as though it were a string tag referring to the filename.
  2. Each event can be the name of a subtable, which is a simple array containing the filenames. One sound is picked at random from the list each time the event occurs.
  3. Each event can be the name of a subtable, which is a simple array containing further tables, which contain the following tags:

string file  default: "" 

The filename of the sound to play.

float volume  default: 1.0 

The default volume of the sound.

Spring checks any referenced sound filename to see if a SoundItem has been created, which allows greater control over how it is played (See Sounds.lua).

sounds Example

For clarification, here is an example of all three methods:

sounds = {
  -- Method 1
  ok = 'oksound', -- .wav appended
  -- Method 2
  arrived = {
    'arrived1.wav',
    'arrived2.wav',
  },
  -- Method 3
  select = {
    { file = 'selsound1.ogg', volume = 2.0 },
    { file = 'selsound2.ogg', volume = 2.5 },
  },
}

sounds Events

The events called by the engine are as follows:

  • ok
Unit is issued a command.
  • select
Unit is selected by the player.
  • arrived
Unit has arrived at its destination. Mobile ground units only.
  • build
Unit begins building. Called for both factories and mobile construction units.
  • activate
Unit is activated, i.e. Is turned on. Also called when a mobile ground unit starts moving.
  • deactivate
Unit deactivates, i.e. Is turned off.
  • cant
Unit cannot carry out this order. Loaded but not currently called by the engine.
  • underattack
Unit gets attacked. Loaded but not currently called by the engine.

customParams

The customParams subtable of a UnitDef allows the game designer to give their units custom attributes, which can then be accessed via lua gadgets and widgets. It is a map (key-value pair indexed table) of strings. When accessing these attributes in lua the strings can be turned back into numbers, bools or even tables. This gives great control to game designers to essentially implement their own behaviour tags.

There are no additional tags specific to this subtable

Examples

MC:L implements OO with inheritance (base classes in unitdefs_pre.lua)


'Balanced Annihilation' UnitDefs

'Conflict Terra' UnitDefs

'Evolution RTS' UnitDefs

'Imperial Winter' UnitDefs

'Journeywar' UnitDefs

'MechCommander: Legacy' UnitDefs

'Spring: 1944' UnitDefs

'Spring Tutorial Game' UnitDefs

'XTA' UnitDefs

'ZeroK' UnitDefs