Difference between revisions of "Boss level ending not triggered if every player is dead"

From DoomWiki.org

[unchecked revision][checked revision]
(Initial article)
 
(Added a technical explanation)
Line 1: Line 1:
In a [[multiplayer]] game with monsters, killing the [[episode]]'s final [[boss]] will end the level and a [[text screen]] will be displayed. The level's ending is normally triggered after the boss' death animation has completed.  
+
In a [[multiplayer]] game with [[monsters]], killing the [[episode]]'s final [[boss]] will end the level and a [[text screen]] will be displayed. The level's ending is normally triggered after the boss' death animation has completed.  
  
Due to a bug, the ending will not be triggered if every player is dead while the boss' death animation finishes. Although this is normal is [[single player]], in multiplayer the [[player]]s are able to [[respawn]] so as a result they remain stuck on the level. There is no way to restart the level unlike when in single player mode where this happens when the player dies.
+
Due to a bug, the ending will not be triggered if every player is dead while the boss' death animation finishes. Although this is normal is [[single player]], in multiplayer the [[player]]s are able to [[respawn]] so as a result they remain stuck on the level. There is no way to restart the level unlike when in single player mode, where this happens when the player dies.
  
This bug doesn't affect the [[final boss]] found in [[Doom II: Hell on Earth]] or similar games.
+
This bug doesn't affect the [[final boss]] found in [[Doom II: Hell on Earth]], [[TNT: Evilution]] and [[The Plutonia Experiment]].
 +
 
 +
== Technical details ==
 +
 
 +
The code that handles the effects of a boss' death is found the file {{c|p_enemy.c}} inside the function {{c|A_BossDeath}}.
 +
 
 +
The relevant code is the following:
 +
 
 +
    // make sure there is a player alive for victory
 +
    for (i=0 ; i<MAXPLAYERS ; i++)
 +
        if (playeringame[i] && players[i].health > 0)
 +
            break;
 +
   
 +
    if (i==MAXPLAYERS)
 +
        return; // no one left alive, so do not end game
 +
 
 +
This code cycles through every player and checks if they have [[health]] remaining. If at least one player is alive, the loop will break and the last condition shown here will not be met. In the other case, the function will return and the remaining portion of the function which calls {{c|G_ExitLevel}} will never be executed.
 +
 
 +
This logic would work correctly if the function was called repetitively after the boss is dead. It would also make sense if the players didn't have the ability to respawn and if the level restarted once every player was dead. This behavior was probably coded before the ability to respawn was added into the game.

Revision as of 20:57, 19 December 2018

In a multiplayer game with monsters, killing the episode's final boss will end the level and a text screen will be displayed. The level's ending is normally triggered after the boss' death animation has completed.

Due to a bug, the ending will not be triggered if every player is dead while the boss' death animation finishes. Although this is normal is single player, in multiplayer the players are able to respawn so as a result they remain stuck on the level. There is no way to restart the level unlike when in single player mode, where this happens when the player dies.

This bug doesn't affect the final boss found in Doom II: Hell on Earth, TNT: Evilution and The Plutonia Experiment.

Technical details

The code that handles the effects of a boss' death is found the file p_enemy.c inside the function A_BossDeath.

The relevant code is the following:

   // make sure there is a player alive for victory
   for (i=0 ; i<MAXPLAYERS ; i++)
       if (playeringame[i] && players[i].health > 0)
           break;
   
   if (i==MAXPLAYERS)
       return;	// no one left alive, so do not end game

This code cycles through every player and checks if they have health remaining. If at least one player is alive, the loop will break and the last condition shown here will not be met. In the other case, the function will return and the remaining portion of the function which calls G_ExitLevel will never be executed.

This logic would work correctly if the function was called repetitively after the boss is dead. It would also make sense if the players didn't have the ability to respawn and if the level restarted once every player was dead. This behavior was probably coded before the ability to respawn was added into the game.