Browse Source

engine: server: use soundlist to acquire random sounds for physics

master
Alibek Omarov 10 months ago
parent
commit
7daa6c3451
  1. 36
      engine/server/sv_move.c
  2. 8
      engine/server/sv_phys.c

36
engine/server/sv_move.c

@ -150,21 +150,9 @@ void SV_WaterMove( edict_t *ent ) @@ -150,21 +150,9 @@ void SV_WaterMove( edict_t *ent )
if( flags & FL_INWATER )
{
// leave the water.
switch( COM_RandomLong( 0, 3 ))
{
case 0:
SV_StartSound( ent, CHAN_BODY, "player/pl_wade1.wav", 1.0f, ATTN_NORM, 0, 100 );
break;
case 1:
SV_StartSound( ent, CHAN_BODY, "player/pl_wade2.wav", 1.0f, ATTN_NORM, 0, 100 );
break;
case 2:
SV_StartSound( ent, CHAN_BODY, "player/pl_wade3.wav", 1.0f, ATTN_NORM, 0, 100 );
break;
case 3:
SV_StartSound( ent, CHAN_BODY, "player/pl_wade4.wav", 1.0f, ATTN_NORM, 0, 100 );
break;
}
const char *snd = SoundList_GetRandom( EntityWaterExit );
if( snd )
SV_StartSound( ent, CHAN_BODY, snd, 1.0f, ATTN_NORM, 0, 100 );
ent->v.flags = flags & ~FL_INWATER;
}
@ -197,21 +185,9 @@ void SV_WaterMove( edict_t *ent ) @@ -197,21 +185,9 @@ void SV_WaterMove( edict_t *ent )
if( watertype == CONTENTS_WATER )
{
// entering the water
switch( COM_RandomLong( 0, 3 ))
{
case 0:
SV_StartSound( ent, CHAN_BODY, "player/pl_wade1.wav", 1.0f, ATTN_NORM, 0, 100 );
break;
case 1:
SV_StartSound( ent, CHAN_BODY, "player/pl_wade2.wav", 1.0f, ATTN_NORM, 0, 100 );
break;
case 2:
SV_StartSound( ent, CHAN_BODY, "player/pl_wade3.wav", 1.0f, ATTN_NORM, 0, 100 );
break;
case 3:
SV_StartSound( ent, CHAN_BODY, "player/pl_wade4.wav", 1.0f, ATTN_NORM, 0, 100 );
break;
}
const char *snd = SoundList_GetRandom( EntityWaterEnter );
if( snd )
SV_StartSound( ent, CHAN_BODY, snd, 1.0f, ATTN_NORM, 0, 100 );
}
ent->v.flags = flags | FL_INWATER;

8
engine/server/sv_phys.c

@ -1384,7 +1384,9 @@ static void SV_CheckWaterTransition( edict_t *ent ) @@ -1384,7 +1384,9 @@ static void SV_CheckWaterTransition( edict_t *ent )
if( ent->v.watertype == CONTENTS_EMPTY )
{
// just crossed into water
SV_StartSound( ent, CHAN_AUTO, "player/pl_wade1.wav", 1.0f, ATTN_NORM, 0, 100 );
const char *snd = SoundList_GetRandom( PlayerWaterEnter );
if( snd )
SV_StartSound( ent, CHAN_AUTO, snd, 1.0f, ATTN_NORM, 0, 100 );
ent->v.velocity[2] *= 0.5f;
}
@ -1418,7 +1420,9 @@ static void SV_CheckWaterTransition( edict_t *ent ) @@ -1418,7 +1420,9 @@ static void SV_CheckWaterTransition( edict_t *ent )
if( ent->v.watertype != CONTENTS_EMPTY )
{
// just crossed into water
SV_StartSound( ent, CHAN_AUTO, "player/pl_wade2.wav", 1.0f, ATTN_NORM, 0, 100 );
const char *snd = SoundList_GetRandom( PlayerWaterExit );
if( snd )
SV_StartSound( ent, CHAN_AUTO, snd, 1.0f, ATTN_NORM, 0, 100 );
}
ent->v.watertype = CONTENTS_EMPTY;
ent->v.waterlevel = 0;

Loading…
Cancel
Save