From: hgn Date: Sat, 3 Dec 2022 17:38:47 +0000 (+0000) Subject: allow reset on death X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;ds=sidebyside;h=1a46c04c21370ae5f81795f7fe05b1743355668e;p=carveJwlIkooP6JGAAIwe30JlM.git allow reset on death --- diff --git a/player.h b/player.h index 0ed16b6..cb36975 100644 --- a/player.h +++ b/player.h @@ -437,63 +437,58 @@ VG_STATIC void player_update_pre(void) struct player_phys *phys = &player.phys; if( player.rewinding ) - { return; - } if( vg_input_button_down( player.input_reset ) && !menu_enabled() ) { - if( player.is_dead ) + double delta = world.time - world.last_use; + + if( (delta <= RESET_MAX_TIME) && (world.last_use != 0.0) ) { - reset_player( 0, NULL ); + player.rewinding = 1; + player.rewind_sound_wait = 1; + player.rewind_time = (float)player.rewind_length - 0.0001f; + player_save_rewind_frame(); audio_lock(); - audio_play_oneshot( &audio_ui[0], 1.0f ); + audio_play_oneshot( &audio_rewind[0], 1.0f ); audio_unlock(); - } - else - { - double delta = world.time - world.last_use; - - if( (delta <= RESET_MAX_TIME) && (world.last_use != 0.0) ) - { - player.rewinding = 1; - player.rewind_sound_wait = 1; - player.rewind_time = (float)player.rewind_length - 0.0001f; - player_save_rewind_frame(); - audio_lock(); - audio_play_oneshot( &audio_rewind[0], 1.0f ); - audio_unlock(); - /* based on analytical testing. DONT CHANGE! - * - * time taken: y = (x^(4/5)) * 74.5 - * inverse : x = (2/149)^(4/5) * y^(4/5) - */ + /* based on analytical testing. DONT CHANGE! + * + * time taken: y = (x^(4/5)) * 74.5 + * inverse : x = (2/149)^(4/5) * y^(4/5) + */ - float constant = powf( 2.0f/149.0f, 4.0f/5.0f ), - curve = powf( player.rewind_total_length, 4.0f/5.0f ); - - player.rewind_predicted_time = constant * curve; - player.diag_rewind_start = vg.time; - player.diag_rewind_time = player.rewind_time; + float constant = powf( 2.0f/149.0f, 4.0f/5.0f ), + curve = powf( player.rewind_total_length, 4.0f/5.0f ); + + player.rewind_predicted_time = constant * curve; + player.diag_rewind_start = vg.time; + player.diag_rewind_time = player.rewind_time; - player.is_dead = 0; - player.death_tick_allowance = 30; - player_restore_frame(); + player.is_dead = 0; + player.death_tick_allowance = 30; + player_restore_frame(); - if( !phys->on_board ) - { - player.angles[0] = atan2f( -phys->rb.forward[2], - -phys->rb.forward[0] ); - } + if( !phys->on_board ) + { + player.angles[0] = atan2f( -phys->rb.forward[2], + -phys->rb.forward[0] ); + } - player.mdl.shoes[0] = 1; - player.mdl.shoes[1] = 1; + player.mdl.shoes[0] = 1; + player.mdl.shoes[1] = 1; - world_routes_notify_reset(); + world_routes_notify_reset(); - /* apply 1 frame of movement */ - player_do_motion(); + /* apply 1 frame of movement */ + player_do_motion(); + } + else + { + if( player.is_dead ) + { + reset_player( 0, NULL ); } else { @@ -744,7 +739,6 @@ VG_STATIC void player_kill(void) { player.is_dead = 1; player_ragdoll_copy_model( player.phys.rb.v ); - world_routes_clear(); } }