Daivuk / apdoom

Archipelago Doom is a fork of Crispy Doom to allow multi-world features from Archipelago
GNU General Public License v2.0
9 stars 11 forks source link

Don't allow alive players to spawn or load in with 0 health (as zombies) #19

Closed KScl closed 4 months ago

KScl commented 4 months ago

The zombie bug that people are experiencing is caused by player->playerstate being PST_LIVE, but player->health and player->mo->health both being zero.

If ap_state.player_state.health somehow gets set to zero, and a player tries to load a level under those conditions, the player will be stuck as a zombie (unless they're loading a save where they're already dead). There is at least one 100% reliable way to cause this: Die, quit the game while dead, and delete the save for the level you're on.

I'm certain that isn't the only possible case where people are getting stuck with zero health, because I can't imagine people are just going around deleting their save files on a whim. So, as a generalized fix that should stop it from ever happening: if we notice us trying to spawn in a player as a zombie, ignore ap_state.player_state.health and instead spawn them with 100 health.


This also fixes a related bug that causes players to spawn in with zero health (or more accurately, zero everything) in Doom 2, by trying to open up a game after somebody else has already cleared its goal. The victory screen that shows up unexpectedly jumps the player into MAP01 when it finishes, and does so without letting AP initialize anything, so the player starts with zero health, zero ammo and max ammo, and no weapons. (Not even the pistol and fist!)

It now instead goes back to the level select properly, and everything behaves as normal from there.