From fbcf5668740d0906bee1ac653cffcb4b198b3884 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Tue, 3 Jul 2018 21:12:25 -0400 Subject: [PATCH 1/4] WANTED recalculates on hit, tons of spectator changes --- src/d_netcmd.c | 2 +- src/doomstat.h | 1 + src/g_game.c | 1 + src/k_kart.c | 24 +++++++++++------------ src/p_inter.c | 4 ++-- src/p_local.h | 1 + src/p_mobj.c | 52 +++++++++++++++++++++++--------------------------- src/p_saveg.c | 2 ++ src/p_setup.c | 1 + src/p_tick.c | 9 ++++++--- src/p_user.c | 25 ++++++++++++++++++++++++ 11 files changed, 75 insertions(+), 47 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2388891d..f616c625 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4263,7 +4263,7 @@ void D_GameTypeChanged(INT32 lastgametype) // When swapping to a gametype that supports spectators, // make everyone a spectator initially. - /*if (!splitscreen && (G_GametypeHasSpectators())) + /*if (G_GametypeHasSpectators()) { INT32 i; for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/doomstat.h b/src/doomstat.h index 5f2ef91e..336c5840 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -449,6 +449,7 @@ extern boolean mirrormode; extern boolean comeback; extern SINT8 battlewanted[4]; +extern tic_t wantedcalcdelay; extern tic_t indirectitemcooldown; extern tic_t spbincoming; extern UINT8 spbplayer; diff --git a/src/g_game.c b/src/g_game.c index 1f517328..8c82ac64 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -258,6 +258,7 @@ SINT8 pickedvote; // What vote the host rolls // Server-sided variables SINT8 battlewanted[4]; // WANTED players in battle, worth x2 points +tic_t wantedcalcdelay; // Time before it recalculates WANTED tic_t indirectitemcooldown; // Cooldown before any more Shrink, SPB, or any other item that works indirectly is awarded tic_t spbincoming; // Timer before SPB hits, can switch targets at this point UINT8 spbplayer; // Player num that used the last SPB diff --git a/src/k_kart.c b/src/k_kart.c index 56c147ef..7fe458b6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1496,9 +1496,9 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, boolean trapitem karmahitbox->destscale = player->mo->scale; P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); - if (K_IsPlayerWanted(player)) - K_CalculateBattleWanted(); } + if (K_IsPlayerWanted(player)) + K_CalculateBattleWanted(); player->kartstuff[k_bumper]--; } @@ -1563,9 +1563,9 @@ void K_SquishPlayer(player_t *player, mobj_t *source) karmahitbox->destscale = player->mo->scale; P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); - if (K_IsPlayerWanted(player)) - K_CalculateBattleWanted(); } + if (K_IsPlayerWanted(player)) + K_CalculateBattleWanted(); player->kartstuff[k_bumper]--; } @@ -1624,9 +1624,9 @@ void K_ExplodePlayer(player_t *player, mobj_t *source) // A bit of a hack, we ju karmahitbox->destscale = player->mo->scale; P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); - if (K_IsPlayerWanted(player)) - K_CalculateBattleWanted(); } + if (K_IsPlayerWanted(player)) + K_CalculateBattleWanted(); player->kartstuff[k_bumper]--; } @@ -3275,13 +3275,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->kartstuff[k_positiondelay]) player->kartstuff[k_positiondelay]--; - // Race Spectator - if (netgame && player->jointime < 1 - && G_RaceGametype() && countdown) - { - player->spectator = true; - player->powers[pw_nocontrol] = 5; - } + // Race force spectate + if (player->spectator && netgame && G_RaceGametype() && P_FindHighestLap() > 0) + player->powers[pw_flashing] = 5; if ((player->pflags & PF_ATTACKDOWN) && !(cmd->buttons & BT_ATTACK)) player->pflags &= ~PF_ATTACKDOWN; @@ -3843,6 +3839,8 @@ void K_CalculateBattleWanted(void) return; } + wantedcalcdelay = wantedfrequency; + for (i = 0; i < MAXPLAYERS; i++) camppos[i] = -1; // initialize diff --git a/src/p_inter.c b/src/p_inter.c index 31e5e581..3fafa0cd 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2839,9 +2839,9 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) karmahitbox->destscale = player->mo->scale; P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); - if (K_IsPlayerWanted(player)) - K_CalculateBattleWanted(); } + if (K_IsPlayerWanted(player)) + K_CalculateBattleWanted(); player->kartstuff[k_bumper]--; } diff --git a/src/p_local.h b/src/p_local.h index cc4c5df5..eeb5bc1e 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -183,6 +183,7 @@ boolean P_AnalogMove(player_t *player); boolean P_TransferToNextMare(player_t *player); UINT8 P_FindLowestMare(void); UINT8 P_FindLowestLap(void); +UINT8 P_FindHighestLap(void); void P_FindEmerald(void); void P_TransferToAxis(player_t *player, INT32 axisnum); boolean P_PlayerMoving(INT32 pnum); diff --git a/src/p_mobj.c b/src/p_mobj.c index 3af12a35..d722fc3e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6940,7 +6940,7 @@ void P_MobjThinker(mobj_t *mobj) { P_SetMobjState(mobj, S_PLAYERARROW_BOX); mobj->tracer->sprite = SPR_ITEM; - mobj->tracer->frame = FF_FULLBRIGHT|((mobj->target->player->kartstuff[k_itemroulette] % (13*3)) / 3); + mobj->tracer->frame = FF_FULLBRIGHT|(((mobj->target->player->kartstuff[k_itemroulette] % (13*3)) / 3) + 1); } else if (mobj->target->player->kartstuff[k_itemtype]) { @@ -6962,9 +6962,11 @@ void P_MobjThinker(mobj_t *mobj) break; } - if (mobj->target->player->kartstuff[k_growshrinktimer]) + if (mobj->target->player->kartstuff[k_growshrinktimer] > 0) { + mobj->tracer->sprite = SPR_ITEM; mobj->tracer->frame = FF_FULLBRIGHT|KITEM_GROW; + if (leveltime & 1) mobj->tracer->flags2 |= MF2_DONTDRAW; else @@ -8178,7 +8180,7 @@ void P_MobjThinker(mobj_t *mobj) P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z); break; case MT_KARMAHITBOX: - if (!mobj->target || !mobj->target->health || !mobj->target->player + if (!mobj->target || !mobj->target->health || !mobj->target->player || mobj->target->player->spectator || (G_RaceGametype() || mobj->target->player->kartstuff[k_bumper])) { P_RemoveMobj(mobj); @@ -9797,24 +9799,27 @@ void P_RespawnSpecials(void) // void P_SpawnPlayer(INT32 playernum) { + UINT8 i, pcount = 0; player_t *p = &players[playernum]; mobj_t *mobj; if (p->playerstate == PST_REBORN) G_PlayerReborn(playernum); + for (i = 0; i < MAXPLAYERS; i++) + { + if (i == playernum) + continue; + if (!playeringame[i] || players[i].spectator) + continue; + pcount++; + } + // spawn as spectator determination if (!G_GametypeHasSpectators()) - { - // Special case for (NiGHTS) special stages! - // if stage has already started, force players to become spectators until the next stage - /*if (multiplayer && netgame && G_IsSpecialStage(gamemap) && useNightsSS && leveltime > 0) - p->spectator = true; - else*/ - p->spectator = false; - } - else if (netgame && p->jointime < 1) - /*p->spectator = true*/; + p->spectator = false; + else if (netgame && p->jointime <= 1 && pcount > 1) + p->spectator = true; else if (multiplayer && !netgame) { // If you're in a team game and you don't have a team assigned yet... @@ -9893,19 +9898,10 @@ void P_SpawnPlayer(INT32 playernum) overheadarrow->flags2 |= MF2_DONTDRAW; P_SetScale(overheadarrow, mobj->destscale); - /*INT32 i; - INT32 pcount = 0; - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator || &players[i] == p) - continue; - if (players[i].jointime > 1) - continue; - pcount++; - }*/ - - if (p->kartstuff[k_bumper] > 0 || leveltime < 1/* || pcount <= 1*/) + if (p->spectator) // HEY! No being cheap... + p->kartstuff[k_bumper] = 0; + else if (p->kartstuff[k_bumper] > 0 || leveltime < 1 + || (p->jointime <= 1 && pcount <= 1)) { INT32 i; angle_t newangle; @@ -9913,8 +9909,8 @@ void P_SpawnPlayer(INT32 playernum) fixed_t newx; fixed_t newy; mobj_t *mo; - - if (leveltime < 1 && !p->spectator /*|| pcount <= 1*/) // Start of the map? + + if (leveltime < 1 || (p->jointime <= 1 && pcount <= 1)) // Start of the map? p->kartstuff[k_bumper] = cv_kartbumpers.value; // Reset those bumpers! if (p->kartstuff[k_bumper] <= 1) diff --git a/src/p_saveg.c b/src/p_saveg.c index 6be42fc0..bd3f9fed 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3260,6 +3260,7 @@ static void P_NetArchiveMisc(void) for (i = 0; i < 4; i++) WRITESINT8(save_p, battlewanted[i]); + WRITEUINT32(save_p, wantedcalcdelay); WRITEUINT32(save_p, indirectitemcooldown); WRITEUINT32(save_p, spbincoming); WRITEUINT8(save_p, spbplayer); @@ -3363,6 +3364,7 @@ static inline boolean P_NetUnArchiveMisc(void) for (i = 0; i < 4; i++) battlewanted[i] = READSINT8(save_p); + wantedcalcdelay = READUINT32(save_p); indirectitemcooldown = READUINT32(save_p); spbincoming = READUINT32(save_p); spbplayer = READUINT8(save_p); diff --git a/src/p_setup.c b/src/p_setup.c index d81e2289..6c44f021 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3009,6 +3009,7 @@ boolean P_SetupLevel(boolean skipprecip) for (i = 0; i < 4; i++) battlewanted[i] = -1; + wantedcalcdelay = wantedfrequency*2; indirectitemcooldown = 0; spbincoming = 0; spbplayer = 0; diff --git a/src/p_tick.c b/src/p_tick.c index d79d2f59..98e39690 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -677,9 +677,6 @@ void P_Ticker(boolean run) if (countdown2) countdown2--; - if (G_BattleGametype() && leveltime % wantedfrequency == 0 && leveltime > wantedfrequency) - K_CalculateBattleWanted(); - if (spbincoming && --spbincoming <= 0) { UINT8 best = 0; @@ -715,6 +712,12 @@ void P_Ticker(boolean run) if (indirectitemcooldown) indirectitemcooldown--; + if (G_BattleGametype()) + { + if (wantedcalcdelay && --wantedcalcdelay <= 0) + K_CalculateBattleWanted(); + } + if (quake.time) { fixed_t ir = quake.intensity>>1; diff --git a/src/p_user.c b/src/p_user.c index 4f194be1..8dfd35a2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -406,6 +406,31 @@ UINT8 P_FindLowestLap(void) return lowest; } +// +// P_FindHighestLap +// +UINT8 P_FindHighestLap(void) +{ + INT32 i; + UINT8 highest = 0; + + if (!G_RaceGametype()) + return 0; + + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator) + continue; + + if (players[i].laps > highest) + highest = players[i].laps; + } + + CONS_Debug(DBG_GAMELOGIC, "Highest laps found: %d\n", highest); + + return highest; +} + // // P_TransferToNextMare // From d25f0b0d7ee8ee63c8fa81d7129a65c2509d1ea1 Mon Sep 17 00:00:00 2001 From: SeventhSentinel Date: Wed, 4 Jul 2018 16:12:05 -0400 Subject: [PATCH 2/4] Killed another file I accidentally made --- src/f_finale.c | 1 + src/null | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 src/null diff --git a/src/f_finale.c b/src/f_finale.c index 3ea2e0bf..6e84bd70 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -528,6 +528,7 @@ static const char *credits[] = { "\"Nev3r\"", "\"Ritz\"", "\"Spherallic\"", + "\"DirkTheHusky\"", "", "\1Produced By", "Kart Krew", diff --git a/src/null b/src/null deleted file mode 100644 index 6fe99727..00000000 --- a/src/null +++ /dev/null @@ -1 +0,0 @@ -Press any key to continue . . . From da0c52330e1ce320c53cb80d003ec2aeaa83fb28 Mon Sep 17 00:00:00 2001 From: Sryder Date: Wed, 4 Jul 2018 22:25:38 +0100 Subject: [PATCH 3/4] Hopefully some medicine for the characters' sore throats from all that taunting Also my editor ate some trailing whitespace. --- src/k_kart.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7fe458b6..044d60cc 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -138,7 +138,7 @@ const UINT8 KartColor_Opposite[MAXSKINCOLORS*2] = SKINCOLOR_INDIGO,8, // 26 // SKINCOLOR_YELLOW SKINCOLOR_INDIGO,8, // 27 // SKINCOLOR_CANARY SKINCOLOR_BROWN,8, // 28 // SKINCOLOR_PEACH - SKINCOLOR_BLUEBERRY,8, // 29 // SKINCOLOR_CREAMSICLE + SKINCOLOR_BLUEBERRY,8, // 29 // SKINCOLOR_CREAMSICLE SKINCOLOR_LAVENDER,8, // 30 // SKINCOLOR_GOLD SKINCOLOR_BEIGE,8, // 31 // SKINCOLOR_CARAMEL SKINCOLOR_PURPLE,8, // 32 // SKINCOLOR_VOMIT @@ -246,7 +246,7 @@ UINT8 colortranslations[MAXSKINCOLORS][16] = { {224, 225, 226, 228, 229, 231, 232, 234, 235, 237, 238, 240, 241, 243, 244, 246}, // SKINCOLOR_SAPPHIRE, removed for other colors {160, 160, 160, 184, 184, 184, 185, 185, 185, 186, 187, 187, 188, 188, 189, 190}, // SKINCOLOR_JADE, removed for other colors {224, 225, 226, 212, 213, 213, 214, 215, 220, 221, 172, 222, 173, 223, 174, 175}, // SKINCOLOR_FROST, merged into Aqua - { 72, 73, 74, 75, 76, 77, 78, 79, 48, 49, 50, 51, 52, 53, 54, 55}, // SKINCOLOR_CARAMEL, new Caramel was previously Shiny Caramel + { 72, 73, 74, 75, 76, 77, 78, 79, 48, 49, 50, 51, 52, 53, 54, 55}, // SKINCOLOR_CARAMEL, new Caramel was previously Shiny Caramel { 1, 145, 125, 73, 83, 114, 106, 180, 187, 168, 219, 205, 236, 206, 199, 255}, // SKINCOLOR_RAINBOW, is Vomit 2.0 */ }; @@ -851,7 +851,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) if (pingame == 1 && oddsvalid[0]) // Record Attack, or just alone useodds = 0; else if (pdis <= 0) // (64*14) * 0 = 0 - useodds = disttable[0]; + useodds = disttable[0]; else if (pdis > distvar * ((12 * distlen) / 14)) // (64*14) * 12 = 10752 useodds = disttable[distlen-1]; else @@ -1241,6 +1241,26 @@ void K_KartMoveAnimation(player_t *player) } } +static void K_TauntVoiceTimers(player_t *player) +{ + if (!player) + return; + + player->kartstuff[k_tauntvoices] = 6*TICRATE; + player->kartstuff[k_voices] = 4*TICRATE; +} + +static void K_RegularVoiceTimers(player_t *player) +{ + if (!player) + return; + + player->kartstuff[k_voices] = 3*TICRATE; + + if (player->kartstuff[k_tauntvoices] < 4*TICRATE) + player->kartstuff[k_tauntvoices] = 4*TICRATE; +} + static void K_PlayTauntSound(mobj_t *source) { if (source->player && source->player->kartstuff[k_tauntvoices]) // Prevents taunt sounds from playing every time the button is pressed @@ -1248,11 +1268,7 @@ static void K_PlayTauntSound(mobj_t *source) S_StartSound(source, sfx_taunt1+P_RandomKey(4)); - if (source->player) - { - source->player->kartstuff[k_tauntvoices] = 6*TICRATE; - source->player->kartstuff[k_voices] = 3*TICRATE; - } + K_TauntVoiceTimers(source->player); } static void K_PlayOvertakeSound(mobj_t *source) @@ -1269,26 +1285,14 @@ static void K_PlayOvertakeSound(mobj_t *source) S_StartSound(source, sfx_slow); - if (source->player) - { - source->player->kartstuff[k_voices] = 3*TICRATE; - - if (source->player->kartstuff[k_tauntvoices] < 3*TICRATE) - source->player->kartstuff[k_tauntvoices] = 3*TICRATE; - } + K_RegularVoiceTimers(source->player); } static void K_PlayHitEmSound(mobj_t *source) { S_StartSound(source, sfx_hitem); - if (source->player) - { - source->player->kartstuff[k_voices] = 3*TICRATE; - - if (source->player->kartstuff[k_tauntvoices] < 3*TICRATE) - source->player->kartstuff[k_tauntvoices] = 3*TICRATE; - } + K_RegularVoiceTimers(source->player); } void K_MomentumToFacing(player_t *player) @@ -2139,7 +2143,7 @@ static mobj_t *K_FindLastTrailMobj(player_t *player) if (!player || !(trail = player->mo) || !player->mo->hnext || !player->mo->hnext->health) return NULL; - + while (trail->hnext && !P_MobjWasRemoved(trail->hnext) && trail->hnext->health) { trail = trail->hnext; @@ -3263,8 +3267,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (!player->exiting) { - if (player->kartstuff[k_oldposition] <= player->kartstuff[k_position]) // But first, if you lost a place, + if (player->kartstuff[k_oldposition] < player->kartstuff[k_position]) // But first, if you lost a place, + { player->kartstuff[k_oldposition] = player->kartstuff[k_position]; // then the other player taunts. + K_RegularVoiceTimers(player); // and you can't for a bit + } else if (player->kartstuff[k_oldposition] > player->kartstuff[k_position]) // Otherwise, { K_PlayOvertakeSound(player->mo); // Say "YOU'RE TOO SLOW!" @@ -3782,7 +3789,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // Start charging once you're given the opportunity. if (leveltime >= starttime-(2*TICRATE) && leveltime <= starttime) - { + { if (cmd->buttons & BT_ACCELERATE) player->kartstuff[k_boostcharge]++; else @@ -3805,7 +3812,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->kartstuff[k_sneakertimer] >= 70) S_StartSound(player->mo, sfx_s25f); // Special sound for the perfect start boost! else if (player->kartstuff[k_sneakertimer] >= sneakertime) - S_StartSound(player->mo, sfx_cdfm01); // Sneaker boost sound for big boost + S_StartSound(player->mo, sfx_cdfm01); // Sneaker boost sound for big boost else S_StartSound(player->mo, sfx_s23c); // Drift boost sound for small boost } @@ -4489,7 +4496,7 @@ static void K_drawKartItem(void) { V_DrawScaledPatch(ITEM_X+28, ITEM_Y+41, V_HUDTRANS|splitflags, kp_itemx); V_DrawKartString(ITEM_X+38, ITEM_Y+36, V_HUDTRANS|splitflags, va("%d", stplyr->kartstuff[k_itemamount])); - } + } } else V_DrawScaledPatch(ITEM_X, ITEM_Y, V_HUDTRANS|splitflags, localpatch); From 735ac85ed830af854a34cb15f1aa51e85a965546 Mon Sep 17 00:00:00 2001 From: Sryder Date: Wed, 4 Jul 2018 22:37:11 +0100 Subject: [PATCH 4/4] Why I should start using defines instead of magic numbers --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 044d60cc..9884890f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1255,7 +1255,7 @@ static void K_RegularVoiceTimers(player_t *player) if (!player) return; - player->kartstuff[k_voices] = 3*TICRATE; + player->kartstuff[k_voices] = 4*TICRATE; if (player->kartstuff[k_tauntvoices] < 4*TICRATE) player->kartstuff[k_tauntvoices] = 4*TICRATE;