G_CoopGametype, for all the GT_COOP cases

This commit is contained in:
Jaime Passos 2020-02-29 00:57:22 -03:00
parent 6fb5a6efb6
commit 4e7b47440f
10 changed files with 58 additions and 38 deletions

View File

@ -3743,7 +3743,7 @@ static void ExitMove_OnChange(void)
{
UINT8 i;
if (!(netgame || multiplayer) || gametype != GT_COOP)
if (!(netgame || multiplayer) || !G_CoopGametype())
return;
if (cv_exitmove.value)

View File

@ -3131,7 +3131,7 @@ void G_AddPlayer(INT32 playernum)
p->height = mobjinfo[MT_PLAYER].height;
if (G_GametypeUsesLives() || ((netgame || multiplayer) && gametype == GT_COOP))
if (G_GametypeUsesLives() || ((netgame || multiplayer) && (gametyperules & GTR_FRIENDLY)))
p->lives = cv_startinglives.value;
if ((countplayers && !notexiting) || G_IsSpecialStage(gamemap))
@ -3591,6 +3591,16 @@ boolean G_PlatformGametype(void)
return (!(gametyperules & GTR_RINGSLINGER));
}
//
// G_CoopGametype
//
// Returns true if a gametype is a Co-op gametype.
//
boolean G_CoopGametype(void)
{
return ((gametyperules & (GTR_FRIENDLY|GTR_CAMPAIGN)) == (GTR_FRIENDLY|GTR_CAMPAIGN));
}
//
// G_TagGametype
//

View File

@ -253,6 +253,7 @@ boolean G_GametypeHasTeams(void);
boolean G_GametypeHasSpectators(void);
boolean G_RingSlingerGametype(void);
boolean G_PlatformGametype(void);
boolean G_CoopGametype(void);
boolean G_TagGametype(void);
boolean G_CompetitionGametype(void);
boolean G_EnoughPlayersFinished(void);

View File

@ -2175,7 +2175,7 @@ void HU_Drawer(void)
if (LUA_HudEnabled(hud_rankings))
#endif
HU_DrawRankings();
if (gametype == GT_COOP)
if (gametyperules & GTR_CAMPAIGN)
HU_DrawNetplayCoopOverlay();
}
else

View File

