From 9bec65ca03afdf7beb991eff6a6f4aee83b9240f Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Thu, 22 Nov 2018 23:38:54 -0500 Subject: [PATCH] Franticized items for 2nd place VS SPB'd 1st --- src/dehacked.c | 3 +++ src/doomstat.h | 1 + src/g_game.c | 1 + src/k_kart.c | 19 ++++++++++++------- src/p_mobj.c | 4 ++++ src/p_saveg.c | 2 ++ src/p_setup.c | 1 + src/p_user.c | 3 +++ 8 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index cfa08b454..27d531cc3 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9770,6 +9770,9 @@ 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); + return 1; } return 0; diff --git a/src/doomstat.h b/src/doomstat.h index 34456b321..aa2ebe311 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -461,6 +461,7 @@ extern tic_t indirectitemcooldown; extern tic_t mapreset; extern UINT8 nospectategrief; extern boolean thwompsactive; +extern boolean spbexists; extern boolean legitimateexit; extern boolean comebackshowninfo; diff --git a/src/g_game.c b/src/g_game.c index e9309b807..cba9d26ce 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -267,6 +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 // 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 8bd08e264..94fa3f328 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -574,8 +574,10 @@ static void K_KartGetItemResult(player_t *player, SINT8 getitem) player->kartstuff[k_itemtype] = KITEM_JAWZ; player->kartstuff[k_itemamount] = 2; break; - case KITEM_SPB: // Indirect items - case KITEM_SHRINK: + case KITEM_SPB: + spbexists = true; + /* FALLTHRU */ + case KITEM_SHRINK: // Indirect items indirectitemcooldown = 30*TICRATE; /* FALLTHRU */ default: @@ -599,7 +601,7 @@ static void K_KartGetItemResult(player_t *player, SINT8 getitem) \return void */ -static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) +static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean insecondplace) { const INT32 distvar = (64*14); INT32 newodds; @@ -648,13 +650,16 @@ static INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed) // POWERITEMODDS handles all of the "frantic item" related functionality, for all of our powerful items. // First, it multiplies it by 2 if franticitems is true; easy-peasy. - // Then, it multiplies it further if there's less than 5 players in game. + // Next, it multiplies it again if it's in SPB mode and 2nd needs to apply pressure to 1st. + // Then, it multiplies it further if there's less than 8 players in game. // This is done to make low player count races more fair & interesting. (1v1s are basically the same as franticitems false in a normal race) // Lastly, it *divides* it by your mashed value, which was determined in K_KartItemRoulette, to punish those who are impatient. // The last two are very fractional and complicated, very sorry! #define POWERITEMODDS(odds) \ if (franticitems) \ odds *= 2; \ + if (spbexists && insecondplace) \ + odds *= 2; \ if (pingame < 8 && !G_BattleGametype()) \ odds = FixedMul(odds*FRACUNIT, FRACUNIT+min((8-pingame)*(FRACUNIT/25), FRACUNIT))/FRACUNIT; \ if (mashed > 0) \ @@ -782,7 +787,7 @@ static INT32 K_FindUseodds(player_t *player, fixed_t mashed, INT32 pingame, INT3 for (j = 0; j < NUMKARTRESULTS; j++) { - if (K_KartGetItemOdds(i, j, mashed) > 0) + if (K_KartGetItemOdds(i, j, mashed, (player->kartstuff[k_position] == 2)) > 0) { available = true; break; @@ -974,7 +979,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) useodds = K_FindUseodds(player, mashed, pingame, bestbumper); #define SETITEMRESULT(itemnum) \ - for (chance = 0; chance < K_KartGetItemOdds(useodds, itemnum, mashed); chance++) \ + for (chance = 0; chance < K_KartGetItemOdds(useodds, itemnum, mashed, (player->kartstuff[k_position] == 2)); chance++) \ spawnchance[numchoices++] = itemnum for (i = 1; i < NUMKARTRESULTS; i++) @@ -7811,7 +7816,7 @@ static void K_drawDistributionDebugger(void) for (i = 1; i < NUMKARTRESULTS; i++) { - const INT32 itemodds = K_KartGetItemOdds(useodds, i, 0); + const INT32 itemodds = K_KartGetItemOdds(useodds, i, 0, (stplyr->kartstuff[k_position] == 2)); if (itemodds <= 0) continue; diff --git a/src/p_mobj.c b/src/p_mobj.c index 2cb12791f..ba0a0c113 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8155,6 +8155,7 @@ void P_MobjThinker(mobj_t *mobj) break; case MT_SPB: indirectitemcooldown = 30*TICRATE; + spbexists = true; /* FALLTHRU */ case MT_BALLHOG: P_SpawnGhostMobj(mobj)->fuse = 3; @@ -10378,6 +10379,9 @@ void P_RemoveMobj(mobj_t *mobj) if (mobj->type == MT_SHADOW) P_RemoveShadow(mobj); + if (mobj->type == MT_SPB) + spbexists = false; + mobj->health = 0; // Just because // unlink from sector and block lists diff --git a/src/p_saveg.c b/src/p_saveg.c index 1b4314b8e..447310006 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3287,6 +3287,7 @@ static void P_NetArchiveMisc(void) WRITEUINT32(save_p, mapreset); WRITEUINT8(save_p, nospectategrief); WRITEUINT8(save_p, thwompsactive); + WRITEUINT8(save_p, spbexists); // Is it paused? if (paused) @@ -3393,6 +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); // Is it paused? if (READUINT8(save_p) == 0x2f) diff --git a/src/p_setup.c b/src/p_setup.c index 68cdc797b..fa8e263c6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3046,6 +3046,7 @@ boolean P_SetupLevel(boolean skipprecip) mapreset = 0; nospectategrief = 0; thwompsactive = false; + spbexists = false; // clear special respawning que iquehead = iquetail = 0; diff --git a/src/p_user.c b/src/p_user.c index b2849c857..d17a7c801 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7758,7 +7758,10 @@ 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; indirectitemcooldown = 0; + } if (mo == inflictor) // Don't nuke yourself, dummy! continue;