Gamedev:UnitDefs: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
tags to buildTime, inclusive
Flozi (talk | contribs)
tags to canRepeat, inclusive
Line 46: Line 46:
* '''<code>mass</code>''' - type: <code>float</code> - default: <code>buildCostMetal</code>
* '''<code>mass</code>''' - type: <code>float</code> - default: <code>buildCostMetal</code>
: The mass of the unit, used in weapon impulse calculations. Any value <= <code>0.0</code> will default to the <code>buildCostMetal</code>.
: The mass of the unit, used in weapon impulse calculations. Any value <= <code>0.0</code> will default to the <code>buildCostMetal</code>.
* '''<code>reclaimable</code>''' - type: <code>bool</code> - default: <code>true</code>
: Can the unit be reclaimed by a builder?
* '''<code>capturable</code>''' - type: <code>bool</code> - default: <code>true</code>
: Can a unit be stolen by a builder using the capture command?
* '''<code>repairable</code>''' - type: <code>bool</code> - default: <code>true</code>
: Can the unit be repaired by a builder?
==Type==
* '''<code>canSubmerge</code>''' - type: <code>bool</code> - default: <code>false</code>
: If the unit is a ship, is it a submarine? If the unit is an aircraft, can it land underwater?
* '''<code>canFly</code>''' - type: <code>bool</code> - default: <code>false</code>
: Can the unit fly, i.e. is it an aircraft?


===Resources===
===Resources===
Line 70: Line 82:


===Sensors===
===Sensors===
* '''<code>sightDistance</code>''' - type: <code>float</code> - default: <code>0.0</code>
: The radius of the units sight (LOS is circular in Spring)
* '''<code>airSightDistance</code>''' - type: <code>float</code> - default: <code>1.5 * sightDistance</code>
: How far away the unit can see aircraft (and some FX).




===Commands===
===Commands===
 
* '''<code>canMove</code>''' - type: <code>bool</code> - default: <code>false</code>
: Can the unit be issued Move orders?
* '''<code>canAttack</code>''' - type: <code>bool</code> - default: <code>true</code>
: Can the unit be issued Attack orders?
* '''<code>canFight</code>''' - type: <code>bool</code> - default: <code>true</code>
: Can the unit be issued Fight orders?
* '''<code>canPatrol</code>''' - type: <code>bool</code> - default: <code>true</code>
: Can the unit be issued Patrol orders?
* '''<code>canGuard</code>''' - type: <code>bool</code> - default: <code>true</code>
: Can the unit be issued Guard orders?
* '''<code>canRepeat</code>''' - type: <code>bool</code> - default: <code>true</code>
: Can the unit be set to repeat its order queue?


===Builder===
===Builder===

Revision as of 22:05, 11 June 2011

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:

https://github.com/spring/spring/blob/master/rts/Sim/Units/UnitDef.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 be true or false.
  • string - Text, or more precisely a string of alphanumeric characters.
  • float[3] - A vector, with three float components, 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.

General

  • name - type: string - default: ""
This is simply the name of the unit as it appears to the player.
  • description - type: string - default: name
This is the tooltip description of the unit seen by the player. It defaults to the name of the unit.
  • buildPic - type: string - default: ""
The filename of of the image to be used as the build picture.
  • maxDamage - type: float - default: 0.0
The base 'hitpoints' the unit will have.
  • autoHeal - type: float - default: 0.0
How much health the unit will regain every second.
  • idleAutoHeal - type: float - default: 10.0
How much health the unit will regain every second whilst it is idle.
  • idleTime - type: int - default: 600
The time in gameframes taken until a unit is considered to be idle.
  • buildCostMetal - type: float - default: 0.0
The amount of metal resource the unit costs to build. Defaults to 0.0 but cannot actually be below 1.0.
  • buildCostEnergy - type: float - default: 0.0
The amount of energy resource the unit costs to build.
  • buildTime - type: float - default: 0.0
The time taken to build the unit, in conjunction with the workerTime of the constructor. Effectively, Time to build = unit buildTime / constructor workerTime. Defaults to 0.0 but cannot actually be below 1.0.
  • mass - type: float - default: buildCostMetal
The mass of the unit, used in weapon impulse calculations. Any value <= 0.0 will default to the buildCostMetal.
  • reclaimable - type: bool - default: true
Can the unit be reclaimed by a builder?
  • capturable - type: bool - default: true
Can a unit be stolen by a builder using the capture command?
  • repairable - type: bool - default: true
Can the unit be repaired by a builder?

Type

  • canSubmerge - type: bool - default: false
If the unit is a ship, is it a submarine? If the unit is an aircraft, can it land underwater?
  • canFly - type: bool - default: false
Can the unit fly, i.e. is it an aircraft?

Resources

  • metalStorage - type: float - default: 0.0
The amount of the metal resource storage the unit contributes.
  • energyStorage - type: float - default: 0.0
The amount of the energy resource storage the unit contributes.
  • extractsMetal - type: float - 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.
  • windGenerator - type: float - default: 0.0
The amount of the energy resource the unit generates which is dependant on the map wind. Works only for structures.
  • tidalGenerator - type: float - 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.
  • metalUse - type: float - default: 0.0
The amount of the metal resource the unit consumes per game 'tick'.
  • energyUse - type: float - default: 0.0
The amount of the energy resource the unit consumes per game 'tick'.
  • metalMake - type: float - default: 0.0
The amount of the metal resource the unit generates unconditionally per game 'tick'.
  • energyMake - type: float - default: 0.0
The amount of the energy resource the unit generates unconditionally per game 'tick'.
  • makesMetal - type: float - default: 0.0
The amount of the energy resource the unit turns into the metal resource per game 'tick'.

Sensors

  • sightDistance - type: float - default: 0.0
The radius of the units sight (LOS is circular in Spring)
  • airSightDistance - type: float - default: 1.5 * sightDistance
How far away the unit can see aircraft (and some FX).


Commands

  • canMove - type: bool - default: false
Can the unit be issued Move orders?
  • canAttack - type: bool - default: true
Can the unit be issued Attack orders?
  • canFight - type: bool - default: true
Can the unit be issued Fight orders?
  • canPatrol - type: bool - default: true
Can the unit be issued Patrol orders?
  • canGuard - type: bool - default: true
Can the unit be issued Guard orders?
  • canRepeat - type: bool - default: true
Can the unit be set to repeat its order queue?

Builder

Movement

Flanking

Aircraft

Transports

Categories

Decals

Collision Volumes

Weapons

Other

  • decoyFor - type: string - default: ""
The unitdef name (not human name) which this unit is a decoy for.


Custom Params

Examples