Gamedev:UnitDefs: Difference between revisions
m →General: match wording of other tags |
m →General: cross reference |
||
| Line 1: | Line 1: | ||
<h2>Location</h2> | |||
UnitDef files are .lua files stored in the <code>Units/</code> directory of a Spring Game. | <p>UnitDef files are .lua files stored in the <code>Units/</code> directory of a Spring Game. | ||
</p> | |||
<h2>Purpose</h2> | |||
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. | <p>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. | ||
</p> | |||
<h2>Source</h2> | |||
The engine source code which loads the tags from these files is viewable here:{{sourcelink|file=rts/Sim/Units/UnitDef.cpp}} | <p>The engine source code which loads the tags from these files is viewable here:<span class="fck_mw_template">{{sourcelink|file=rts/Sim/Units/UnitDef.cpp}}</span> | ||
</p><p><br /> | |||
The engine source which reads the <a _fcknotitle="true" href="#sounds">#sounds</a> subtable can be found here:<span class="fck_mw_template">{{sourcelink|file=rts/Sim/Units/UnitDefHandler.cpp}}</span> | |||
The engine source which reads the | </p> | ||
<h2>Data Types</h2> | |||
<p>Tags may be one of the following data types: | |||
Tags may be one of the following data types: | </p> | ||
<ul><li> <code>int</code> - An integer number | |||
</li><li> <code>float</code> - A number with decimals. | |||
</li><li> <code>bool</code> - A value which can be <code>true</code> or <code>false</code>. | |||
</li><li> <code>string</code> - Text, or more precisely a string of alphanumeric characters. | |||
</li><li> <code>float[3]</code> - A vector, with three <code>float</code> components, representing x, y and z axes (y is 'up'). | |||
</li></ul> | |||
<h2>Details</h2> | |||
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. | <p>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. | ||
</p><p>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 <code>lowerkeys</code> function on your final table to ensure the keys are properly cased. | |||
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 <code>lowerkeys</code> function on your final table to ensure the keys are properly cased. | </p><p>It is usual to name the returned UnitDef table the internal <code>unitName</code> desired for the unit. | ||
</p> | |||
It is usual to name the returned UnitDef table the internal <code>unitName</code> desired for the unit. | <h3>General</h3> | ||
<p><span class="fck_mw_template">{{tagfckLR|name = namefckLR|type = stringfckLR|default = ""fckLR|description = This is simply the name of the unit as it appears to the player.}}</span> | |||
</p><p><span class="fck_mw_template">{{tagfckLR|name = descriptionfckLR|type = stringfckLR|default = namefckLR|description = This is the tooltip description of the unit seen by the player. It defaults to the <code>name</code> of the unit.}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = buildPicfckLR|type = stringfckLR|default = ""fckLR|description = The filename of the image to be used as the build picture, assumes <code>Unitpics/</code> directory.}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = objectNamefckLR|type = stringfckLR|default = ""fckLR|description = The filename of the 3D model file for this unit, assumes <code>Objects3D/</code> directory.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = scriptfckLR|type = stringfckLR|default = unitName + ".cob"fckLR|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.}}</span> | |||
|default = | </p><p><span class="fck_mw_template">{{tagfckLR|name = maxDamagefckLR|type = floatfckLR|default = 0.0fckLR|description = The base 'hitpoints' the unit will have.}}</span> | ||
|description = This is simply the name of the unit as it appears to the player.}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = autoHealfckLR|type = floatfckLR|default = 0.0fckLR|description = How much health the unit will regain every second.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = idleAutoHealfckLR|type = floatfckLR|default = 10.0fckLR|description = How much health the unit will regain every second whilst it is idle.}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = idleTimefckLR|type = intfckLR|default = 600fckLR|description = The time in [[frames]] taken until a unit is considered to be idle.}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = buildCostMetalfckLR|type = floatfckLR|default = 1.0fckLR|description = The amount of metal resource the unit costs to build. Cannot be below <code>1.0</code>.}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = buildCostEnergyfckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of energy resource the unit costs to build.}}</span> | ||
|default = | </p><p><span class="fck_mw_template">{{tagfckLR|name = buildTimefckLR|type = floatfckLR|default = 0.0fckLR|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>.}}</span> | ||
|description = This is the tooltip description of the unit seen by the player. It defaults to the | </p><p><span class="fck_mw_template">{{tagfckLR|name = massfckLR|type = floatfckLR|default = buildCostMetalfckLR|description = The mass of the unit, used in weapon impulse calculations. Cannot be less than <code>1.0</code>.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = reclaimablefckLR|type = boolfckLR|default = truefckLR|description = Can the unit be reclaimed by a builder?}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = capturablefckLR|type = boolfckLR|default = truefckLR|description = Can a unit be stolen by a builder using the capture command?}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = repairablefckLR|type = boolfckLR|default = truefckLR|description = Can the unit be repaired by a builder?}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = maxRepairSpeedfckLR|type = floatfckLR|default = 1e20fckLR|description = The maximum cumulative speed at which this unit can be repaired.}}</span> | ||
|default = | </p><p><span class="fck_mw_template">{{tagfckLR|name = iconTypefckLR|type = stringfckLR|default = "default"fckLR|description = The name of the radar icon type this unit should use. See [[Icontypes.lua]].}}</span> | ||
|description = The filename of the image to be used as the build picture, assumes | </p><p><span class="fck_mw_template">{{tagfckLR|name = corpsefckLR|type = stringfckLR|default = ""fckLR|description = The name of the feature this unit should leave behind as a wreck when it dies (See [[Units-FeatureDefs]]).}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = explodeAsfckLR|type = stringfckLR|default = ""fckLR|description = The name of the weapon this unit should explode as when it is killed (See [[Units-WeaponDefs]]).}}</span> | |||
</p><p><span class="fck_mw_template">{{tagfckLR|name = selfDestructAsfckLR|type = stringfckLR|default = ""fckLR|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.}}</span> | |||
|name = | </p> | ||
|type = | <h3>Resources</h3> | ||
|default = | <p><span class="fck_mw_template">{{tagfckLR|name = metalStoragefckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the metal resource storage the unit contributes.}}</span> | ||
|description = The filename of the 3D model file for this unit, assumes | </p><p><span class="fck_mw_template">{{tagfckLR|name = energyStoragefckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the energy resource storage the unit contributes.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = extractsMetalfckLR|type = floatfckLR|default = 0.0fckLR|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.}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = extractSquarefckLR|type = boolfckLR|default = falsefckLR|description = Is the metal extractors extraction area circular or square?}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = windGeneratorfckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the energy resource the unit generates which is dependant on the map wind. Works only for structures.}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = tidalGeneratorfckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the energy resource the unit generates which is dependant on the maps tidal power. Clearly, this only works on water structures.}}</span> | ||
|default = unitName + | </p><p><span class="fck_mw_template">{{tagfckLR|name = metalUsefckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the metal resource the unit consumes per game 'tick'.}}</span> | ||
|description = The filename of the animation script file for this unit, assumes | </p><p><span class="fck_mw_template">{{tagfckLR|name = energyUsefckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the energy resource the unit consumes per game 'tick'.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = metalMakefckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the metal resource the unit generates unconditionally per game 'tick'.}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = energyMakefckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the energy resource the unit generates unconditionally per game 'tick'.}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = makesMetalfckLR|type = floatfckLR|default = 0.0fckLR|description = The amount of the energy resource the unit turns into the metal resource per game 'tick'.}}</span> | ||
|type = | </p> | ||
|default = 0. | <h3>Sensors</h3> | ||
|description = The base 'hitpoints' the unit will have.}} | <p><span class="fck_mw_template">{{tagfckLR|name = onoffablefckLR|type = boolfckLR|default = falsefckLR|description = 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.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = activateWhenBuiltfckLR|type = boolfckLR|default = falsefckLR|description = Should the unit's activation status be on or off when it is created?}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = sightDistancefckLR|type = floatfckLR|default = 0.0fckLR|description = The radius of the units sight (LOS is circular in Spring)}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = airSightDistancefckLR|type = floatfckLR|default = 1.5 * sightDistancefckLR|description = How far away the unit can see aircraft (and some FX).}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = losEmitHeightfckLR|type = floatfckLR|default = 20.0fckLR|special={{new|83.0}}fckLR|description = How high up the unit is the point used to calculate it's LOS vs. the terrain?}}</span> | ||
|default = 0. | </p><p><span class="fck_mw_template">{{tagfckLR|name = radarEmitHeightfckLR|type = floatfckLR|default = 20.0fckLR|special={{new|83.0}}fckLR|description = How high up the unit is the point used to calculate it's radar vs. the terrain?}}</span> | ||
|description = How much health the unit will regain every second.}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = radarDistancefckLR|type = intfckLR|default = 0fckLR|description = The radius of the units radar.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = sonarDistancefckLR|type = intfckLR|default = 0fckLR|description = The radius of the units sonar.}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = radarDistanceJamfckLR|type = intfckLR|default = 0fckLR|description = The radius of the units radar jamming.}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = sonarDistancefckLR|type = intfckLR|default = 0fckLR|description = The radius of the units sonar jamming.}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = stealthfckLR|type = boolfckLR|default = falsefckLR|description = Is the unit undetectable by radar?}}</span> | ||
|default = 10. | </p><p><span class="fck_mw_template">{{tagfckLR|name = sonarStealthfckLR|type = boolfckLR|default = falsefckLR|description = Is the unit undetectable by sonar?}}</span> | ||
|description = How much health the unit will regain every second whilst it is idle.}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = seismicDistancefckLR|type = intfckLR|default = 0fckLR|description = The radius of the unit's seismic (movement) sensor.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = seismicSignaturefckLR|type = floatfckLR|default = 0 for units with <code>floater</code>, <code>canHover</code> or <code>canFly</code>, otherwise sqrt(mass / 100.0)fckLR|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.}}</span> | |||
{{ | </p> | ||
|name = | <h4>Cloaking</h4> | ||
|type = | <p>For units with <a href="Units-UnitDefs#Commands">canCloak</a> set to <code>true</code>: | ||
|default = | <span class="fck_mw_template">{{tagfckLR|name = cloakCostfckLR|type = floatfckLR|default = 0.0fckLR|description = The energy cost per tick to cloak the unit while it is stationary.}}</span> | ||
|description = The time in [[frames]] taken until a unit is considered to be idle.}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = cloakCostMovingfckLR|type = floatfckLR|default = cloakCostfckLR|description = The energy cost per tick to cloak the unit while it is moving.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = initCloakedfckLR|type = boolfckLR|default = falsefckLR|description = Is the unit cloaked as soon as it is created?}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = minCloakDistancefckLR|type = floatfckLR|default = 0.0fckLR|description = The minimum distance (radius) which the unit must be from any enemy units to remain cloaked.}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = decloakSphericalfckLR|type = boolfckLR|default = truefckLR|description = Does <code>minCloakDistance</code> apply in 3D or only 2D? i.e. can aircraft flying above the unit decloak it?}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = decloakOnFirefckLR|type = boolfckLR|default = truefckLR|description = Does the unit deloak when it fires a weapon?}}</span> | ||
|default = 1. | </p><p><span class="fck_mw_template">{{tagfckLR|name = cloakTimeoutfckLR|type = intfckLR|default = 128fckLR|description = The minimum time, in [[frames]], between a decloak and subsequent re-cloak.}}</span> | ||
|description = The amount of metal resource the unit costs to build. Cannot be below | </p> | ||
<h3>Commands</h3> | |||
{{ | <p><span class="fck_mw_template">{{tagfckLR|name = canMovefckLR|type = boolfckLR|default = falsefckLR|description = Can the unit be issued Move orders?}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = canAttackfckLR|type = boolfckLR|default = truefckLR|description = Can the unit be issued Attack orders?}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = canFightfckLR|type = boolfckLR|default = truefckLR|description = Can the unit be issued Fight orders?}}</span> | ||
|default = 0. | </p><p><span class="fck_mw_template">{{tagfckLR|name = canPatrolfckLR|type = boolfckLR|default = truefckLR|description = Can the unit be issued Patrol orders?}}</span> | ||
|description = The amount of energy resource the unit costs to build.}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = canGuardfckLR|type = boolfckLR|default = truefckLR|description = Can the unit be issued Guard orders?}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR| name = canCloakfckLR| type = boolfckLR| default = falsefckLR| description =fckLRCan the unit be issued Cloak orders?}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = canRepeatfckLR|type = boolfckLR|default = truefckLR|description = Can the unit be issued Repeat orders?}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = canSelfDestructfckLR|type = boolfckLR|default = truefckLR|description = Can the unit be issued a self destruct order?}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = moveStatefckLR|type = intfckLR|default = -1 for mobile units, <code>1</code> for structuresfckLR|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.}}</span> | ||
|default = 0. | </p><p><span class="fck_mw_template">{{tagfckLR|name = fireStatefckLR|type = intfckLR|default = -1 for units without <code>noAutoFire</code>, <code>2</code> otherwisefckLR|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.}}</span> | ||
|description = The time taken to build the unit, in conjunction with the | </p><p><span class="fck_mw_template">{{tagfckLR|name = noAutoFirefckLR|type = boolfckLR|default = falsefckLR|description = Controls whether or not the unit has a fire state button.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = canManualFirefckLR|type = boolfckLR|default = falsefckLR|description = Can the unit be issued ManualFire commands? A ManualFire command will fire any weapons with the <code>commandfire</code> tag (See [[Units-WeaponDefs]]).}}</span> | |||
{{ | </p> | ||
|name = | <h4>Builder Commands</h4> | ||
|type = | <p><span class="fck_mw_template">{{tagfckLR|name = canRestorefckLR|type = boolfckLR|default = builderfckLR|description = Can the unit be issued restore terrain commands? For builders only.}}</span> | ||
|default = | </p><p><span class="fck_mw_template">{{tagfckLR|name = canRepairfckLR|type = boolfckLR|default = builderfckLR|description = Can the unit be issued repair commands? For builders only.}}</span> | ||
|description = The mass of the unit, used in weapon impulse calculations. Cannot be less than | </p><p><span class="fck_mw_template">{{tagfckLR|name = canReclaimfckLR|type = boolfckLR|default = builderfckLR|description = Can the unit be issued reclaim commands? For builders only.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = canResurrectfckLR|type = boolfckLR|default = falsefckLR|description = Can the unit be issued resurrection commands? For builders only.}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = canCapturefckLR|type = boolfckLR|default = falsefckLR|description = Can the unit be issued capture commands? For builders only.}}</span> | ||
|name = | </p> | ||
|type = | <h3>Builder</h3> | ||
|default = | <p><span class="fck_mw_template">{{tagfckLR|name = builderfckLR|type = boolfckLR|default = falsefckLR|description = Is the unit a builder?}}</span> | ||
|description = Can the unit be reclaimed by a builder?}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = buildDistancefckLR|type = floatfckLR|default = 128.0fckLR|description = How far away from itself the unit can build, measured to the centre of the unit being built. The minimum value is <code>38.0</code>.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = buildRange3DfckLR|type = boolfckLR|default = falsefckLR|description = Does the builders <code>buildDistance</code> apply in all 3 dimensions or only 2?}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = workerTimefckLR|type = floatfckLR|default = 0.0fckLR|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.}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = repairSpeedfckLR|type = floatfckLR|default = workerTimefckLR|description = How fast the builder can repair other units.}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = reclaimSpeedfckLR|type = floatfckLR|default = workerTimefckLR|description = How fast the builder can reclaim other units and features.}}</span> | ||
|default = | </p><p><span class="fck_mw_template">{{tagfckLR|name = resurrectSpeedfckLR|type = floatfckLR|default = workerTimefckLR|description = How fast the builder can resurrect corpse features back into living units.}}</span> | ||
|description = Can a unit be stolen by a builder using the capture command?}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = captureSpeedfckLR|type = floatfckLR|default = workerTimefckLR|description = How fast the builder can capture other units.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = terraformSpeedfckLR|type = floatfckLR|default = workerTimefckLR|description = How fast the builder levels and restores terrain.}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = canAssistfckLR|type = boolfckLR|default = builderfckLR|description = Can the builder assist other constructions?}}</span> | ||
|name = | </p><p><span class="fck_mw_template">{{tagfckLR|name = canBeAssistedfckLR|type = boolfckLR|default = truefckLR|description = Can the builder be assisted by other builders?}}</span> | ||
|type = | </p><p><span class="fck_mw_template">{{tagfckLR|name = canSelfRepairfckLR|type = boolfckLR|default = falsefckLR|description = Can the builder repair itself?}}</span> | ||
|default = | </p><p><span class="fck_mw_template">{{tagfckLR|name = showNanoSprayfckLR|type = boolfckLR|default = truefckLR|description = Does the builder emit OTA-style nanospray whilst constructing?}}</span> | ||
|description = Can the unit be repaired by a builder?}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = nanoColorfckLR|type = float[3]fckLR|default = {0.2, 0.7, 0.2} aka greenfckLR|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>.}}</span> | ||
</p><p><span class="fck_mw_template">{{tagfckLR|name = fullHealthFactoryfckLR|type = boolfckLR|default = falsefckLR|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.}}</span> | |||
{{ | </p><p><span class="fck_mw_template">{{tagfckLR|name = isAirbasefckLR|type = boolfckLR|default = falsefckLR|description = Is this unit an airbase? Aircraft may land and repair on units which are airbases.}}</span> | ||
|name = | </p> | ||
|type = | <h3>Movement & Placement</h3> | ||
|default = | <p><span class="fck_mw_template">{{tagfckLR|name = footprintXfckLR|type = intfckLR|default = 1fckLR|description = fckLRHow 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.}}</span> | ||
|description = The maximum cumulative speed at which this unit can be repaired.}} | </p><p><span class="fck_mw_template">{{tagfckLR|name = footprintZfckLR|type = intfckLR|default = 1fckLR|description = fckLRHow 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.}}</span> | ||
</p><p>{{tag | |||
|name = | |||
|type = | |||
|default = | |||
|description = The name of the radar icon type this unit should use. See [[Icontypes.lua]].}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = The name of the feature this unit should leave behind as a wreck when it dies (See [[Units-FeatureDefs]]).}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = The name of the weapon this unit should explode as when it is killed (See [[Units-WeaponDefs]]).}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = The name of the weapon this unit should explode as when it self destructs (See [[Units-WeaponDefs]]). Also used as the | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the metal resource storage the unit contributes.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the energy resource storage the unit contributes.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 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.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Is the metal extractors extraction area circular or square?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the energy resource the unit generates which is dependant on the map wind. Works only for structures.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the energy resource the unit generates which is dependant on the maps tidal power. Clearly, this only works on water structures.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the metal resource the unit consumes per game 'tick'.}} | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the energy resource the unit consumes per game 'tick'.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the metal resource the unit generates unconditionally per game 'tick'.}} | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the energy resource the unit generates unconditionally per game 'tick'.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The amount of the energy resource the unit turns into the metal resource per game 'tick'.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = 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.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Should the unit's activation status be on or off when it is created?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The radius of the units sight (LOS is circular in Spring)}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 1.5 * | |||
|description = How far away the unit can see aircraft (and some FX).}} | |||
|name = | |||
|type = | |||
|default = 20. | |||
|special={{new|83.0}} | |||
|description = How high up the unit is the point used to calculate it's LOS vs. the terrain?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 20. | |||
|special={{new|83.0}} | |||
|description = How high up the unit is the point used to calculate it's radar vs. the terrain?}} | |||
|name = | |||
|type = | |||
|default = | |||
|description = The radius of the units radar.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = The radius of the units sonar.}} | |||
|name = | |||
|type = | |||
|default = | |||
|description = The radius of the units radar jamming.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = The radius of the units sonar jamming.}} | |||
|name = | |||
|type = | |||
|default = | |||
|description = Is the unit undetectable by radar?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Is the unit undetectable by sonar?}} | |||
|name = | |||
|type = | |||
|default = | |||
|description = The radius of the unit's seismic (movement) sensor.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0 for units with | |||
|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.}} | |||
For units with | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = The energy cost per tick to cloak the unit while it is stationary.}} | |||
{{ | |||
|name = | |||
|type = | |||
|description = The energy cost per tick to cloak the unit while it is moving.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Is the unit cloaked as soon as it is created?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Does | |||
|name = | |||
|type = | |||
|default = | |||
|description = Does the unit deloak when it fires a weapon?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = The minimum time, in [[frames]], between a decloak and subsequent re-cloak.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued Move orders?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued Attack orders?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued Fight orders?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued Patrol orders?}} | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued Guard orders?}} | |||
{{ | |||
| name = | |||
| type = | |||
| default = | |||
| description = | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued Repeat orders?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued a self destruct order?}} | |||
|name = | |||
|type = | |||
|default = -1 for mobile units, | |||
|description = The initial movement state for the unit. Can be | |||
{{ | |||
|name = | |||
|type = | |||
|default = -1 for units without | |||
|description = The initial firing state for the unit. Can be | |||
{{ | |||
|type = | |||
|default = | |||
|description = Controls whether or not the unit has a fire state button.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued ManualFire commands? A ManualFire command will fire any weapons with the | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued restore terrain commands? For builders only.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued repair commands? For builders only.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued reclaim commands? For builders only.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued resurrection commands? For builders only.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the unit be issued capture commands? For builders only.}} | |||
{{ | |||
|type = | |||
|default = | |||
|description = Is the unit a builder?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 128. | |||
|description = How far away from itself the unit can build, measured to the centre of the unit being built. The minimum value is | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Does the builders | |||
{{ | |||
|name = | |||
|type = | |||
|default = 0. | |||
|description = How fast the builder builds, used in conjunction with the | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = How fast the builder can repair other units.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = How fast the builder can reclaim other units and features.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = How fast the builder can resurrect corpse features back into living units.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = How fast the builder can capture other units.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = How fast the builder levels and restores terrain.}} | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the builder assist other constructions?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the builder be assisted by other builders?}} | |||
|name = | |||
|type = | |||
|default = | |||
|description = Can the builder repair itself?}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Does the builder emit OTA-style nanospray whilst constructing?}} | |||
|name = | |||
|type = float[3] | |||
|default = {0.2, 0.7, 0.2} aka | |||
|description = The RGB colour of a builders' emitted nano particles if | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = If | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = Is this unit an airbase? Aircraft may land and repair on units which are airbases.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = | |||
{{ | |||
|name = | |||
|type = | |||
|default = | |||
|description = | |||
{{tag | |||
|name = yardmap | |name = yardmap | ||
|type = string | |type = string | ||
| Line 574: | Line 134: | ||
|description = | |description = | ||
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: | 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: | ||
</p> | |||
<dl><dd><dl><dd> <code>y</code> - 'Yard' - Always open, unblocking, | |||
</dd><dd> <code>c</code> - 'Construction' - Open and unblocking only while constructing (for factories, controlled via <code>COB.YARD_OPEN</code> see <a _fcknotitle="true" href="Animation-LuaCallouts#Other">Animation-LuaCallouts#Other</a>), | |||
</dd><dd> <code>i</code> - 'Inversed Construction' - Closed and blocking only while constructing (for factories, controlled via <code>COB.YARD_OPEN</code> see <a _fcknotitle="true" href= | |||
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 <code>name</code>!). | ||
</p><p>There are no additional tags specific to this subtable. | |||
There are no additional tags specific to this subtable. | </p> | ||
<h3>SFXTypes</h3> | |||
<p>The <code>SFXTypes</code> subtable of a UnitDef tells Spring which <a _fcknotitle="true" href="CEG">CEG</a> effects are associated with the unit. It consists of two further subtables, with no additional tags specific to them. | |||
The <code>SFXTypes</code> subtable of a UnitDef tells Spring which | </p> | ||
<h4>explosionGenerators</h4> | |||
<p>The <code>explosionGenerators</code> subtable of <code>SFXTypes</code> tells Spring which <a _fcknotitle="true" href="CEG">CEG</a>s the unit's script can call, via the <code>EmitSFX()</code> callout (See <a _fcknotitle="true" href="Animation-LuaCallouts#Effects">Animation-LuaCallouts#Effects</a>). It is a simple array (number indexed table) of CEG names, prefaced by the string <code>"custom:"</code>. | |||
</p> | |||
The <code>explosionGenerators</code> subtable of <code>SFXTypes</code> tells Spring which | <h4>pieceExplosionGenerators</h4> | ||
<p><span class="fck_mw_template">{{new|83.0}}</span> | |||
</p><p>The <code>pieceExplosionGenerators</code> subtable of <code>SFXTypes</code> tells Spring which <a _fcknotitle="true" href="CEG">CEG</a>s the unit's script can pick at random to attach to a flying unit piece, created from the <code>Explode()</code> callout (See <a _fcknotitle="true" href="Animation-LuaCallouts#Effects">Animation-LuaCallouts#Effects</a>). It is a simple array (number indexed table) of CEG names, with no prefix. | |||
{{new|83.0}} | </p><p>Forum thread (with examples): <span class="fck_mw_template">{{forumlink|topic=27554|title=pieceExplosionGenerators}}</span> | ||
</p> | |||
The <code>pieceExplosionGenerators</code> subtable of <code>SFXTypes</code> tells Spring which | <h3>sounds</h3> | ||
<p>The <code>sounds</code> subtable of a UnitDef tells Spring which sound files to play when the unit triggers various events. | |||
Forum thread (with examples): {{forumlink|topic=27554|title=pieceExplosionGenerators}} | </p><p>Files are assumed to be in the <code>Sounds/</code> directory; accepted formats are .wav and .ogg, the former being assumed if no extension is given. | ||
</p><p>Sounds can be defined in one of three ways: | |||
</p> | |||
<ol><li> Each event can be used as though it were a <code>string</code> tag referring to the filename. | |||
The <code>sounds</code> subtable of a UnitDef tells Spring which sound files to play when the unit triggers various events. | </li><li> 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. | ||
</li><li> Each event can be the name of a subtable, which is a simple array containing further tables, which contain the following tags: | |||
Files are assumed to be in the <code>Sounds/</code> directory; accepted formats are .wav and .ogg, the former being assumed if no extension is given. | </li></ol> | ||
<p><span class="fck_mw_template">{{tagfckLR|name = filefckLR|type = stringfckLR|default = ""fckLR|description = The filename of the sound to play.}}</span> | |||
Sounds can be defined in one of three ways: | </p><p><span class="fck_mw_template">{{tagfckLR|name = volumefckLR|type = floatfckLR|default = 1.0fckLR|description = The default volume of the sound.}}</span> | ||
</p><p>Spring checks any referenced sound filename to see if a SoundItem has been created, which allows greater control over how it is played (See <a _fcknotitle="true" href="Sounds.lua">Sounds.lua</a>). | |||
</p> | |||
<h4>sounds Example</h4> | |||
<p>For clarification, here is an example of all three methods: | |||
{{ | </p> | ||
|name = | |||
|type = | |||
|default = | |||
|description = The filename of the sound to play.}} | |||
{{ | |||
|name = | |||
|type = | |||
|default = 1. | |||
|description = 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 | |||
For clarification, here is an example of all three methods: | |||
<code><pre>sounds = { | <code><pre>sounds = { | ||
-- Method 1 | -- Method 1 | ||
| Line 1,378: | Line 339: | ||
}, | }, | ||
}</pre></code> | }</pre></code> | ||
<h4>sounds Events</h4> | |||
<p>The events called by the engine are as follows: | |||
</p> | |||
The events called by the engine are as follows: | <ul><li> <b><code>ok</code></b> | ||
</li></ul> | |||
<dl><dd> Unit is issued a command. | |||
</dd></dl> | |||
<ul><li> <b><code>select</code></b> | |||
</li></ul> | |||
<dl><dd> Unit is selected by the player. | |||
</dd></dl> | |||
<ul><li> <b><code>arrived</code></b> | |||
</li></ul> | |||
<dl><dd> Unit has arrived at its destination. Mobile ground units only. | |||
</dd></dl> | |||
<ul><li> <b><code>build</code></b> | |||
</li></ul> | |||
<dl><dd> Unit begins building. Called for both factories and mobile construction units. | |||
</dd></dl> | |||
<ul><li> <b><code>activate</code></b> | |||
</li></ul> | |||
<dl><dd> Unit is activated, i.e. Is turned on. Also called when a mobile ground unit starts moving. | |||
</dd></dl> | |||
<ul><li> <b><code>deactivate</code></b> | |||
</li></ul> | |||
<dl><dd> Unit deactivates, i.e. Is turned off. | |||
</dd></dl> | |||
<ul><li> <b><code>cant</code></b> | |||
</li></ul> | |||
<dl><dd> Unit cannot carry out this order. Loaded but not currently called by the engine. | |||
The <code>customParams</code> 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. | </dd></dl> | ||
<ul><li> <b><code>underattack</code></b> | |||
There are no additional tags specific to this subtable | </li></ul> | ||
<dl><dd> Unit gets attacked. Loaded but not currently called by the engine. | |||
</dd></dl> | |||
<h3>customParams</h3> | |||
<p>The <code>customParams</code> 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. | |||
</p><p>There are no additional tags specific to this subtable | |||
</p> | |||
<h2>Examples</h2> | |||
<p><a href="http://imolarpg.dyndns.org/trac/balatest/browser/trunk/units">'Balanced Annihilation' UnitDefs</a> | |||
</p><p><a href="http://trac.caspring.org/browser/trunk/mods/ca/units">'Complete Annihilation' UnitDefs</a> | |||
</p><p><a href="http://code.google.com/p/conflictterra/source/browse/#svn%2Fgames%2FCT%2Funits">'Conflict Terra' UnitDefs</a> | |||
</p><p><a href="https://code.google.com/p/evolutionrts/source/browse/#svn%2Ftrunk%2Fevolutiondev.sdd%2FUnits">'Evolution RTS' UnitDefs</a> | |||
</p><p><a href="http://code.google.com/p/springtutorialgame/source/browse/#svn%2Ftrunk%2FSpringTutorialGame.sdd%2FUnits">'Spring Tutorial Game' UnitDefs</a> | |||
</p><p><a href="http://code.google.com/p/zero-k/source/browse/trunk#trunk%2Fmods%2Fzk%2Funits">'ZeroK' UnitDefs</a> | |||
</p><br/><span _fcknotitle="true" class="fck_mw_category" sort="Unit_development">Unit development</span> <br/><span _fcknotitle="true" class="fck_mw_category" sort="Game_development">Game development</span> <br/> | |||
Revision as of 14:43, 9 July 2012
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:rts/Sim/Units/UnitDef.cpp
The engine source which reads the <a _fcknotitle="true" href="#sounds">#sounds</a> subtable can be found here:rts/Sim/Units/UnitDefHandler.cpp
Data Types
Tags may be one of the following data types:
-
int- An integer number -
float- A number with decimals. -
bool- A value which can betrueorfalse. -
string- Text, or more precisely a string of alphanumeric characters. -
float[3]- A vector, with threefloatcomponents, representing x, y and z axes (y is 'up').
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
Resources
Sensors
Cloaking
For units with <a href="Units-UnitDefs#Commands">canCloak</a> set to true:
Template:TagfckLR
Commands
Builder Commands
Builder
Movement & Placement
{{tag
|name = yardmap |type = string |default = "" |description = 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 viaCOB.YARD_OPENsee <a _fcknotitle="true" href="Animation-LuaCallouts#Other">Animation-LuaCallouts#Other</a>), -
i- 'Inversed Construction' - Closed and blocking only while constructing (for factories, controlled viaCOB.YARD_OPENsee <a _fcknotitle="true" href="Animation-LuaCallouts#Other">Animation-LuaCallouts#Other</a>) (New in version 89.0), -
g- 'Geothermal' - Flags that the unit must be placed over ageoThermalfeature, does not actually count as a square (See <a _fcknotitle="true" href="Units-FeatureDefs">Units-FeatureDefs</a>), o- 'Obstacle' - Always closed, blocking, all other chars are treated the same way.
-
- Tip: 'Draw' out the yardmap over multiple lines. Prior to 89.0 newlines should be replaced with spaces as newlines are treated as
o.
Flanking
For a deeper explanation of these tags, see <a _fcknotitle="true" href="Units:FlankingBonus">Units:FlankingBonus</a>.
Aircraft
Advanced Air Tags
The following set of tags are not well understood and using non-default values can lead to undesired flight behaviours. Template:TagfckLR
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 <a _fcknotitle="true" href="Resources.lua">Resources.lua</a>.
Template:TagfckLR
Transports
Categories
For a deeper explanation of these tags, see <a _fcknotitle="true" href="Unit Categories">Unit Categories</a>. Template:TagfckLR
Decals
Collision Volumes
For a deeper explanation of these tags, see <a href="Unit collision volumes"> Unit Collision Volumes</a>. Template:TagfckLR
Attack Behaviours
Other
Sub Tables
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:
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 <a _fcknotitle="true" href="CEG">CEG</a> 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 <a _fcknotitle="true" href="CEG">CEG</a>s the unit's script can call, via the EmitSFX() callout (See <a _fcknotitle="true" href="Animation-LuaCallouts#Effects">Animation-LuaCallouts#Effects</a>). 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 <a _fcknotitle="true" href="CEG">CEG</a>s the unit's script can pick at random to attach to a flying unit piece, created from the Explode() callout (See <a _fcknotitle="true" href="Animation-LuaCallouts#Effects">Animation-LuaCallouts#Effects</a>). 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:
- Each event can be used as though it were a
stringtag referring to the filename. - 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.
- Each event can be the name of a subtable, which is a simple array containing further tables, which contain the following tags:
Spring checks any referenced sound filename to see if a SoundItem has been created, which allows greater control over how it is played (See <a _fcknotitle="true" href="Sounds.lua">Sounds.lua</a>).
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
<a href="http://imolarpg.dyndns.org/trac/balatest/browser/trunk/units">'Balanced Annihilation' UnitDefs</a>
<a href="http://trac.caspring.org/browser/trunk/mods/ca/units">'Complete Annihilation' UnitDefs</a>
<a href="http://code.google.com/p/conflictterra/source/browse/#svn%2Fgames%2FCT%2Funits">'Conflict Terra' UnitDefs</a>
<a href="https://code.google.com/p/evolutionrts/source/browse/#svn%2Ftrunk%2Fevolutiondev.sdd%2FUnits">'Evolution RTS' UnitDefs</a>
<a href="http://code.google.com/p/springtutorialgame/source/browse/#svn%2Ftrunk%2FSpringTutorialGame.sdd%2FUnits">'Spring Tutorial Game' UnitDefs</a>
<a href="http://code.google.com/p/zero-k/source/browse/trunk#trunk%2Fmods%2Fzk%2Funits">'ZeroK' UnitDefs</a>
Unit development
Game development