DECORATE expressions
From ZDoom Wiki
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.
The expression may include certain actor properties (occasionally called “keywords” in the forums) to compare values with. Note that these keywords can also be used outside of A_JumpIf 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
- cos(x), sin(x) — trigonometry functions, x must be in degrees
- random[identifier](min,max) — returns a random integer value between min and max
- 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
- ACS_ExecuteWithResult — runs a script and uses its return value.
Variables
There are a few variables you can use for dynamic data in DECORATE definitions. These are:
- 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
- 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.
- pitch — The Actor's pitch. (Presumably, in degrees, based on the above.)
- health — How much health the Actor has left.
- alpha — The alpha value of the Actor.
- tid — The Actor's TID
- tidtohate — TID of the current target (see Thing_Hate et al.)
- ceilingz — See GetActorCeilingZ
- floorz — See GetActorFloorZ
- special — ID of the special currently assigned to this actor
- args[] — Arguments passed to the thing special; args[0] through args[4] are valid.
- User Variables — user variables are defined as "var int user_(name);" in actor properties
- User Arrays — user arrays are defined as "var int user_(name)[(size)];" in actor properties
- waterlevel — How "submerged" the actor is
- 0: Not submerged at all (e.g. standing on solid ground)
- 1: Less than half submerged ("ankle deep")
- 2: At least half submerged ("waist deep")
- 3: Entirely submerged (completely underwater)
Examples
See Projectile Trap