diff --git a/src/d_player.h b/src/d_player.h index 304dcb7bb..48cd80532 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -771,6 +771,7 @@ struct player_t INT16 growshrinktimer; // > 0 = Big, < 0 = small UINT16 rocketsneakertimer; // Rocket Sneaker duration timer UINT16 invincibilitytimer; // Invincibility timer + UINT16 invincibilityextensions; // Used to control invinc time gains when it's already been extended. UINT8 eggmanexplode; // Fake item recieved, explode in a few seconds SINT8 eggmanblame; // (-1 to 15) - Fake item recieved, who set this fake diff --git a/src/k_kart.c b/src/k_kart.c index 3f0c7e48e..2ebc91b31 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3281,7 +3281,7 @@ static void K_GetKartBoostPower(player_t *player) if (player->invincibilitytimer) // Invincibility { - ADDBOOST(3*FRACUNIT/8, 3*FRACUNIT, SLIPTIDEHANDLING/2); // + 37.5% top speed, + 300% acceleration, +25% handling + ADDBOOST(3*FRACUNIT/8 + (FRACUNIT / 1400 * (player->invincibilitytimer)), 3*FRACUNIT, SLIPTIDEHANDLING/2); // + 37.5 + ?% top speed, + 300% acceleration, +25% handling } if (player->growshrinktimer > 0) // Grow @@ -8594,6 +8594,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->invincibilitytimer && onground == true) player->invincibilitytimer--; + if (!player->invincibilitytimer) + player->invincibilityextensions = 0; + if (player->preventfailsafe) player->preventfailsafe--; @@ -11729,7 +11732,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) case KITEM_INVINCIBILITY: if (ATTACK_IS_DOWN && !HOLDING_ITEM && NO_HYUDORO) // Doesn't hold your item slot hostage normally, so you're free to waste it if you have multiple { - K_DoInvincibility(player, 10 * TICRATE); + UINT32 behind = K_GetItemRouletteDistance(player, player->itemRoulette.playing); + UINT32 behindScaled = behind * TICRATE / 4000; + behindScaled = min(behindScaled, 10*TICRATE); + + K_DoInvincibility(player, 10 * TICRATE + behindScaled); K_PlayPowerGloatSound(player->mo); player->itemamount--; player->botvars.itemconfirm = 0; diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 7283b91dc..be0e0b9d3 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -413,6 +413,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->rocketsneakertimer); else if (fastcmp(field,"invincibilitytimer")) lua_pushinteger(L, plr->invincibilitytimer); + else if (fastcmp(field,"invincibilityextensions")) + lua_pushinteger(L, plr->invincibilityextensions); else if (fastcmp(field,"eggmanexplode")) lua_pushinteger(L, plr->eggmanexplode); else if (fastcmp(field,"eggmanblame")) @@ -911,6 +913,8 @@ static int player_set(lua_State *L) plr->rocketsneakertimer = luaL_checkinteger(L, 3); else if (fastcmp(field,"invincibilitytimer")) plr->invincibilitytimer = luaL_checkinteger(L, 3); + else if (fastcmp(field,"invincibilityextensions")) + plr->invincibilityextensions = luaL_checkinteger(L, 3); else if (fastcmp(field,"eggmanexplode")) plr->eggmanexplode = luaL_checkinteger(L, 3); else if (fastcmp(field,"eggmanblame")) diff --git a/src/p_inter.c b/src/p_inter.c index d8512e194..1f2583000 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -3194,9 +3194,20 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (gametyperules & GTR_CLOSERPLAYERS) kinvextend = 2*TICRATE; else - kinvextend = 5*TICRATE; + kinvextend = 3*TICRATE; + + // Reduce the value of subsequent invinc extensions + kinvextend = kinvextend / (1 + source->player->invincibilityextensions); // 50%, 33%, 25%[...] + kinvextend = max(kinvextend, TICRATE); + + source->player->invincibilityextensions++; source->player->invincibilitytimer += kinvextend; + // This has a scaling boost type now, don't let it get too crazy + source->player->invincibilitytimer = max(source->player->invincibilitytimer, 20*TICRATE); + + if (P_IsDisplayPlayer(source->player)) + S_StartSound(NULL, sfx_gsha7); } K_TryHurtSoundExchange(target, source); diff --git a/src/p_saveg.c b/src/p_saveg.c index 176b521f1..04b59c277 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -512,6 +512,7 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEINT16(save->p, players[i].growshrinktimer); WRITEUINT16(save->p, players[i].rocketsneakertimer); WRITEUINT16(save->p, players[i].invincibilitytimer); + WRITEUINT16(save->p, players[i].invincibilityextensions); WRITEUINT8(save->p, players[i].eggmanexplode); WRITESINT8(save->p, players[i].eggmanblame); @@ -1066,6 +1067,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].growshrinktimer = READINT16(save->p); players[i].rocketsneakertimer = READUINT16(save->p); players[i].invincibilitytimer = READUINT16(save->p); + players[i].invincibilityextensions = READUINT16(save->p); players[i].eggmanexplode = READUINT8(save->p); players[i].eggmanblame = READSINT8(save->p);