oh yeah mr crabs
authorhgn <hgodden00@gmail.com>
Sat, 22 Oct 2022 02:48:43 +0000 (03:48 +0100)
committerhgn <hgodden00@gmail.com>
Sat, 22 Oct 2022 02:48:43 +0000 (03:48 +0100)
34 files changed:
audio.h
blender_export.py
common.h
menu.h
model.h
models_src/mp_dev.mdl
player.h
player_audio.h
player_physics.h
sound_src/gate_ambient.ogg
sound_src/gate_lap.ogg
sound_src/gate_pass.ogg
sound_src/jump0.ogg
sound_src/jump1.ogg
sound_src/land0.ogg [new file with mode: 0644]
sound_src/land1.ogg [new file with mode: 0644]
sound_src/land2.ogg [new file with mode: 0644]
sound_src/landsk0.ogg [new file with mode: 0644]
sound_src/landsk1.ogg [new file with mode: 0644]
sound_src/onto.ogg [new file with mode: 0644]
sound_src/outo.ogg [new file with mode: 0644]
sound_src/rewind_clack.ogg [new file with mode: 0644]
sound_src/rewind_end_1.5.ogg [new file with mode: 0644]
sound_src/rewind_end_2.5.ogg [new file with mode: 0644]
sound_src/rewind_end_6.5.ogg [new file with mode: 0644]
sound_src/rewind_start.ogg [new file with mode: 0644]
sound_src/ui_click.ogg [new file with mode: 0644]
sound_src/ui_ding.ogg [new file with mode: 0644]
sound_src/ute.ogg [new file with mode: 0644]
sound_src/ute_horn.ogg [new file with mode: 0644]
textures_src/gradients.png
world.h
world_gen.h
world_routes.h

