Merge branch 'improved-spindash-fucking-again' into 'master'

Improved spindash + ebrake

Closes #1345 and #1344

See merge request KartKrew/Kart!2341
This commit is contained in:
Oni 2024-05-02 04:58:29 +00:00
commit f3824b5ad9
6 changed files with 49 additions and 2 deletions

View file

@ -698,6 +698,7 @@ struct player_t
INT32 nullHitlag; // Numbers of tics of hitlag that will ultimately be ignored by subtracting from hitlag INT32 nullHitlag; // Numbers of tics of hitlag that will ultimately be ignored by subtracting from hitlag
UINT8 wipeoutslow; // Timer before you slowdown when getting wiped out UINT8 wipeoutslow; // Timer before you slowdown when getting wiped out
UINT8 justbumped; // Prevent players from endlessly bumping into each other UINT8 justbumped; // Prevent players from endlessly bumping into each other
UINT8 noEbrakeMagnet; // Briefly disable 2.2 responsive ebrake if you're bumped by another player.
UINT8 tumbleBounces; UINT8 tumbleBounces;
UINT16 tumbleHeight; // In *mobjscaled* fracunits, or mfu, not raw fu UINT16 tumbleHeight; // In *mobjscaled* fracunits, or mfu, not raw fu
UINT8 justDI; // Turn-lockout timer to briefly prevent unintended turning after DI, resets when actionable or no input UINT8 justDI; // Turn-lockout timer to briefly prevent unintended turning after DI, resets when actionable or no input

View file

@ -797,6 +797,7 @@ extern INT32 itemtime;
extern INT32 bubbletime; extern INT32 bubbletime;
extern INT32 comebacktime; extern INT32 comebacktime;
extern INT32 bumptime; extern INT32 bumptime;
extern INT32 ebraketime;
extern INT32 greasetics; extern INT32 greasetics;
extern INT32 wipeoutslowtime; extern INT32 wipeoutslowtime;
extern INT32 wantedreduce; extern INT32 wantedreduce;

View file

@ -265,6 +265,7 @@ INT32 itemtime = 8*TICRATE;
INT32 bubbletime = TICRATE/2; INT32 bubbletime = TICRATE/2;
INT32 comebacktime = 3*TICRATE; INT32 comebacktime = 3*TICRATE;
INT32 bumptime = 6; INT32 bumptime = 6;
INT32 ebraketime = TICRATE;
INT32 greasetics = 3*TICRATE; INT32 greasetics = 3*TICRATE;
INT32 wipeoutslowtime = 20; INT32 wipeoutslowtime = 20;
INT32 wantedreduce = 5*TICRATE; INT32 wantedreduce = 5*TICRATE;

View file

