From fbcf5668740d0906bee1ac653cffcb4b198b3884 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Tue, 3 Jul 2018 21:12:25 -0400 Subject: [PATCH] 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 //