Same deal, but for starposts.

This commit is contained in:
Jaime Passos 2019-12-27 17:14:56 -03:00
parent 1f96f70173
commit 3b341245f1
6 changed files with 34 additions and 10 deletions

View File

@ -2890,11 +2890,11 @@ void G_DoReborn(INT32 playernum)
if (countdowntimeup || (!(netgame || multiplayer) && gametype == GT_COOP))
resetlevel = true;
else if (gametype == GT_COOP && (netgame || multiplayer) && !G_IsSpecialStage(gamemap))
else if ((G_GametypeUsesCoopLives() || G_GametypeUsesCoopStarposts()) && (netgame || multiplayer) && !G_IsSpecialStage(gamemap))
{
boolean notgameover = true;
if (cv_cooplives.value != 0 && player->lives <= 0) // consider game over first
if (G_GametypeUsesCoopLives() && (cv_cooplives.value != 0 && player->lives <= 0)) // consider game over first
{
for (i = 0; i < MAXPLAYERS; i++)
{
@ -2929,7 +2929,7 @@ void G_DoReborn(INT32 playernum)
}
}
if (notgameover && cv_coopstarposts.value == 2)
if (G_GametypeUsesCoopStarposts() && (notgameover && cv_coopstarposts.value == 2))
{
for (i = 0; i < MAXPLAYERS; i++)
{
@ -3005,7 +3005,7 @@ void G_DoReborn(INT32 playernum)
}
// restore time in netgame (see also p_setup.c)
if ((netgame || multiplayer) && gametype == GT_COOP && cv_coopstarposts.value == 2)
if ((netgame || multiplayer) && G_GametypeUsesCoopStarposts() && cv_coopstarposts.value == 2)
{
// is this a hack? maybe
tic_t maxstarposttime = 0;
@ -3076,7 +3076,7 @@ void G_AddPlayer(INT32 playernum)
if (!players[i].exiting)
notexiting++;
if (!(cv_coopstarposts.value && (gametype == GT_COOP) && (p->starpostnum < players[i].starpostnum)))
if (!(cv_coopstarposts.value && G_GametypeUsesCoopStarposts() && (p->starpostnum < players[i].starpostnum)))
continue;
p->starpostscale = players[i].starpostscale;
@ -3453,6 +3453,20 @@ boolean G_GametypeUsesCoopLives(void)
return (gametype == GT_COOP);
}
//
// G_GametypeUsesCoopStarposts
//
// Returns true if the current gametype uses
// the coopstarposts CVAR. False otherwise.
//
boolean G_GametypeUsesCoopStarposts(void)
{
// Preparing for the inevitable
// gametype rule that will
// handle coopstarposts...
return (gametype == GT_COOP);
}
//
// G_GametypeHasTeams
//

View File

@ -219,6 +219,7 @@ INT32 G_GetGametypeByName(const char *gametypestr);
boolean G_IsSpecialStage(INT32 mapnum);
boolean G_GametypeUsesLives(void);
boolean G_GametypeUsesCoopLives(void);
boolean G_GametypeUsesCoopStarposts(void);
boolean G_GametypeHasTeams(void);
boolean G_GametypeHasSpectators(void);
boolean G_RingSlingerGametype(void);

View File

@ -2862,6 +2862,14 @@ static int lib_gGametypeUsesCoopLives(lua_State *L)
return 1;
}
static int lib_gGametypeUsesCoopStarposts(lua_State *L)
{
//HUDSAFE
INLEVEL
lua_pushboolean(L, G_GametypeUsesCoopStarposts());
return 1;
}
static int lib_gGametypeHasTeams(lua_State *L)
{
//HUDSAFE
@ -3156,6 +3164,7 @@ static luaL_Reg lib[] = {
{"G_IsSpecialStage",lib_gIsSpecialStage},
{"G_GametypeUsesLives",lib_gGametypeUsesLives},
{"G_GametypeUsesCoopLives",lib_gGametypeUsesCoopLives},
{"G_GametypeUsesCoopStarposts",lib_gGametypeUsesCoopStarposts},
{"G_GametypeHasTeams",lib_gGametypeHasTeams},
{"G_GametypeHasSpectators",lib_gGametypeHasSpectators},
{"G_RingSlingerGametype",lib_gRingSlingerGametype},

View File

@ -1451,7 +1451,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
if (player->starpostnum >= special->health)
return; // Already hit this post
if (cv_coopstarposts.value && gametype == GT_COOP && (netgame || multiplayer))
if (cv_coopstarposts.value && G_GametypeUsesCoopStarposts() && (netgame || multiplayer))
{
for (i = 0; i < MAXPLAYERS; i++)
{

View File

@ -2141,7 +2141,7 @@ static void P_LevelInitStuff(void)
// earthquake camera
memset(&quake,0,sizeof(struct quake));
if ((netgame || multiplayer) && gametype == GT_COOP && cv_coopstarposts.value == 2)
if ((netgame || multiplayer) && G_GametypeUsesCoopStarposts() && cv_coopstarposts.value == 2)
{
for (i = 0; i < MAXPLAYERS; i++)
{
@ -2848,7 +2848,7 @@ boolean P_SetupLevel(boolean skipprecip)
}
// restore time in netgame (see also g_game.c)
if ((netgame || multiplayer) && gametype == GT_COOP && cv_coopstarposts.value == 2)
if ((netgame || multiplayer) && G_GametypeUsesCoopStarposts() && cv_coopstarposts.value == 2)
{
// is this a hack? maybe
tic_t maxstarposttime = 0;

View File

@ -9447,7 +9447,7 @@ static void P_DeathThink(player_t *player)
player->playerstate = PST_REBORN;
else if ((player->lives > 0 || j != MAXPLAYERS) && !(!(netgame || multiplayer) && G_IsSpecialStage(gamemap))) // Don't allow "click to respawn" in special stages!
{
if (gametype == GT_COOP && (netgame || multiplayer) && cv_coopstarposts.value == 2)
if (G_GametypeUsesCoopStarposts() && (netgame || multiplayer) && cv_coopstarposts.value == 2)
{
P_ConsiderAllGone();
if ((player->deadtimer > TICRATE<<1) || ((cmd->buttons & BT_JUMP) && (player->deadtimer > TICRATE)))
@ -11537,7 +11537,7 @@ void P_PlayerThink(player_t *player)
#else
if (player->spectator &&
#endif
gametype == GT_COOP && (netgame || multiplayer) && cv_coopstarposts.value == 2)
G_GametypeUsesCoopStarposts() && (netgame || multiplayer) && cv_coopstarposts.value == 2)
P_ConsiderAllGone();
if (player->playerstate == PST_DEAD)