diff --git a/audio.h b/audio.h
index 1bf710fb3255789fc1e0d9c6f342d6ab48417a93..fd212868153367ca2c19c7aad147ffb1adc684e5 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -28,8 +28,6 @@ audio_clip audio_splash =
 audio_clip audio_jumps[] = {
    { .path = "sound/jump0.ogg", .source_mode=k_audio_source_compressed, },
    { .path = "sound/jump1.ogg", .source_mode=k_audio_source_compressed, },
-   { .path = "sound/jump2.ogg", .source_mode=k_audio_source_compressed, },
-   { .path = "sound/jump3.ogg", .source_mode=k_audio_source_compressed, }
 };
 
 audio_clip audio_footsteps[] = {
@@ -40,11 +38,13 @@ audio_clip audio_footsteps[] = {
 };
 
 audio_clip audio_lands[] = {
-   { .path = "sound/revert0.ogg", .source_mode=k_audio_source_compressed },
-   { .path = "sound/revert1.ogg", .source_mode=k_audio_source_compressed },
-   { .path = "sound/revert2.ogg", .source_mode=k_audio_source_compressed },
-   { .path = "sound/revert3.ogg", .source_mode=k_audio_source_compressed },
-   { .path = "sound/revert4.ogg", .source_mode=k_audio_source_compressed }
+   { .path = "sound/land0.ogg", .source_mode=k_audio_source_compressed },
+   { .path = "sound/land1.ogg", .source_mode=k_audio_source_compressed },
+   { .path = "sound/land2.ogg", .source_mode=k_audio_source_compressed },
+   { .path = "sound/landsk0.ogg", .source_mode=k_audio_source_compressed },
+   { .path = "sound/landsk1.ogg", .source_mode=k_audio_source_compressed },
+   { .path = "sound/onto.ogg", .source_mode=k_audio_source_compressed },
+   { .path = "sound/outo.ogg", .source_mode=k_audio_source_compressed },
 };
 
 audio_clip audio_water[] = {
@@ -86,6 +86,24 @@ audio_player ambient_player =
    .name = "Ambience"
 };
 
+audio_player audio_rewind_player =
+{
+   .name = "Rewind"
+};
+
+audio_clip audio_rewind[] = {
+{ .path = "sound/rewind_start.ogg", .source_mode=k_audio_source_compressed },
+{ .path = "sound/rewind_end_1.5.ogg", .source_mode=k_audio_source_compressed},
+{ .path = "sound/rewind_end_2.5.ogg", .source_mode=k_audio_source_compressed },
+{ .path = "sound/rewind_end_6.5.ogg", .source_mode=k_audio_source_compressed },
+{ .path = "sound/rewind_clack.ogg", .source_mode=k_audio_source_compressed },
+};
+
+audio_clip audio_ui[] = {
+   { .path = "sound/ui_click.ogg", .source_mode=k_audio_source_compressed },
+   { .path = "sound/ui_ding.ogg", .source_mode=k_audio_source_compressed },
+};
+
 audio_player ambient_sprites[4] =
 {
    { .name = "Ambient Sprites 0" },
@@ -137,6 +155,7 @@ static void audio_init(void)
    audio_player_init( &ambient_sprites[2] );
    audio_player_init( &ambient_sprites[3] );
    audio_player_init( &audio_player_extra );
+   audio_player_init( &audio_rewind_player );
 
    audio_clip_loadn( audio_board, vg_list_size(audio_board) );
    audio_clip_loadn( audio_ambience, vg_list_size(audio_ambience) );
@@ -149,6 +168,8 @@ static void audio_init(void)
    audio_clip_loadn( audio_water, vg_list_size(audio_water) );
    audio_clip_loadn( audio_grass, vg_list_size(audio_grass) );
    audio_clip_loadn( audio_footsteps, vg_list_size(audio_footsteps) );
+   audio_clip_loadn( audio_rewind, vg_list_size(audio_rewind) );
+   audio_clip_loadn( audio_ui, vg_list_size(audio_ui) );
 
    audio_lock();
    u32 flags = AUDIO_FLAG_LOOP|AUDIO_FLAG_SPACIAL_3D;
@@ -166,6 +187,8 @@ static void audio_init(void)
    audio_player_set_vol( &ambient_player, 1.0f );
    audio_player_set_vol( &audio_player_gate, 0.0f );
    audio_player_set_vol( &audio_player_extra, 1.0f );
+   audio_player_set_vol( &audio_rewind_player, 0.2f );
+   audio_player_set_flags( &audio_rewind_player, 0x00 );
 
    audio_player_playclip( &audio_player0, &audio_board[0] );
    audio_player_playclip( &audio_player1, &audio_board[1] );
index 3cff63d7eed48bb2023e8dc64e788423af102aff..c069d7f925fa5412562eadee4e9bc5e27dd1e38e 100644 (file)
@@ -163,7 +163,14 @@ class classtype_bone(Structure):
 
 class classtype_achievement_box(Structure):
    _pack_ = 1
-   _fields_ = [("pstr_name",c_uint32)]
+   _fields_ = [("pstr_name",c_uint32),
+               ("trigger",c_uint32)]
+
+class classtype_audio(Structure):
+   _pack_ = 1
+   _fields_ = [("pstr_file",c_uint32),
+               ("flags",c_uint32),
+               ("volume",c_float)]
 
 # Exporter
 # ==============================================================================
@@ -822,8 +829,24 @@ def write_model(collection_name):
          entdata_length += sizeof( classtype_achievement_box )
          ach = classtype_achievement_box()
          ach.pstr_name = emplace_string( obj.cv_data.strp )
+         ach.trigger = 0
+
+         if obj.cv_data.target != None:
+            ach.trigger = obj.cv_data.target.cv_data.uid
+
          entdata_buffer += [ach]
 
+      elif classtype == 'k_classtype_audio':
+         node.classtype = 14
+
+         entdata_length += sizeof( classtype_audio )
+         aud = classtype_audio()
+         aud.pstr_file = emplace_string( obj.cv_data.strp )
+         aud.flags = obj.cv_data.intp
+         aud.volume = obj.cv_data.fltp
+
+         entdata_buffer += [aud]
+
       elif classtype == 'k_classtype_spawn':
          node.classtype = 3
 
@@ -1191,6 +1214,19 @@ def cv_draw():
             verts += [(v1[0],v1[1],v1[2])]
             colours += [(0,1,0,1),(0,1,0,1)]
 
+         if obj.cv_data.target != None:
+            vs = [None]*2
+            vs[0] = obj.location
+            vs[1] = obj.cv_data.target.location
+            indices = [(0,1)]
+            for l in indices:
+               v0 = vs[l[0]]
+               v1 = vs[l[1]]
+               verts += [(v0[0],v0[1],v0[2])]
+               verts += [(v1[0],v1[1],v1[2])]
+               colours += [(0,1,1,1),(0,1,1,1)]
+
+
       elif obj.cv_data.classtype == 'k_classtype_block':
          a = obj.data.cv_data.v0
          b = obj.data.cv_data.v1
@@ -1368,7 +1404,9 @@ class CV_MESH_SETTINGS(bpy.types.PropertyGroup):
 class CV_OBJ_SETTINGS(bpy.types.PropertyGroup):
    uid: bpy.props.IntProperty( name="" )
 
-   strp: bpy.props.StringProperty(name="string")
+   strp: bpy.props.StringProperty( name="strp" )
+   intp: bpy.props.IntProperty( name="intp" )
+   fltp: bpy.props.FloatProperty( name="fltp" )
 
    target: bpy.props.PointerProperty( type=bpy.types.Object, name="target", \
          poll=cv_poll_target )
@@ -1395,6 +1433,7 @@ class CV_OBJ_SETTINGS(bpy.types.PropertyGroup):
       ('k_classtype_SKELETON', "","", 11 ),
       ('k_classtype_SKIN',"","",12),
       ('k_classtype_achievement_box',"k_classtype_achievement_box","",13),
+      ('k_classtype_audio',"k_classtype_audio","",14),
       ])
 
 class CV_BONE_SETTINGS(bpy.types.PropertyGroup):
