Movedefs.lua: Difference between revisions
→Heat Tags: use Template:tag |
more or less done |
||
| Line 1: | Line 1: | ||
=Movedefs.lua= | |||
==Location== | ==Location== | ||
<code>movedefs.lua</code> is a file in the <code>Gamedata/</code> directory of a Spring Game. | <code>movedefs.lua</code> is a file in the <code>Gamedata/</code> directory of a Spring Game. | ||
| Line 25: | Line 26: | ||
|default = "" | |default = "" | ||
|description = The name of the '''MoveClass'''. Usually passed by the sub-table variable name rather than using the <code>name</code> tag (See [[#Example]]). Must contain "tank", "hover", "ship" or "boat" respectively for non-Bot types. | |description = The name of the '''MoveClass'''. Usually passed by the sub-table variable name rather than using the <code>name</code> tag (See [[#Example]]). Must contain "tank", "hover", "ship" or "boat" respectively for non-Bot types. | ||
{{tag | }}{{tag | ||
|name = footprintX | |name = footprintX | ||
|type = int | |type = int | ||
|default = 1 | |default = 1 | ||
|description = How wide the '''MoveClass''' 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 [[Units-UnitDefs#Movement_.26_Placement|UnitDef]]. | |description = How wide the '''MoveClass''' 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 [[Units-UnitDefs#Movement_.26_Placement|UnitDef]]. | ||
{{tag | }}{{tag | ||
|name = footprintZ | |name = footprintZ | ||
|type = int | |type = int | ||
|default = footprintX | |default = footprintX | ||
|description = How wide the '''MoveClass''' 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 [[Units-UnitDefs#Movement_.26_Placement|UnitDef]]. | |description = How wide the '''MoveClass''' 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 [[Units-UnitDefs#Movement_.26_Placement|UnitDef]]. | ||
{{tag | }}{{tag | ||
|name = crushStrength | |name = crushStrength | ||
|type = float | |type = float | ||
|default = 10.0 | |default = 10.0 | ||
|description = Power of a unit with this '''MoveClass''' to crush features and units. Any features (and units with crushing enabled via [[Lua_SyncedCtrl#Unit_Control|Spring.SetUnitBlocking]]) with a <code>crushResistance</code> less than this value will be crushed on contact (See [[Units-FeatureDefs#General]] and [[Units-UnitDefs#General]]). | |description = Power of a unit with this '''MoveClass''' to crush features and units. Any features (and units with crushing enabled via [[Lua_SyncedCtrl#Unit_Control|Spring.SetUnitBlocking]]) with a <code>crushResistance</code> less than this value will be crushed on contact (See [[Units-FeatureDefs#General]] and [[Units-UnitDefs#General]]). | ||
{{tag | }}{{tag | ||
|name = maxSlope | |name = maxSlope | ||
|type = float | |type = float | ||
|default = 60.0</code> (<code>15.0</code> for hover types)<code> <!-- ugly! --> | |default = 60.0</code> (<code>15.0</code> for hover types)<code> <!-- ugly! --> | ||
|description = The maximum steepness of slope a unit with this '''MoveClass''' can climb | |description = The maximum steepness of slope a unit with this '''MoveClass''' can climb in degrees. For further details see [[#How_slope_is_determined]]. | ||
{{tag | }}{{tag | ||
|name = slopeMod | |name = slopeMod | ||
|type = float | |type = float | ||
| Line 63: | Line 59: | ||
=== Heat Tags === | === Heat Tags === | ||
These tags are used in unit avoidance. | These tags are used in unit avoidance. {{tag | ||
{{tag | |||
|name = heatMapping | |name = heatMapping | ||
|type = bool | |type = bool | ||
|default = false | |default = false | ||
|description = This enables/disables generation and usage of path heats. | |description = This enables/disables generation and usage of path heats. | ||
{{tag | }}{{tag | ||
|name = heatMod | |name = heatMod | ||
|type = float | |type = float | ||
|default = 0.05 | |default = 0.05 | ||
|description = The pathfinder cost modifier that is multiplied by the heat of the current square. | |description = The pathfinder cost modifier that is multiplied by the heat of the current square. | ||
{{tag | }}{{tag | ||
|name = heatProduced | |name = heatProduced | ||
|type = int | |type = int | ||
| Line 86: | Line 79: | ||
=== Tank & Bot-Only Tags === | === Tank & Bot-Only Tags === | ||
{{tag | |||
|name = depthMod | |||
|type = float | |||
|default = 0.1 | |||
|description = How much water will slow amphibious units. The deeper the water, the slower the movement.<span class="warning">Replaced with a subtable in Spring 86.x</span> | |||
}}{{tag | |||
|name = maxWaterDepth | |||
|type = float | |||
|default = 0.0 | |||
|description = The maximum depth of water in [[elmos]] the unit can wade through. | |||
}} | |||
=== Ship-Only Tags === | === Ship-Only Tags === | ||
{{tag | |||
|name = minWaterDepth | |||
|type = float | |||
|default = 10.0 | |||
|description = The minimum depth of water in [[elmos]] the ship requires to float in. | |||
== | }}{{tag | ||
|name = subMarine | |||
|type = bool | |||
|default = false | |||
|description = Is the ship a submarine; can it move underneath other ships? | |||
}} | |||
==How slope is determined== | ==How slope is determined== | ||
Revision as of 21:00, 12 February 2012
Movedefs.lua
Location
movedefs.lua is a file in the Gamedata/ directory of a Spring Game.
Purpose
This file defines MoveClasses which are used to determine pathing for units.
Source
The engine source code which parses the data from this file is viewable here: rts/Sim/MoveTypes/MoveInfo.cpp
Details
A mobile unit is assigned a MoveClass using the movementClass UnitDef tag. The engine determines the unit's pathfinding based on the properties of the MoveClass, so analogous properties (e.g. FootprintX) in the UnitDef should be the same for optimal behaviour.
All MoveClasses must belong to one of four possible types. A MoveClass is assigned a type simply by including it within the name string e.g. Tank_MyMoveClassName. Types are used in TypeMaps of Spring maps, which allow mappers to set per-type speed multipliers.
Types
Bot- A ground based MoveClass. The default type if no matching type string is found.Tank- A ground based MoveClass. Identical toBotother than interaction with TypeMaps.ShiporBoat- Are synonyms. All ships / boat MoveClasses must belong to this type to behave as ships.Hover- All hovercraft MoveClasses (traverse any depth of water without speed reduction) must belong to this class, as well as havingcanHoverin their UnitDef to behave as hovers.
MoveClass Tags
string name default: ""
- The name of the MoveClass. Usually passed by the sub-table variable name rather than using the
nametag (See #Example). Must contain "tank", "hover", "ship" or "boat" respectively for non-Bot types.int footprintX default: 1 - How wide the MoveClass 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 thefootprintXof its UnitDef.int footprintZ default: footprintX - How wide the MoveClass 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 thefootprintZof its UnitDef.float crushStrength default: 10.0 - Power of a unit with this MoveClass to crush features and units. Any features (and units with crushing enabled via Spring.SetUnitBlocking) with a
crushResistanceless than this value will be crushed on contact (See Units-FeatureDefs#General and Units-UnitDefs#General).float maxSlope default: 60.0 (15.0for hover types) - The maximum steepness of slope a unit with this MoveClass can climb in degrees. For further details see #How_slope_is_determined.float slopeMod default: 4.0 / (maxSlope + 0.001)
- How much a slope will slow a unit,
0means no slowdown.
Heat Tags
These tags are used in unit avoidance. bool heatMapping default: false
- This enables/disables generation and usage of path heats.float heatMod default: 0.05
- The pathfinder cost modifier that is multiplied by the heat of the current square.int heatProduced default: 30
- How much heat to place on a square if a path goes through it. heat set = max(currentSquareHeat,
heatProduced).
Tank & Bot-Only Tags
float depthMod default: 0.1
- How much water will slow amphibious units. The deeper the water, the slower the movement.Replaced with a subtable in Spring 86.xfloat maxWaterDepth default: 0.0
- The maximum depth of water in elmos the unit can wade through.
Ship-Only Tags
float minWaterDepth default: 10.0
How slope is determined
Spring doesn't represent terrain slopes in degrees, internally it uses
(1.0 - the terrain normal's y-component) so the slope of vertical faces is 1 and that of horizontal ones 0. A unit's maxSlope value (which is in
degrees in its movedef) is converted so that the "can we go here?" (ie
"maxSlope > terrainSlope?") comparisons are meaningful, the formula
is 1.0 - cos(DEG2RAD(maxSlope * 1.5)). If you want to know the terrain angle in degrees, compute RAD2DEG(arccos(1.0 - terrainSlope)). For a bot with a maxSlope of 36 degrees (~0.41221 in "Spring format"), the maximum tolerable terrain angle is approximately
RAD2DEG(arccos(1.0 - 0.41221))
or 54 degrees. If maxSlope was 30, the MTTA would be 45, and if it was 60 (the highest sensible value due to that 1.5 scalar and the absence of overhanging cliffs) the bot could mount any terrain. In other words you do not need the long mathematical derivation, just remember that
maxTerrainAngle = maxSlope * 1.5
--kloot, Thu Jul 31, 2008
Example
External Examples
'Balanced Annihilation' movedefs.lua
'Complete Annihilation' movedefs.lua