From fc86b5b1db057ba198023f20b2a48447424cbc20 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 8 Mar 2024 22:12:22 -0800 Subject: [PATCH 1/5] Let water sound effects be heard from slightly further away (louder) --- src/sounds.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sounds.c b/src/sounds.c index d1e4a7f65..de2ada781 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -117,9 +117,9 @@ sfxinfo_t S_sfx[NUMSFX] = {"bubbl3", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, {"bubbl4", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, {"bubbl5", false, 11, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, - {"floush", false, 16, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, + {"floush", false, 16, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, {"splash", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Glub"}, // labeling sfx_splash as "glub" and sfx_splish as "splash" seems wrong but isn't - {"splish", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Splash"}, // Splish Tails 12-08-2000 + {"splish", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Splash"}, // Splish Tails 12-08-2000 {"wdrip1", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, {"wdrip2", false, 8 , 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, {"wdrip3", false, 8, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Drip"}, @@ -666,7 +666,7 @@ sfxinfo_t S_sfx[NUMSFX] = {"s3kd9l", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Magnetism"}, // ditto {"s3kdas", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Click"}, {"s3kdal", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Click"}, // ditto - {"s3kdbs", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Running on water"}, + {"s3kdbs", false, 64, 8, -1, NULL, 0, -1, -1, LUMPERROR, "Running on water"}, {"s3kdbl", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, "Running on water"}, // ditto // 3D Blast sounds (the "missing" ones are direct copies of S3K's, no minor differences what-so-ever) From 44ff1d26ccc971e1201d9990ce0aa16ec994515d Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 8 Mar 2024 22:08:39 -0800 Subject: [PATCH 2/5] Underwater: player must be submerged for 15 seconds to play a "gasp" when they resurface --- src/d_player.h | 2 ++ src/k_kart.c | 6 ++++++ src/p_mobj.c | 16 ++++++++++------ src/p_saveg.c | 4 ++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index f78a07e38..34894ee66 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -810,6 +810,8 @@ struct player_t SINT8 glanceDir; // Direction the player is trying to look backwards in + UINT16 breathTimer; // Holding your breath underwater + ////////////// // rideroid // ////////////// diff --git a/src/k_kart.c b/src/k_kart.c index a8916621c..470bb4b7a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9306,6 +9306,12 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) player->icecube.shaketimer--; } + + if ((player->mo->eflags & MFE_UNDERWATER) && player->curshield != KSHIELD_BUBBLE) + { + if (player->breathTimer < UINT16_MAX) + player->breathTimer++; + } } void K_KartResetPlayerColor(player_t *player) diff --git a/src/p_mobj.c b/src/p_mobj.c index 2d24166f4..8dd8624a0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3441,13 +3441,17 @@ void P_MobjCheckWater(mobj_t *mobj) return; } - if (p != NULL - && p->curshield != KSHIELD_BUBBLE - && mobj->waterskip == 0 - && wasinwater) + if (wasinwater && p != NULL) { - // Play the gasp sound - S_StartSound(mobj, sfx_s3k38); + if (p->curshield != KSHIELD_BUBBLE + && mobj->waterskip == 0 + && p->breathTimer > 15*TICRATE) + { + // Play the gasp sound + S_StartSound(mobj, sfx_s3k38); + } + + p->breathTimer = 0; } if (mobj->flags & MF_APPLYTERRAIN) diff --git a/src/p_saveg.c b/src/p_saveg.c index 8a1956ba4..ac30523dc 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -549,6 +549,8 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITESINT8(save->p, players[i].glanceDir); + WRITEUINT16(save->p, players[i].breathTimer); + WRITEUINT8(save->p, players[i].typing_timer); WRITEUINT8(save->p, players[i].typing_duration); @@ -1137,6 +1139,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].glanceDir = READSINT8(save->p); + players[i].breathTimer = READUINT16(save->p); + players[i].typing_timer = READUINT8(save->p); players[i].typing_duration = READUINT8(save->p); From 33a31f9979593822e414a857ede0e62624a2a5ae Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 8 Mar 2024 22:13:17 -0800 Subject: [PATCH 3/5] Underwater: do not spawn bubbles around player using Bubble Shield --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 2712a126a..4ad7fd590 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1778,7 +1778,7 @@ static void P_DoBubbleBreath(player_t *player) fixed_t z = player->mo->z; mobj_t *bubble = NULL; - if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator) + if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator || player->curshield == KSHIELD_BUBBLE) return; if (player->charflags & SF_MACHINE) From 2b121bf3d0036481820147cec274b18dc05193d0 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 8 Mar 2024 22:13:35 -0800 Subject: [PATCH 4/5] Underwater: tweak bubble VFX - Spawn around the player, not just on a single point - 1.5x scaled - Opaque, not translucent - Carries player momentum --- src/info.c | 4 ++-- src/p_mobj.c | 2 ++ src/p_user.c | 39 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/info.c b/src/info.c index 8707a57f3..7883d74bd 100644 --- a/src/info.c +++ b/src/info.c @@ -1880,8 +1880,8 @@ state_t states[NUMSTATES] = {SPR_SMOK, FF_TRANS50|4, 8, {NULL}, 0, 0, S_NULL}, // S_SMOKE5 // Bubbles - {SPR_BUBL, FF_TRANS50, 1, {A_BubbleRise}, 0, 1024, S_SMALLBUBBLE}, // S_SMALLBUBBLE - {SPR_BUBL, FF_TRANS50|1, 1, {A_BubbleRise}, 0, 1024, S_MEDIUMBUBBLE}, // S_MEDIUMBUBBLE + {SPR_BUBL, FF_SEMIBRIGHT, 1, {A_BubbleRise}, 1, 1024, S_SMALLBUBBLE}, // S_SMALLBUBBLE + {SPR_BUBL, FF_SEMIBRIGHT|1, 1, {A_BubbleRise}, 1, 1024, S_MEDIUMBUBBLE}, // S_MEDIUMBUBBLE // Extra Large Bubble (breathable) {SPR_BUBL, FF_TRANS50|FF_FULLBRIGHT|2, 8, {A_BubbleRise}, 0, 1024, S_LARGEBUBBLE2}, // S_LARGEBUBBLE1 diff --git a/src/p_mobj.c b/src/p_mobj.c index 8dd8624a0..7fcb120a9 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -5941,6 +5941,8 @@ static void P_MobjSceneryThink(mobj_t *mobj) P_RemoveMobj(mobj); return; } + mobj->momx -= mobj->momx / 64; + mobj->momy -= mobj->momy / 64; break; case MT_FLAMEJET: P_FlameJetSceneryThink(mobj); diff --git a/src/p_user.c b/src/p_user.c index 4ad7fd590..956bf7d37 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1781,6 +1781,7 @@ static void P_DoBubbleBreath(player_t *player) if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator || player->curshield == KSHIELD_BUBBLE) return; +#if 0 if (player->charflags & SF_MACHINE) { if (P_RandomChance(PR_BUBBLE, FRACUNIT/5)) @@ -1794,22 +1795,54 @@ static void P_DoBubbleBreath(player_t *player) } } else +#endif { + fixed_t topspeed = K_GetKartSpeed(player, false, false); + fixed_t f = FixedDiv(player->speed, topspeed/2); + if (player->mo->eflags & MFE_VERTICALFLIP) z += player->mo->height - FixedDiv(player->mo->height,5*(FRACUNIT/4)); else z += FixedDiv(player->mo->height,5*(FRACUNIT/4)); - if (P_RandomChance(PR_BUBBLE, FRACUNIT/16)) + if (P_RandomChance(PR_BUBBLE, FixedMul(FRACUNIT/16, FRACUNIT + 3*f))) + { + UINT32 seed = P_GetRandSeed(PR_BUBBLE); + x += P_RandomRange(PR_BUBBLE, -16, 16) * player->mo->scale; + y += P_RandomRange(PR_BUBBLE, -16, 16) * player->mo->scale; + z += P_RandomRange(PR_BUBBLE, -16, 16) * player->mo->scale; + P_SetRandSeed(PR_BUBBLE, seed); bubble = P_SpawnMobj(x, y, z, MT_SMALLBUBBLE); - else if (P_RandomChance(PR_BUBBLE, 3*FRACUNIT/256)) + } + else if (P_RandomChance(PR_BUBBLE, FixedMul(3*FRACUNIT/256, FRACUNIT + 3*f))) + { + UINT32 seed = P_GetRandSeed(PR_BUBBLE); + x += P_RandomRange(PR_BUBBLE, -16, 16) * player->mo->scale; + y += P_RandomRange(PR_BUBBLE, -16, 16) * player->mo->scale; + z += P_RandomRange(PR_BUBBLE, -16, 16) * player->mo->scale; + P_SetRandSeed(PR_BUBBLE, seed); bubble = P_SpawnMobj(x, y, z, MT_MEDIUMBUBBLE); + } + + if (bubble) + { + bubble->color = SKINCOLOR_TEAL; + bubble->colorized = true; + + f = min(f, 11*FRACUNIT/10); + vector3_t v = {FixedMul(player->mo->momx, f), FixedMul(player->mo->momy, f), FixedMul(player->mo->momz, f)}; + if (player->mo->standingslope) + P_QuantizeMomentumToSlope(&v, player->mo->standingslope); + bubble->momx += v.x; + bubble->momy += v.y; + bubble->momz += v.z; + } } if (bubble) { bubble->threshold = 42; - bubble->destscale = player->mo->scale; + bubble->destscale = 3 * player->mo->scale / 2; P_SetScale(bubble, bubble->destscale); } } From b12dba03934b0ee13e07bf1f19c24e1b382bbc9a Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 8 Mar 2024 22:16:09 -0800 Subject: [PATCH 5/5] Underwater: SF_MACHINE characters play a different sound effect when resurfacing --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7fcb120a9..2c1baa78a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3448,7 +3448,7 @@ void P_MobjCheckWater(mobj_t *mobj) && p->breathTimer > 15*TICRATE) { // Play the gasp sound - S_StartSound(mobj, sfx_s3k38); + S_StartSound(mobj, (p->charflags & SF_MACHINE) ? sfx_s25a : sfx_s3k38); } p->breathTimer = 0;