diff --git a/src/d_player.h b/src/d_player.h index f36065f0a..255f5dc75 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -1131,6 +1131,7 @@ struct player_t UINT32 lastringboost; // What was our accumulated boost when locking the award? UINT8 amps; + UINT8 recentamps; UINT8 amppickup; UINT8 ampspending; diff --git a/src/k_kart.c b/src/k_kart.c index a3eb8716b..34af36832 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4430,6 +4430,22 @@ void K_SpawnAmps(player_t *player, UINT8 amps, mobj_t *impact) // FixedMul(scaledamps<>FRACBITS); scaledamps = FixedMul(scaledamps<>FRACBITS; + //CONS_Printf("SA=%d ", scaledamps); + + // Arbitrary tuning constants. + // Reduce amp payouts by 1/40th for each 2 amps obtained recently + UINT8 num = 40; + UINT8 div = 40; + UINT8 reduction = min(30, player->recentamps); + + num -= reduction; + + //CONS_Printf("N=%d D=%d RA=%d ", num, div, player->recentamps); + + scaledamps = num * scaledamps / div; + + //CONS_Printf("SA2=%d\n", scaledamps); + /* if (player->position <= 1) scaledamps /= 2; @@ -4446,6 +4462,7 @@ void K_SpawnAmps(player_t *player, UINT8 amps, mobj_t *impact) pickup->color = player->skincolor; P_SetTarget(&pickup->target, player->mo); player->ampspending++; + player->recentamps++; } } @@ -10608,6 +10625,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) } } + if (player->recentamps && (leveltime%TICRATE == 0)) + player->recentamps--; + if (player->invincibilitytimer && (player->ignoreAirtimeLeniency > 0 || onground == true || K_PowerUpRemaining(player, POWERUP_SMONITOR))) { player->invincibilitytimer--; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index ea815ca5e..6fee01b18 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -295,6 +295,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->lastringboost); else if (fastcmp(field,"amps")) lua_pushinteger(L, plr->amps); + else if (fastcmp(field,"recentamps")) + lua_pushinteger(L, plr->recentamps); else if (fastcmp(field,"amppickup")) lua_pushinteger(L, plr->amppickup); else if (fastcmp(field,"ampspending")) @@ -958,6 +960,8 @@ static int player_set(lua_State *L) plr->lastringboost = luaL_checkinteger(L, 3); else if (fastcmp(field,"amps")) plr->amps = luaL_checkinteger(L, 3); + else if (fastcmp(field,"recentamps")) + plr->recentamps = luaL_checkinteger(L, 3); else if (fastcmp(field,"amppickup")) plr->amppickup = luaL_checkinteger(L, 3); else if (fastcmp(field,"ampspending")) diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 97f497bba..760fef520 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -708,6 +708,7 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT32(save->p, players[i].lastringboost); WRITEUINT8(save->p, players[i].amps); + WRITEUINT8(save->p, players[i].recentamps); WRITEUINT8(save->p, players[i].amppickup); WRITEUINT8(save->p, players[i].ampspending); @@ -1383,6 +1384,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].lastringboost = READUINT32(save->p); players[i].amps =READUINT8(save->p); + players[i].recentamps =READUINT8(save->p); players[i].amppickup =READUINT8(save->p); players[i].ampspending =READUINT8(save->p);