Gamedev:FeatureDefs: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
m →Collision Volumes: - always enable continuous hit-testing (
Flozi (talk | contribs)
→Sub Tables: here also
 
(24 intermediate revisions by 2 users not shown)
Line 6: Line 6:


==Source==
==Source==
The engine source code which loads the tags from these files is viewable here: {{sourcelink|file=rts/Sim/Features/FeatureHandler.cpp}}
The engine source code which loads the tags from these files is viewable here:
 
* {{sourcelink|file=rts/Sim/Features/FeatureHandler.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 28: Line 25:
|type = string
|type = string
|default = ""
|default = ""
|description = This is the tooltip description of the feature seen by the player.}}
|description = This is the tooltip description of the feature seen by the player.
}}


{{tag
{{tag
Line 34: Line 32:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How much damage this feature can take before being destroyed. Analogous to <code>maxDamage</code> for units (See [[Units-UnitDefs#General]]).}}
|description = How much damage this feature can take before being destroyed. Analogous to {{xtaglink|Gamedev:UnitDefs|maxDamage}} for units.
}}


{{tag
{{tag
Line 40: Line 39:
|type = string
|type = string
|default = ""
|default = ""
|description = The <code>featureName</code> 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 <code>corpse</code> for units (See [[Units-UnitDefs#General]]).}}
|description = The <code>featureName</code> 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 {{xtaglink|Gamedev:UnitDefs|corpse}} for units.
}}


{{tag
{{tag
Line 46: Line 46:
|type = bool
|type = bool
|default = false
|default = false
|description = Can the feature be destroyed or not? If <code>true</code> the feature will not even take damage.}}
|description = Can the feature be destroyed or not? If <code>true</code> the feature will not even take damage.
}}


{{tag
{{tag
|name = flammable
|name = flammable
|type = bool
|type = bool
|default = false
|default = false (true for engine trees)
|description = Can the feature be set on fire? Engine trees default to <code>true</code>. 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].}}
|description = 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].
}}


{{tag
{{tag
Line 58: Line 60:
|type = bool
|type = bool
|default = false
|default = false
|description = If <code>true</code> the cursor won't change to `reclaim` when hovering the feature.}}
|description = If <code>true</code> the cursor won't change to `reclaim` when hovering the feature.
}}


{{tag
{{tag
Line 64: Line 67:
|type = float
|type = float
|default = 0.4 * metal + 0.1 * damage
|default = 0.4 * metal + 0.1 * damage
|description = The mass of the feature, used in unit/feature crushing calculations (See [[Movedefs.lua]]). Minimum value is <code>1.0</code>.}}
|description = The mass of the feature, used in unit/feature crushing calculations (See [[Movedefs.lua]]). Minimum value is <code>1.0</code>.
}}


{{tag
{{tag
Line 71: Line 75:
|default = mass
|default = mass
|special ={{new|85.0}}
|special ={{new|85.0}}
|description = How resistant is the feature to being crushed? Any [[Movedefs.lua|'''MoveClass''']] with a <code>crushStrength</code> greater than this will crush the feature.
|description = How resistant is the feature to being crushed? Any [[Movedefs.lua|'''MoveClass''']] with a {{xtaglink|Movedefs.lua|crushStrength}} greater than this will crush the feature.
}}
}}


Line 79: Line 83:
|type = string
|type = string
|default = ""
|default = ""
|description = The filename of the 3D model file for this unit, assumes <code>Objects3D/</code> directory. Analagous to <code>objectName</code> for units (See [[Units-UnitDefs#General]])}}
|lua = modelname
|description = The filename of the 3D model file for this unit, assumes <code>Objects3D/</code> directory. Analagous to {{xtaglink|Gamedev:UnitDefs|objectName}} for units.
}}


{{tag
{{tag
Line 85: Line 91:
|type = int
|type = int
|default = 300
|default = 300
|description = How many frames a corpse feature should emit smoke for after unit death.}}
|description = How many frames a corpse feature should emit smoke for after unit death.
}}


{{tag
{{tag
Line 91: Line 98:
|type = int
|type = int
|default = 0
|default = 0
|description = What kind of drawing type is the feature. Can be <code>0</code> - A loaded model, <code>-1</code> - Nothing rendered for this feature at all (used for geovents), values >= <code>1</code> are used for the engine default trees. Generally speaking you should ignore this tag.}}
|description = What kind of drawing type is the feature. Can be <code>0</code> - A loaded model, <code>-1</code> - Nothing rendered for this feature at all (used for geovents), values >= <code>1</code> are used for the engine default trees. Generally speaking you should ignore this tag.
}}


===Reclaim & Resources===
===Reclaim & Resources===
Line 97: Line 105:
|name = reclaimable
|name = reclaimable
|type = bool
|type = bool
|default = true if not <code>indestructible</code>, <code>false</code> otherwise
|default = true if not {{taglink|indestructible}}, false otherwise
|description = Can this feature be reclaimed by a construction unit?}}
|description = Can this feature be reclaimed by a construction unit?
}}


{{tag
{{tag
Line 104: Line 113:
|type = bool
|type = bool
|default = reclaimable
|default = reclaimable
|description = Should this feature be reclaimed by a construction unit executing a patrol or area-reclaim command?}}
|description = Should this feature be reclaimed by a construction unit executing a patrol or area-reclaim command?
}}


{{tag
{{tag
Line 110: Line 120:
|type = float
|type = float
|default = (metal + energy) * 6.0
|default = (metal + energy) * 6.0
|description = The time taken to reclaim this feature. Related to unit <code>reclaimSpeed</code> such that ''Time taken to reclaim = feature <code>reclaimTime</code> / unit <code>reclaimSpeed</code>''}}
|description = The time taken to reclaim this feature. Related to unit {{xtaglink|Gamedev:UnitDefs|reclaimSpeed}} such that <code>Time taken to reclaim = feature reclaimTime / unit reclaimSpeed</code>.
}}


{{tag
{{tag
Line 116: Line 127:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How much metal resource this feature gives the player when reclaimed.}}
|description = How much metal resource this feature gives the player when reclaimed.
}}


{{tag
{{tag
Line 122: Line 134:
|type = float
|type = float
|default = 0.0
|default = 0.0
|description = How much energy resource this feature gives the player when reclaimed.}}
|description = How much energy resource this feature gives the player when reclaimed.
}}


{{tag
{{tag
Line 128: Line 141:
|type = int
|type = int
|default = -1
|default = -1
|description = Can this feature be resurrected back into a living unit? Can be the following values <code>-1</code> - Only resurrectable if it is the 1st level <code>corpse</code> of the [[Units-UnitDefs|UnitDef]], <code>0</code> - Not resurrectable, <code>1</code> - Always ressurrectable.}}
|description = Can this feature be resurrected back into a living unit? Can be the following values <code>-1</code> - Only resurrectable if it is the 1st level {{xtaglink|Gamedev:UnitDefs|corpse}} of the [[Gamedev:UnitDefs|UnitDef]], <code>0</code> - Not resurrectable, <code>1</code> - Always ressurrectable.
}}


{{tag
{{tag
Line 135: Line 149:
|default = false
|default = false
|special={{new|83.0}}
|special={{new|83.0}}
|description = Does this feature act as a geothermal vent?}}
|description = Does this feature act as a geothermal vent?
}}


===Placement===
===Placement===
Line 142: Line 157:
|type = int
|type = int
|default = 1
|default = 1
|description = How wide the feature is in footprint units, left to right. 1 footprint unit = 16 [[elmos]]. Cannot be below <code>1</code>.}}
|description = How wide the feature is in footprint units, left to right. 1 footprint unit = 16 [[elmo]]s. Cannot be below <code>1</code>.
}}


{{tag
{{tag
Line 148: Line 164:
|type = int
|type = int
|default = 1
|default = 1
|description = How wide the feature is in footprint units, top to bottom. 1 footprint unit = 16 [[elmos]]. Cannot be below <code>1</code>.}}
|description = How wide the feature is in footprint units, top to bottom. 1 footprint unit = 16 [[elmo]]s. Cannot be below <code>1</code>.
}}


{{tag
{{tag
Line 154: Line 171:
|type = bool
|type = bool
|default = true
|default = true
|description = 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 animing.}}
|description = 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.
}}


{{tag
{{tag
Line 160: Line 178:
|type = bool
|type = bool
|default = false
|default = false
|description = Does the feature tilt with the slope of the terrain or remain upright?}}
|description = Does the feature tilt with the slope of the terrain or remain upright?
}}
 
{{tag
|name = floating
|type = bool
|default = false
|special = {{new|90.0}}
|description = Does this feature float on the top of water or is it placed on the seabed?
}}


===Decals===
{{tag
{{tag
|name = nodrawundergray
|name = useBuildingGroundDecal
|type = bool
|type = bool
|default = false
|default = false
|description = Does this feature float on the top of water or is it placed on the seabed? Features which are not <code>blocking</code> cannot float. The strange name of this tag is a vestige of OTA.}}
|description = For structures, do they display a ground decal on the terrain under their model?}}


===Collision Volumes===
For a deeper explanation of these tags, see [[Unit_collision_volumes | Collision Volumes]].
{{tag
{{tag
|name = collisionVolumeType
|name = buildingGroundDecalType
|type = string
|type = string
|default = ""
|default = ""
|description = What shape should the feature'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>.}}
|description = The filename of the image to be used as ground decal. Assumed to be in <code>Unittextures/</code>.}}


{{tag
{{tag
|name = collisionVolumeScales
|name = buildingGroundDecalSizeX
|type = float[3]
|type = int
|default = {0.0, 0.0, 0.0}
|default = 4
|description = The length of the collision volume in each of the three axes.}}
|description = How wide the decal is left to right, in footprint units.}}


{{tag
{{tag
|name = collisionVolumeOffsets
|name = buildingGroundDecalSizeY
|type = float[3]
|type = int
|default = {0.0, 0.0, 0.0}
|default = 4
|description = The offset from the unit centre to the hit volume centre in each axis.}}
|description = How wide the decal is top to bottom, in footprint units.}}


{{tag
{{tag
|name = collisionVolumeTest
|name = buildingGroundDecalDecaySpeed
|type = int
|type = float
|default = 0
|default = 0.1
|special = <span class="warning">Removed in 90.0 (Now always continuous)</span>
|description = 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.}}
|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.}}
 
===Collision Volumes===
See [[Gamedev:UnitDefs#Collision_Volumes]].
 
===Selection Volumes===
See [[Gamedev:UnitDefs#Selection_Volumes]].


===Other===
===Other===
Line 204: Line 235:
There are no additional tags specific to this subtable.
There are no additional tags specific to this subtable.


==Examples==
===collisionVolume===
See [[Gamedev:UnitDefs#collisionVolume]].


[https://code.google.com/p/evolutionrts/source/browse/#svn%2Ftrunk%2Fevolutiondev.sdd%2FFeatures 'Evolution RTS' FeatureDefs]
===selectionVolume===
See [[Gamedev:UnitDefs#selectionVolume]].


Many games include unit corpse features into the UnitDef (See [[Units-UnitDefs#Examples]])
==Examples==
Many games include unit corpse features into the UnitDef (See [[Gamedev:UnitDefs#Examples]])


{{ExampleRepoLinks
|path = features/
|entity = FeatureDefs
}}


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

Latest revision as of 10:45, 22 December 2017

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: mass New 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: false New 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: false New 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