From d3fb778a521ccf6ec18c372d07bc68f9576ffa2c Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Sat, 24 Nov 2018 20:41:17 -0500 Subject: [PATCH] Keep track of the place SPB is following This makes it so that if the SPB'd person is passed, then the person who's getting SPB'd won't get the increased item odds for the weird feedback loop. --- src/dehacked.c | 4 ++-- src/doomstat.h | 2 +- src/g_game.c | 2 +- src/k_kart.c | 6 ++---- src/p_enemy.c | 6 ++++++ src/p_mobj.c | 3 +-- src/p_saveg.c | 4 ++-- src/p_setup.c | 2 +- src/p_user.c | 2 +- 9 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index c1195849e..95cd30a24 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9773,8 +9773,8 @@ static inline int lib_getenum(lua_State *L) } else if (fastcmp(word,"thwompsactive")) { lua_pushboolean(L, thwompsactive); return 1; - } else if (fastcmp(word,"spbexists")) { - lua_pushboolean(L, spbexists); + } else if (fastcmp(word,"spbplace")) { + lua_pushinteger(L, spbplace); return 1; } diff --git a/src/doomstat.h b/src/doomstat.h index aa2ebe311..a002bb34d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -461,7 +461,7 @@ extern tic_t indirectitemcooldown; extern tic_t mapreset; extern UINT8 nospectategrief; extern boolean thwompsactive; -extern boolean spbexists; +extern SINT8 spbplace; extern boolean legitimateexit; extern boolean comebackshowninfo; diff --git a/src/g_game.c b/src/g_game.c index cba9d26ce..d44ad266e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -267,7 +267,7 @@ tic_t indirectitemcooldown; // Cooldown before any more Shrink, SPB, or any othe tic_t mapreset; // Map reset delay when enough players have joined an empty game UINT8 nospectategrief; // How many players need to be in-game to eliminate last; for preventing spectate griefing boolean thwompsactive; // Thwomps activate on lap 2 -boolean spbexists; // SPB exists, give 2nd place better items +SINT8 spbplace; // SPB exists, give the person behind better items // Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) boolean legitimateexit; // Did this client actually finish the match? diff --git a/src/k_kart.c b/src/k_kart.c index 03030f236..8b2e62bd7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -583,8 +583,6 @@ static void K_KartGetItemResult(player_t *player, SINT8 getitem) player->kartstuff[k_itemamount] = 2; break; case KITEM_SPB: - spbexists = true; - /* FALLTHRU */ case KITEM_SHRINK: // Indirect items indirectitemcooldown = 30*TICRATE; /* FALLTHRU */ @@ -988,7 +986,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) spawnchance[i] = 0; // Split into another function for a debug function below - useodds = K_FindUseodds(player, mashed, pingame, bestbumper, (player->kartstuff[k_position] == 2 && spbexists)); + useodds = K_FindUseodds(player, mashed, pingame, bestbumper, (spbplace != -1 && player->kartstuff[k_position] == spbplace+1)); #define SETITEMRESULT(itemnum) \ for (chance = 0; chance < K_KartGetItemOdds(useodds, itemnum, mashed); chance++) \ @@ -7944,7 +7942,7 @@ static void K_drawDistributionDebugger(void) bestbumper = players[i].kartstuff[k_bumper]; } - useodds = K_FindUseodds(stplyr, 0, pingame, bestbumper, (stplyr->kartstuff[k_position] == 2 && spbexists)); + useodds = K_FindUseodds(stplyr, 0, pingame, bestbumper, (spbplace != -1 && stplyr->kartstuff[k_position] == spbplace+1)); for (i = 1; i < NUMKARTRESULTS; i++) { diff --git a/src/p_enemy.c b/src/p_enemy.c index b81f1ea9a..d8735d9bb 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -8354,6 +8354,7 @@ void A_SPBChase(mobj_t *actor) if (actor->threshold) // Just fired, go straight. { actor->lastlook = -1; + spbplace = -1; P_InstaThrust(actor, actor->angle, wspeed); return; } @@ -8382,6 +8383,8 @@ void A_SPBChase(mobj_t *actor) actor->extravalue2 = 7*TICRATE; else if (actor->extravalue2-- <= 0) actor->extravalue1 = 0; // back to SEEKING + + spbplace = actor->tracer->player->kartstuff[k_position]; } // Play the intimidating gurgle @@ -8466,6 +8469,8 @@ void A_SPBChase(mobj_t *actor) else if (actor->extravalue1 == 2) // MODE: WAIT... { actor->momx = actor->momy = actor->momz = 0; // Stoooop + spbplace = -1; + if (actor->extravalue2-- <= 0) { if (actor->lastlook != -1 && playeringame[actor->lastlook] && players[actor->lastlook].mo) @@ -8482,6 +8487,7 @@ void A_SPBChase(mobj_t *actor) else // MODE: SEEKING { actor->lastlook = -1; // Just make sure this is reset + spbplace = -1; // Find the player with the best rank for (i = 0; i < MAXPLAYERS; i++) diff --git a/src/p_mobj.c b/src/p_mobj.c index f6ef4ba52..7c6987a7d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8167,7 +8167,6 @@ void P_MobjThinker(mobj_t *mobj) break; case MT_SPB: indirectitemcooldown = 30*TICRATE; - spbexists = true; /* FALLTHRU */ case MT_BALLHOG: P_SpawnGhostMobj(mobj)->fuse = 3; @@ -10392,7 +10391,7 @@ void P_RemoveMobj(mobj_t *mobj) P_RemoveShadow(mobj); if (mobj->type == MT_SPB) - spbexists = false; + spbplace = -1; mobj->health = 0; // Just because diff --git a/src/p_saveg.c b/src/p_saveg.c index 447310006..e702d460f 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3287,7 +3287,7 @@ static void P_NetArchiveMisc(void) WRITEUINT32(save_p, mapreset); WRITEUINT8(save_p, nospectategrief); WRITEUINT8(save_p, thwompsactive); - WRITEUINT8(save_p, spbexists); + WRITESINT8(save_p, spbplace); // Is it paused? if (paused) @@ -3394,7 +3394,7 @@ static inline boolean P_NetUnArchiveMisc(void) mapreset = READUINT32(save_p); nospectategrief = READUINT8(save_p); thwompsactive = (boolean)READUINT8(save_p); - spbexists = (boolean)READUINT8(save_p); + spbplace = READSINT8(save_p); // Is it paused? if (READUINT8(save_p) == 0x2f) diff --git a/src/p_setup.c b/src/p_setup.c index fa8e263c6..bd3856d6e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3046,7 +3046,7 @@ boolean P_SetupLevel(boolean skipprecip) mapreset = 0; nospectategrief = 0; thwompsactive = false; - spbexists = false; + spbplace = -1; // clear special respawning que iquehead = iquetail = 0; diff --git a/src/p_user.c b/src/p_user.c index d17a7c801..7b4ef789c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7759,7 +7759,7 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) if (mo->type == MT_SPB) // If you destroy a SPB, you don't get the luxury of a cooldown. { - spbexists = false; + spbplace = -1; indirectitemcooldown = 0; }