Tag 666

Tag 666 is a special tag number used to denote map-specific behaviour. Tag 666 is invoked not by crossing a linedef, but by killing monsters. The specific behaviour is defined in p_enemy.c.

Relevant maps
Tag 666 can be used in E1M8, E2M8, E3M8 of Doom; E4M6 and E4M8 of Ultimate Doom; MAP07 and MAP32 of Doom 2.

void A_KeenDie(mobj_t* mo)
This procedure is called by the death of each Commander Keen present in the level. When the last Keen dies, doors tagged 666 are opened. This procedure was used as part of an easter egg in MAP32 of Doom 2.

void A_BossDeath(mobj_t *mo)
This procedure is called by the death of a boss monster. However, it only takes effect if the monster is the last of its type on the level. There are additional restrictions which differ depending on the game and level.

Bugs
The behaviour of tag 666 changed at some point after Ultimate Doom v 1.9, adding a test for the specific monster which has been killed, and only triggering if the monster is of the correct type for the original in that slot. This has rendered the classic PWAD Doomsday of UAC unplayable in modern source ports, as it relies on the death of the last Cyberdemon to trigger 666.

Specifically, the following code is responsible (lines 2096 to 2104 in prBoom 2.2.6):

switch(gameepisode) {       case 1: if (gamemap != 8) return; /* */   if (mo->type != MT_BRUISER) /* */     return; break;

The version of Doom prevalent at the time that Doomsday of UAC was created did not have the lines lines marked /* */. These lines dictate that only the death of the last Baron of Hell (known internally as MT_BRUISER) will trigger tag 666 on E1M8.