TERRAIN
The TERRAIN lump is used to add sounds, liquid splashes and damaging effects to certain flats. The most common use is to create splashing sounds (such as water, mud, and lava in Heretic and Hexen), but it can also be used to give the player a custom landing sound when dropping onto a particular flat. For instance, if the player lands on a wood flat one may want to hear a heavy 'clunk' sound, and on a metal flat it will instead be a metallic 'clang' sort of sound. Note that those are only landing sounds, not footsteps.
Entries in the TERRAIN lump are created with the Terrain and Splash blocks. The effects of these blocks are then applied to certain flats using the Floor command.
In ZScript terrain data is stored in the TerrainDef struct and can be obtained from actors with GetFloorTerrain. Splash data is stored in the FSplashDef struct which is currently not exposed to ZScript.
Terrain blocks
Terrain blocks are defined as follows:
Terrain <Unique name> [modify] { Splash <splash block name> Footclip <integer value> Liquid <boolean value> Friction <float value> DamageType <type> DamageAmount <value> DamageTimeMask <value> DamageOnLand <boolean> AllowProtection <boolean> LeftStepSounds <sound from SNDINFO> RightStepSounds <sound from SNDINFO> StepSounds <sound from SNDINFO> StepDistance <float value> StepDistanceMinVel <float value> WalkStepTics <integer value> RunStepTics <integer value> }
The <unique name> must be unique to all the other terrain blocks, however you may have a splash block with the same name (so splash water and terrain water can co-exist just fine). The names None and Null should not be used as they are reserved for engine use.
The modify keyword allows for altering an already-existing terrain definition with the same name. If the keyword is not present, then the new definition replaces the old one completely.
Terrain properties
- Splash
- The name of the associated Splash block attached to this terrain definition. Splashes can play sounds, spawn splash actors, and interact with the NOSPLASHALERT and DONTSPLASH flags.
- Footclip
- The number of pixels relative to the height of an actor that will be clipped off actors that are in the sector that uses this terrain definition on its floor. See Floorclip.
- Liquid
- If set, marks the terrain as being liquid. This can affect projectile behavior based on their use bouncing flags.
- Friction
- A float-point value (1.0 by default) that determines the friction of the floor this terrain is applied to. Larger values are more slippery (ice), and lesser values have more friction, resulting in a "muddy" effect.
- DamageAmount
- Specifies how much damage the player entering this terrain will receive. (0 by default).
- DamageType
- Allows defining a custom damage type for the damage dealt by this terrain. This correlates directly to damage types defined in ZScript or DECORATE.
- DamageTimeMask
- Determines how often the damage is dealt, based on the current gametic. If none of the current gametic value's bits match the mask, then damage is inflicted. In practice, it is simpler to just assume that using for value a power of two, minus one, will result in damage inflicted every power of two tics. For example, using a damage time mask of
31
results in damage being inflicted every 32 tics. See this forum link for more information. - Starting with GZDoom 4.4.0, the damage interval is calculated by using a modulo operation, instead of a bitwise AND operation. This removes the restriction of only using power of two values minus one as the mask value. To retain the same results from the original way of calculating the interval, the engine adds 1 to the specified mask value before the calculations are performed. This needs to be taken into account for when setting the mask value by subtracting 1 from it. For instance, if a two-second interval (2 * 35 = 70) is desired, then the mask value should be 69, not 70.
- AllowProtection
- If true, PowerIronFeet-based powerups (such as Doom's RadSuit) will protect against the periodic damage.
- DamageOnLand
- Determines whether or not damage is applied upon hitting this terrain, in addition to the periodic damage.
- RightStepSounds and LeftStepSounds
- Allows providing a right and left footstep sound for this terrain; takes a SNDINFO sound name.
- These properties, as well as other footstep properties, do nothing on their own unless a player actor with MAKEFOOTSTEPS flag set walks over the terrain, in which case the footstep system will run.
- Note that the internal ZScript field names are
RightStepSound
andLeftStepSound
(with no s on the end). - For randomization the
$random
instruction in SNDINFO can be used.
- StepSounds (development version 12d1afc only)
- Serves a similar purpose to the above sound properties, except that it is meant to be used for foot-agnostic stepping sounds. If present, this sound takes precedence in the default footstep system.
- StepVolume
- The volume of the step sounds (if defined).
- StepDistance (development version d07d08c only)
- Makes the terrain produce footsteps only on every interval of distance the player travels that is at or greater than this value. i.e if set to 32, a footstep will be made every 32 map units the player travels. If this is kept to 0, the default footstep system will use the above step time intervals instead.
- StepDistanceMinVel (development version d07d08c only)
- If StepDistance is over 0, the player must be moving over this specified velocity to make a footstep. Can be used to prevent footsteps if the player is move very slowly, such as crawling around.
- WalkStepTics and RunStepTics
- The frequency of the footstep sound when walking and running, respectively.
Splash blocks
Splash blocks are defined as follows:
Splash <unique name> [modify] { SmallClass <small class> SmallClip <clipping of small chunks?> SmallSound <sound (as defined in SNDINFO)> BaseClass <base class> ChunkBaseZvel <z velocity of base> ChunkClass <chunk class> ChunkXVelShift <x velocity of chunks> ChunkYVelShift <y velocity of chunks> ChunkZVelShift <z velocity of chunks> Sound <sound (defined in SNDINFO)> noalert <does not alert monsters of the player's presence> }
The modify keyword allows for altering an already-existing splash definition with the same name. If the keyword is not present, then the new definition replaces the old one completely.
Splash properties
- SmallClass
- An actor class that will spawn when this splash is triggered, provided the actor who triggered the splash has a Mass value below 10.
- If this isn't provided,
BaseClass
will be spawned instead.
- SmallClip
- (Need more info)
- SmallSound
- The sound played when an actor triggers this splash, provided the actor who triggered the splash has a Mass value below 10.
- If this isn't provided,
Sound
will be played instead.
- BaseClass
- Splash actor spawned, if the actor who triggered it has a Mass of 10 or above.
- ChunkBaseZVel
- SmallClass/BaseClass actor will be given this velocity, slightly randomized.
- Sound
- The sound played when an actor triggers this splash, provided the actor who triggered the splash has a Mass value of 10 or above.
- ChunkClass
- An actor class that will spawn in addition to SmallClass/BaseClass when this splash is triggered. Usually this is smaller "drops of liquid", in contrast to the base splash actor. Chunks can be given randomized velocity with:
- ChunkXVelShift
- ChunkYVelShift
- ChunkZVelShift
- Note, giving velocity to the chunks via TERRAIN is not obligatory; it's perfectly possible to apply velocity to the chunk actors on spawn directly in ZScript/DECORATE.
A number of predefined splash classes exist, though one may of course create new splashes to use as well.
- WaterSplash - small water splashes
- WaterSplashBase - normal water splashes
- BloodSplash - small blood splashes
- BloodSplashBase - normal blood splash
- SlimeChunk - small green slime or nukage chunks
- SlimeSplash - normal green slime or nukage splash
- LavaSmoke - smoke (for lava or 'hot' rocks)
- LavaSplash - splash of lava (normal sized)
- SludgeChunk - small sludge (brown slime) chunks
- SludgeSplash - normal sized sludge splash
Note that DamageType 'Ice'
will cause IceChunk and IceChunkHead actors to melt and disappear more slowly on this terrain. DamageType 'Lava'
or 'Fire'
will cause them to melt faster. Furthermore, 'Lava' and 'Fire' are identical: the engine will remap any DamageType 'Lava'
to DamageType 'Fire'
.
Floor command
Finally we use the floor command to define the actual flats that get the terrain treatment. This is simply:
floor [optional] <flatname> <terrain name>
Where <flatname> is the name of the flat (if a flat is animated it is best to define each frame here) and <terrain name> is the name of the terrain block (defined above) which you want to correspond to <flatname>. The presence of optional tells the engine that the flat is not to be error-logged if it does not exist or is invalid.
Setting <terrain name> to Null or None allows to remove an association between a texture and a terrain type.
DefaultTerrain command
The DefaultTerrain command sets the terrain that is used for all floors that are not explicitly tied to a terrain type by the floor command. The DefaultTerrain command takes only one parameter, which is the name of a terrain.
defaultterrain <terrain name>
Examples
This reduces the friction on all floors.
Terrain lowfriction { friction 2.0 } Defaultterrain lowfriction