Cacodemon commits suicide in Doom 1.1

Because of a bug in the implementation of monster infighting in Doom v1.1 and earlier, monsters will try to commitby attacking themselves if they are injured when they destroy

A simple explanation for this behavior is as follows: when a barrel explodes, the Doom engine tracks which player or monster caused the barrel explosion. When damaging another object as a result of the barrel explosion, the "source" of the explosion is then passed on to the damaged object. A monster hurt in a barrel explosion will then retaliate against the monster or player that caused the barrel to explode (an example of monster infighting, if the source is another monster).

However, if a monster damages itself in a barrel explosion, it is the cause of its own injury. Doom v1.1 does not check for this special case (it is not a scenario that occurs frequently during normal play). As a result, monsters that injure themselves through a barrel explosion will retaliate against themselves. Monsters such as cacodemons, barons of hell and imps will "tear themselves apart" with their own melee attack. Former humans (or monsters without melee attacks) will "go crazy", firing ahead blindly, possibly causing monster infighting as a result.

Technical

The likely cause of this can be seen in the Doom source code. In the P_DamageMobj function in p_inter.c is the following code:

if ( (!target->threshold || target->type == MT_VILE) && source && source != target && source->type != MT_VILE) { // if not intent on another player, // chase after this one target->target = source; target->threshold = BASETHRESHOLD; if (target->state == &states[target->info->spawnstate] && target->info->seestate != S_NULL) P_SetMobjState (target, target->info->seestate); }

This code is executed when an object is damaged by another object; this includes barrel explosions. The variable source is a reference to the object which caused the damage, while the variable target is a reference to the object on which damage is inflicted. When a barrel is destroyed, any affected enemies are injured with source equal to the player or enemy which caused the explosion.