@@ -1474,6 +1513,11 @@ class CV_OBJ_PANEL(bpy.types.Panel):
          _.layout.prop( mesh.cv_data, "v0" )
       elif active_object.cv_data.classtype == 'k_classtype_achievement_box':
          _.layout.prop( active_object.cv_data, "strp" )
+         _.layout.prop( active_object.cv_data, "target" )
+      elif active_object.cv_data.classtype == 'k_classtype_audio':
+         _.layout.prop( active_object.cv_data, "strp" )
+         _.layout.prop( active_object.cv_data, "intp" )
+         _.layout.prop( active_object.cv_data, "fltp" )
 
 class CV_INTERFACE(bpy.types.Panel):
    bl_idname = "VIEW3D_PT_carve"
index c0a5f3599187fa39904489082b25954c1f13d847..0890ac4ef005d6ec3ccf6236fb0f117a80fc864f 100644 (file)
--- a/common.h
+++ b/common.h
@@ -11,6 +11,8 @@
 #include "vg/vg.h"
 #include "anyascii/anyascii.h"
 
+#define RESET_MAX_TIME 45.0
+
 typedef struct ray_hit ray_hit;
 struct ray_hit
 {
diff --git a/menu.h b/menu.h
index 0bfdd261047b640c2d46a6e5dde5dbfd1f89b1fa..7d8bf764441bb5fcfb01363c697759759c82171c 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -134,6 +134,10 @@ static void menu_run_directional(void)
    {
       if( btn->fn_press )
       {
+         audio_lock();
+         audio_play_oneshot( &audio_ui[0], 1.0f );
+         audio_unlock();
+
          btn->fn_press( 1 );
          return;
       }
diff --git a/model.h b/model.h
index d067b8fd8e6e8fb69eb29e563b9056b812454b98..faa9f5fd8988483bcc774ba4d70667b1a53d4f2e 100644 (file)
--- a/model.h
+++ b/model.h
@@ -40,7 +40,8 @@ enum classtype
    k_classtype_bone = 10,
    k_classtype_skeleton = 11,
    k_classtype_skin = 12,
-   k_classtype_achievement_box = 13
+   k_classtype_achievement_box = 13,
+   k_classtype_audio = 14
 };
 
 
@@ -197,7 +198,16 @@ struct classtype_skin
 
 struct classtype_achievement_box
 {
-   u32 pstr_name;
+   u32 pstr_name,
+       trigger;
+};
+
+struct classtype_audio
+{
+   u32 pstr_file,
+       flags;
+
+   float volume;
 };
 
 #pragma pack(pop)
index 3447ab4c2ea431542798a420ae80e330818f980f..7a27b2518b05d8de2631ff81b97a5b7d4ea2451d 100644 (file)
Binary files a/models_src/mp_dev.mdl and b/models_src/mp_dev.mdl differ
index 442d03e0ab7a783fd1b71bba44762e9675cb6e20..b4290af70a5e67ec774b8c1856bde58a5e102fae 100644 (file)
--- a/player.h
+++ b/player.h
@@ -77,6 +77,7 @@ static struct gplayer
          inv_visual_transform;
 
    int is_dead, death_tick_allowance, rewinding;
+   int rewind_sound_wait;
 
    v3f land_target;
    v3f land_target_log[22];
@@ -88,6 +89,7 @@ static struct gplayer
    
    /* Camera */
    float air_blend;
+   float air_time;
    
    v3f camera_pos, smooth_localcam;
    v2f angles;
@@ -101,7 +103,9 @@ static struct gplayer
    u32 rewind_incrementer,
        rewind_length;
 
-   float rewind_time;
+   float rewind_time, rewind_total_length, rewind_predicted_time;
+   double diag_rewind_start, diag_rewind_time;
+   float dist_accum;
 
    /* animation */
    double jump_time;
@@ -263,6 +267,13 @@ static void player_save_rewind_frame(void)
       v3_copy( player.camera_pos, fr->pos );
 
       player.rewind_incrementer = 0;
+
+      if( player.rewind_length > 1 )
+      {
+         player.rewind_total_length += 
+            v3_dist( player.rewind_buffer[player.rewind_length-1].pos,
+                     player.rewind_buffer[player.rewind_length-2].pos );
+      }
    }
 }
 
