DECORATE expressions

From ZDoom Wiki
Jump to: navigation, search

DECORATE supports complex mathematical expressions as parameters for codepointers. (Unfortunately, expressions are not supported for the values of properties.) The expression may include standard operators (+, -, *, /, <<, >>, |, etc.), math functions, and certain actor properties (occasionally called “keywords” in the forums) to compare values with. A_JumpIf, in particular, is meant to be used with expressions, but they can be used for any numeric (integer or floating point) parameter. For example, using velx, vely, and velz in A_SpawnItemEx to preserve velocity, or using args[] as arguments to a call of ACS_Execute.

Contents

Mathematical functions

  • abs(x) — returns the absolute value of x
  • cos(x), sin(x)trigonometry functions, x must be in degrees
  • sqrt(x) — returns the square root of x
  • random[identifier](min,max) — returns a random integer value between min and max
  • random2[identifier](mask) — returns a random integer value between -mask and +mask. It is roughly equivalent to random(0, mask) - random(0, mask). If no mask is provided (random2()), the maximum value of 255 is used instead. Mask is used as a binary mask, e.g. if 9 is used, the random results can be [0, 1, 8, 9] - [0, 1, 8, 9], so it is advised to use as a mask values one less than a power of two, such as 1, 3, 7, 15, 31, 63, or 127.
  • frandom[identifier](min,max) — returns a random floating point value between min and max

The identifier for random functions is optional. Calls to a random function with an identifier do not interfere with the RNG for calls with a different identifier, so using unique identifiers where appropriate reduces the risk of desync in demo playback.

ACS function

Variables

There are a few variables you can use for dynamic data in DECORATE definitions. These are:

Actor position and movement
  • x — The actor's X position in the world.
  • y — Same, but for Y.
  • z — Same, but for Z.
  • angle — Actor's angle, in degrees
  • ceilingz — See GetActorCeilingZ
  • floorz — See GetActorFloorZ
  • pitch — The actor's pitch. (Presumably, in degrees, based on the above.)
  • velx or momx — Actor's velocity along the absolute X axis. The "mom" names are (deprecated).
  • vely or momy — Same, but for Y.
  • velz or momz — Same, but for Z.
Actor properties
0: Not submerged at all (e.g. standing on solid ground or on shallow TERRAIN-based water)
1: Less than half submerged ("ankle deep")
2: At least half submerged ("waist deep")
3: Entirely submerged (completely underwater)

Examples

See Projectile Trap

Personal tools
Namespaces

Variants
Actions
Navigation
ACS
DECORATE
ZDoom mods
Toolbox