@ -2937,6 +2937,14 @@ static int lib_gPlatformGametype(lua_State *L)
return 1;
}
static int lib_gCoopGametype(lua_State *L)
{
//HUDSAFE
INLEVEL
lua_pushboolean(L, G_CoopGametype());
return 1;
}
static int lib_gTagGametype(lua_State *L)
{
//HUDSAFE
@ -3209,6 +3217,7 @@ static luaL_Reg lib[] = {
{"G_GametypeHasSpectators",lib_gGametypeHasSpectators},
{"G_RingSlingerGametype",lib_gRingSlingerGametype},
{"G_PlatformGametype",lib_gPlatformGametype},
{"G_CoopGametype",lib_gCoopGametype},
{"G_TagGametype",lib_gTagGametype},
{"G_CompetitionGametype",lib_gCompetitionGametype},
{"G_TicsToHours",lib_gTicsToHours},

View File

@ -2525,7 +2525,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
}
P_RestoreMusic(target->player);
if (gametype != GT_COOP)
if (!G_CoopGametype())
{
HU_SetCEchoFlags(0);
HU_SetCEchoDuration(5);
@ -3257,7 +3257,7 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage)
}
// If the player was super, tell them he/she ain't so super nomore.
if (gametype != GT_COOP && player->powers[pw_super])
if (!G_CoopGametype() && player->powers[pw_super])
{
S_StartSound(NULL, sfx_s3k66); //let all players hear it.
HU_SetCEchoFlags(0);
@ -3627,7 +3627,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (source == target)
return false; // Don't hit yourself with your own paraloop, baka
if (source && source->player && !(cv_friendlyfire.value || (gametyperules & GTR_FRIENDLYFIRE))
&& (gametype == GT_COOP
&& ((gametyperules & GTR_FRIENDLY)
|| (G_GametypeHasTeams() && player->ctfteam == source->player->ctfteam)))
return false; // Don't run eachother over in special stages and team games and such
}

View File

@ -11440,7 +11440,7 @@ void P_SpawnPlayer(INT32 playernum)
if (!G_GametypeHasSpectators())
{
p->spectator = p->outofcoop =
(((multiplayer || netgame) && gametype == GT_COOP) // only question status in coop
(((multiplayer || netgame) && G_CoopGametype()) // only question status in coop
&& ((leveltime > 0
&& ((G_IsSpecialStage(gamemap)) // late join special stage
|| (cv_coopstarposts.value == 2 && (p->jointime < 1 || p->outofcoop)))) // late join or die in new coop
@ -11594,7 +11594,7 @@ void P_AfterPlayerSpawn(INT32 playernum)
if (CheckForReverseGravity)
P_CheckGravity(mobj, false);
if (p->pflags & PF_FINISHED)
P_GiveFinishFlags(p);
}
@ -11918,7 +11918,7 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i)
case MT_EMERALD5:
case MT_EMERALD6:
case MT_EMERALD7:
if (gametype != GT_COOP) // Don't place emeralds in non-coop modes
if (!G_CoopGametype()) // Don't place emeralds in non-coop modes
return false;
if (metalrecording)
@ -11938,7 +11938,7 @@ static boolean P_AllowMobjSpawn(mapthing_t* mthing, mobjtype_t i)
runemeraldmanager = true;
break;
case MT_ROSY:
if (!(gametype == GT_COOP || (mthing->options & MTF_EXTRA)))
if (!(G_CoopGametype() || (mthing->options & MTF_EXTRA)))
return false; // she doesn't hang out here
if (!mariomode && !(netgame || multiplayer) && players[consoleplayer].skin == 3)
@ -12053,7 +12053,7 @@ static mobjtype_t P_GetMobjtypeSubstitute(mapthing_t *mthing, mobjtype_t i)
}
}
// Set powerup boxes to user settings for other netplay modes
else if (gametype != GT_COOP)
else if (!G_CoopGametype())
{
switch (cv_matchboxes.value)
{

View File

@ -4100,7 +4100,7 @@ void P_SetupSignExit(player_t *player)
if (!numfound
&& !(player->mo->target && player->mo->target->type == MT_SIGN)
&& !(gametype == GT_COOP && (netgame || multiplayer) && cv_exitmove.value))
&& !(G_CoopGametype() && (netgame || multiplayer) && cv_exitmove.value))
P_SetTarget(&player->mo->target, thing);
if (thing->state != &states[thing->info->spawnstate])
@ -4131,7 +4131,7 @@ void P_SetupSignExit(player_t *player)
if (!numfound
&& !(player->mo->target && player->mo->target->type == MT_SIGN)
&& !(gametype == GT_COOP && (netgame || multiplayer) && cv_exitmove.value))
&& !(G_CoopGametype() && (netgame || multiplayer) && cv_exitmove.value))
P_SetTarget(&player->mo->target, thing);
if (thing->state != &states[thing->info->spawnstate])
@ -4486,7 +4486,7 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
continue;
if (players[i].bot)
continue;
if (gametype == GT_COOP && players[i].lives <= 0)
if (G_CoopGametype() && players[i].lives <= 0)
continue;
if (roversector)
{
@ -4717,7 +4717,7 @@ DoneSection2:
// FOF custom exits not to work.
lineindex = P_FindSpecialLineFromTag(2, sector->tag, -1);
if (gametype == GT_COOP && lineindex != -1) // Custom exit!
if (G_CoopGametype() && lineindex != -1) // Custom exit!
{
// Special goodies with the block monsters flag depending on emeralds collected
if ((lines[lineindex].flags & ML_BLOCKMONSTERS) && ALL7EMERALDS(emeralds))

View File

@ -1351,7 +1351,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings)
player->powers[pw_sneakers] = 0;
}
if (gametype != GT_COOP)
if (!G_CoopGametype())
{
HU_SetCEchoFlags(0);
HU_SetCEchoDuration(5);
@ -1418,7 +1418,7 @@ void P_AddPlayerScore(player_t *player, UINT32 amount)
}
}
if (gametype == GT_COOP)
if (G_CoopGametype())
return;
}
@ -4305,7 +4305,7 @@ static void P_DoSuperStuff(player_t *player)
G_GhostAddColor(GHC_NORMAL);
}
if (gametype != GT_COOP)
if (!G_CoopGametype())
{
HU_SetCEchoFlags(0);
HU_SetCEchoDuration(5);
@ -4355,14 +4355,14 @@ static void P_DoSuperStuff(player_t *player)
G_GhostAddColor(GHC_NORMAL);
}
if (gametype != GT_COOP)
if (!G_CoopGametype())
player->powers[pw_flashing] = flashingtics-1;
if (player->mo->sprite2 & FF_SPR2SUPER)
P_SetPlayerMobjState(player->mo, player->mo->state-states);
// Inform the netgame that the champion has fallen in the heat of battle.
if (gametype != GT_COOP)
if (!G_CoopGametype())
{
S_StartSound(NULL, sfx_s3k66); //let all players hear it.
HU_SetCEchoFlags(0);
@ -9639,7 +9639,7 @@ static void P_DeathThink(player_t *player)
}
if ((cv_cooplives.value != 1)
&& (gametype == GT_COOP)
&& (G_GametypeUsesCoopLives())
&& (netgame || multiplayer)
&& (player->lives <= 0))
{
@ -9721,17 +9721,17 @@ static void P_DeathThink(player_t *player)
countdown2 = 1*TICRATE;
}
}
//else if (gametype == GT_COOP) -- moved to G_DoReborn
//else if (G_CoopGametype()) -- moved to G_DoReborn
}
if (gametype == GT_COOP && (multiplayer || netgame) && (player->lives <= 0) && (player->deadtimer >= 8*TICRATE || ((cmd->buttons & BT_JUMP) && (player->deadtimer > TICRATE))))
if (G_CoopGametype() && (multiplayer || netgame) && (player->lives <= 0) && (player->deadtimer >= 8*TICRATE || ((cmd->buttons & BT_JUMP) && (player->deadtimer > TICRATE))))
{
//player->spectator = true;
player->outofcoop = true;
player->playerstate = PST_REBORN;
}
if ((gametyperules & GTR_RACE) || (gametype == GT_COOP && (multiplayer || netgame)))
if ((gametyperules & GTR_RACE) || (G_CoopGametype() && (multiplayer || netgame)))
{
// Keep time rolling in race mode
if (!(countdown2 && !countdown) && !player->exiting && !(player->pflags & PF_GAMETYPEOVER) && !stoppedclock)
@ -9748,7 +9748,7 @@ static void P_DeathThink(player_t *player)
}
// Return to level music
if (gametype != GT_COOP && player->lives <= 0 && player->deadtimer == gameovertics)
if (!G_CoopGametype() && player->lives <= 0 && player->deadtimer == gameovertics)
P_RestoreMultiMusic(player);
}
@ -9925,7 +9925,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (player->exiting)
{
if (mo->target && mo->target->type == MT_SIGN && mo->target->spawnpoint
&& !(gametype == GT_COOP && (netgame || multiplayer) && cv_exitmove.value)
&& !(G_CoopGametype() && (netgame || multiplayer) && cv_exitmove.value)
&& !(twodlevel || (mo->flags2 & MF2_TWOD)))
sign = mo->target;
else if ((player->powers[pw_carry] == CR_NIGHTSMODE)
@ -10594,7 +10594,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
boolean P_SpectatorJoinGame(player_t *player)
{
if (gametype != GT_COOP && !cv_allowteamchange.value)
if (!G_CoopGametype() && !cv_allowteamchange.value)
{
if (P_IsLocalPlayer(player))
CONS_Printf(M_GetText("Server does not allow team change.\n"));
@ -10705,7 +10705,7 @@ boolean P_SpectatorJoinGame(player_t *player)
displayplayer = consoleplayer;
}
if (gametype != GT_COOP)
if (!G_CoopGametype())
CONS_Printf(M_GetText("%s entered the game.\n"), player_names[player-players]);
return true; // no more player->mo, cannot continue.
}
@ -11753,7 +11753,7 @@ void P_PlayerThink(player_t *player)
// so we can fade music
if (!exitfadestarted &&
player->exiting > 0 && player->exiting <= 1*TICRATE &&
(!multiplayer || gametype == GT_COOP ? !mapheaderinfo[gamemap-1]->musinterfadeout : true) &&
(!multiplayer || G_CoopGametype() ? !mapheaderinfo[gamemap-1]->musinterfadeout : true) &&
// don't fade if we're fading during intermission. follows Y_StartIntermission intertype = int_coop
((gametyperules & GTR_RACE) ? countdown2 == 0 : true) && // don't fade on timeout
player->lives > 0 && // don't fade on game over (competition)
@ -11826,7 +11826,7 @@ void P_PlayerThink(player_t *player)
if (player->pflags & PF_FINISHED)
{
if ((gametype == GT_COOP && cv_exitmove.value) && !G_EnoughPlayersFinished())
if ((G_CoopGametype() && cv_exitmove.value) && !G_EnoughPlayersFinished())
player->exiting = 0;
else
P_DoPlayerExit(player);
@ -11864,10 +11864,10 @@ void P_PlayerThink(player_t *player)
// Make sure spectators always have a score and ring count of 0.
if (player->spectator)
{
if (gametype != GT_COOP)
if (!(gametyperules & GTR_CAMPAIGN))
player->score = 0;
}
else if ((netgame || multiplayer) && player->lives <= 0 && gametype != GT_COOP)
else if ((netgame || multiplayer) && player->lives <= 0 && !G_CoopGametype())
{
// Outside of Co-Op, replenish a user's lives if they are depleted.
// of course, this is just a cheap hack, meh...
@ -12732,7 +12732,7 @@ void P_PlayerAfterThink(player_t *player)
player->mo->momz = tails->momz;
}
if (gametype == GT_COOP && (!tails->player || tails->player->bot != 1))
if (G_CoopGametype() && (!tails->player || tails->player->bot != 1))
{
player->mo->angle = tails->angle;

View File

@ -2239,7 +2239,7 @@ static void ST_drawTextHUD(void)
if (F_GetPromptHideHud(y))
return;
if (stplyr->spectator && (gametype != GT_COOP || stplyr->playerstate == PST_LIVE))
if (stplyr->spectator && (!G_CoopGametype() || stplyr->playerstate == PST_LIVE))
textHUDdraw(M_GetText("\x86""Spectator mode:"))
if (circuitmap)
@ -2250,7 +2250,7 @@ static void ST_drawTextHUD(void)
textHUDdraw(va("Lap:""\x82 %u/%d", stplyr->laps+1, cv_numlaps.value))
}
if (gametype != GT_COOP && (stplyr->exiting || (G_GametypeUsesLives() && stplyr->lives <= 0 && countdown != 1)))
if (!G_CoopGametype() && (stplyr->exiting || (G_GametypeUsesLives() && stplyr->lives <= 0 && countdown != 1)))
{
if (!splitscreen && !donef12)
{
@ -2267,7 +2267,7 @@ static void ST_drawTextHUD(void)
else
textHUDdraw(M_GetText("\x82""JUMP:""\x80 Respawn"))
}
else if (stplyr->spectator && (gametype != GT_COOP || stplyr->playerstate == PST_LIVE))
else if (stplyr->spectator && (!G_CoopGametype() || stplyr->playerstate == PST_LIVE))
{
if (!splitscreen && !donef12)
{
@ -2314,7 +2314,7 @@ static void ST_drawTextHUD(void)
textHUDdraw(M_GetText("\x82""FIRE:""\x80 Enter game"))
}
if (gametype == GT_COOP && (!stplyr->spectator || (!(maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap))) && (stplyr->exiting || (stplyr->pflags & PF_FINISHED)))
if (G_CoopGametype() && (!stplyr->spectator || (!(maptol & TOL_NIGHTS) && G_IsSpecialStage(gamemap))) && (stplyr->exiting || (stplyr->pflags & PF_FINISHED)))
{
UINT8 numneeded = (G_IsSpecialStage(gamemap) ? 4 : cv_playersforexit.value);
if (numneeded)
@ -2683,7 +2683,7 @@ static void ST_overlayDrawer(void)
}
// GAME OVER hud
if ((gametype == GT_COOP)
if (G_GametypeUsesCoopLives()
&& (netgame || multiplayer)
&& (cv_cooplives.value == 0))
;