Skip to content

Commit

Permalink
Add water related Player soundscripts
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Nov 25, 2024
1 parent 252d7f5 commit 4bb8ad4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
7 changes: 3 additions & 4 deletions dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1008,10 +1008,9 @@ void ClientPrecache( void )
PRECACHE_SOUND( "player/pl_tile4.wav" );
PRECACHE_SOUND( "player/pl_tile5.wav" );

PRECACHE_SOUND( "player/pl_swim1.wav" ); // breathe bubbles
PRECACHE_SOUND( "player/pl_swim2.wav" );
PRECACHE_SOUND( "player/pl_swim3.wav" );
PRECACHE_SOUND( "player/pl_swim4.wav" );
pWorld->RegisterAndPrecacheSoundScript(Player::underwaterExhaleSoundScript); // breathe bubbles
pWorld->RegisterAndPrecacheSoundScript(Player::undrownSoundScript);
pWorld->RegisterAndPrecacheSoundScript(Player::emergeInhaleSoundScript);

PRECACHE_SOUND( "player/pl_ladder1.wav" ); // climb ladder rung
PRECACHE_SOUND( "player/pl_ladder2.wav" );
Expand Down
20 changes: 20 additions & 0 deletions dlls/common_soundscripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,24 @@ const NamedSoundScript vehicleIgnitionSoundScript = {
"Player.VehicleUse"
};

const NamedSoundScript underwaterExhaleSoundScript = {
CHAN_BODY,
{"player/pl_swim1.wav", "player/pl_swim2.wav", "player/pl_swim3.wav", "player/pl_swim4.wav"},
0.8f,
ATTN_NORM,
"Player.UnderwaterExhale"
};

const NamedSoundScript undrownSoundScript = {
CHAN_VOICE,
{"player/pl_wade1.wav"},
"Player.Undrown"
};

const NamedSoundScript emergeInhaleSoundScript = {
CHAN_VOICE,
{"player/pl_wade2.wav"},
"Player.EmergeInhale"
};

}
3 changes: 3 additions & 0 deletions dlls/common_soundscripts.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ namespace Player
extern const NamedSoundScript fallBodySplatSoundScript;
extern const NamedSoundScript trainUseSoundScript;
extern const NamedSoundScript vehicleIgnitionSoundScript;
extern const NamedSoundScript underwaterExhaleSoundScript;
extern const NamedSoundScript undrownSoundScript;
extern const NamedSoundScript emergeInhaleSoundScript;
}

#endif
20 changes: 3 additions & 17 deletions dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1479,9 +1479,9 @@ void CBasePlayer::WaterMove()

// play 'up for air' sound
if( pev->air_finished < gpGlobals->time )
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_wade1.wav", 1, ATTN_NORM );
EmitSoundScript(Player::undrownSoundScript);
else if( pev->air_finished < gpGlobals->time + 9 )
EMIT_SOUND( ENT( pev ), CHAN_VOICE, "player/pl_wade2.wav", 1, ATTN_NORM );
EmitSoundScript(Player::emergeInhaleSoundScript);

pev->air_finished = gpGlobals->time + AIRTIME;
pev->dmg = 2;
Expand Down Expand Up @@ -1545,21 +1545,7 @@ void CBasePlayer::WaterMove()
air = (int)( pev->air_finished - gpGlobals->time );
if( !RANDOM_LONG( 0, 0x1f ) && RANDOM_LONG( 0, AIRTIME - 1 ) >= air )
{
switch( RANDOM_LONG( 0, 3 ) )
{
case 0:
EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim1.wav", 0.8, ATTN_NORM );
break;
case 1:
EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim2.wav", 0.8, ATTN_NORM );
break;
case 2:
EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim3.wav", 0.8, ATTN_NORM );
break;
case 3:
EMIT_SOUND( ENT( pev ), CHAN_BODY, "player/pl_swim4.wav", 0.8, ATTN_NORM );
break;
}
EmitSoundScript(Player::underwaterExhaleSoundScript);
}
}

Expand Down

0 comments on commit 4bb8ad4

Please sign in to comment.