* Renamed "steallives" to "lifedistribution".

* Gave lifedistribution a "Sharing" option to go along with its previous individual and stealing options.
* Made the game over graphic and music only happen if everyone's out of lives if you're sharing or stealing lives.
* Fixed a bug where game over wouldn't come to fruition because it kept on happening each tic of the countdown2.
* Made spectator stuff display in Co-op splitscreen.
This commit is contained in:
toasterbabe 2017-06-03 12:26:42 +01:00
parent 25a1ffe02a
commit f3cad19184
8 changed files with 135 additions and 85 deletions

View File

@ -85,7 +85,7 @@ static void NetTimeout_OnChange(void);
static void JoinTimeout_OnChange(void);
static void PlayStyle_OnChange(void);
static void StealLives_OnChange(void);
static void LifeDistribution_OnChange(void);
static void Ringslinger_OnChange(void);
static void Gravity_OnChange(void);
@ -355,7 +355,8 @@ consvar_t cv_inttime = {"inttime", "10", CV_NETVAR, inttime_cons_t, NULL, 0, NUL
static CV_PossibleValue_t playstyle_cons_t[] = {{0, "Individual"}, {1, "Sharing"}, {2, "Together"}, {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_CALL, CV_YesNo, StealLives_OnChange, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t lifedistribution_cons_t[] = {{0, "Individual"}, {1, "Stealing"}, {2, "Sharing"}, {0, NULL}};
consvar_t cv_lifedistribution = {"lifedistribution", "Stealing", CV_NETVAR|CV_CALL, lifedistribution_cons_t, LifeDistribution_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};
@ -516,7 +517,7 @@ void D_RegisterServerCommands(void)
CV_RegisterVar(&cv_downloading);
CV_RegisterVar(&cv_playstyle);
CV_RegisterVar(&cv_steallives);
CV_RegisterVar(&cv_lifedistribution);
CV_RegisterVar(&cv_specialrings);
CV_RegisterVar(&cv_powerstones);
@ -3407,32 +3408,31 @@ static void JoinTimeout_OnChange(void)
static void PlayStyle_OnChange(void)
{
if (!(netgame || multiplayer) || gametype != GT_COOP || G_IsSpecialStage(gamemap))
INT32 i;
if (!(netgame || multiplayer) || gametype != GT_COOP || cv_playstyle.value == 2 || G_IsSpecialStage(gamemap))
return;
if (cv_playstyle.value != 2)
for (i = 0; i < MAXPLAYERS; i++)
{
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
if (!playeringame[i])
continue;
if (!players[i].spectator)
continue;
if (!players[i].spectator)
continue;
if (players[i].lives <= 0 && !cv_steallives.value)
continue;
if (players[i].lives <= 0 && !cv_lifedistribution.value)
continue;
players[i].playerstate = PST_REBORN;
}
P_SpectatorJoinGame(&players[i]);
}
}
static void StealLives_OnChange(void)
static void LifeDistribution_OnChange(void)
{
if (!(netgame || multiplayer) || gametype != GT_COOP)
if (!(netgame || multiplayer) || gametype != GT_COOP || cv_playstyle.value == 2)
return;
if (cv_playstyle.value != 2 && cv_steallives.value)
if (cv_lifedistribution.value)
{
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
@ -3446,7 +3446,7 @@ static void StealLives_OnChange(void)
if (players[i].lives > 0)
continue;
players[i].playerstate = PST_REBORN;
P_SpectatorJoinGame(&players[i]);
}
}
}

View File

@ -89,7 +89,7 @@ extern consvar_t cv_recycler;
extern consvar_t cv_itemfinder;
extern consvar_t cv_inttime, cv_playstyle, cv_steallives, cv_advancemap, cv_playersforexit;
extern consvar_t cv_inttime, cv_playstyle, cv_lifedistribution, cv_advancemap, cv_playersforexit;
extern consvar_t cv_overtime;
extern consvar_t cv_startinglives;

View File

@ -2592,10 +2592,6 @@ 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;
@ -2606,18 +2602,18 @@ void G_DoReborn(INT32 playernum)
{
if (!playeringame[i])
continue;
if (players[i].exiting || players[i].lives)
if (players[i].exiting || players[i].lives > 0)
break;
if (players[i].playerstate == PST_DEAD && players[i].deadtimer < deadtimercheck)
deadtimercheck = players[i].deadtimer;
}
if (i == MAXPLAYERS && deadtimercheck >= 8*TICRATE)
if (!countdown2 && i == MAXPLAYERS && deadtimercheck >= 8*TICRATE)
{
// They're dead, Jim.
//nextmapoverride = spstage_start;
nextmapoverride = gamemap;
countdown2 = 1*TICRATE;
countdown2 = TICRATE;
skipstats = true;
for (i = 0; i < MAXPLAYERS; i++)
@ -2697,6 +2693,12 @@ void G_DoReborn(INT32 playernum)
}
}
// Not resetting map, so return to level music
if (!countdown2
&& player->lives <= 0
&& !cv_lifedistribution.value) // not allowed for life steal because no way to come back from zero group lives without addons, which should call this anyways
P_RestoreMultiMusic(player);
if (player->starposttime)
starpost = true;

