From 7564aa466effe6a2eaf60618b1d4f8c3233da761 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 22 Jul 2018 16:16:03 +0100 Subject: [PATCH] * FREE PLAY! The necessary corollary to HERE COMES A NEW CHALLENGER... * Activates when there are less than two non-spectators in a netgame. * Shows flashing text at the bottom of the screen. * Prevents drawing several UI elements that only make sense with multiple players. * Prevents matchesplayed being increased. * Improve the mapreset timer's behaviour. * Now you get to see the HERE COMES A NEW CHALLENGER screen as the starting frame of the relevant map transition, since it happens on mapreset being 1 rather than 0. * Make a bunch of normal gameplay stuff that might've activated unnecessarily during mapreset now not able to. * Hide some other stuff that might've been visible for no good reason. * Improve Mirror mode. * First person now works with it! * Tweaked the minimap player heads. Although the main section of the automap is mirrored, it feels... wrong to mirror the player head? IDK, you may wish to revert this, but given that everything else is the right way around except for the level itself...* Disable the titlescreen demos, at least until we actually gear up for release and make real ones. * Disable the titlescreen demos, at least until we actually gear up for release and make real ones. --- src/g_game.c | 32 +++++++++--- src/hu_stuff.c | 3 ++ src/k_kart.c | 85 ++++++++++++++++++++++++++------ src/k_kart.h | 1 + src/p_tick.c | 8 ++- src/p_user.c | 129 +++++++++++++++++++++++++------------------------ src/st_stuff.c | 18 +++---- src/y_inter.c | 21 ++++++-- 8 files changed, 194 insertions(+), 103 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index beb40ba5..801a810f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -95,7 +95,7 @@ boolean imcontinuing = false; boolean runemeraldmanager = false; // menu demo things -UINT8 numDemos = 3; +UINT8 numDemos = 0; //3; -- i'm FED UP of losing my skincolour to a broken demo. change this back when we make new ones UINT32 demoDelayTime = 15*TICRATE; UINT32 demoIdleTime = 3*TICRATE; @@ -2235,13 +2235,30 @@ static inline void G_PlayerFinishLevel(INT32 player) // SRB2kart: Increment the "matches played" counter. if (player == consoleplayer) { - if (legitimateexit && !demoplayback) // (yes you're allowed to unlock stuff this way when the game is modified) + if (legitimateexit && !demoplayback && !mapreset) // (yes you're allowed to unlock stuff this way when the game is modified) { - matchesplayed++; - if (M_UpdateUnlockablesAndExtraEmblems(true)) + UINT8 i = 0; + + if (netgame) { - S_StartSound(NULL, sfx_ncitem); - G_SaveGameData(true); // only save if unlocked something + // check to see if there's anyone else at all + for (; i < MAXPLAYERS; i++) + { + if (i == consoleplayer) + continue; + if (playeringame[i] && !stplyr->spectator) + break; + } + } + + if (i != MAXPLAYERS) // Not FREE PLAY + { + matchesplayed++; + if (M_UpdateUnlockablesAndExtraEmblems(true)) + { + S_StartSound(NULL, sfx_ncitem); + G_SaveGameData(true); // only save if unlocked something + } } } @@ -3467,6 +3484,7 @@ static void G_DoStartContinue(void) { I_Assert(!netgame && !multiplayer); + legitimateexit = false; G_PlayerFinishLevel(consoleplayer); // take away cards and stuff F_StartContinue(); @@ -4092,7 +4110,7 @@ void G_InitNew(UINT8 pultmode, const char *mapname, boolean resetplayer, boolean { // Clear a bunch of variables tokenlist = token = sstimer = redscore = bluescore = lastmap = 0; - countdown = countdown2 = 0; + countdown = countdown2 = mapreset = 0; for (i = 0; i < MAXPLAYERS; i++) { diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 329d5879..fd71470b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1757,6 +1757,9 @@ static void HU_DrawRankings(void) numplayersingame++; } + if (netgame && numplayersingame <= 1) + K_drawKartFreePlay(leveltime); + for (j = 0; j < numplayersingame; j++) { UINT8 lowestposition = MAXPLAYERS; diff --git a/src/k_kart.c b/src/k_kart.c index bee9aa0f..6a4286ce 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4846,7 +4846,7 @@ static void K_DrawKartPositionNum(INT32 num) } } -static void K_drawKartPositionFaces(void) +static boolean K_drawKartPositionFaces(void) { // FACE_X = 15; // 15 // FACE_Y = 72; // 72 @@ -4855,7 +4855,7 @@ static void K_drawKartPositionFaces(void) INT32 i, j, ranklines; boolean completed[MAXPLAYERS]; INT32 rankplayer[MAXPLAYERS]; - INT32 bumperx; + INT32 bumperx, numplayersingame = 0; UINT8 *colormap; patch_t *localpatch = kp_facenull; @@ -4864,13 +4864,20 @@ static void K_drawKartPositionFaces(void) memset(rankplayer, 0, sizeof (rankplayer)); for (i = 0; i < MAXPLAYERS; i++) + { rankplayer[i] = -1; - for (j = 0; j < MAXPLAYERS; j++) - { - if (!playeringame[j] || players[j].spectator || !players[j].mo) + if (!playeringame[i] || players[i].spectator || !players[i].mo) continue; + numplayersingame++; + } + + if (numplayersingame <= 1) + return true; + + for (j = 0; j < numplayersingame; j++) + { for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && completed[i] == false && players[i].mo && !players[i].spectator @@ -4934,6 +4941,8 @@ static void K_drawKartPositionFaces(void) Y += 18; } + + return false; } static void K_drawKartLaps(void) @@ -5142,12 +5151,12 @@ static void K_drawKartPlayerCheck(void) { UINT8 pnum = 0; + if (&players[i] == stplyr) + continue; if (!playeringame[i] || players[i].spectator) continue; if (!players[i].mo) continue; - if (&players[i] == stplyr) - continue; if ((players[i].kartstuff[k_invincibilitytimer] <= 0) && (leveltime & 2)) pnum++; // white frames @@ -5263,14 +5272,18 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags, pat amnumxpos = (FixedMul(mo->x, zoom) - FixedMul(xoffset, zoom)); amnumypos = -(FixedMul(mo->y, zoom) - FixedMul(yoffset, zoom)); + if (mirrormode) + amnumxpos = -amnumxpos; + amxpos = amnumxpos + ((x + AutomapPic->width/2 - (iconprefix[skin]->width/2))<height/2 - (iconprefix[skin]->height/2))<width/2 + (iconprefix[skin]->width/2))<color) // 'default' color V_DrawSciencePatch(amxpos, amypos, flags, iconprefix[skin], FRACUNIT); @@ -5538,6 +5551,22 @@ static void K_drawBattleFullscreen(void) V_DrawKartString(x-txoff, ty, 0, va("%d", stplyr->kartstuff[k_comebacktimer]/TICRATE)); } } + + if (netgame && !stplyr->spectator && timeinmap > 113) // FREE PLAY? + { + UINT8 i; + + // check to see if there's anyone else at all + for (i = 0; i < MAXPLAYERS; i++) + { + if (i == displayplayer) + continue; + if (playeringame[i] && !stplyr->spectator) + return; + } + + K_drawKartFreePlay(leveltime); + } } static void K_drawKartFirstPerson(void) @@ -5590,6 +5619,9 @@ static void K_drawKartFirstPerson(void) else // forward target = 0; + if (mirrormode) + target = -target; + if (pn < target) pn++; else if (pn > target) @@ -5654,7 +5686,10 @@ static void K_drawKartFirstPerson(void) if (stplyr->mo->momz > 0) // TO-DO: Draw more of the kart so we can remove this if! yoffs += stplyr->mo->momz/3; - x += xoffs; + if (mirrormode) + x -= xoffs; + else + x += xoffs; if (!splitscreen) y += yoffs; } @@ -5798,8 +5833,19 @@ static void K_drawCheckpointDebugger(void) V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); } +void K_drawKartFreePlay(UINT32 flashtime) +{ + if ((flashtime % TICRATE) < TICRATE/2) + return; + + V_DrawKartString(BASEVIDWIDTH/2 - (6*9), // horizontally centered, nice + LAPS_Y+3, V_SNAPTOBOTTOM, "FREE PLAY"); +} + void K_drawKartHUD(void) { + boolean isfreeplay = false; + // Define the X and Y for each drawn object // This is handled by console/menu values K_initKartHUD(); @@ -5863,9 +5909,8 @@ void K_drawKartHUD(void) if (!modeattacking) { - // The little triple-item icons at the bottom // The top-four faces on the left - K_drawKartPositionFaces(); + isfreeplay = K_drawKartPositionFaces(); } } @@ -5883,11 +5928,18 @@ void K_drawKartHUD(void) K_drawKartSpeedometer(); } - if (!modeattacking) + if (isfreeplay) + ; + else if (!modeattacking) { // Draw the numerical position K_DrawKartPositionNum(stplyr->kartstuff[k_position]); } + else //if (!(demoplayback && hu_showscores)) + { + // Draw the input UI + K_drawInput(); + } // You're about to DIEEEEE K_drawSPBWarning(); @@ -5897,9 +5949,6 @@ void K_drawKartHUD(void) // Draw the hits left! K_drawKartBumpersOrKarma(); } - - if (modeattacking) //&& !(demoplayback && hu_showscores)) - K_drawInput(); } // Draw the countdowns after everything else. @@ -5924,6 +5973,10 @@ void K_drawKartHUD(void) if (cv_kartdebugcheckpoint.value) K_drawCheckpointDebugger(); + + // Draw FREE PLAY. + if (isfreeplay && !stplyr->spectator && timeinmap > 113) + K_drawKartFreePlay(leveltime); } //} diff --git a/src/k_kart.h b/src/k_kart.h index 6a128cb5..81173380 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -56,6 +56,7 @@ INT32 K_calcSplitFlags(INT32 snapflags); void K_LoadKartHUDGraphics(void); fixed_t K_FindCheckX(fixed_t px, fixed_t py, angle_t ang, fixed_t mx, fixed_t my); void K_drawKartHUD(void); +void K_drawKartFreePlay(UINT32 flashtime); void K_LoadIconGraphics(char *facestr, INT32 skinnum); void K_ReloadSkinIconGraphics(void); diff --git a/src/p_tick.c b/src/p_tick.c index c36c9312..b9aaccf7 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -741,12 +741,10 @@ void P_Ticker(boolean run) if (modeattacking) G_GhostTicker(); - if (mapreset && --mapreset <= 0) - { - mapreset = 0; - if (server) + if (mapreset > 1 + && --mapreset <= 1 + && server) // Remember: server uses it for mapchange, but EVERYONE ticks down for the animation D_MapChange(gamemap, gametype, ultimatemode, true, 0, false, false); - } } P_MapEnd(); diff --git a/src/p_user.c b/src/p_user.c index 3f522ac9..ee477a7d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9145,81 +9145,84 @@ void P_PlayerThink(player_t *player) I_Error("player %s is in PST_REBORN\n", sizeu1(playeri)); #endif - if (G_RaceGametype()) + if (!mapreset) { - INT32 i; - - // Check if all the players in the race have finished. If so, end the level. - for (i = 0; i < MAXPLAYERS; i++) - { - if (playeringame[i] && !players[i].spectator) - { - if (!players[i].exiting && players[i].lives > 0) - break; - } - } - - if (i == MAXPLAYERS && player->exiting == 3*TICRATE) // finished - player->exiting = (14*TICRATE)/5 + 1; - - // If 10 seconds are left on the timer, - // begin the drown music for countdown! - - // SRB2Kart: despite how perfect this is, it's disabled FOR A REASON - /*if (countdown == 11*TICRATE - 1) - { - if (P_IsLocalPlayer(player)) - S_ChangeMusicInternal("drown", false); - }*/ - - // If you've hit the countdown and you haven't made - // it to the exit, you're a goner! - else if (countdown == 1 && !player->exiting && !player->spectator && player->lives > 0) - { - P_DoTimeOver(player); - - if (player->playerstate == PST_DEAD) - return; - } - } - - // If it is set, start subtracting - // Don't allow it to go back to 0 - if (player->exiting > 1 && (player->exiting < 3*TICRATE || !G_RaceGametype())) // SRB2kart - "&& player->exiting > 1" - player->exiting--; - - if (player->exiting && countdown2) - player->exiting = 99; // SRB2kart - - if (player->exiting == 2 || countdown2 == 2) - { - if (cv_playersforexit.value) // Count to be sure everyone's exited + if (G_RaceGametype()) { INT32 i; + // Check if all the players in the race have finished. If so, end the level. for (i = 0; i < MAXPLAYERS; i++) { - if (!playeringame[i] || players[i].spectator || players[i].bot) - continue; - if (players[i].lives <= 0) - continue; - - if (!players[i].exiting || players[i].exiting > 3) - break; + if (playeringame[i] && !players[i].spectator) + { + if (!players[i].exiting && players[i].lives > 0) + break; + } } - if (i == MAXPLAYERS) + if (i == MAXPLAYERS && player->exiting == 3*TICRATE) // finished + player->exiting = (14*TICRATE)/5 + 1; + + // If 10 seconds are left on the timer, + // begin the drown music for countdown! + + // SRB2Kart: despite how perfect this is, it's disabled FOR A REASON + /*if (countdown == 11*TICRATE - 1) + { + if (P_IsLocalPlayer(player)) + S_ChangeMusicInternal("drown", false); + }*/ + + // If you've hit the countdown and you haven't made + // it to the exit, you're a goner! + else if (countdown == 1 && !player->exiting && !player->spectator && player->lives > 0) + { + P_DoTimeOver(player); + + if (player->playerstate == PST_DEAD) + return; + } + } + + // If it is set, start subtracting + // Don't allow it to go back to 0 + if (player->exiting > 1 && (player->exiting < 3*TICRATE || !G_RaceGametype())) // SRB2kart - "&& player->exiting > 1" + player->exiting--; + + if (player->exiting && countdown2) + player->exiting = 99; // SRB2kart + + if (player->exiting == 2 || countdown2 == 2) + { + if (cv_playersforexit.value) // Count to be sure everyone's exited + { + INT32 i; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator || players[i].bot) + continue; + if (players[i].lives <= 0) + continue; + + if (!players[i].exiting || players[i].exiting > 3) + break; + } + + if (i == MAXPLAYERS) + { + if (server) + SendNetXCmd(XD_EXITLEVEL, NULL, 0); + } + else + player->exiting = 3; + } + else { if (server) SendNetXCmd(XD_EXITLEVEL, NULL, 0); } - else - player->exiting = 3; - } - else - { - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); } } diff --git a/src/st_stuff.c b/src/st_stuff.c index aecfe34d..7efbe6d2 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1828,7 +1828,7 @@ static void ST_overlayDrawer(void) */ // GAME OVER pic - if (G_GametypeUsesLives() && stplyr->lives <= 0 && !(hu_showscores && (netgame || multiplayer))) + /*if (G_GametypeUsesLives() && stplyr->lives <= 0 && !(hu_showscores && (netgame || multiplayer))) { patch_t *p; @@ -1838,7 +1838,7 @@ static void ST_overlayDrawer(void) p = sboover; V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, STRINGY(BASEVIDHEIGHT/2 - (SHORT(p->height)/2)), 0, p); - } + }*/ if (!hu_showscores) // hide the following if TAB is held { @@ -1919,16 +1919,16 @@ static void ST_overlayDrawer(void) #endif // draw level title Tails - if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer)) + if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) #ifdef HAVE_BLUA && LUA_HudEnabled(hud_stagetitle) #endif ) ST_drawLevelTitle(); - if (!hu_showscores && !splitscreen && netgame && displayplayer == consoleplayer) + if (!hu_showscores && !splitscreen && netgame && displayplayer == consoleplayer && !mapreset) { - if (G_GametypeUsesLives() && stplyr->lives <= 0 && countdown != 1) + /*if (G_GametypeUsesLives() && stplyr->lives <= 0 && countdown != 1) V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), 0, M_GetText("Press F12 to watch another player.")); else if (gametype == GT_HIDEANDSEEK && (!stplyr->spectator && !(stplyr->pflags & PF_TAGIT)) && (leveltime > hidetime * TICRATE)) @@ -1936,15 +1936,15 @@ static void ST_overlayDrawer(void) 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.")); } - /*else if (!G_RaceGametype() && stplyr->playerstate == PST_DEAD && stplyr->lives) //Death overrides spectator text. + else if (!G_RaceGametype() && stplyr->playerstate == PST_DEAD && stplyr->lives) //Death overrides spectator text. { INT32 respawntime = cv_respawntime.value - stplyr->deadtimer/TICRATE; if (respawntime > 0 && !stplyr->spectator) V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, va(M_GetText("Respawn in: %d second%s."), respawntime, respawntime == 1 ? "" : "s")); else V_DrawCenteredString(BASEVIDWIDTH/2, STRINGY(132), V_HUDTRANSHALF, M_GetText("Press Jump to respawn.")); - }*/ - else if (stplyr->spectator + } + else*/ if (stplyr->spectator #ifdef HAVE_BLUA && LUA_HudEnabled(hud_textspectator) #endif @@ -1970,7 +1970,7 @@ static void ST_overlayDrawer(void) void ST_Drawer(void) { #ifdef SEENAMES - if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo) + if (cv_seenames.value && cv_allowseenames.value && displayplayer == consoleplayer && seenplayer && seenplayer->mo && !mapreset) { if (cv_seenames.value == 1) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, player_names[seenplayer-players]); diff --git a/src/y_inter.c b/src/y_inter.c index 8f4b607c..31ea8ade 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -262,7 +262,6 @@ static void Y_CalculateMatchData(boolean rankingsmode, void (*comparison)(INT32) // void Y_IntermissionDrawer(void) { - // Bonus loops INT32 i, whiteplayer = MAXPLAYERS, x = 4, hilicol = V_YELLOWMAP; // fallback if (intertype == int_none || rendermode == render_none) @@ -482,16 +481,32 @@ void Y_IntermissionDrawer(void) } dotimer: + + if (netgame) // FREE PLAY? + { + // check to see if there's anyone else at all + for (i = 0; i < MAXPLAYERS; i++) + { + if (i == consoleplayer) + continue; + if (playeringame[i] && !stplyr->spectator) + break; + } + + if (i == MAXPLAYERS) + K_drawKartFreePlay(intertic); + } + if (timer) { INT32 tickdown = (timer+1)/TICRATE; - V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol, + V_DrawCenteredString(BASEVIDWIDTH/2, 188, hilicol|V_SNAPTOBOTTOM, va("start in %d second%s", tickdown, (tickdown == 1 ? "" : "s"))); } // Make it obvious that scrambling is happening next round. if (cv_scrambleonchange.value && cv_teamscramble.value && (intertic/TICRATE % 2 == 0)) - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, V_YELLOWMAP, M_GetText("Teams will be scrambled next round!")); + V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, hilicol|V_SNAPTOBOTTOM, M_GetText("Teams will be scrambled next round!")); } //