@@ -278,37 +289,67 @@ static void player_update_pre(void)
 
    if( vg_get_button_down( "reset" ) )
    {
-      player.rewinding = 1;
-      player.rewind_time = (float)player.rewind_length - 0.0001f;
-      player_save_rewind_frame();
-
-      player.is_dead = 0;
-      player.death_tick_allowance = 30;
-      player_restore_frame();
+      double delta = world.routes.time - world.routes.last_use;
 
-      if( !phys->on_board )
+      if( delta <= RESET_MAX_TIME )
       {
-         player.angles[0] = atan2f( -phys->rb.forward[2], 
-                                    -phys->rb.forward[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)
+          */
+
+         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.mdl.shoes[0] = 1;
-      player.mdl.shoes[1] = 1;
+         player.is_dead = 0;
+         player.death_tick_allowance = 30;
+         player_restore_frame();
 
-      world_routes_notify_reset();
+         if( !phys->on_board )
+         {
+            player.angles[0] = atan2f( -phys->rb.forward[2], 
+                                       -phys->rb.forward[0] );
+         }
 
-      /* apply 1 frame of movement */
-      player_do_motion();
+         player.mdl.shoes[0] = 1;
+         player.mdl.shoes[1] = 1;
+
+         world_routes_notify_reset();
+
+         /* apply 1 frame of movement */
+         player_do_motion();
+      }
    }
 
    if( vg_get_button_down( "switchmode" ) )
    {
       phys->on_board ^= 0x1;
 
+      audio_lock();
       if( phys->on_board )
       {
          v3_muladds( phys->rb.v, phys->rb.forward, 0.2f, phys->rb.v );
+         audio_play_oneshot( &audio_lands[6], 1.0f );
+      }
+      else
+      {
+         audio_play_oneshot( &audio_lands[5], 1.0f );
       }
+
+      audio_unlock();
    }
 }
 
@@ -372,8 +413,15 @@ static void player_update_post(void)
    {
       if( player.rewind_time <= 0.0f )
       {
+         double taken = vg.time - player.diag_rewind_start;
+         vg_success( "Rewind took (rt, pl, tl): %f, %f, %f\n", 
+                           taken, player.diag_rewind_time,
+                           player.rewind_total_length );
+
          player.rewinding = 0;
          player.rewind_length = 1;
+         player.rewind_total_length = 0.0f;
+         player.rewind_incrementer = 0;
          world.sky_target_rate = 1.0;
       }
       else
@@ -407,12 +455,63 @@ static void player_update_post(void)
 
                   advl = vg_minf( mod, subl ),
                   advt = (advl / mod) * budget;
-
+            
+            player.dist_accum += speed * advt;
             player.rewind_time -= advl;
             budget -= advt;
          }
 