@ -840,6 +840,7 @@ static void K_PlayerJustBumped(player_t *player)
} }
player->justbumped = bumptime; player->justbumped = bumptime;
player->noEbrakeMagnet = ebraketime;
player->spindash = 0; player->spindash = 0;
// If spinouttimer is not set yet but could be set later, // If spinouttimer is not set yet but could be set later,
@ -983,12 +984,14 @@ boolean K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2)
if (mobj1->player && mobj1->player->justbumped && !K_JustBumpedException(mobj2)) if (mobj1->player && mobj1->player->justbumped && !K_JustBumpedException(mobj2))
{ {
mobj1->player->justbumped = bumptime; mobj1->player->justbumped = bumptime;
mobj1->player->noEbrakeMagnet = ebraketime;
return false; return false;
} }
if (mobj2->player && mobj2->player->justbumped && !K_JustBumpedException(mobj1)) if (mobj2->player && mobj2->player->justbumped && !K_JustBumpedException(mobj1))
{ {
mobj2->player->justbumped = bumptime; mobj2->player->justbumped = bumptime;
mobj2->player->noEbrakeMagnet = ebraketime;
return false; return false;
} }
@ -3369,7 +3372,17 @@ fixed_t K_GetSpindashChargeSpeed(const player_t *player)
// more speed for higher weight & speed // more speed for higher weight & speed
// Tails = +16.94%, Fang = +34.94%, Mighty = +34.94%, Metal = +43.61% // Tails = +16.94%, Fang = +34.94%, Mighty = +34.94%, Metal = +43.61%
// (can be higher than this value when overcharged) // (can be higher than this value when overcharged)
const fixed_t val = (10*FRACUNIT/277) + (((player->kartspeed + player->kartweight) + 2) * FRACUNIT) / 45;
// The above comment is now strictly incorrect and I can't be assed to do the math properly.
// 2.2 introduces a power fudge to compensate for the removal of spindash overcharge. -Tyron
fixed_t val = (10*FRACUNIT/277) + (((player->kartspeed + player->kartweight) + 2) * FRACUNIT) / 45;
// 2.2 - Improved Spindash
if (!G_CompatLevel(0x000A))
{
if (gametyperules & GTR_CIRCUIT)
val = 5 * val / 4;
}
// Old behavior before desperation spindash // Old behavior before desperation spindash
// return (gametyperules & GTR_CLOSERPLAYERS) ? (4 * val) : val; // return (gametyperules & GTR_CLOSERPLAYERS) ? (4 * val) : val;
@ -9146,6 +9159,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->justbumped > 0) if (player->justbumped > 0)
player->justbumped--; player->justbumped--;
if (player->noEbrakeMagnet > 0)
player->noEbrakeMagnet--;
if (player->defenseLockout) if (player->defenseLockout)
{ {
player->instaWhipCharge = 0; player->instaWhipCharge = 0;
@ -11788,6 +11804,18 @@ static void K_KartSpindash(player_t *player)
player->pflags &= ~PF_NOFASTFALL; player->pflags &= ~PF_NOFASTFALL;
return; return;
} }
else
{
// 2.2 - More responsive ebrake
if (!G_CompatLevel(0x000A))
{
if (player->noEbrakeMagnet == 0 && (FixedHypot(player->mo->momx, player->mo->momy) < 20*player->mo->scale))
{
P_Thrust(player->mo, K_MomentumAngleReal(player->mo) + ANGLE_180, FixedHypot(player->mo->momx, player->mo->momy)/8);
}
}
}
// Handle fast falling behaviors first. // Handle fast falling behaviors first.
if (player->respawn.state != RESPAWNST_NONE) if (player->respawn.state != RESPAWNST_NONE)
@ -11861,8 +11889,18 @@ static void K_KartSpindash(player_t *player)
// Intentionally a lop-sided trade-off, so the game doesn't become // Intentionally a lop-sided trade-off, so the game doesn't become
// Funky Kong's Ring Racers. // Funky Kong's Ring Racers.
// 2.2 - No extended ring debt for recovery spindash
if (G_CompatLevel(0x000A))
{
P_PlayerRingBurst(player, 1); P_PlayerRingBurst(player, 1);
} }
else
{
if (player->rings > 0)
P_PlayerRingBurst(player, 1);
}
}
if (chargetime > 0) if (chargetime > 0)
{ {

View file

@ -250,6 +250,8 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->wipeoutslow); lua_pushinteger(L, plr->wipeoutslow);
else if (fastcmp(field,"justbumped")) else if (fastcmp(field,"justbumped"))
lua_pushinteger(L, plr->justbumped); lua_pushinteger(L, plr->justbumped);
else if (fastcmp(field,"noebrakemagnet"))
lua_pushinteger(L, plr->noEbrakeMagnet);
else if (fastcmp(field,"tumblebounces")) else if (fastcmp(field,"tumblebounces"))
lua_pushinteger(L, plr->tumbleBounces); lua_pushinteger(L, plr->tumbleBounces);
else if (fastcmp(field,"tumbleheight")) else if (fastcmp(field,"tumbleheight"))
@ -802,6 +804,8 @@ static int player_set(lua_State *L)
plr->wipeoutslow = luaL_checkinteger(L, 3); plr->wipeoutslow = luaL_checkinteger(L, 3);
else if (fastcmp(field,"justbumped")) else if (fastcmp(field,"justbumped"))
plr->justbumped = luaL_checkinteger(L, 3); plr->justbumped = luaL_checkinteger(L, 3);
else if (fastcmp(field,"noebrakemagnet"))
plr->noEbrakeMagnet = luaL_checkinteger(L, 3);
else if (fastcmp(field,"tumblebounces")) else if (fastcmp(field,"tumblebounces"))
plr->tumbleBounces = luaL_checkinteger(L, 3); plr->tumbleBounces = luaL_checkinteger(L, 3);
else if (fastcmp(field,"tumbleheight")) else if (fastcmp(field,"tumbleheight"))

View file

@ -434,6 +434,7 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEINT32(save->p, players[i].nullHitlag); WRITEINT32(save->p, players[i].nullHitlag);
WRITEUINT8(save->p, players[i].wipeoutslow); WRITEUINT8(save->p, players[i].wipeoutslow);
WRITEUINT8(save->p, players[i].justbumped); WRITEUINT8(save->p, players[i].justbumped);
WRITEUINT8(save->p, players[i].noEbrakeMagnet);
WRITEUINT8(save->p, players[i].tumbleBounces); WRITEUINT8(save->p, players[i].tumbleBounces);
WRITEUINT16(save->p, players[i].tumbleHeight); WRITEUINT16(save->p, players[i].tumbleHeight);
@ -1032,6 +1033,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
players[i].nullHitlag = READINT32(save->p); players[i].nullHitlag = READINT32(save->p);
players[i].wipeoutslow = READUINT8(save->p); players[i].wipeoutslow = READUINT8(save->p);
players[i].justbumped = READUINT8(save->p); players[i].justbumped = READUINT8(save->p);
players[i].noEbrakeMagnet = READUINT8(save->p);
players[i].tumbleBounces = READUINT8(save->p); players[i].tumbleBounces = READUINT8(save->p);
players[i].tumbleHeight = READUINT16(save->p); players[i].tumbleHeight = READUINT16(save->p);