basic replayable replays
[carveJwlIkooP6JGAAIwe30JlM.git] / player_walk.c
index fbae15d4e1dc12b1c18bb21094d0dcdf645c89b6..21390c2610ee462aaafa770886a261b98fb1ce9c 100644 (file)
@@ -2,6 +2,8 @@
 #define PLAYER_WALK_C
 
 #include "player.h"
+#include "input.h"
+#include "audio.h"
 
 VG_STATIC void player_walk_drop_in_vector( player_instance *player, v3f vec )
 {
@@ -68,6 +70,7 @@ VG_STATIC void player_walk_generic_to_skate( player_instance *player,
 
 VG_STATIC void player_walk_drop_in_to_skate( player_instance *player )
 {
+   player->immobile = 0;
    player->subsystem = k_player_subsystem_skate;
 
    struct player_walk *w = &player->_walk;
@@ -85,7 +88,7 @@ VG_STATIC void player_walk_drop_in_to_skate( player_instance *player )
    v3_muladds( player->rb.co, player->rb.to_world[1], 1.0f, s->state.cog );
    v3_copy( init_velocity, s->state.cog_v );
    v3_copy( init_velocity, player->rb.v );
-   v3_copy( init_velocity, player->cam_velocity_smooth );
+   v3_copy( init_velocity, player->cam_control.cam_velocity_smooth );
    v3_copy( (v3f){1.0f,0.0f,0.0f}, s->state.trick_euler );
 }
 
@@ -118,7 +121,7 @@ VG_STATIC void player_walk_drop_in_overhang_transform( player_instance *player,
 VG_STATIC int player_walk_scan_for_drop_in( player_instance *player )
 {
    struct player_walk *w = &player->_walk;
-   world_instance *world = get_active_world();
+   world_instance *world = world_current_instance();
 
    v3f dir, center;
    q_mulv( player->rb.q, (v3f){0.0f,0.0f,1.0f}, dir );
@@ -144,7 +147,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player )
       if( ray_world( world, pos, ray_dir, ray ) )
       {
          vg_line( pos, ray->pos, VG__RED );
-         vg_line_pt3( ray->pos, 0.025f, VG__BLACK );
+         vg_line_point( ray->pos, 0.025f, VG__BLACK );
          
          sample_count ++;
       }
@@ -222,7 +225,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player )
          if( ray_world( world, va, v0, &ray ) )
          {
             vg_line( va, vb, VG__RED );
-            vg_line_pt3( ray.pos, 0.1f, VG__RED );
+            vg_line_point( ray.pos, 0.1f, VG__RED );
             vg_error( "invalidated\n" );
             return 0;
          }
@@ -231,7 +234,7 @@ VG_STATIC int player_walk_scan_for_drop_in( player_instance *player )
          if( ray_world( world, vb, v0, &ray ) )
          {
             vg_line( va, vb, VG__RED );
-            vg_line_pt3( ray.pos, 0.1f, VG__RED );
+            vg_line_point( ray.pos, 0.1f, VG__RED );
             vg_error( "invalidated\n" );
             return 0;
          }
@@ -252,28 +255,23 @@ VG_STATIC void player__walk_pre_update( player_instance *player )
 {
    struct player_walk *w = &player->_walk;
 
-   if( w->state.activity != k_walk_activity_immobile )
+   if( !player->immobile )
       player_look( player, player->angles );
 
-   if( w->state.outro_anim )
-   {
+   if( w->state.outro_anim ){
       float outro_length = (float)w->state.outro_anim->length /
                                   w->state.outro_anim->rate,
             outro_time   = vg.time - w->state.outro_start_time;
 
-      if( outro_time >= outro_length )
-      {
+      if( outro_time >= outro_length ){
          w->state.outro_anim = NULL;
-         if( w->state.outro_type == k_walk_outro_drop_in )
-         {
+         if( w->state.outro_type == k_walk_outro_drop_in ){
             player_walk_drop_in_to_skate( player );
          }
-         else if( w->state.outro_type == k_walk_outro_jump_to_air )
-         {
+         else if( w->state.outro_type == k_walk_outro_jump_to_air ){
             player_walk_generic_to_skate( player, k_skate_activity_air, 0.0f );
          }
-         else
-         {
+         else{
             player_walk_generic_to_skate( player, 
                                           k_skate_activity_ground, 1.0f );
          }
@@ -281,40 +279,50 @@ VG_STATIC void player__walk_pre_update( player_instance *player )
          return;
       }
    }
-   else if( vg_input_button_down( player->input_use ) )
-   {
-      if( w->state.activity == k_walk_activity_ground )
-      {
-         if( player_walk_scan_for_drop_in( player ) )
-         {
-            w->state.outro_type = k_walk_outro_drop_in;
-            w->state.outro_anim = w->anim_drop_in;
-            w->state.outro_start_time = vg.time;
-            w->state.activity = k_walk_activity_immobile;
-
-            struct player_avatar *av = player->playeravatar;
-            m4x3_mulv( av->sk.final_mtx[ av->id_ik_foot_r ], 
-                       av->sk.bones[ av->id_ik_foot_r ].co, 
-                       w->state.drop_in_foot_anchor );
+   else if( button_down( k_srbind_use ) && !player->immobile ){
+      if( v3_dist2( player->rb.co, gzoomer.obj.rb.co ) <= 4.0f*4.0f ){
+         player->subsystem = k_player_subsystem_drive;
+      }
+      else{
+         struct player_board *board = 
+            addon_cache_item_if_loaded( k_addon_type_board,
+                                        player->board_view_slot );
+
+         if( !board ) return;
+
+         if( w->state.activity == k_walk_activity_ground ){
+            if( player_walk_scan_for_drop_in( player ) ){
+               w->state.outro_type = k_walk_outro_drop_in;
+               w->state.outro_anim = w->anim_drop_in;
+               w->state.outro_start_time = vg.time;
+               player->immobile = 1;
+
+               struct player_avatar *av = player->playeravatar;
+               m4x3_mulv( av->sk.final_mtx[ av->id_ik_foot_r ], 
+                          av->sk.bones[ av->id_ik_foot_r ].co, 
+                          w->state.drop_in_foot_anchor );
+            }
+            else{
+               w->state.outro_type = k_walk_outro_regular;
+               w->state.outro_anim = w->anim_intro;
+               w->state.outro_start_time = vg.time;
+               w->state.activity = k_walk_activity_lockedmove;
+
+               if( player_xyspeed2(player) < 0.1f * 0.1f )
+                  q_mulv( player->rb.q, (v3f){0.0f,0.0f,1.6f}, player->rb.v );
+            }
          }
-         else
-         {
-            w->state.outro_type = k_walk_outro_regular;
-            w->state.outro_anim = w->anim_intro;
+         else{
+            w->state.outro_type = k_walk_outro_jump_to_air;
+            w->state.outro_anim = w->anim_jump_to_air;
             w->state.outro_start_time = vg.time;
-            w->state.activity = k_walk_activity_lockedmove;
-
-            if( player_xyspeed2(player) < 0.1f * 0.1f )
-               q_mulv( player->rb.q, (v3f){0.0f,0.0f,1.6f}, player->rb.v );
+            return;
          }
       }
-      else
-      {
-         w->state.outro_type = k_walk_outro_jump_to_air;
-         w->state.outro_anim = w->anim_jump_to_air;
-         w->state.outro_start_time = vg.time;
-         return;
-      }
+   }
+   else if( button_down( k_srbind_jump ) && !player->immobile ){
+      w->state.jump_queued = 1;
+      w->state.jump_input_time = vg.time;
    }
 }
 
@@ -360,8 +368,21 @@ VG_STATIC void player__walk_update( player_instance *player )
 {
    struct player_walk *w = &player->_walk;
    v3_copy( player->rb.co, w->state.prev_pos );
+   v3_zero( player->rb.w );
+
+   world_instance *world = world_current_instance();
 
-   if( w->state.activity == k_walk_activity_immobile )
+   if( world->water.enabled ){
+      if( player->rb.co[1]+0.4f < world->water.height ){
+         audio_oneshot_3d( &audio_splash, player->rb.co, 40.0f, 1.0f );
+         player__dead_transition( player );
+         return;
+      }
+   }
+
+   enum walk_activity prev_state = w->state.activity;
+
+   if( player->immobile )
       return;
 
    w->collider.height = 2.0f;
@@ -371,32 +392,27 @@ VG_STATIC void player__walk_update( player_instance *player )
    m3x3_copy( player->rb.to_world, mtx );
    v3_add( player->rb.co, player->basis[1], mtx[3] );
 
-   debug_capsule( mtx, w->collider.radius, w->collider.height, VG__WHITE );
+   vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__WHITE );
 
    rb_ct manifold[64];
    int len;
 
    float yaw = player->angles[0];
 
-   v3f forward_dir = { sinf(yaw),          0.0f, -cosf(yaw) };
-   v3f right_dir   = { -forward_dir[2],    0.0f,  forward_dir[0] };
+   v3f forward_dir = { -sinf(yaw),         0.0f,  cosf(yaw) };
+   v3f right_dir   = {  forward_dir[2],    0.0f, -forward_dir[0] };
 
    m3x3_mulv( player->basis, forward_dir, forward_dir );
    m3x3_mulv( player->basis, right_dir,   right_dir );
 
+   v2f steer;
+   joystick_state( k_srjoystick_steer, steer );
 
-   v2f walk = { player->input_walkh->axis.value,
-                player->input_walkv->axis.value };
-
-   if( v2_length2(walk) > 0.001f )
-      v2_normalize_clamp( walk );
-
-   w->move_speed = v2_length( walk );
+   w->move_speed = v2_length( steer );
 
    /* 
     * Collision detection
     */
-   world_instance *world = get_active_world();
 
    len = rb_capsule__scene( mtx, &w->collider, NULL, 
                             &world->rb_geo.inf.scene, manifold );
@@ -408,17 +424,21 @@ VG_STATIC void player__walk_update( player_instance *player )
    if( w->state.activity != k_walk_activity_lockedmove )
       w->state.activity = k_walk_activity_air;
 
-   for( int i=0; i<len; i++ )
-   {
+   w->surface = k_surface_prop_concrete;
+
+   for( int i=0; i<len; i++ ){
       struct contact *ct = &manifold[i];
       rb_debug_contact( ct );
 
-      if( player_walk_normal_standable( player, ct->n ) )
-      {
+      if( player_walk_normal_standable( player, ct->n ) ){
          if( w->state.activity != k_walk_activity_lockedmove )
             w->state.activity = k_walk_activity_ground;
 
          v3_add( surface_avg, ct->n, surface_avg );
+
+         struct world_surface *surf = world_contact_surface( world, ct );
+         if( surf->info.surface_prop > w->surface )
+            w->surface = surf->info.surface_prop;
       }
 
       rb_prepare_contact( ct, k_rb_delta );
@@ -429,18 +449,17 @@ VG_STATIC void player__walk_update( player_instance *player )
     */
    float accel_speed = 0.0f, nominal_speed = 0.0f;
    v3f movedir;
-   v3_muls( right_dir,  walk[0], movedir );
-   v3_muladds( movedir, forward_dir, walk[1], movedir );
 
-   if( w->state.activity == k_walk_activity_ground )
-   {
+   v3_muls( right_dir, steer[0], movedir );
+   v3_muladds( movedir, forward_dir, steer[1], movedir );
+
+   if( w->state.activity == k_walk_activity_ground ){
       v3_normalize( surface_avg );
 
       v3f tx, ty;
-      rb_tangent_basis( surface_avg, tx, ty );
+      v3_tangent_basis( surface_avg, tx, ty );
 
-      if( v2_length2(walk) > 0.001f )
-      {
+      if( v2_length2(steer) > 0.001f ){
          /* clip movement to the surface */
          float d = v3_dot(surface_avg,movedir);
          v3_muladds( movedir, surface_avg, -d, movedir );
@@ -450,30 +469,30 @@ VG_STATIC void player__walk_update( player_instance *player )
       nominal_speed = k_walkspeed;
 
       /* jump */
-      if( player->input_jump->button.value )
-      {
-         v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v );
-         w->state.activity = k_walk_activity_air;
-         accel_speed = k_walk_air_accel;
-         nominal_speed = k_airspeed;
+      if( w->state.jump_queued ){
+         w->state.jump_queued = 0;
+
+         f32 t = vg.time - w->state.jump_input_time;
+         if( t < PLAYER_JUMP_EPSILON ){
+            float d = v3_dot( player->basis[1], player->rb.v );
+            v3_muladds( player->rb.v, player->basis[1], -d, player->rb.v );
+            v3_muladds( player->rb.v, player->basis[1], 5.0f, player->rb.v );
+            w->state.activity = k_walk_activity_air;
+            prev_state = k_walk_activity_air;
+            accel_speed = k_walk_air_accel;
+            nominal_speed = k_airspeed;
+         }
       }
-      else
-      {
+      else{
          player_friction( player->rb.v );
-
-         struct world_material *surface_mat = 
-                                       world_contact_material( world, manifold);
-         w->surface = surface_mat->info.surface_prop;
       }
    }
-   else
-   {
+   else{
       accel_speed = k_walk_air_accel;
       nominal_speed = k_airspeed;
    }
 
-   if( v2_length2(walk) > 0.001f )
-   {
+   if( v2_length2( steer ) > 0.001f ){
       player_accelerate( player->rb.v, movedir, nominal_speed, accel_speed );
       v3_normalize( movedir );
    }
@@ -481,10 +500,8 @@ VG_STATIC void player__walk_update( player_instance *player )
    /*
     * Resolve velocity constraints
     */
-   for( int j=0; j<5; j++ )
-   {
-      for( int i=0; i<len; i++ )
-      {
+   for( int j=0; j<5; j++ ){
+      for( int i=0; i<len; i++ ){
          struct contact *ct = &manifold[i];
          
          /*normal */
@@ -498,54 +515,51 @@ VG_STATIC void player__walk_update( player_instance *player )
       }
    }
 
-   /* 
-    * Depenetrate
-    */
-   v3f dt;
-   rb_depenetrate( manifold, len, dt );
-   v3_add( dt, player->rb.co, player->rb.co );
-
-   /* TODO: Stepping......
-    *
-    *        ideas; walkgrid style steps
-    */
-#if 0
-   if( w->state.activity == k_walk_activity_ground )
-   {
-      /* step */
+   /* stepping */
+   if( w->state.activity == k_walk_activity_ground||
+       prev_state == k_walk_activity_ground ){
       float max_dist = 0.4f;
 
       v3f pa, pb;
       v3_copy( player->rb.co, pa );
-      pa[1] += w->collider.radius + max_dist;
-
-      v3_muladds( pa, (v3f){0.0f,1.0f,0.0f}, -max_dist * 2.0f, pb );
+      v3_muladds( pa, player->basis[1],  w->collider.radius + max_dist, pa );
+      v3_muladds( pa, player->basis[1], -max_dist * 2.0f, pb );
       vg_line( pa, pb, 0xff000000 );
 
       v3f n;
       float t;
-      if( spherecast_world( pa, pb, w->collider.radius, &t, n ) != -1 )
-      {
-         if( player_walk_normal_standable( n ) )
-         {
+      if( spherecast_world( world, pa, pb, w->collider.radius, &t, n ) != -1 ){
+         if( player_walk_normal_standable( player, n ) ){
             v3_lerp( pa, pb, t, player->rb.co );
-            player->rb.co[1] -= w->collider.radius;
+            v3_muladds( player->rb.co, player->basis[1], 
+                        -w->collider.radius - k_penetration_slop,
+                        player->rb.co );
+            w->state.activity = k_walk_activity_ground;
+
+            float d = -v3_dot(n,player->rb.v),
+                  g = -k_gravity * k_rb_delta;
+            v3_muladds( player->rb.v, n, d, player->rb.v );
+            v3_muladds( player->rb.v, player->basis[1], g, player->rb.v );
          }
       }
    }
-#endif
 
+   /* 
+    * Depenetrate
+    */
+   v3f dt;
+   rb_depenetrate( manifold, len, dt );
+   v3_add( dt, player->rb.co, player->rb.co );
 
    /* integrate */
-   if( w->state.activity == k_walk_activity_air )
-   {
+   if( w->state.activity == k_walk_activity_air ){
       v3_muladds( player->rb.v, player->basis[1], -k_gravity*k_rb_delta, 
                   player->rb.v );
    }
 
    v3_muladds( player->rb.co, player->rb.v, k_rb_delta, player->rb.co );
    v3_add( player->rb.co, player->basis[1], mtx[3] );
-   debug_capsule( mtx, w->collider.radius, w->collider.height, VG__GREEN );
+   vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__GREEN );
 
    /* 
     * CCD routine 
@@ -564,26 +578,23 @@ VG_STATIC void player__walk_update( player_instance *player )
 
    float movedist = v3_length( movedelta );
 
-   if( movedist > 0.3f )
-   {
+   if( movedist > 0.3f ){
       float t, sr = w->collider.radius-0.04f;
       v3f n;
 
-      if( spherecast_world( world, lwr_prev, lwr_now, sr, &t, n ) != -1 )
-      {
+      if( spherecast_world( world, lwr_prev, lwr_now, sr, &t, n ) != -1 ){
          v3_lerp( lwr_prev, lwr_now, vg_maxf(0.01f,t), player->rb.co );
          player->rb.co[1] -= w->collider.radius;
          rb_update_transform( &player->rb );
 
          v3_add( player->rb.co, player->basis[1], mtx[3] );
-         debug_capsule( mtx, w->collider.radius, w->collider.height, VG__RED );
+         vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__RED );
       }
    }
 
-   struct gate_hit hit;
-   if( world_intersect_gates(world, player->rb.co, w->state.prev_pos, &hit) )
-   {
-      teleport_gate *gate = hit.gate;
+   ent_gate *gate = 
+      world_intersect_gates( world, player->rb.co, w->state.prev_pos );
+   if( gate ){
       m4x3_mulv( gate->transport, player->rb.co, player->rb.co );
       m3x3_mulv( gate->transport, player->rb.v,  player->rb.v );
 
@@ -594,8 +605,15 @@ VG_STATIC void player__walk_update( player_instance *player )
       rb_update_transform( &player->rb );
 
       w->state_gate_storage = w->state;
-      player__pass_gate( player, &hit );
+      player__pass_gate( player, gate );
    }
+   rb_update_transform( &player->rb );
+}
+
+VG_STATIC void player__walk_restore( player_instance *player )
+{
+   struct player_walk *w = &player->_walk;
+   w->state = w->state_gate_storage;
 }
 
 VG_STATIC void player__walk_post_update( player_instance *player )
@@ -606,9 +624,9 @@ VG_STATIC void player__walk_post_update( player_instance *player )
    m3x3_copy( player->rb.to_world, mtx );
    v3_add( player->rb.co, player->basis[1], mtx[3] );
 
-   float substep = vg_clampf( vg.accumulator / k_rb_delta, 0.0f, 1.0f );
+   float substep = vg.time_fixed_extrapolate;
    v3_muladds( mtx[3], player->rb.v, k_rb_delta*substep, mtx[3] );
-   debug_capsule( mtx, w->collider.radius, w->collider.height, VG__YELOW );
+   vg_line_capsule( mtx, w->collider.radius, w->collider.height, VG__YELOW );
 
 
    /* Calculate header */
@@ -624,7 +642,7 @@ VG_STATIC void player__walk_post_update( player_instance *player )
       q_normalize( player->rb.q );
    }
 
-   vg_line_pt3( w->state.drop_in_target, 0.1f, VG__GREEN );
+   vg_line_point( w->state.drop_in_target, 0.1f, VG__GREEN );
    v3f p1;
    v3_muladds( w->state.drop_in_target, w->state.drop_in_normal, 0.3f, p1 );
    vg_line( w->state.drop_in_target, p1, VG__GREEN );
@@ -632,7 +650,7 @@ VG_STATIC void player__walk_post_update( player_instance *player )
    vg_line( w->state.drop_in_target, p1, VG__GREEN );
 
    vg_line( w->state.drop_in_target, w->state.drop_in_foot_anchor, VG__WHITE );
-   vg_line_pt3( w->state.drop_in_foot_anchor, 0.08f, VG__PINK );
+   vg_line_point( w->state.drop_in_foot_anchor, 0.08f, VG__PINK );
 
 
    float a = player_get_heading_yaw( player );
@@ -643,6 +661,40 @@ VG_STATIC void player__walk_post_update( player_instance *player )
 
    v3_add( player->rb.co, p1, p1 );
    vg_line( player->rb.co, p1, VG__PINK );
+
+
+   int walk_phase = 0;
+   if( vg_fractf(w->walk_timer) > 0.5f )
+      walk_phase = 1;
+   else
+      walk_phase = 0;
+
+   if( (w->step_phase != walk_phase) && 
+       (w->state.activity == k_walk_activity_ground ) )
+   {
+      audio_lock();
+      if( w->surface == k_surface_prop_concrete ){
+         audio_oneshot_3d( 
+               &audio_footsteps[vg_randu32()%vg_list_size(audio_footsteps)], 
+               player->rb.co, 40.0f, 1.0f 
+         );
+      }
+      else if( w->surface == k_surface_prop_grass ){
+         audio_oneshot_3d( 
+           &audio_footsteps_grass[vg_randu32()%vg_list_size(audio_footsteps_grass)],
+            player->rb.co, 40.0f, 1.0f 
+         );
+      }
+      else if( w->surface == k_surface_prop_wood ){
+         audio_oneshot_3d( 
+           &audio_footsteps_wood[vg_randu32()%vg_list_size(audio_footsteps_wood)],
+            player->rb.co, 40.0f, 1.0f 
+         );
+      }
+      audio_unlock();
+   }
+
+   w->step_phase = walk_phase;
 }
 
 VG_STATIC void player__walk_animate( player_instance *player, 
@@ -661,16 +713,12 @@ VG_STATIC void player__walk_animate( player_instance *player,
          rate = 9.0f;
 
       w->blend_fly = vg_lerpf( w->blend_fly, fly, rate*vg.time_delta );
-      w->blend_run = vg_lerpf( w->blend_run,
-                               w->move_speed *
-                               (1.0f + player->input_walk->button.value*0.5f),
-                               2.0f*vg.time_delta );
+      w->blend_run = vg_lerpf( w->blend_run, w->move_speed, 2.0f*vg.time_delta);
    }
 
    player_pose apose, bpose;
 
-   if( w->move_speed > 0.025f )
-   {
+   if( w->move_speed > 0.025f ){
       /* TODO move */
       float walk_norm = 30.0f/(float)w->anim_walk->length,
             run_norm  = 30.0f/(float)w->anim_run->length,
@@ -678,8 +726,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
 
       w->walk_timer += walk_adv * vg.time_delta;
    }
-   else
-   {
+   else{
       w->walk_timer = 0.0f;
    }
 
@@ -708,8 +755,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
 
    float walk_yaw = player_get_heading_yaw( player );
 
-   if( w->state.outro_anim )
-   {
+   if( w->state.outro_anim ){
       struct player_avatar *av = player->playeravatar;
       float outro_length = (float)w->state.outro_anim->length /
                                   w->state.outro_anim->rate,
@@ -721,8 +767,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
                                     outro_time, bpose );
       skeleton_lerp_pose( sk, apose, bpose, outro_t * 10.0f, dest->pose );
 
-      if( w->state.outro_type == k_walk_outro_drop_in )
-      {
+      if( w->state.outro_type == k_walk_outro_drop_in ){
          float inv_rate      = 1.0f / w->state.outro_anim->rate,
                anim_frames   = w->state.outro_anim->length * inv_rate,
                step_frames   = 12.0f * inv_rate,
@@ -754,8 +799,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
          
 
          /* the drop in bit */
-         if( step_t >= 1.0f )
-         {
+         if( step_t >= 1.0f ){
             v4f final_q;
             player_walk_drop_in_overhang_transform( player, dop_t, 
                                                     player->rb.co, final_q );
@@ -770,8 +814,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
          }
          return;
       }
-      else
-      {
+      else{
          v3_muladds( dest->root_co, player->rb.to_world[1], 
                      -0.1f * outro_t, dest->root_co );
 
@@ -779,8 +822,7 @@ VG_STATIC void player__walk_animate( player_instance *player,
          player->holdout_time = 1.0f;
       }
    }
-   else
-   {
+   else{
       skeleton_copy_pose( sk, apose, dest->pose );
    }
 
@@ -824,12 +866,17 @@ VG_STATIC void player__walk_im_gui( player_instance *player )
                            (const char *[]){ "k_walk_activity_air",
                                              "k_walk_activity_ground",
                                              "k_walk_activity_sleep",
-                                             "k_walk_activity_immobile",
                                              "k_walk_activity_lockedmove" }
                                              [w->state.activity] );
-
-   if( w->state.outro_anim )
-   {
+   player__debugtext( 1, "surface: %s\n",
+                           (const char *[]){ "concrete",
+                                             "wood",
+                                             "grass",
+                                             "tiles",
+                                             "metal" }
+                                             [w->surface] );
+
+   if( w->state.outro_anim ){
       float outro_length = (float)w->state.outro_anim->length /
                                   w->state.outro_anim->rate,
             outro_time   = vg.time - w->state.outro_start_time;
@@ -868,4 +915,13 @@ VG_STATIC void player__walk_transition( player_instance *player, v3f angles )
    rb_update_transform( &player->rb );
 }
 
+VG_STATIC void player__walk_reset( player_instance *player, ent_spawn *rp )
+{
+   struct player_walk *w = &player->_walk;
+   w->state.activity = k_walk_activity_air;
+   w->state.outro_type = k_walk_outro_none;
+   w->state.outro_anim = NULL;
+   w->state.outro_start_time = 0.0;
+}
+
 #endif /* PLAYER_DEVICE_WALK_H */