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..33355b26c 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,36 @@ 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 > 4 && player->tumbleHeight < 40); } static void K_HandleTumbleBounce(player_t *player) { + fixed_t gravityadjust; player->tumbleBounces++; player->tumbleHeight = (player->tumbleHeight * 4) / 5; + player->tumbleSound = 0; if (player->tumbleHeight < 10) { @@ -2556,14 +2576,15 @@ static void K_HandleTumbleBounce(player_t *player) player->tumbleHeight = 10; } - if (player->tumbleBounces > 4 && player->tumbleHeight < 30) + if (K_LastTumbleBounceCondition(player)) { - // 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) { // End tumble state player->tumbleBounces = 0; + player->tumbleLastBounce = false; // Reset for next time return; } else @@ -2571,13 +2592,42 @@ 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 stop rotating the player automatically } } + if (P_IsDisplayPlayer(player) && player->tumbleHeight >= 40) + P_StartQuake((player->tumbleHeight*3/2)<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; - 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 (!K_LastTumbleBounceCondition(player) && + !player->tumbleSound && momz < -10*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 +6052,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 +8069,17 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // debug shit //CONS_Printf("%d\n", player->mo->momz / mapobjectscale); + if (momz < -10*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);