Knowledge Base - Recessed Switch

Recessed Switch


Recessed Switch
Figure 1: Recessed Switch

Figure 1 shows a recessed switch in action. The switch is actually a poly object sitting in a sector that has a floor of 32 and a ceiling of 48. When the player uses the switch, a script is activated and the poly moves back into the wall. The script also triggers a secondary function, in this case opening a door. The sample wad recsw.wad also has a switch sound to complete the switch effect.

Map Layout
Figure 2: Map Layout

The poly is created in the usual way, in a separate hidden sector. In addition to having a standard startline, the side that will be facing into the game space room, has a acs_execute special associated with it, illustrated in Figure 3.

Poly Trigger Special
Figure 3: Poly Trigger Special

The special executes script 1 when the players uses the switch. The special is marked player uses and repeatable. Again, this is on the facing line of the poly object, not the line in the poly start space.

script 1 (int doortag, int polyid, int bangle)
{
    PolyObj_DoorSlide (polyid, 16, bangle, 16, 35);
    Generic_Door (doortag, 16, 0, 24, 0);
}
Figure 4: Activation Script

The script takes 3 parameters, the tag of the door to open, the id of the poly object, and the byte angle to move the poly. The script is parameterized so that this single script can be used for any switchable door in the map. The generic door special is an encapsulation of the Boom type of generic door.

Generic_Door door-tag, speed, kind, delay, lock

  • door-tag: This is a unique number that identifies the door sector.
  • speed: How fast the door moves.
  • kind: The type of door (see table below).
  • delay: Delay in octics until door is automatically closed or opened. An octic is 1/8 of a second.
  • lock: The type of required key, if any (see table below).
0Raise door and close it after delay.
1Open door and leave it open.
2Close door and open after delay.
3Close door and leave it closed.
Table 1: Door Types
0None.
1Any key.
2Red key card.
3Blue key card.
4Yellow key card.
5Red skull key.
6Blue skull key.
7Yellow skull key.
8All six keys.
Table 2: Key Types

The recessed switch is very easy to construct and use, and adds another level of interaction to ZDoom maps.

Sources

ZDoom reference by Marisa Heit.

Back