Fandom

Glitchipedia

Doom - Barrel Suicide

214pages on
this wiki
Add New Page
Talk0 Share

Because of a bug in the implementation of monster infighting, if some monsters in v1.1 (or earlier) of Doom injured themselves by destroying barrels, they would commit suicide.

The code

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.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.