diff --git a/src/d_player.h b/src/d_player.h index c6328c3ca..e81e4b6f1 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -281,6 +281,7 @@ typedef struct respawnvars_s tic_t airtimer; // Time spent in the air before respawning UINT32 distanceleft; // How far along the course to respawn you tic_t dropdash; // Drop Dash charge timer + boolean truedeath; // Your soul has left your body } respawnvars_t; // player_t struct for all bot variables diff --git a/src/k_respawn.c b/src/k_respawn.c index 1576af681..1132f182b 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -278,6 +278,7 @@ void K_DoIngameRespawn(player_t *player) player->respawn.state = RESPAWNST_MOVE; player->respawn.airtimer = player->airtime; + player->respawn.truedeath = false; } /*-------------------------------------------------- @@ -567,7 +568,9 @@ static void K_MovePlayerToRespawnPoint(player_t *player) lasersteps--; } - if (lasersteps == 0) // Don't spawn them beyond the respawn point. + // Respawning after death: everything about the player + // is invisible + if (!player->respawn.truedeath && lasersteps == 0) // Don't spawn them beyond the respawn point. { mobj_t *lasermo = P_SpawnMobj(laser.x, laser.y, laser.z + (player->mo->height / 2), MT_DEZLASER); diff --git a/src/p_inter.c b/src/p_inter.c index 27455872d..03d9e77a6 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1076,6 +1076,11 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget target->player->playerstate = PST_DEAD; + // respawn from where you died + target->player->respawn.pointx = target->x; + target->player->respawn.pointy = target->y; + target->player->respawn.pointz = target->z; + if (target->player == &players[consoleplayer]) { // don't die in auto map, diff --git a/src/p_mobj.c b/src/p_mobj.c index 5219fb707..2b5d68807 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11250,8 +11250,6 @@ void P_MovePlayerToStarpost(INT32 playernum) mobj_t *mobj = p->mo; I_Assert(mobj != NULL); - K_DoIngameRespawn(p); - P_UnsetThingPosition(mobj); mobj->x = p->respawn.pointx; mobj->y = p->respawn.pointy; @@ -11293,6 +11291,11 @@ void P_MovePlayerToStarpost(INT32 playernum) else p->drawangle = mobj->angle; // default to the camera angle + K_DoIngameRespawn(p); + p->respawn.truedeath = true; + + mobj->renderflags |= RF_DONTDRAW; + P_AfterPlayerSpawn(playernum); } diff --git a/src/p_saveg.c b/src/p_saveg.c index 0ae0ee72a..554be67d2 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -373,6 +373,7 @@ static void P_NetArchivePlayers(void) WRITEUINT32(save_p, players[i].respawn.airtimer); WRITEUINT32(save_p, players[i].respawn.distanceleft); WRITEUINT32(save_p, players[i].respawn.dropdash); + WRITEUINT8(save_p, players[i].respawn.truedeath); // botvars_t WRITEUINT8(save_p, players[i].botvars.difficulty); @@ -654,6 +655,7 @@ static void P_NetUnArchivePlayers(void) players[i].respawn.airtimer = READUINT32(save_p); players[i].respawn.distanceleft = READUINT32(save_p); players[i].respawn.dropdash = READUINT32(save_p); + players[i].respawn.truedeath = READUINT8(save_p); // botvars_t players[i].botvars.difficulty = READUINT8(save_p);