+#if 0
+         if( player.dist_accum >= 5.0f )
+         {
+            audio_lock();
+            audio_player_playclip( &audio_rewind_player, &audio_rewind[4] );
+            audio_unlock();
+
+            player.dist_accum -= 5.0f;
+         }
+#endif
+
          player.rewind_time = vg_maxf( 0.0f, player.rewind_time );
+
+         float current_time = vg.time - player.diag_rewind_start,
+               remaining    = player.rewind_predicted_time - current_time;
+
+         if( player.rewind_sound_wait )
+         {
+            if( player.rewind_predicted_time >= 6.5f )
+            {
+               if( remaining <= 6.5f )
+               {
+                  audio_lock();
+                  audio_play_oneshot( &audio_rewind[3], 1.0f );
+                  audio_unlock();
+                  player.rewind_sound_wait = 0;
+               }
+            }
+            else if( player.rewind_predicted_time >= 2.5f )
+            {
+               if( remaining <= 2.5f )
+               {
+                  audio_lock();
+                  audio_play_oneshot( &audio_rewind[2], 1.0f );
+                  audio_unlock();
+                  player.rewind_sound_wait = 0;
+               }
+            }
+            else if( player.rewind_predicted_time >= 1.5f )
+            {
+               if( remaining <= 1.5f )
+               {
+                  audio_lock();
+                  audio_play_oneshot( &audio_rewind[1], 1.0f );
+                  audio_unlock();
+                  player.rewind_sound_wait = 0;
+               }
+            }
+
+
+         }
          
          int i0 = floorf( player.rewind_time ),
              i1 = VG_MIN( i0+1, player.rewind_length-1 );
index 33a050a7d523457711f290c818bfcb4f71e2b3db..00bc9c440fb39540c54afc8611188b3e4efd1d74 100644 (file)
@@ -25,15 +25,23 @@ static void player_audio(void)
 
 
    audio_lock();
-   
+
    double revert_delta = vg.time - last_revert;
-   if( phys->on_board && (!_air && l2) && (fabsf(phys->slip) > 0.5f) && 
-         (revert_delta > 0.7) )
+   if( phys->on_board && (!_air && l2) && (revert_delta > 0.7) &&
+       (player.air_time > 0.5f) )
    {
       audio_player_set_position( &audio_player_extra, phys->rb.co );
       audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
       audio_player_set_vol( &audio_player_extra, 2.0f );
-      audio_player_playclip( &audio_player_extra, &audio_lands[rand()%5] );
+
+      if( (fabsf(phys->slip) > 0.75f) )
+      {
+         audio_player_playclip( &audio_player_extra, &audio_lands[rand()%2+3] );
+      }
+      else
+      {
+         audio_player_playclip( &audio_player_extra, &audio_lands[rand()%3] );
+      }
 
       last_revert = vg.time;
    }
@@ -147,6 +155,12 @@ static void player_audio(void)
    world_audio_update( cam, ears );
 #endif
    audio_unlock();
+
+   if( player.phys.in_air )
+      player.air_time += vg.time_delta;
+   else
+      player.air_time = 0.0f;
+   
 }
 
 #endif /* PLAYER_AUDIO_H */
index b93ac0394b32aa8211cc0f7490b2134fa5cbd5c7..6c170c6d9ae16f54272096c44c69b448c340c03c 100644 (file)
@@ -465,7 +465,9 @@ static void player_physics(void)
          player_start_air();
       }
       else
+      {
          phys->in_air = 0;
+      }
    }
 
    for( int j=0; j<5; j++ )
@@ -595,7 +597,7 @@ static void player_physics(void)
          audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
          audio_player_set_position( &audio_player_extra, phys->rb.co );
          audio_player_set_vol( &audio_player_extra, 20.0f );
