mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Merge branch 'gasping-for-air' into 'master'
Add gasp sound effect when emerging from water See merge request KartKrew/Kart!484
This commit is contained in:
commit
463cbcef62
1 changed files with 63 additions and 54 deletions
117
src/p_mobj.c
117
src/p_mobj.c
|
|
@ -3059,14 +3059,76 @@ void P_MobjCheckWater(mobj_t *mobj)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// The rest of this code only executes on a water state change.
|
// The rest of this code only executes on a water state change.
|
||||||
if (waterwasnotset || !!(mobj->eflags & MFE_UNDERWATER) == wasinwater)
|
if (!!(mobj->eflags & MFE_UNDERWATER) == wasinwater)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (p && !p->waterskip &&
|
||||||
|
p->curshield != KSHIELD_BUBBLE && wasinwater)
|
||||||
|
{
|
||||||
|
S_StartSound(mobj, sfx_s3k38);
|
||||||
|
}
|
||||||
|
|
||||||
if ((p) // Players
|
if ((p) // Players
|
||||||
|| (mobj->flags & MF_PUSHABLE) // Pushables
|
|| (mobj->flags & MF_PUSHABLE) // Pushables
|
||||||
|| ((mobj->info->flags & MF_PUSHABLE) && mobj->fuse) // Previously pushable, might be moving still
|
|| ((mobj->info->flags & MF_PUSHABLE) && mobj->fuse) // Previously pushable, might be moving still
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
// Time to spawn the bubbles!
|
||||||
|
{
|
||||||
|
INT32 i;
|
||||||
|
INT32 bubblecount;
|
||||||
|
UINT8 prandom[4];
|
||||||
|
mobj_t *bubble;
|
||||||
|
mobjtype_t bubbletype;
|
||||||
|
|
||||||
|
if (mobj->eflags & MFE_GOOWATER || wasingoo)
|
||||||
|
S_StartSound(mobj, sfx_ghit);
|
||||||
|
else if (mobj->eflags & MFE_TOUCHLAVA)
|
||||||
|
S_StartSound(mobj, sfx_splash);
|
||||||
|
else
|
||||||
|
S_StartSound(mobj, sfx_splish); // And make a sound!
|
||||||
|
|
||||||
|
bubblecount = FixedDiv(abs(mobj->momz), mobj->scale)>>(FRACBITS-1);
|
||||||
|
// Max bubble count
|
||||||
|
if (bubblecount > 128)
|
||||||
|
bubblecount = 128;
|
||||||
|
|
||||||
|
// Create tons of bubbles
|
||||||
|
for (i = 0; i < bubblecount; i++)
|
||||||
|
{
|
||||||
|
// P_RandomByte()s are called individually to allow consistency
|
||||||
|
// across various compilers, since the order of function calls
|
||||||
|
// in C is not part of the ANSI specification.
|
||||||
|
prandom[0] = P_RandomByte();
|
||||||
|
prandom[1] = P_RandomByte();
|
||||||
|
prandom[2] = P_RandomByte();
|
||||||
|
prandom[3] = P_RandomByte();
|
||||||
|
|
||||||
|
bubbletype = MT_SMALLBUBBLE;
|
||||||
|
if (!(prandom[0] & 0x3)) // medium bubble chance up to 64 from 32
|
||||||
|
bubbletype = MT_MEDIUMBUBBLE;
|
||||||
|
|
||||||
|
bubble = P_SpawnMobj(
|
||||||
|
mobj->x + FixedMul((prandom[1]<<(FRACBITS-3)) * (prandom[0]&0x80 ? 1 : -1), mobj->scale),
|
||||||
|
mobj->y + FixedMul((prandom[2]<<(FRACBITS-3)) * (prandom[0]&0x40 ? 1 : -1), mobj->scale),
|
||||||
|
mobj->z + FixedMul((prandom[3]<<(FRACBITS-2)), mobj->scale), bubbletype);
|
||||||
|
|
||||||
|
if (bubble)
|
||||||
|
{
|
||||||
|
if (P_MobjFlip(mobj)*mobj->momz < 0)
|
||||||
|
bubble->momz = mobj->momz >> 4;
|
||||||
|
else
|
||||||
|
bubble->momz = 0;
|
||||||
|
|
||||||
|
bubble->destscale = mobj->scale;
|
||||||
|
P_SetScale(bubble, mobj->scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (waterwasnotset)
|
||||||
|
return;
|
||||||
|
|
||||||
// Check to make sure you didn't just cross into a sector to jump out of
|
// Check to make sure you didn't just cross into a sector to jump out of
|
||||||
// that has shallower water than the block you were originally in.
|
// that has shallower water than the block you were originally in.
|
||||||
if ((!(mobj->eflags & MFE_VERTICALFLIP) && mobj->watertop-mobj->floorz <= height>>1)
|
if ((!(mobj->eflags & MFE_VERTICALFLIP) && mobj->watertop-mobj->floorz <= height>>1)
|
||||||
|
|
@ -3151,59 +3213,6 @@ void P_MobjCheckWater(mobj_t *mobj)
|
||||||
P_SetScale(splish, mobj->scale);
|
P_SetScale(splish, mobj->scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time to spawn the bubbles!
|
|
||||||
{
|
|
||||||
INT32 i;
|
|
||||||
INT32 bubblecount;
|
|
||||||
UINT8 prandom[4];
|
|
||||||
mobj_t *bubble;
|
|
||||||
mobjtype_t bubbletype;
|
|
||||||
|
|
||||||
if (mobj->eflags & MFE_GOOWATER || wasingoo)
|
|
||||||
S_StartSound(mobj, sfx_ghit);
|
|
||||||
else if (mobj->eflags & MFE_TOUCHLAVA)
|
|
||||||
S_StartSound(mobj, sfx_splash);
|
|
||||||
else
|
|
||||||
S_StartSound(mobj, sfx_splish); // And make a sound!
|
|
||||||
|
|
||||||
bubblecount = FixedDiv(abs(mobj->momz), mobj->scale)>>(FRACBITS-1);
|
|
||||||
// Max bubble count
|
|
||||||
if (bubblecount > 128)
|
|
||||||
bubblecount = 128;
|
|
||||||
|
|
||||||
// Create tons of bubbles
|
|
||||||
for (i = 0; i < bubblecount; i++)
|
|
||||||
{
|
|
||||||
// P_RandomByte()s are called individually to allow consistency
|
|
||||||
// across various compilers, since the order of function calls
|
|
||||||
// in C is not part of the ANSI specification.
|
|
||||||
prandom[0] = P_RandomByte();
|
|
||||||
prandom[1] = P_RandomByte();
|
|
||||||
prandom[2] = P_RandomByte();
|
|
||||||
prandom[3] = P_RandomByte();
|
|
||||||
|
|
||||||
bubbletype = MT_SMALLBUBBLE;
|
|
||||||
if (!(prandom[0] & 0x3)) // medium bubble chance up to 64 from 32
|
|
||||||
bubbletype = MT_MEDIUMBUBBLE;
|
|
||||||
|
|
||||||
bubble = P_SpawnMobj(
|
|
||||||
mobj->x + FixedMul((prandom[1]<<(FRACBITS-3)) * (prandom[0]&0x80 ? 1 : -1), mobj->scale),
|
|
||||||
mobj->y + FixedMul((prandom[2]<<(FRACBITS-3)) * (prandom[0]&0x40 ? 1 : -1), mobj->scale),
|
|
||||||
mobj->z + FixedMul((prandom[3]<<(FRACBITS-2)), mobj->scale), bubbletype);
|
|
||||||
|
|
||||||
if (bubble)
|
|
||||||
{
|
|
||||||
if (P_MobjFlip(mobj)*mobj->momz < 0)
|
|
||||||
bubble->momz = mobj->momz >> 4;
|
|
||||||
else
|
|
||||||
bubble->momz = 0;
|
|
||||||
|
|
||||||
bubble->destscale = mobj->scale;
|
|
||||||
P_SetScale(bubble, mobj->scale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue