Gamedev:FeatureDefs

From Spring
(Redirected from Units-FeatureDefs)
Jump to: navigation, search

Location

FeatureDef files are .lua files stored in the Features/ directory of a Spring Game.

Purpose

FeatureDef files have one purpose; to define the properties of features. They are the main description file for what attributes your features should have and how units interact with them.

Source

The engine source code which loads the tags from these files is viewable 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 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 FeatureDef table the internal featureName desired for the unit.

General

string description  default: ""

This is the tooltip description of the feature seen by the player.

float damage  default: 0.0

How much damage this feature can take before being destroyed. Analogous to maxDamage for units.

string featureDead  default: ""

The featureName of the feature to spawn when this feature is destroyed. Used to make chains of features which 'disintegrate' as they are further damaged. Analogous to corpse for units.

bool indestructible  default: false

Can the feature be destroyed or not? If true the feature will not even take damage.

bool flammable  default: false (true for engine trees)

Can the feature be set on fire? The size of the flame particle is determined by the model radius. The duration of the fire in frames is a random number in the range [200, 230].

bool noSelect  default: false

If true the cursor won't change to `reclaim` when hovering the feature.

float mass  default: 0.4 * metal + 0.1 * damage

The mass of the feature, used in unit/feature crushing calculations (See Movedefs.lua). Minimum value is 1.0.

float crushResistance  default: massNew in version 85.0

How resistant is the feature to being crushed? Any MoveClass with a crushStrength greater than this will crush the feature.

Visual

string object  default: "" lua: modelname

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

int smokeTime  default: 300

How many frames a corpse feature should emit smoke for after unit death.

int drawType  default: 0

What kind of drawing type is the feature. Can be 0 - A loaded model, -1 - Nothing rendered for this feature at all (used for geovents), values >= 1 are used for the engine default trees. Generally speaking you should ignore this tag.

Reclaim & Resources

bool reclaimable  default: true if not indestructible, false otherwise

Can this feature be reclaimed by a construction unit?

bool autoReclaimable  default: reclaimable

Should this feature be reclaimed by a construction unit executing a patrol or area-reclaim command?

float reclaimTime  default: (metal + energy) * 6.0

The time taken to reclaim this feature. Related to unit reclaimSpeed such that Time taken to reclaim = feature reclaimTime / unit reclaimSpeed.

float metal  default: 0.0

How much metal resource this feature gives the player when reclaimed.

float energy  default: 0.0

How much energy resource this feature gives the player when reclaimed.

int resurrectable  default: -1

Can this feature be resurrected back into a living unit? Can be the following values -1 - Only resurrectable if it is the 1st level corpse of the UnitDef, 0 - Not resurrectable, 1 - Always ressurrectable.

bool geoThermal  default: falseNew in version 83.0

Does this feature act as a geothermal vent?

Placement

int footprintX  default: 1

How wide the feature is in footprint units, left to right. 1 footprint unit = 16 elmos. Cannot be below 1.

int footprintZ  default: 1

How wide the feature is in footprint units, top to bottom. 1 footprint unit = 16 elmos. Cannot be below 1.

bool blocking  default: true

Does this feature block the movement of units or can they pass right through it? Features that are non-blocking are also ignored by weapon aiming.

bool upright  default: false

Does the feature tilt with the slope of the terrain or remain upright?

bool floating  default: falseNew in version 90.0

Does this feature float on the top of water or is it placed on the seabed?

Decals

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

See Gamedev:UnitDefs#Collision_Volumes.

Selection Volumes

See Gamedev:UnitDefs#Selection_Volumes.

Other

Sub Tables

customParams

The customParams subtable of a FeatureDef allows the game designer to give their features 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.

collisionVolume

See Gamedev:UnitDefs#collisionVolume.

selectionVolume

See Gamedev:UnitDefs#selectionVolume.

Examples

Many games include unit corpse features into the UnitDef (See Gamedev:UnitDefs#Examples)

'Balanced Annihilation' FeatureDefs

'Conflict Terra' FeatureDefs

'Evolution RTS' FeatureDefs

'Imperial Winter' FeatureDefs

'Journeywar' FeatureDefs

'MechCommander: Legacy' FeatureDefs

'Spring: 1944' FeatureDefs

'Spring Tutorial Game' FeatureDefs

'XTA' FeatureDefs

'ZeroK' FeatureDefs