-         audio_player_playclip( &audio_player_extra, &audio_jumps[rand()%4] );
+         audio_player_playclip( &audio_player_extra, &audio_jumps[rand()%2] );
          audio_unlock();
       }
    }
@@ -713,6 +715,7 @@ static void player_do_motion(void)
          }
          
          player.rewind_length = 0;
+         player.rewind_total_length = 0.0f;
          player.rewind_incrementer = 10000;
          player_save_frame();
 
index b30ff3c32f80802ecf62903cee824e3031f36195..5dfa781adb823bc63b2ef8f1912104db9df44899 100644 (file)
Binary files a/sound_src/gate_ambient.ogg and b/sound_src/gate_ambient.ogg differ
index 85a3cdc667da150fd0a80fdfeaa0729638efb364..81a093053403d39bfde6909da2749ce32c509fb8 100644 (file)
Binary files a/sound_src/gate_lap.ogg and b/sound_src/gate_lap.ogg differ
index 8067a12e68e8acfec8851ce0f773ad1b735081b9..1201d4e16d78f3723dbb06f514e599c27b0ca944 100644 (file)
Binary files a/sound_src/gate_pass.ogg and b/sound_src/gate_pass.ogg differ
index c1fce981ca97f16968a9453868a6e0eaf9e8848e..6dfc54125e84929fb942aacde702bafde0ec8b25 100644 (file)
Binary files a/sound_src/jump0.ogg and b/sound_src/jump0.ogg differ
index c4d3a6cf7468b630f00aabe7ac7ac134f8c415a6..fac31652bedf8e9eef97c22933dc4d9246605903 100644 (file)
Binary files a/sound_src/jump1.ogg and b/sound_src/jump1.ogg differ
diff --git a/sound_src/land0.ogg b/sound_src/land0.ogg
new file mode 100644 (file)
index 0000000..6fafaf4
Binary files /dev/null and b/sound_src/land0.ogg differ
diff --git a/sound_src/land1.ogg b/sound_src/land1.ogg
new file mode 100644 (file)
index 0000000..b28b3f3
Binary files /dev/null and b/sound_src/land1.ogg differ
diff --git a/sound_src/land2.ogg b/sound_src/land2.ogg
new file mode 100644 (file)
index 0000000..17d1949
Binary files /dev/null and b/sound_src/land2.ogg differ
diff --git a/sound_src/landsk0.ogg b/sound_src/landsk0.ogg
new file mode 100644 (file)
index 0000000..6de28b5
Binary files /dev/null and b/sound_src/landsk0.ogg differ
diff --git a/sound_src/landsk1.ogg b/sound_src/landsk1.ogg
new file mode 100644 (file)
index 0000000..136b512
Binary files /dev/null and b/sound_src/landsk1.ogg differ
diff --git a/sound_src/onto.ogg b/sound_src/onto.ogg
new file mode 100644 (file)
index 0000000..d982b77
Binary files /dev/null and b/sound_src/onto.ogg differ
diff --git a/sound_src/outo.ogg b/sound_src/outo.ogg
new file mode 100644 (file)
index 0000000..371002d
Binary files /dev/null and b/sound_src/outo.ogg differ
diff --git a/sound_src/rewind_clack.ogg b/sound_src/rewind_clack.ogg
new file mode 100644 (file)
index 0000000..1f46789
Binary files /dev/null and b/sound_src/rewind_clack.ogg differ
diff --git a/sound_src/rewind_end_1.5.ogg b/sound_src/rewind_end_1.5.ogg
new file mode 100644 (file)
index 0000000..9bc606c
Binary files /dev/null and b/sound_src/rewind_end_1.5.ogg differ
diff --git a/sound_src/rewind_end_2.5.ogg b/sound_src/rewind_end_2.5.ogg
new file mode 100644 (file)
index 0000000..e154612
Binary files /dev/null and b/sound_src/rewind_end_2.5.ogg differ
diff --git a/sound_src/rewind_end_6.5.ogg b/sound_src/rewind_end_6.5.ogg
new file mode 100644 (file)
index 0000000..1569bb1
Binary files /dev/null and b/sound_src/rewind_end_6.5.ogg differ
diff --git a/sound_src/rewind_start.ogg b/sound_src/rewind_start.ogg
new file mode 100644 (file)
index 0000000..8f9513a
Binary files /dev/null and b/sound_src/rewind_start.ogg differ
diff --git a/sound_src/ui_click.ogg b/sound_src/ui_click.ogg
new file mode 100644 (file)
index 0000000..fd8728e
Binary files /dev/null and b/sound_src/ui_click.ogg differ
diff --git a/sound_src/ui_ding.ogg b/sound_src/ui_ding.ogg
new file mode 100644 (file)
index 0000000..9b8c8f6
Binary files /dev/null and b/sound_src/ui_ding.ogg differ
diff --git a/sound_src/ute.ogg b/sound_src/ute.ogg
new file mode 100644 (file)
index 0000000..fb73263
Binary files /dev/null and b/sound_src/ute.ogg differ
diff --git a/sound_src/ute_horn.ogg b/sound_src/ute_horn.ogg
new file mode 100644 (file)
index 0000000..770807c
Binary files /dev/null and b/sound_src/ute_horn.ogg differ
index 15bd11389e922143fdc1334a1dcf6bff40b255f3..6c2015f6023c5b4534d25766d99b1af04d3df8e0 100644 (file)
Binary files a/textures_src/gradients.png and b/textures_src/gradients.png differ
diff --git a/world.h b/world.h
index ba5d5e4b7409e7f57492aaef82cad54675cbf02a..3b30973099152990e276dbc780869f1f08dc623c 100644 (file)
--- a/world.h
+++ b/world.h
@@ -58,11 +58,31 @@ static struct gworld
    spawns[32];
    u32 spawn_count;
 
