Added material based footsteps
This commit is contained in:
parent
69c032d56d
commit
99b25733a3
3 changed files with 99 additions and 6 deletions
|
@ -156,5 +156,9 @@ void Ammo_BuyPrimary( float fFree );
|
|||
void Ammo_BuySecondary( float fFree );
|
||||
|
||||
void Input_Handle( void );
|
||||
|
||||
// WIP
|
||||
string __fullspawndata;
|
||||
hashtable hashMaterials;
|
||||
|
||||
#define NULL __NULL__
|
||||
|
|
|
@ -31,6 +31,7 @@ void Footsteps_Update( void ) {
|
|||
float fForce;
|
||||
float dDelay;
|
||||
vector vStep;
|
||||
string sStepSound = "";
|
||||
|
||||
if ( ( self.movetype == MOVETYPE_WALK ) && ( self.flags & FL_ONGROUND ) ) {
|
||||
if ( ( self.velocity_x == 0 && self.velocity_y == 0 ) || self.fSteptime > time ) {
|
||||
|
@ -44,8 +45,46 @@ void Footsteps_Update( void ) {
|
|||
dDelay = clamp( 0.1, 1 / ( fForce / 90 ), 1 );
|
||||
|
||||
traceline( self.origin + self.view_ofs, self.origin + '0 0 -48', FALSE, self );
|
||||
sound( self, CHAN_BODY, sprintf( "player/pl_step%d.wav", floor( ( random() * 4 ) + 1 ) ), 0.5, ATTN_IDLE );
|
||||
|
||||
string sTexture = getsurfacetexture( trace_ent, getsurfacenearpoint( trace_ent, trace_endpos ) );
|
||||
|
||||
switch( (float)hash_get( hashMaterials, sTexture ) ) {
|
||||
case 'M':
|
||||
sStepSound = sprintf( "player/pl_metal%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'V':
|
||||
sStepSound = sprintf( "player/pl_duct%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'D':
|
||||
sStepSound = sprintf( "player/pl_dirt%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'S':
|
||||
sStepSound = sprintf( "player/pl_slosh%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'T':
|
||||
sStepSound = sprintf( "player/pl_tile%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'G':
|
||||
sStepSound = sprintf( "player/pl_grate%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'W':
|
||||
sStepSound = sprintf( "player/pl_step%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'P':
|
||||
sStepSound = sprintf( "player/pl_step%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'Y':
|
||||
sStepSound = sprintf( "player/pl_step%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
case 'N':
|
||||
sStepSound = sprintf( "player/pl_snow%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
default:
|
||||
sStepSound = sprintf( "player/pl_step%d.wav", floor( ( random() * 4 ) + 1 ) );
|
||||
break;
|
||||
}
|
||||
|
||||
sound( self, CHAN_BODY, sStepSound, 0.5, ATTN_IDLE );
|
||||
self.fSteptime = time + dDelay;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,21 @@ void StartFrame( void ) {
|
|||
|
||||
// The map... entity.
|
||||
void worldspawn( void ) {
|
||||
// Let's load materials.txt because someone thought this was the best idea
|
||||
string sTemp;
|
||||
filestream fileMaterial = fopen( "sound/materials.txt", FILE_READ );
|
||||
hashMaterials = hash_createtab( 512, HASH_ADD );
|
||||
|
||||
if ( fileMaterial >= 0 ) {
|
||||
while ( ( sTemp = fgets( fileMaterial ) ) ) {
|
||||
// Tokenize and just parse this stuff in
|
||||
if ( tokenize_console( sTemp ) == 2 ) {
|
||||
hash_add( hashMaterials, strtolower( argv( 1 ) ), str2chr( argv( 0 ), 0 ) );
|
||||
}
|
||||
}
|
||||
fclose( fileMaterial );
|
||||
}
|
||||
|
||||
precache_model( sCSPlayers[1] );
|
||||
precache_model( sCSPlayers[2] );
|
||||
precache_model( sCSPlayers[3] );
|
||||
|
@ -79,11 +94,6 @@ void worldspawn( void ) {
|
|||
precache_sound( "hostage/hos4.wav" );
|
||||
precache_sound( "hostage/hos5.wav" );
|
||||
|
||||
precache_sound( "player/pl_step1.wav" );
|
||||
precache_sound( "player/pl_step2.wav" );
|
||||
precache_sound( "player/pl_step3.wav" );
|
||||
precache_sound( "player/pl_step4.wav" );
|
||||
|
||||
precache_sound( "player/pl_pain2.wav" );
|
||||
precache_sound( "player/pl_pain4.wav" );
|
||||
precache_sound( "player/pl_pain5.wav" );
|
||||
|
@ -295,6 +305,46 @@ void worldspawn( void ) {
|
|||
precache_sound( "debris/bustceiling1.wav" );
|
||||
precache_sound( "debris/bustceiling2.wav" );
|
||||
precache_sound( "debris/bustceiling3.wav" );
|
||||
|
||||
precache_sound( "player/pl_metal1.wav" );
|
||||
precache_sound( "player/pl_metal2.wav" );
|
||||
precache_sound( "player/pl_metal3.wav" );
|
||||
precache_sound( "player/pl_metal4.wav" );
|
||||
|
||||
precache_sound( "player/pl_duct1.wav" );
|
||||
precache_sound( "player/pl_duct2.wav" );
|
||||
precache_sound( "player/pl_duct3.wav" );
|
||||
precache_sound( "player/pl_duct4.wav" );
|
||||
|
||||
precache_sound( "player/pl_dirt1.wav" );
|
||||
precache_sound( "player/pl_dirt2.wav" );
|
||||
precache_sound( "player/pl_dirt3.wav" );
|
||||
precache_sound( "player/pl_dirt4.wav" );
|
||||
|
||||
precache_sound( "player/pl_slosh1.wav" );
|
||||
precache_sound( "player/pl_slosh2.wav" );
|
||||
precache_sound( "player/pl_slosh3.wav" );
|
||||
precache_sound( "player/pl_slosh4.wav" );
|
||||
|
||||
precache_sound( "player/pl_tile1.wav" );
|
||||
precache_sound( "player/pl_tile2.wav" );
|
||||
precache_sound( "player/pl_tile3.wav" );
|
||||
precache_sound( "player/pl_tile4.wav" );
|
||||
|
||||
precache_sound( "player/pl_grate1.wav" );
|
||||
precache_sound( "player/pl_grate2.wav" );
|
||||
precache_sound( "player/pl_grate3.wav" );
|
||||
precache_sound( "player/pl_grate4.wav" );
|
||||
|
||||
precache_sound( "player/pl_snow1.wav" );
|
||||
precache_sound( "player/pl_snow2.wav" );
|
||||
precache_sound( "player/pl_snow3.wav" );
|
||||
precache_sound( "player/pl_snow4.wav" );
|
||||
|
||||
precache_sound( "player/pl_step1.wav" );
|
||||
precache_sound( "player/pl_step2.wav" );
|
||||
precache_sound( "player/pl_step3.wav" );
|
||||
precache_sound( "player/pl_step4.wav" );
|
||||
|
||||
lightstyle( 0, "m" );
|
||||
lightstyle( 1, "mmnmmommommnonmmonqnmmo" );
|
||||
|
|
Loading…
Reference in a new issue