Wikia

Doom Wiki

Barrel suicide

Talk11
3,232pages on
this wiki
Cacodemon commits suicide in Doom 101:12

Cacodemon commits suicide in Doom 1.1

A Cacodemon suicides when it hurts itself.

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

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 Edit

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.

The above code is supposed to cause monsters to retaliate against players which attack them. However, when a monster injures itself through a barrel explosion, both target and source will reference the monster. It is likely that the code in bold type was not present in version 1.1. As a result, the monster's target (target->target, the object it is currently chasing/attacking) is set to itself. The result is that it attacks itself.

External links Edit

Around Wikia's network

Random Wiki