+   struct world_audio_thing
+   {
+      v3f pos;
+      float volume;
+      u32 flags;
+
+      audio_player player;
+      audio_clip temp_embedded_clip;
+   }
+   * audio_things;
+   
+   u32 audio_things_count,
+       audio_things_cap;
+
    struct achievement_zone
    {
       m4x3f transform, inv_transform;
       char name[32];
       int triggered;
+
+      union
+      {
+         mdl_node *ptarget_delegated;
+         struct world_audio_thing *ptarget;
+      };
    }
    * achievement_zones;
 
@@ -305,13 +325,18 @@ static void world_free( void *_ )
    mesh_free( &world.cars );
    mesh_free( &world.skydome );
    vg_free( world.achievement_zones );
+
+   /* FIXME: This fucks with the audio player. Use-after-free */
+#if 0
+   vg_free( world.audio_things );
+#endif
 }
 
 static void world_update( v3f pos )
 {
    world.sky_time += world.sky_rate * vg.time_delta;
    world.sky_rate = vg_lerp( world.sky_rate, world.sky_target_rate, 
-                                 vg.time_delta * 10.0 );
+                                 vg.time_delta * 5.0 );
 
    world_routes_update();
 #if 0
@@ -353,13 +378,14 @@ static void world_update( v3f pos )
       }
    }
 
+   static int in_zone = 0;
+
+   int in_zone_this_time = 0;
+
    for( int i=0; i<world.achievement_zones_count; i++ )
    {
       struct achievement_zone *zone = &world.achievement_zones[i];
 
-      if( zone->triggered )
-         continue;
-
       v3f local;
       m4x3_mulv( zone->inv_transform, pos, local );
       
@@ -367,15 +393,31 @@ static void world_update( v3f pos )
           (fabsf(local[1]) <= 1.0f) &&
           (fabsf(local[2]) <= 1.0f) )
       {
+         in_zone_this_time = 1;
+
+         if( !in_zone && zone->ptarget )
+         {
+            audio_lock();
+            audio_player_playclip( &zone->ptarget->player, 
+                                   &zone->ptarget->temp_embedded_clip );
+            audio_unlock();
+         }
+
+         if( !zone->triggered )
+         {
+            steam_set_achievement( zone->name );
+            steam_store_achievements();
+         }
+
          zone->triggered = 1;
-         steam_set_achievement( zone->name );
-         steam_store_achievements();
       }
 
       vg_line_boxf_transformed( zone->transform, (boxf){{-1.0f,-1.0f,-1.0f},
                                                         { 1.0f, 1.0f, 1.0f}}, 
                                                         0xff00ff00 );
    }
