Merge branch 'invinc-time-scaling' into 'master'

Rebalanced Invinc

See merge request KartKrew/Kart!1761
This commit is contained in:
Oni 2024-01-01 16:22:55 +00:00
commit 5f643ae5d1
5 changed files with 28 additions and 3 deletions

View file

@ -771,6 +771,7 @@ struct player_t
INT16 growshrinktimer; // > 0 = Big, < 0 = small INT16 growshrinktimer; // > 0 = Big, < 0 = small
UINT16 rocketsneakertimer; // Rocket Sneaker duration timer UINT16 rocketsneakertimer; // Rocket Sneaker duration timer
UINT16 invincibilitytimer; // Invincibility 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 UINT8 eggmanexplode; // Fake item recieved, explode in a few seconds
SINT8 eggmanblame; // (-1 to 15) - Fake item recieved, who set this fake SINT8 eggmanblame; // (-1 to 15) - Fake item recieved, who set this fake

View file

@ -3281,7 +3281,7 @@ static void K_GetKartBoostPower(player_t *player)
if (player->invincibilitytimer) // Invincibility 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 if (player->growshrinktimer > 0) // Grow
@ -8594,6 +8594,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->invincibilitytimer && onground == true) if (player->invincibilitytimer && onground == true)
player->invincibilitytimer--; player->invincibilitytimer--;
if (!player->invincibilitytimer)
player->invincibilityextensions = 0;
if (player->preventfailsafe) if (player->preventfailsafe)
player->preventfailsafe--; player->preventfailsafe--;
@ -11729,7 +11732,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
case KITEM_INVINCIBILITY: 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 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); K_PlayPowerGloatSound(player->mo);
player->itemamount--; player->itemamount--;
player->botvars.itemconfirm = 0; player->botvars.itemconfirm = 0;

View file

@ -413,6 +413,8 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->rocketsneakertimer); lua_pushinteger(L, plr->rocketsneakertimer);
else if (fastcmp(field,"invincibilitytimer")) else if (fastcmp(field,"invincibilitytimer"))
lua_pushinteger(L, plr->invincibilitytimer); lua_pushinteger(L, plr->invincibilitytimer);
else if (fastcmp(field,"invincibilityextensions"))
lua_pushinteger(L, plr->invincibilityextensions);
else if (fastcmp(field,"eggmanexplode")) else if (fastcmp(field,"eggmanexplode"))
lua_pushinteger(L, plr->eggmanexplode); lua_pushinteger(L, plr->eggmanexplode);
else if (fastcmp(field,"eggmanblame")) else if (fastcmp(field,"eggmanblame"))
@ -911,6 +913,8 @@ static int player_set(lua_State *L)
plr->rocketsneakertimer = luaL_checkinteger(L, 3); plr->rocketsneakertimer = luaL_checkinteger(L, 3);
else if (fastcmp(field,"invincibilitytimer")) else if (fastcmp(field,"invincibilitytimer"))
plr->invincibilitytimer = luaL_checkinteger(L, 3); plr->invincibilitytimer = luaL_checkinteger(L, 3);
else if (fastcmp(field,"invincibilityextensions"))
plr->invincibilityextensions = luaL_checkinteger(L, 3);
else if (fastcmp(field,"eggmanexplode")) else if (fastcmp(field,"eggmanexplode"))
plr->eggmanexplode = luaL_checkinteger(L, 3); plr->eggmanexplode = luaL_checkinteger(L, 3);
else if (fastcmp(field,"eggmanblame")) else if (fastcmp(field,"eggmanblame"))

View file

@ -3194,9 +3194,20 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
if (gametyperules & GTR_CLOSERPLAYERS) if (gametyperules & GTR_CLOSERPLAYERS)
kinvextend = 2*TICRATE; kinvextend = 2*TICRATE;
else 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; 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); K_TryHurtSoundExchange(target, source);

View file

@ -512,6 +512,7 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEINT16(save->p, players[i].growshrinktimer); WRITEINT16(save->p, players[i].growshrinktimer);
WRITEUINT16(save->p, players[i].rocketsneakertimer); WRITEUINT16(save->p, players[i].rocketsneakertimer);
WRITEUINT16(save->p, players[i].invincibilitytimer); WRITEUINT16(save->p, players[i].invincibilitytimer);
WRITEUINT16(save->p, players[i].invincibilityextensions);
WRITEUINT8(save->p, players[i].eggmanexplode); WRITEUINT8(save->p, players[i].eggmanexplode);
WRITESINT8(save->p, players[i].eggmanblame); 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].growshrinktimer = READINT16(save->p);
players[i].rocketsneakertimer = READUINT16(save->p); players[i].rocketsneakertimer = READUINT16(save->p);
players[i].invincibilitytimer = READUINT16(save->p); players[i].invincibilitytimer = READUINT16(save->p);
players[i].invincibilityextensions = READUINT16(save->p);
players[i].eggmanexplode = READUINT8(save->p); players[i].eggmanexplode = READUINT8(save->p);
players[i].eggmanblame = READSINT8(save->p); players[i].eggmanblame = READSINT8(save->p);