Doom Wiki
Register
(restoring video deleted in 2009)
WikiaBot (talk | contribs)
m (Updating Video:TITLE links to File:TITLE links)
Line 1: Line 1:
[[Video:Cacodemon commits suicide in Doom 1.1|thumb|320px|right|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 '''[[barrel]]s'''.
+
[[File:Cacodemon commits suicide in Doom 1.1|thumb|320px|right|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 '''[[barrel]]s'''.
   
 
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).
 
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).

Revision as of 19:12, 10 December 2014

Cacodemon_commits_suicide_in_Doom_1.1

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

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