X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_skate.c;h=b39b016be42c4f95dd2830addbb1693d6d69731f;hb=ce0205fd929e5fb1446f8c52fcab344884d82569;hp=7acc9f5ff0292652a4caa0ce6e7afbbc5b5b89db;hpb=5388f705086600105358d9880e8895673ac0e247;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_skate.c b/player_skate.c index 7acc9f5..b39b016 100644 --- a/player_skate.c +++ b/player_skate.c @@ -974,11 +974,9 @@ static void skate_apply_jump_model(void){ v3_muladds( localplayer.rb.v, jumpdir, force, localplayer.rb.v ); state->jump_charge = 0.0f; state->jump_time = vg.time; - - audio_lock(); - audio_oneshot_3d( &audio_jumps[vg_randu32()%2], - localplayer.rb.co,40.0f,1.0f); - audio_unlock(); + player__networked_sfx( k_player_subsystem_skate, 32, + k_player_skate_soundeffect_jump, + localplayer.rb.co, 1.0f ); } } @@ -2039,7 +2037,11 @@ static void player__skate_update(void){ if( world->water.enabled ){ if( localplayer.rb.co[1]+0.25f < world->water.height ){ - audio_oneshot_3d( &audio_splash, localplayer.rb.co, 40.0f, 1.0f ); +#if 0 + player__networked_sfx( k_player_subsystem_walk, 32, + k_player_walk_soundeffect_splash, + localplayer.rb.co, 1.0f ); +#endif player__skate_kill_audio(); player__dead_transition(); return; @@ -2160,15 +2162,15 @@ static void player__skate_update(void){ } if( (prev_contacts[0]+prev_contacts[1] == 1) && (contact_count == 2) ){ - audio_lock(); for( int i=0; i<2; i++ ){ if( !prev_contacts[i] ){ v3f co; m4x3_mulv( localplayer.rb.to_world, wheels[i].pos, co ); - audio_oneshot_3d( &audio_taps[vg_randu32()%4], co, 40.0f, 0.75f ); + player__networked_sfx( k_player_subsystem_skate, 32, + k_player_skate_soundeffect_tap, + localplayer.rb.co, 0.75f ); } } - audio_unlock(); } if( contact_count ){ @@ -2558,28 +2560,30 @@ begin_collision:; if( stick_frames > 5 ) stick_frames = 5; if( stick_frames == 4 ){ - audio_lock(); - if( state->activity == k_skate_activity_ground ){ if( (fabsf(state->slip) > 0.75f) ){ - audio_oneshot_3d( &audio_lands[vg_randu32()%2+3], localplayer.rb.co, - 40.0f, 1.0f ); + player__networked_sfx( k_player_subsystem_skate, 128, + k_player_skate_soundeffect_land_bad, + localplayer.rb.co, 0.6f ); } else{ - audio_oneshot_3d( &audio_lands[vg_randu32()%3], localplayer.rb.co, - 40.0f, 1.0f ); + player__networked_sfx( k_player_subsystem_skate, 128, + k_player_skate_soundeffect_land_good, + localplayer.rb.co, 1.0f ); } } else if( player_skate.surface == k_surface_prop_metal ){ - audio_oneshot_3d( &audio_board[3], localplayer.rb.co, 40.0f, 1.0f ); + player__networked_sfx( k_player_subsystem_skate, 128, + k_player_skate_soundeffect_grind_metal, + localplayer.rb.co, 1.0f ); } else{ - audio_oneshot_3d( &audio_board[8], localplayer.rb.co, 40.0f, 1.0f ); + player__networked_sfx( k_player_subsystem_skate, 128, + k_player_skate_soundeffect_grind_wood, + localplayer.rb.co, 1.0f ); } - - audio_unlock(); } else if( stick_frames == 0 ){ - + /* TODO: EXIT SOUNDS */ } } @@ -3190,8 +3194,9 @@ static void player__skate_reset( ent_spawn *rp ){ static void player__skate_animator_exchange( bitpack_ctx *ctx, void *data ){ struct player_skate_animator *animator = data; - bitpack_bytes( ctx, sizeof(animator->root_co), animator->root_co ); + bitpack_qv3f( ctx, 24, -1024.0f, 1024.0f, animator->root_co ); bitpack_qquat( ctx, animator->root_q ); + bitpack_qv3f( ctx, 8, -1.0f, 1.0f, animator->offset ); bitpack_qv3f( ctx, 8, -1.0f, 1.0f, animator->local_cog ); bitpack_qf32( ctx, 8, 0.0f, 1.0f, &animator->slide ); @@ -3232,6 +3237,32 @@ static void player__skate_animator_exchange( bitpack_ctx *ctx, void *data ){ bitpack_qv2f( ctx, 8, -1.0f, 1.0f, animator->grab ); bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->push_time ); + bitpack_qf32( ctx, 16, 0.0f, 120.0f, &animator->jump_time ); +} + +static void player__skate_sfx_oneshot( u8 id, v3f pos, f32 volume ){ + audio_lock(); + + if( id == k_player_skate_soundeffect_jump ){ + audio_oneshot_3d( &audio_jumps[vg_randu32()%2], pos, 40.0f, volume ); + } + else if( id == k_player_skate_soundeffect_tap ){ + audio_oneshot_3d( &audio_taps[vg_randu32()%4], pos, 40.0f, volume ); + } + else if( id == k_player_skate_soundeffect_land_good ){ + audio_oneshot_3d( &audio_lands[vg_randu32()%3], pos, 40.0f, volume ); + } + else if( id == k_player_skate_soundeffect_land_bad ){ + audio_oneshot_3d( &audio_lands[vg_randu32()%2+3], pos, 40.0f, volume ); + } + else if( id == k_player_skate_soundeffect_grind_metal ){ + audio_oneshot_3d( &audio_board[3], pos, 40.0f, volume ); + } + else if( id == k_player_skate_soundeffect_grind_wood ){ + audio_oneshot_3d( &audio_board[8], pos, 40.0f, volume ); + } + + audio_unlock(); } #endif /* PLAYER_SKATE_C */