View File

@ -1391,7 +1391,7 @@ static menuitem_t OP_ServerOptionsMenu[] =
{IT_HEADER, NULL, "Cooperative", NULL, 90},
{IT_STRING | IT_CVAR, NULL, "Players required for exit", &cv_playersforexit, 96},
{IT_STRING | IT_CVAR, NULL, "Play style", &cv_playstyle, 101},
{IT_STRING | IT_CVAR, NULL, "Steal lives on game over", &cv_steallives, 106},
{IT_STRING | IT_CVAR, NULL, "Life distribution", &cv_lifedistribution, 106},
{IT_HEADER, NULL, "Race, Competition", NULL, 115},
{IT_STRING | IT_CVAR, NULL, "Level completion countdown", &cv_countdowntime, 121},

View File

@ -1309,7 +1309,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
players[i].starpostangle = special->angle;
players[i].starpostnum = special->health;
if (cv_playstyle.value == 2 && (P_GetLives(&players[i]) || players[i].lives > 0) && (players[i].playerstate == PST_DEAD || players[i].spectator))
if (cv_playstyle.value == 2 && (players[i].playerstate == PST_DEAD || players[i].spectator) && P_GetLives(&players[i]))
P_SpectatorJoinGame(&players[i]); //players[i].playerstate = PST_REBORN;
}
}
@ -2253,7 +2253,25 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
if (target->player->lives <= 0) // Tails 03-14-2000
{
if (P_IsLocalPlayer(target->player)/* && target->player == &players[consoleplayer] */)
boolean gameovermus = false;
if ((netgame || multiplayer) && (gametype == GT_COOP) && cv_lifedistribution.value)
{
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
if (players[i].lives > 0)
break;
}
if (i == MAXPLAYERS)
gameovermus = true;
}
else if (P_IsLocalPlayer(target->player))
gameovermus = true;
if (gameovermus)
{
S_StopMusic(); // Stop the Music! Tails 03-14-2000
S_ChangeMusicInternal("_gover", false); // Yousa dead now, Okieday? Tails 03-14-2000

View File

@ -9084,10 +9084,10 @@ void P_SpawnPlayer(INT32 playernum)
// spawn as spectator determination
if (!G_GametypeHasSpectators())
{
if ( ((multiplayer || netgame) && gametype == GT_COOP && leveltime > 0)
&& ((G_IsSpecialStage(gamemap) && useNightsSS) // late join special stage
|| (cv_playstyle.value == 2 && (p->jointime < 1 || p->spectator)) // late join or die in new coop
|| (p->lives <= 0 && (!cv_steallives.value || !P_GetLives(p)))) ) // game over
if ( ( (multiplayer || netgame) && gametype == GT_COOP && leveltime > 0) // only question status in coop
&& ( (G_IsSpecialStage(gamemap) && useNightsSS) // late join special stage
|| (cv_playstyle.value == 2 && (p->jointime < 1 || p->spectator) ) // late join or die in new coop
|| ((!cv_lifedistribution.value || !P_GetLives(p)) && p->lives <= 0))) // game over and can't redistribute lives
p->spectator = true;
else
p->spectator = false;

View File

@ -958,7 +958,7 @@ void P_GivePlayerLives(player_t *player, INT32 numlives)
void P_GiveCoopLives(player_t *player, INT32 numlives, boolean sound)
{
if (!((netgame || multiplayer) && gametype == GT_COOP && cv_playstyle.value))
if (!((netgame || multiplayer) && gametype == GT_COOP))
{
P_GivePlayerLives(player, numlives);
if (sound)
@ -8109,12 +8109,12 @@ void P_FindEmerald(void)
boolean P_GetLives(player_t *player)
{
INT32 i, maxlivesplayer = -1, livescheck = 1;
if (!(cv_steallives.value
if (!(cv_lifedistribution.value
&& (gametype == GT_COOP)
&& (netgame || multiplayer)))
return true;
if (player->lives > 0)
if (cv_lifedistribution.value == 1 && player->lives > 0)
return true;
for (i = 0; i < MAXPLAYERS; i++)
@ -8128,17 +8128,17 @@ boolean P_GetLives(player_t *player)
livescheck = players[i].lives;
}
}
if (maxlivesplayer != -1)
if (maxlivesplayer != -1 && &players[maxlivesplayer] != player)
{
if (players[maxlivesplayer].mo)
S_StartSound(players[maxlivesplayer].mo, sfx_jshard); // placeholder
if (cv_lifedistribution.value == 1 && P_IsLocalPlayer(&players[maxlivesplayer]))
S_StartSound(NULL, sfx_jshard); // placeholder
players[maxlivesplayer].lives--;
player->lives++;
if (player->lives < 1)
player->lives = 1;
return true;
}
return false;
return (player->lives > 0);
}
//
@ -8219,7 +8219,7 @@ static void P_DeathThink(player_t *player)
G_UseContinue(); // Even if we don't have one this handles ending the game
}
if (cv_steallives.value
if (cv_lifedistribution.value
&& (gametype == GT_COOP)
&& (netgame || multiplayer)
&& (player->lives <= 0))
@ -8330,7 +8330,7 @@ static void P_DeathThink(player_t *player)
}
// Return to level music
if (player->lives <= 0 && player->deadtimer == gameovertics)
if (gametype != GT_COOP && player->lives <= 0 && player->deadtimer == gameovertics)
P_RestoreMultiMusic(player);
}
@ -9436,11 +9436,7 @@ void P_PlayerThink(player_t *player)
player->realtime = leveltime;
}
if ((netgame || splitscreen) && player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing]
&& (G_GametypeHasSpectators()
|| !((G_IsSpecialStage(gamemap) && useNightsSS)
|| (gametype == GT_COOP && cv_playstyle.value == 2)
)))
if (player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing] && G_GametypeHasSpectators())
{
if (P_SpectatorJoinGame(player))
return; // player->mo was removed.

View File

@ -728,31 +728,59 @@ static void ST_drawLives(void)
// x
V_DrawScaledPatch(hudinfo[HUD_LIVESX].x, hudinfo[HUD_LIVESX].y + (v_splitflag ? -4 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, stlivex);
// lives
V_DrawRightAlignedString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, va("%d",stplyr->lives));
if (cv_steallives.value
&& (gametype == GT_COOP)
&& (netgame || multiplayer))
// lives number
if ((netgame || multiplayer) && gametype == GT_COOP)
{
INT32 i, sum = 0;
for (i = 0; i < MAXPLAYERS; i++)
switch (cv_lifedistribution.value)
{
if (!playeringame[i])
continue;
case 2:
{
INT32 i, sum = 0;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
if (&players[i] == stplyr)
continue;
if (players[i].lives < 1)
continue;
if (players[i].lives < 2)
continue;
sum += (players[i].lives);
}
V_DrawRightAlignedString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,
va("%d",(sum)));
return;
}
case 1:
{
INT32 i, sum = 0;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i])
continue;
sum += (players[i].lives - 1);
if (&players[i] == stplyr)
continue;
if (players[i].lives < 2)
continue;
sum += (players[i].lives - 1);
}
V_DrawString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|v_splitflag, va("/%d",sum));
}
// intentional fallthrough
default:
// don't return so the SP one can be drawn below
break;
}
V_DrawString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|v_splitflag, va("/%d",sum));
}
V_DrawRightAlignedString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0),
V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,
va("%d",stplyr->lives));
}
static void ST_drawLevelTitle(void)
@ -1847,11 +1875,8 @@ static void ST_overlayDrawer(void)
else
p = sboover;
V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, STRINGY(BASEVIDHEIGHT/2 - (SHORT(p->height)/2)), 0, p);
if (cv_steallives.value
&& (gametype == GT_COOP)
&& (netgame || multiplayer))
if (cv_lifedistribution.value
&& gametype == GT_COOP)
{
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
@ -1862,13 +1887,16 @@ static void ST_overlayDrawer(void)
if (&players[i] == stplyr)
continue;
if (players[i].lives > 1)
if (players[i].lives > 0)
{
p = NULL;
break;
}
}
if (i != MAXPLAYERS)
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(BASEVIDHEIGHT/2 + (SHORT(p->height)/2)) + 14, 0, M_GetText("You'll steal a life on respawn."));
}
if (p)
V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, STRINGY(BASEVIDHEIGHT/2 - (SHORT(p->height)/2)), (stplyr->spectator ? V_HUDTRANSHALF : V_HUDTRANS), p);
}
@ -1953,15 +1981,16 @@ static void ST_overlayDrawer(void)
)
ST_drawLevelTitle();
if (!hu_showscores && !splitscreen && netgame && displayplayer == consoleplayer)
if (!hu_showscores && (netgame || multiplayer) && displayplayer == consoleplayer)
{
if (G_GametypeUsesLives() && stplyr->lives <= 0 && countdown != 1)
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press F12 to watch another player."));
if (!splitscreen && G_GametypeUsesLives() && stplyr->lives <= 0 && countdown != 1)
V_DrawCenteredString(BASEVIDWIDTH/2, 132, 0, M_GetText("Press F12 to watch another player."));
else if (gametype == GT_HIDEANDSEEK &&
(!stplyr->spectator && !(stplyr->pflags & PF_TAGIT)) && (leveltime > hidetime * TICRATE))
{
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(116), 0, M_GetText("You cannot move while hiding."));
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press F12 to watch another player."));
if (!splitscreen)
V_DrawCenteredString(BASEVIDWIDTH/2, 132, 0, M_GetText("Press F12 to watch another player."));
}
else if (!G_PlatformGametype() && stplyr->playerstate == PST_DEAD && stplyr->lives) //Death overrides spectator text.
{
@ -1971,20 +2000,20 @@ static void ST_overlayDrawer(void)
else
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Jump to respawn."));
}
else if (stplyr->spectator
else if (stplyr->spectator && (gametype != GT_COOP || stplyr->playerstate == PST_LIVE)
#ifdef HAVE_BLUA
&& LUA_HudEnabled(hud_textspectator)
#endif
)
{
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60), V_HUDTRANSHALF, M_GetText("You are a spectator."));
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(60)+(splitscreen ? 4 : 0), V_HUDTRANSHALF, M_GetText("You are a spectator."));
if (G_GametypeHasTeams())
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
if (cv_lifedistribution.value == 1
&& (netgame || multiplayer))
{
INT32 i;
@ -2001,13 +2030,18 @@ static void ST_overlayDrawer(void)
}
if (i != MAXPLAYERS)
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("You'll steal a life on respawn."));
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132)-(splitscreen ? 8 : 0), 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."));
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(164), V_HUDTRANSHALF, M_GetText("Press Jump to float and Spin to sink."));
if (!splitscreen)
{
V_DrawCenteredString(BASEVIDWIDTH/2, 148, V_HUDTRANSHALF, M_GetText("Press F12 to watch another player."));
V_DrawCenteredString(BASEVIDWIDTH/2, 164, V_HUDTRANSHALF, M_GetText("Press Jump to float and Spin to sink."));
}
else
V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(144), V_HUDTRANSHALF, M_GetText("Press Jump to float and Spin to sink."));
}
}