Mapdev:terraintype

From Spring
Jump to navigationJump to search

Terrain Types

Type Maps or terrain Types allow altering the speed of units, and the mount of deformation.

(FIXME: Example typemap)
Example Typemap
Icon-caution.png Caution
The use of type maps for unit speed adjustment is discouraged; due to the way units are automatically assigned to categories and the invisible nature of the type map it makes game play unpredictable.

Spring already provides speed alteration, with pathing optimisation based on terrain incline. Units will always take the "road" if its completely flat and have to travel a fair distance along otherwise uneven terrain.

Type maps use in deformation can show distinction between terrains like sand, rock, etc. This will suffer from edges between hardness levels having different heights after deformation, however it can be somewhat mitigated by making transitional typemaps with multiple hardness levels.

Use sparingly, with obvious visual indicators in the texture image.

Specification

mapinfo.lua

The relevant sections of the mapinfo.lua file are in the terrainTypes subtable

local mapinfo = {
   ...
   smf = {
        ....
        typemapTex = "",
        ....
    },
    ...
   terrainTypes = {
      [0] = {
         name = "Default",
         hardness = 1.0,
         receiveTracks = true,
         moveSpeeds = {
            tank  = 1.0,
            kbot  = 1.0,
            hover = 1.0,
            ship  = 1.0,
         },
      },
      [1]  = { 
         ...
      },
      ...
   },
   ...
}

Image File

An 8bpp greyscale image has 256 values for grey. each value represents a different terrain type, so you can have 256 different terrains, starting at zero(black)(default) to 255(white)

File Location The metal map is an intermediary file compiled into the SMF file using MapConv or MapConvNG, it can also be specified in the mapinfo.lua
File Format Any that the Mapconv programs support
Colour Depth 8bpp
Channels Greyscale
Resolution
Spring Map Size* pixels = Spring Map Size * 32
2 64
4 128
6 192
... ...
32 1024
* must be multiples of 2

Forum Discussions