diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b76586249..ff78cfb49 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -85,6 +85,7 @@ static void NetTimeout_OnChange(void); static void JoinTimeout_OnChange(void); static void PlayStyle_OnChange(void); +static void StealLives_OnChange(void); static void Ringslinger_OnChange(void); static void Gravity_OnChange(void); @@ -352,9 +353,9 @@ static CV_PossibleValue_t inttime_cons_t[] = {{0, "MIN"}, {3600, "MAX"}, {0, NUL consvar_t cv_inttime = {"inttime", "10", CV_NETVAR, inttime_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t playstyle_cons_t[] = {{0, "Individual"}, {1, "Sharing"}, {2, "Together"}, {0, NULL}}; -consvar_t cv_playstyle = {"playstyle", "Together", CV_NETVAR|CV_CHEAT|CV_CALL, playstyle_cons_t, PlayStyle_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_playstyle = {"playstyle", "Together", CV_NETVAR|CV_CALL|CV_CHEAT, playstyle_cons_t, PlayStyle_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_steallives = {"steallives", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_steallives = {"steallives", "Yes", CV_NETVAR|CV_CALL, CV_YesNo, StealLives_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t advancemap_cons_t[] = {{0, "Off"}, {1, "Next"}, {2, "Random"}, {0, NULL}}; consvar_t cv_advancemap = {"advancemap", "Next", CV_NETVAR, advancemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -3419,7 +3420,30 @@ static void PlayStyle_OnChange(void) if (!players[i].spectator) continue; - if (players[i].lives <= 0) + if (players[i].lives <= 0 && !cv_steallives.value) + continue; + + players[i].playerstate = PST_REBORN; + } + } +} + +static void StealLives_OnChange(void) +{ + if (!(netgame || multiplayer) || gametype != GT_COOP) + return; + if (cv_playstyle.value != 2 && cv_steallives.value) + { + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (!players[i].spectator) + continue; + + if (players[i].lives > 0) continue; players[i].playerstate = PST_REBORN; diff --git a/src/g_game.c b/src/g_game.c index a3eb8d6c1..2e4dc6dd6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2592,6 +2592,10 @@ void G_DoReborn(INT32 playernum) // respawn at the start mobj_t *oldmo = NULL; + // Return to level music + if (player->lives <= 0) + P_RestoreMultiMusic(player); + if (gametype == GT_COOP && (netgame || multiplayer)) { INT32 i; diff --git a/src/p_local.h b/src/p_local.h index f34ed1307..a579eaeff 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -201,6 +201,7 @@ void P_PlayLivesJingle(player_t *player); boolean P_GetLives(player_t *player); boolean P_SpectatorJoinGame(player_t *player); +void P_RestoreMultiMusic(player_t *player); // // P_MOBJ diff --git a/src/p_user.c b/src/p_user.c index 964c4ba73..9589bafbe 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -8132,11 +8132,9 @@ boolean P_GetLives(player_t *player) if (players[maxlivesplayer].mo) S_StartSound(players[maxlivesplayer].mo, sfx_jshard); // placeholder players[maxlivesplayer].lives--; - player->lives = 1; - if (netgame && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); - else if (player == &players[displayplayer] || player == &players[secondarydisplayplayer]) - P_RestoreMusic(player); + player->lives++; + if (player->lives < 1) + player->lives = 1; return true; } return false; @@ -8177,6 +8175,24 @@ static void P_ConsiderAllGone(void) } } +void P_RestoreMultiMusic(player_t *player) +{ + if (netgame) + { + if (P_IsLocalPlayer(player)) + S_ChangeMusic(mapmusname, mapmusflags, true); + } + else if (multiplayer) // local multiplayer only + { + // Restore the other player's music once we're dead for long enough + // -- that is, as long as they aren't dead too + if (player == &players[displayplayer] && players[secondarydisplayplayer].lives > 0) + P_RestoreMusic(&players[secondarydisplayplayer]); + else if (player == &players[secondarydisplayplayer] && players[displayplayer].lives > 0) + P_RestoreMusic(&players[displayplayer]); + } +} + // // P_DeathThink // Fall on your face when dying. @@ -8287,42 +8303,10 @@ static void P_DeathThink(player_t *player) countdown2 = 1*TICRATE; } } - // In a coop game, and out of lives - /*else if (gametype == GT_COOP) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i]) - continue; - if (players[i].exiting || players[i].lives) - break; - if (players[i].playerstate == PST_DEAD && players[i].deadtimer < deadtimercheck) - deadtimercheck = players[i].deadtimer; - } - - if (i == MAXPLAYERS && deadtimercheck == 8*TICRATE) - { - // They're dead, Jim. - //nextmapoverride = spstage_start; - nextmapoverride = gamemap; - countdown2 = 1*TICRATE; - skipstats = true; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i]) - players[i].score = 0; - } - - //emeralds = 0; - tokenbits = 0; - tokenlist = 0; - token = 0; - } - }*/ + //else if (gametype == GT_COOP) -- moved to G_DoReborn } - if (gametype == GT_COOP && (player->lives <= 0) && (player->deadtimer > gameovertics || ((cmd->buttons & BT_JUMP) && (player->deadtimer > TICRATE)))) + if (gametype == GT_COOP && (player->lives <= 0) && (player->deadtimer >= 8*TICRATE || ((cmd->buttons & BT_JUMP) && (player->deadtimer > TICRATE)))) { player->spectator = true; player->playerstate = PST_REBORN; @@ -8345,25 +8329,8 @@ static void P_DeathThink(player_t *player) } // Return to level music - if (player->lives <= 0) - { - if (netgame) - { - if (player->deadtimer == gameovertics && P_IsLocalPlayer(player)) - S_ChangeMusic(mapmusname, mapmusflags, true); - } - else if (multiplayer) // local multiplayer only - { - if (player->deadtimer != gameovertics) - ; - // Restore the other player's music once we're dead for long enough - // -- that is, as long as they aren't dead too - else if (player == &players[displayplayer] && players[secondarydisplayplayer].lives > 0) - P_RestoreMusic(&players[secondarydisplayplayer]); - else if (player == &players[secondarydisplayplayer] && players[displayplayer].lives > 0) - P_RestoreMusic(&players[displayplayer]); - } - } + if (player->lives <= 0 && player->deadtimer == gameovertics) + P_RestoreMultiMusic(player); } if (!player->mo) diff --git a/src/st_stuff.c b/src/st_stuff.c index 30b9bdb04..a447025c6 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1982,6 +1982,28 @@ static void ST_overlayDrawer(void) V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Fire to be assigned to a team.")); else if (G_IsSpecialStage(gamemap) && useNightsSS) V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("You cannot join the game until the stage has ended.")); + else if (gametype == GT_COOP) + { + if (cv_steallives.value + && (netgame || multiplayer)) + { + INT32 i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i]) + continue; + + if (&players[i] == stplyr) + continue; + + if (players[i].lives > 1) + break; + } + + if (i != MAXPLAYERS) + V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("You'll steal a life on respawn.")); + } + } else if (!gametype == GT_COOP) V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Fire to enter the game.")); V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(148), V_HUDTRANSHALF, M_GetText("Press F12 to watch another player."));