Doom Wiki
m (Category:Monsters, Category:Hazards)
No edit summary
Line 19: Line 19:
   
 
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.
  +
  +
However, in [[MAP23: Barrels o' Fun]] of [[Doom 2]], the mancubus that fires at the player with barrels in the way kills itself despite the code revision.
   
 
== External links ==
 
== External links ==

Revision as of 10:14, 18 March 2006

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 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.

However, in MAP23: Barrels o' Fun of Doom 2, the mancubus that fires at the player with barrels in the way kills itself despite the code revision.

External links