+
+   in_zone = in_zone_this_time;
    
    sfd_update( &world.sfd.tester );
 }
index 54857f59137ea40c3c34f84ad6004cb8ebcf49aa..31722e563bf40f8a662929b000cdb5747fefe559 100644 (file)
@@ -227,9 +227,79 @@ static void world_load(void)
          vg_strncpy( mdl_pstr(mworld, box->pstr_name), zone->name, 31 );
          zone->name[31] = 0x00;
          zone->triggered = 0;
+
+         if( box->trigger )
+            zone->ptarget_delegated = mdl_node_from_id( mworld, box->trigger );
+         else
+            zone->ptarget_delegated = NULL;
+      }
+      else if( pnode->classtype == k_classtype_audio )
+      {
+         world.audio_things = 
+            buffer_reserve( world.audio_things,
+                            world.audio_things_count,
+                            &world.audio_things_cap, 1, 
+                            sizeof(struct world_audio_thing) );
+
+         struct world_audio_thing *thing = &world.audio_things[
+                                            world.audio_things_count ];
+         memset( thing, 0, sizeof(struct world_audio_thing) );
+         struct classtype_audio *aud = mdl_get_entdata(mworld,pnode);
+
+         v3_copy( pnode->co, thing->pos );
+         
+         if( aud->flags & AUDIO_FLAG_SPACIAL_3D )
+            thing->volume = aud->volume * pnode->s[0];
+         else
+            thing->volume = aud->volume;
+
+         thing->flags = aud->flags;
+         const char *fp = mdl_pstr( mworld, aud->pstr_file );
+         char *path2 = vg_alloc( strlen(fp)+1 );
+         strcpy( path2, fp );
+         thing->temp_embedded_clip.path = path2;
+         thing->temp_embedded_clip.source_mode = k_audio_source_compressed;
+         audio_clip_load( &thing->temp_embedded_clip );
+         thing->player.name = "[temp]";
+         thing->player.enqued = 0;
+
+         pnode->sub_uid = world.audio_things_count;
+         world.audio_things_count ++;
       }
    }
 
+   /* fixup links */
+   for( int i=0; i<world.achievement_zones_count; i ++ )
+   {
+      struct achievement_zone *ach = &world.achievement_zones[ i ];
+      if( ach->ptarget_delegated )
+      {
+         u32 id = ach->ptarget_delegated->sub_uid;
+         ach->ptarget = &world.audio_things[ id ];
+      }
+      else
+         ach->ptarget = NULL;
+   }
+
+   /* initialize audio if need be */
+   audio_lock();
+   for( int i=0; i<world.audio_things_count; i++ )
+   {
+      struct world_audio_thing *thingy = &world.audio_things[ i ];
+      
+      audio_player_init( &thingy->player );
+      audio_player_set_flags( &thingy->player, thingy->flags );
+      audio_player_set_vol( &thingy->player, thingy->volume );
+      audio_player_set_pan( &thingy->player, 0.0f );
+
+      if( thingy->flags & AUDIO_FLAG_SPACIAL_3D )
+         audio_player_set_position( &thingy->player, thingy->pos );
+
+      if( thingy->flags & AUDIO_FLAG_AUTO_START )
+         audio_player_playclip( &thingy->player, &thingy->temp_embedded_clip );
+   }
+   audio_unlock();
+
    world.instance_cache = buffer_fix( world.instance_cache, 
                                       world.instance_cache_count,
                                      &world.instance_cache_cap,
index 8d859891623807ec26c01c8e6d37e5f23e6a2433..35d3cd7088f32fc8330be7412a62d3ccdd6ff15a 100644 (file)
@@ -1114,6 +1114,8 @@ static void world_routes_init(void)
 {
    struct subworld_routes *r = &world.routes;
    r->current_run_version = 2;
+   r->time = RESET_MAX_TIME*2.0;
+   r->last_use = 0.0;
 
    shader_route_register();
    shader_routeui_register();