Merge branch 'gasp' into 'master'

Tweak underwater VFX

Closes #1125

See merge request KartKrew/Kart!2058
This commit is contained in:
James R. 2024-03-10 08:24:57 +00:00
commit f4ab9b0be7
7 changed files with 66 additions and 15 deletions

View file

@ -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 //
//////////////

View file

@ -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

View file

@ -9324,6 +9324,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)

View file

@ -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, (p->charflags & SF_MACHINE) ? sfx_s25a : sfx_s3k38);
}
p->breathTimer = 0;
}
if (mobj->flags & MF_APPLYTERRAIN)
@ -5937,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);

View file

@ -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);

View file

@ -1778,9 +1778,10 @@ 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 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);
}
}

View file

@ -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)