States and Masters

XashXT

States and Masters

This system has been borrowed virtually unchanged from the Spirit of Half-Life mod. In a nutshell, it enables any entity to be the master of another entity. Being a master means blocking activation or deactivation. Entity states take into account each entity's specifics and purpose. The following states are available:

State The object is...
STATE_ON Turned on and working
STATE_TURN_ON Turning on (for example, func_rotating spinning up)
STATE_TURN_OFF Turning off (for example, func_rotating spinning down)
STATE_OFF Turned off
STATE_DEAD Broken (applicable to inanimate objects), doesn't respond to activation attempts any more
STATE_IN_USE Being used by the player or an NPC

All of these states can be monitored using the specialised multi_watcher entity. Alternatively, you can use the multisource entity with its simplistic treatment of states: STATE_ON means the object is on, and any other state means it is off. XashXT lets you block the same object with multiple masters just by giving these would-be masters the same name and specifying the name in the master field of the entity you want to block. For more details about this technique, see the description of the multisource entity.

For this system, the master field has been added to almost all objects that support activation. Importantly, all objects that have the item_ prefix can be made masters to disallow picking them up.

System Limitations

Some objects cannot be made masters of other objects or of themselves, because that would break compatibility with Half-Life. Such are all light entities and the multi_manager entity. However, you can still monitor their states using the multi_watcher entity and use it as a master.