Knowledge Base - Using the Monster Special
Using the Monster Special
A feature that really sets off ZDoom from the other Doom ports is the Monster Special. When a monster is killed, a script or action can be executed. This can add a whole new dimension to map editing. In the example wad, monspec.wad, when the player kills the sergeant, a script is executed that performs several actions simultaneously.
Figure 2 shows the map layout. Sectors #1 and #2 are tagged, as is the door. The door will be opened by the script so the door has normal linedefs associated with it. The spawn sector is where a Soulsphere will spawn and it contains a Map Spot for the Thing_Spawn special.
Figure 3 illustrates the enemy setup. The special is assigned to script number 1. When the monster is killed the following will happen:
- The light in sector #1 will fade from level 180 to 120.
- The light is sector #2 will brighten from level 120 to 180.
- The door will open.
- A soul sphere will spawn at the map spot.
The door and sectors are tagged in the usual manner. The Map Spot must be tagged as well as is illustrated in Figure 4.
I put the map spot in its own sector, but it isn't necessary. Since one command is acting on a map spot and one command is acting on a sector, there is no conflict (this is corrected information from Marisa).
Side note from Marisa:
A similar note also applies to teleport destinations: They are identified by their thing IDs, not their containing sectors. So you can have multiple destinations in a single sector, and as long as they have different tid's, you can use them all independently.
The last piece of work is to code the script itself. The script is fairly simple. The monster special is tagged to script 1. When the monster dies, the commands in script will be executed, one after another without any delay. In other words, all these actions occur simultaneously. The effect is quite nice as you can see by playing the demo wad. The const is not required, but will speed up the script by a miniscule amount (Marisa). You can also use named constants if you use the #include "zcommon.acs" directive. In the case of the Thing_Spawn, the 25 becomes T_SOULSPHERE. This makes the script much more readable.
The following lists all the commands and their arguments:
Door_Open tag speed
- tag: This is the tag number assigned to the door.
- speed: How fast the door opens.
Light_Fade tag target speed
- tag: This is the tag number assigned to the sector.
- target: This is the target light level. The light can either get dimmer or brighter. To dim the light, set the initial light level to a high value, and the target in the command to a low level. To brighten the light, just do the opposite.
Thing_Spawn tag item angle
- tag: This is the tag number assigned to the map spot.
- item: This is the thing's id number. The list of spawnable things is in the ZDoom reference file included in the ZDoom package.
- angle: The angle that the item will be facing after it is spawned.
In addition to monsters, things can have a special assigned to them as well. So, when your player picks up the rocket launcher, you can have a surprise waiting.