Doom Wiki
m (category tweaks)
No edit summary
Line 1: Line 1:
 
[[Video:DOOM v1.1 barrel suicide bug - Cacodemon 2|thumb|300px|right|A Cacodemon commits suicide on E3M4]]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'''.
 
[[Video:DOOM v1.1 barrel suicide bug - Cacodemon 2|thumb|300px|right|A Cacodemon commits suicide on E3M4]]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).
   
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 [[cacodemon]]s, [[Baron of hell|barons of hell]] and [[imp]]s will "tear themselves apart" with their own [[melee]] attack. [[Former human]]s (or monsters without [[melee attack]]s) will "go crazy", firing ahead blindly, possibly causing monster infighting as a result.
+
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 [[cacodemon]]s, [[Baron of hell|barons of hell]] and [[imp]]s will "tear themselves apart" with their own [[melee]] attack. [[Former human]]s (or monsters without [[melee attack]]s) will "go crazy", firing ahead blindly, possibly causing monster infighting as a result.
   
 
== Technical ==
 
== Technical ==
Line 9: Line 9:
 
The likely cause of this can be seen in the [[Doom source code]]. In the <code>P_DamageMobj</code> function in [[Doom source code files | p_inter.c]] is the following code:
 
The likely cause of this can be seen in the [[Doom source code]]. In the <code>P_DamageMobj</code> function in [[Doom source code files | p_inter.c]] is the following code:
   
if ( (!target->threshold || target->type == MT_VILE)
+
if ( (!target->threshold || target->type == MT_VILE)
 
&& source '''&& source != target'''
 
&& source '''&& source != target'''
 
&& source->type != MT_VILE)
 
&& source->type != MT_VILE)
Line 22: Line 22:
 
}
 
}
   
This code is executed when an object is damaged by another object; this includes barrel explosions. The variable <code>source</code> is a reference to the object which caused the damage, while the variable <code>target</code> is a reference to the object on which damage is inflicted. When a barrel is destroyed, any affected enemies are injured with <code>source</code> equal to the player or enemy which caused the explosion.
+
This code is executed when an object is damaged by another object; this includes barrel explosions. The variable <code>source</code> is a reference to the object which caused the damage, while the variable <code>target</code> is a reference to the object on which damage is inflicted. When a barrel is destroyed, any affected enemies are injured with <code>source</code> 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 <code>target</code> and <code>source</code> 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 (<code>target->target</code>, the object it is currently chasing/attacking) is set to itself. The result is that it attacks itself.
+
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 <code>target</code> and <code>source</code> 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 (<code>target->target</code>, the object it is currently chasing/attacking) is set to itself. The result is that it attacks itself.
   
 
== External links ==
 
== External links ==
Line 30: Line 30:
 
* [http://www.johnromero.com/lee_killough/memorabilia/index.shtml Demos on Lee Killough's webpage demonstrating barrel suicide]
 
* [http://www.johnromero.com/lee_killough/memorabilia/index.shtml Demos on Lee Killough's webpage demonstrating barrel suicide]
 
* [http://www.doomworld.com/vb/showthread.php?goto=all&threadid=10323&perpage=2000 Doom Oddities] thread at the [[Doomworld forums]]
 
* [http://www.doomworld.com/vb/showthread.php?goto=all&threadid=10323&perpage=2000 Doom Oddities] thread at the [[Doomworld forums]]
 
 
[[Category:Errors and bugs]]
 
[[Category:Errors and bugs]]
 
[[Category:Hazards]]
 
[[Category:Hazards]]
Line 36: Line 35:
 
[[Category:Monsters]]
 
[[Category:Monsters]]
 
[[Category:Tactics]]
 
[[Category:Tactics]]
  +
[[Category:Benefit glitches]]

Revision as of 05:14, 28 August 2010

thumb|300px|right|A Cacodemon commits suicide on E3M4Because 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