Prefixes and Postfixes for Switching Target Object States

XashXT

Prefixes and Postfixes for Switching Target Object States

An early implementation of this system was available in the Spirit of Half-Life mod. The purpose is to introduce a way to explicitly define the behaviour of a controllable target. This means that objects with two or more possible states can be explicitly forced to switch to any of these states. The classic example involves a door: func_door. If a door is in “toggle” mode, then subsequent activations open and close it intermittently, but the mapper has no way to activate the door so that it opens every time and, by extension, to ignore the open request if the door is already open.

The prefix system addresses this precise issue and gives the mapper ample possibilities. In addition, it makes scripts more stable and less dependent on the actions of the player, who might block objects in such a way as to break the predefined script behaviour. The object activation field (usually named target) can contain the following prefixes:

+ Activate target, turn on
- Deactivate target, turn off
< Set a numeric parameter for the object further on in the postfix (what parameter is affected depends on the object)
> Reset the object parameter that was set using the previous method or perform a custom action (depends on the object)
! Remove the object from the map

The + and - prefixes work identically for all entities except those that are not supposed to ever be activated, such as worldspawn or player. The ! prefix works likewise, and it removes all objects except those that are protected by the engine from inadvertent removal. Such are players and worldspawn.

The < and > prefixes, however, are tailored for each entity, because the current implementation does not support configuring arbitrary parameters of arbitrary objects. Therefore, only the highest-priority parameter (if any) is configured for each entity. For example, in a func_rotating entity these prefixes let you change the rotation speed and motion direction; in a func_screenmovie entity they make playback start from a specific time in the video file, and so on.

For details about the use of prefixes, refer to the descriptions of particular entities. A postfixed numeric value usually complements a prefix, but some logic entities can pass this numeric value on intact, without using or changing it. Such specifics are also detailed in the descriptions of particular objects.

System Limitations

The primary limitation is that the effect of some prefixes is unpredictable. This detracts from the usefulness of the technique as a global system.