Creating decorations that can be (de)activated

From ZDoom Wiki
Jump to navigation Jump to search

You can also define objects that change their state when being activated or deactivated.

For this purpose, two base classes exist: SwitchableDecoration and SwitchingDecoration.

Switchable decoration can be activated and deactivated; whereas switching decorations can only be activated but not deactivated again.

These classes use two special state labels: Active and Inactive. You must of course include a spawn state in addition to these two special states to have the actor work properly when spawned.

Activation and deactivation can be controlled by the action specials Thing_Activate (130) and Thing_Deactivate (131). In addition, the Activation property and the BUMPSPECIAL and USESPECIAL flags can be used to make it possible to control how the actor is activated even without ACS.

An example: this torch starts unlit (TRCHA0), but if the player presses "use" in front of it, it is lighted (TRCHB0). With a switchable decoration and the THINGSPEC_Switch activation flag as well, then it would be possible to make a torch that can be lit and unlit several times.

Actor Torch : SwitchingDecoration 10242
  Height 40
  Radius 20
  Activation THINGSPEC_Activate
    TRCH A 10
    TRCH B 10 A_PlaySound("torch/start")
    TRCH B 10

External links