Recessed Switch
By Richard Clark

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.

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.

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).

0 | Raise door and close it after delay.
1 | Open door and leave it open.
2 | Close door and open after delay.
3 | Close door and leave it closed.

Table 1: Door Types

0 | None.
1 | Any key.
2 | Red key card.
3 | Blue key card.
4 | Yellow key card.
5 | Red skull key.
6 | Blue skull key.
7 | Yellow skull key
8 | All 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 Randy Heit.

Back