From 3cd4c87df5eeddcbbdf368a11306aaf520f9e307 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 9 Jan 2021 21:58:35 +0100 Subject: [PATCH 1/5] Weaker tumble, some effects + tumble on spring panel fail --- src/d_clisrv.c | 2 ++ src/d_clisrv.h | 1 + src/d_netcmd.c | 4 +-- src/d_player.h | 1 + src/k_kart.c | 63 +++++++++++++++++++++++++++++++++++++++++---- src/k_respawn.c | 8 ++++++ src/lua_playerlib.c | 4 +++ src/p_saveg.c | 2 ++ 8 files changed, 78 insertions(+), 7 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b59adf9f3..0121fbf62 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -629,6 +629,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->tumbleBounces = players[i].tumbleBounces; rsp->tumbleHeight = SHORT(players[i].tumbleHeight); rsp->tumbleLastBounce = players[i].tumbleLastBounce; + rsp->tumbleSound = players[i].tumbleSound; // respawnvars_t rsp->respawn_state = players[i].respawn.state; @@ -786,6 +787,7 @@ static void resynch_read_player(resynch_pak *rsp) players[i].tumbleBounces = rsp->tumbleBounces; players[i].tumbleHeight = SHORT(rsp->tumbleHeight); players[i].tumbleLastBounce = (boolean)rsp->tumbleLastBounce; + players[i].tumbleSound = (boolean)rsp->tumbleSound; // respawnvars_t players[i].respawn.state = rsp->respawn_state; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 99a96fea3..66e58055e 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -294,6 +294,7 @@ typedef struct UINT8 tumbleBounces; UINT16 tumbleHeight; boolean tumbleLastBounce; + boolean tumbleSound; // respawnvars_t UINT8 respawn_state; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 460591817..e86bef0a0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2967,7 +2967,7 @@ static void Command_Respawn(void) UINT8 buf[4]; UINT8 *cp = buf; - + if (!(gamestate == GS_LEVEL || gamestate == GS_INTERMISSION || gamestate == GS_VOTING)) { @@ -4572,7 +4572,7 @@ retryscramble: // Team B gets 2nd, 3rd, 5th, 7th. // So 1st on one team, 2nd/3rd on the other, then alternates afterwards. // Sounds strange on paper, but works really well in practice! - else if (i != 2) + else if (i != 2) { // We will only randomly pick the team for the first guy. // Otherwise, just alternate back and forth, distributing players. diff --git a/src/d_player.h b/src/d_player.h index 7f9ffb959..cf5bafd24 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -573,6 +573,7 @@ typedef struct player_s UINT8 tumbleBounces; UINT16 tumbleHeight; boolean tumbleLastBounce; + boolean tumbleSound; // diff --git a/src/k_kart.c b/src/k_kart.c index 7f16afbb4..646cc0507 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2522,6 +2522,7 @@ static void K_RemoveGrowShrink(player_t *player) void K_TumblePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) { + fixed_t gravityadjust; (void)source; player->tumbleBounces = 1; @@ -2530,6 +2531,7 @@ void K_TumblePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) player->mo->momy = 2 * player->mo->momy / 3; player->tumbleHeight = 30; + player->tumbleSound = 0; if (inflictor && !P_MobjWasRemoved(inflictor)) { @@ -2537,18 +2539,31 @@ void K_TumblePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) player->tumbleHeight += (addHeight / player->mo->scale); } - player->mo->momz = player->tumbleHeight * player->mo->scale * P_MobjFlip(player->mo); + S_StartSound(player->mo, sfx_s3k9b); + + // adapt momz w/ gravity? + // as far as kart goes normal gravity is 2 (FRACUNIT*2) + + gravityadjust = P_GetMobjGravity(player->mo)/2; // so we'll halve it for our calculations. + + if (player->mo->eflags & MFE_UNDERWATER) + gravityadjust /= 2; // halve "gravity" underwater + + // and then modulate momz like that... + player->mo->momz = -gravityadjust * player->tumbleHeight; P_SetPlayerMobjState(player->mo, S_KART_SPINOUT); if (P_IsDisplayPlayer(player)) - P_StartQuake(64<tumbleBounces++; player->tumbleHeight = (player->tumbleHeight * 4) / 5; + player->tumbleSound = 0; if (player->tumbleHeight < 10) { @@ -2556,7 +2571,7 @@ static void K_HandleTumbleBounce(player_t *player) player->tumbleHeight = 10; } - if (player->tumbleBounces > 4 && player->tumbleHeight < 30) + if (player->tumbleBounces > 4 && player->tumbleHeight < 50) { // Leave tumble state when below 30 height, and have bounced off the ground enough @@ -2571,13 +2586,41 @@ static void K_HandleTumbleBounce(player_t *player) // One last bounce at the minimum height, to reset the animation player->tumbleHeight = 10; player->tumbleLastBounce = true; + player->mo->rollangle = 0; // p_user.c will sotp rotating the player automatically } } + if (P_IsDisplayPlayer(player) && player->tumbleHeight >= 50) + P_StartQuake((player->tumbleHeight*3/2)<mo, (player->tumbleHeight < 50) ? sfx_s3k5d : sfx_s3k5f); // s3k5d is bounce < 50, s3k5f otherwise! + player->mo->momx = player->mo->momx / 2; player->mo->momy = player->mo->momy / 2; - player->mo->momz = player->tumbleHeight * player->mo->scale * P_MobjFlip(player->mo); + // adapt momz w/ gravity? + // as far as kart goes normal gravity is 2 (FRACUNIT*2) + + gravityadjust = P_GetMobjGravity(player->mo)/2; // so we'll halve it for our calculations. + + if (player->mo->eflags & MFE_UNDERWATER) + gravityadjust /= 2; // halve "gravity" underwater + + // and then modulate momz like that... + player->mo->momz = -gravityadjust * player->tumbleHeight; +} + +// Play a falling sound when you start falling while tumbling and you're nowhere near done bouncing +static void K_HandleTumbleSound(player_t *player) +{ + fixed_t momz; + momz = player->mo->momz * P_MobjFlip(player->mo); + + if (!player->tumbleSound && momz < -25*player->mo->scale) + { + S_StartSound(player->mo, sfx_s3k51); + player->tumbleSound = 1; + } } void K_ExplodePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) // A bit of a hack, we just throw the player up higher here and extend their spinout timer @@ -6002,6 +6045,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->tumbleBounces > 0) { + K_HandleTumbleSound(player); if (P_IsObjectOnGround(player->mo) && player->mo->momz * P_MobjFlip(player->mo) <= 0) K_HandleTumbleBounce(player); } @@ -8018,8 +8062,17 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // debug shit //CONS_Printf("%d\n", player->mo->momz / mapobjectscale); + if (momz < -20*FRACUNIT) // :youfuckedup: + { + // tumble if you let your chance pass!! + player->tumbleBounces = 1; + player->tumbleSound = 0; + player->tumbleHeight = 30; // Base tumble bounce height + player->trickpanel = 0; + P_SetPlayerMobjState(player->mo, S_KART_SPINOUT); + } - if (player->trickdelay <= 0) + else if (player->trickdelay <= 0) // don't allow tricking at the same frame you tumble obv { if (cmd->turning > 0) diff --git a/src/k_respawn.c b/src/k_respawn.c index 875e05055..c05e1262f 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -118,6 +118,14 @@ void K_DoIngameRespawn(player_t *player) player->kartstuff[k_ringboost] = 0; player->kartstuff[k_driftboost] = 0; + + // If player was tumbling, set variables so that they don't tumble like crazy after they're done respawning + if (player->tumbleBounces > 0) + { + player->tumbleBounces = 3; // Max # of bounces-1 (so you still tumble once) + player->tumbleLastBounce = 0; // Still force them to bounce at least once for the funny + players->tumbleHeight = 20; // force tumble height + } P_ResetPlayer(player); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 63eeaa47b..81adeebc5 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -220,6 +220,8 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->tumbleHeight); else if (fastcmp(field,"tumbleLastBounce")) lua_pushboolean(L, plr->tumbleLastBounce); + else if (fastcmp(field,"tumbleSound")) + lua_pushboolean(L, plr->tumbleSound); else if (fastcmp(field,"trickpanel")) lua_pushinteger(L, plr->trickpanel); else if (fastcmp(field,"trickdelay")) @@ -525,6 +527,8 @@ static int player_set(lua_State *L) plr->tumbleHeight = (UINT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"tumbleLastBounce")) plr->tumbleLastBounce = luaL_checkboolean(L, 3); + else if (fastcmp(field,"tumbleSound")) + plr->tumbleSound = luaL_checkboolean(L, 3); else if (fastcmp(field,"trickpanel")) plr->trickpanel = luaL_checkinteger(L, 3); else if (fastcmp(field,"trickdelay")) diff --git a/src/p_saveg.c b/src/p_saveg.c index 5d8c2e2f1..650f77ef1 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -269,6 +269,7 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].tumbleBounces); WRITEUINT16(save_p, players[i].tumbleHeight); WRITEUINT8(save_p, players[i].tumbleLastBounce); + WRITEUINT8(save_p, players[i].tumbleSound); // respawnvars_t WRITEUINT8(save_p, players[i].respawn.state); @@ -468,6 +469,7 @@ static void P_NetUnArchivePlayers(void) players[i].tumbleBounces = READUINT8(save_p); players[i].tumbleHeight = READUINT16(save_p); players[i].tumbleLastBounce = (boolean)READUINT8(save_p); + players[i].tumbleSound = (boolean)READUINT8(save_p); // respawnvars_t players[i].respawn.state = READUINT8(save_p); From 0663f8fa5aeb53d7b179cb312c9821aad441a844 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 9 Jan 2021 19:02:37 -0800 Subject: [PATCH 2/5] Max tumble height 50 -> 40 --- src/k_kart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 646cc0507..1bebbcf17 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2571,9 +2571,9 @@ static void K_HandleTumbleBounce(player_t *player) player->tumbleHeight = 10; } - if (player->tumbleBounces > 4 && player->tumbleHeight < 50) + if (player->tumbleBounces > 4 && player->tumbleHeight < 40) { - // Leave tumble state when below 30 height, and have bounced off the ground enough + // Leave tumble state when below 40 height, and have bounced off the ground enough if (player->tumbleLastBounce == true) { @@ -2590,10 +2590,10 @@ static void K_HandleTumbleBounce(player_t *player) } } - if (P_IsDisplayPlayer(player) && player->tumbleHeight >= 50) + if (P_IsDisplayPlayer(player) && player->tumbleHeight >= 40) P_StartQuake((player->tumbleHeight*3/2)<mo, (player->tumbleHeight < 50) ? sfx_s3k5d : sfx_s3k5f); // s3k5d is bounce < 50, s3k5f otherwise! + S_StartSound(player->mo, (player->tumbleHeight < 40) ? sfx_s3k5d : sfx_s3k5f); // s3k5d is bounce < 50, s3k5f otherwise! player->mo->momx = player->mo->momx / 2; player->mo->momy = player->mo->momy / 2; From 12626cc883bf6f5bef63cfbd305a0c676587be65 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 9 Jan 2021 19:03:13 -0800 Subject: [PATCH 3/5] Play tumble falling sound if downward momentum is at least 10 fracunits, except on last two bounces --- src/k_kart.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1bebbcf17..1eeddb3ff 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2558,6 +2558,11 @@ void K_TumblePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) P_StartQuake(64<tumbleBounces > 4 && player->tumbleHeight < 40); +} + static void K_HandleTumbleBounce(player_t *player) { fixed_t gravityadjust; @@ -2571,7 +2576,7 @@ static void K_HandleTumbleBounce(player_t *player) player->tumbleHeight = 10; } - if (player->tumbleBounces > 4 && player->tumbleHeight < 40) + if (K_LastTumbleBounceCondition(player)) { // Leave tumble state when below 40 height, and have bounced off the ground enough @@ -2616,7 +2621,8 @@ static void K_HandleTumbleSound(player_t *player) fixed_t momz; momz = player->mo->momz * P_MobjFlip(player->mo); - if (!player->tumbleSound && momz < -25*player->mo->scale) + if (!K_LastTumbleBounceCondition(player) && + !player->tumbleSound && momz < -10*player->mo->scale) { S_StartSound(player->mo, sfx_s3k51); player->tumbleSound = 1; From 9a2bdc090c4be6d73e63ffe92e29285423da70af Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 9 Jan 2021 19:04:31 -0800 Subject: [PATCH 4/5] Make trick panel tumble penalty condition stricter --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 1eeddb3ff..6b409f19d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8068,7 +8068,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // debug shit //CONS_Printf("%d\n", player->mo->momz / mapobjectscale); - if (momz < -20*FRACUNIT) // :youfuckedup: + if (momz < -10*FRACUNIT) // :youfuckedup: { // tumble if you let your chance pass!! player->tumbleBounces = 1; From 33b6c320b2936d5714325f745c84d35c1fd660d1 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 9 Jan 2021 19:47:41 -0800 Subject: [PATCH 5/5] Reset tumbleLastBounce so the final bounce always happens --- src/k_kart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 6b409f19d..33355b26c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2584,6 +2584,7 @@ static void K_HandleTumbleBounce(player_t *player) { // End tumble state player->tumbleBounces = 0; + player->tumbleLastBounce = false; // Reset for next time return; } else @@ -2591,7 +2592,7 @@ static void K_HandleTumbleBounce(player_t *player) // One last bounce at the minimum height, to reset the animation player->tumbleHeight = 10; player->tumbleLastBounce = true; - player->mo->rollangle = 0; // p_user.c will sotp rotating the player automatically + player->mo->rollangle = 0; // p_user.c will stop rotating the player automatically } }