AND THER WAS LIGHT
authorhgn <hgodden00@gmail.com>
Thu, 29 May 2025 01:23:57 +0000 (02:23 +0100)
committerhgn <hgodden00@gmail.com>
Thu, 29 May 2025 01:23:57 +0000 (02:23 +0100)
19 files changed:
content_skaterift/maps/dev_hub/main.mdl
content_skaterift/maps/dev_tutorial/main.mdl
content_skaterift/maps/mp_line1/main.mdl
content_skaterift/maps/mp_spawn/main.mdl
content_skaterift/sound/city.ogg [new file with mode: 0644]
content_skaterift/sound/gino.ogg [new file with mode: 0644]
content_skaterift/sound/happy.ogg [new file with mode: 0644]
content_skaterift/sound/heli.ogg [new file with mode: 0644]
content_skaterift/sound/island.ogg [new file with mode: 0644]
content_skaterift/sound/jungle.ogg [new file with mode: 0644]
content_skaterift/sound/techno.ogg [new file with mode: 0644]
skaterift_blender/sr_main.py
src/audio.c
src/ent_npc.c
src/ent_script.c
src/ent_skateshop.c
src/entity.h
src/scripts/l1_speed.c [new file with mode: 0644]
src/world_entity.c

index ad7c362c6304e52651f968328fa099999da8c226..0c90209e981dce9d3cb982b89d896f3d3f9efb0d 100644 (file)
Binary files a/content_skaterift/maps/dev_hub/main.mdl and b/content_skaterift/maps/dev_hub/main.mdl differ
index 5ffb99f4c9dbef40cfdefe359078cca420269a20..9b6ec4b7d3aaace5e1a06ab5caf74af28b4810e2 100644 (file)
Binary files a/content_skaterift/maps/dev_tutorial/main.mdl and b/content_skaterift/maps/dev_tutorial/main.mdl differ
index 83c567ea5f8455c34e0976e6d4713c3f2f1585bf..79141db9b1bdec858cfef224942695a16d565ce5 100644 (file)
Binary files a/content_skaterift/maps/mp_line1/main.mdl and b/content_skaterift/maps/mp_line1/main.mdl differ
index d8d1473aa358ce448bbd8a713ae8b7f87018c996..58b4d7d762d2c89ae6cc2b6217e84f1ea1dd2586 100644 (file)
Binary files a/content_skaterift/maps/mp_spawn/main.mdl and b/content_skaterift/maps/mp_spawn/main.mdl differ
diff --git a/content_skaterift/sound/city.ogg b/content_skaterift/sound/city.ogg
new file mode 100644 (file)
index 0000000..13900d6
Binary files /dev/null and b/content_skaterift/sound/city.ogg differ
diff --git a/content_skaterift/sound/gino.ogg b/content_skaterift/sound/gino.ogg
new file mode 100644 (file)
index 0000000..353a2b3
Binary files /dev/null and b/content_skaterift/sound/gino.ogg differ
diff --git a/content_skaterift/sound/happy.ogg b/content_skaterift/sound/happy.ogg
new file mode 100644 (file)
index 0000000..b9f82a3
Binary files /dev/null and b/content_skaterift/sound/happy.ogg differ
diff --git a/content_skaterift/sound/heli.ogg b/content_skaterift/sound/heli.ogg
new file mode 100644 (file)
index 0000000..63b3c1e
Binary files /dev/null and b/content_skaterift/sound/heli.ogg differ
diff --git a/content_skaterift/sound/island.ogg b/content_skaterift/sound/island.ogg
new file mode 100644 (file)
index 0000000..c503e49
Binary files /dev/null and b/content_skaterift/sound/island.ogg differ
diff --git a/content_skaterift/sound/jungle.ogg b/content_skaterift/sound/jungle.ogg
new file mode 100644 (file)
index 0000000..827f14a
Binary files /dev/null and b/content_skaterift/sound/jungle.ogg differ
diff --git a/content_skaterift/sound/techno.ogg b/content_skaterift/sound/techno.ogg
new file mode 100644 (file)
index 0000000..9f197a0
Binary files /dev/null and b/content_skaterift/sound/techno.ogg differ
index 8af6c51e99ab5de83a7f0a333e7f5fae845cecef..d272cbd2c20067d78002a334a3b08f896cf3b025 100644 (file)
@@ -42,6 +42,7 @@ sr_entity_list = [
    ('ent_script',       'Script',         '', 29 ),
    ('ent_atom',         'Atom',           '', 30 ),
    ('ent_cutscene',     'Cutscene',       '', 31 ),
+   # reserved 32.. light
 ]
 
 MDL_VERSION_NR = 109
@@ -60,6 +61,7 @@ def get_entity_enum_id( alias ):
 
    if alias == 'ent_cubemap': return 21
    if alias == 'mdl_armature': return 28
+   if alias == 'ent_light': return 32
 
    return 0
 #}
@@ -217,6 +219,7 @@ class ent_light(Structure):
                ("range",c_float),
                ("inverse_world",(c_float*3)*4),  # Runtime
                ("angle_sin_cos",(c_float*2))]    # Runtime
+   sr_functions = { 'on': 0x1 }
 #}
 
 class version_refcount_union(Union):
@@ -2340,14 +2343,14 @@ class SR_UL_ENT_EVENT_LIST(bpy.types.UIList):
       if item.reciever == None:
          rec.alert=True
       rec.prop( item, 'reciever', text='',emboss=True )
-      rec.label( text=(item.reciever.SR_data.ent_type if item.reciever else '') + \
+      rec.label( text=( obj_ent_type( item.reciever ) if item.reciever else '') + \
                       (' (self)' if item.reciever == context.active_object else '' ) )
 
       rec_ev = layout.column()
       errstr = None
       if item.reciever:
       #{
-         tipo = item.reciever.SR_data.ent_type
+         tipo = obj_ent_type( item.reciever )
          cls = globals()[ tipo ]
          table = getattr( cls, 'sr_functions', None )
          if table:
index 463269b1e8e62b7ee7c6ccde072f313cf99c8ce6..2d47ca542f8bf2d88627ad09ac5e0810d311341c 100644 (file)
@@ -99,11 +99,6 @@ audio_clip audio_grass[] = {
    { .path = "sound/grass3.ogg" },
 };
 
-audio_clip audio_ambience[] =
-{
-   { .path="sound/town_generic.ogg" }
-};
-
 audio_clip audio_gate_pass = {
    .path = "sound/gate_pass.ogg"
 };
@@ -121,6 +116,11 @@ audio_clip audio_wood_break =
 .path = "sound/woodbreak.ogg"
 };
 
+audio_clip audio_gino[] = 
+{
+   { .path = "sound/gino.ogg" },
+};
+
 audio_clip audio_rewind[] = {
 { .path = "sound/rewind_start.ogg" },
 { .path = "sound/rewind_end_1.5.ogg" },
@@ -192,7 +192,6 @@ void audio_init(void)
    audio_clip_loadn( audio_taps, VG_ARRAY_LEN(audio_taps), NULL );
    audio_clip_loadn( audio_flips, VG_ARRAY_LEN(audio_flips), NULL );
    audio_clip_loadn( audio_hits, VG_ARRAY_LEN(audio_hits), NULL );
-   audio_clip_loadn( audio_ambience, VG_ARRAY_LEN(audio_ambience), NULL );
    audio_clip_loadn( &audio_splash, 1, NULL );
    audio_clip_loadn( &audio_gate_pass, 1, NULL );
    audio_clip_loadn( &audio_gate_lap, 1, NULL );
@@ -209,6 +208,7 @@ void audio_init(void)
    audio_clip_loadn( audio_rewind, VG_ARRAY_LEN(audio_rewind), NULL );
    audio_clip_loadn( audio_ui, VG_ARRAY_LEN(audio_ui), NULL );
    audio_clip_loadn( audio_challenge, VG_ARRAY_LEN(audio_challenge), NULL );
+   audio_clip_loadn( audio_gino, VG_ARRAY_LEN(audio_gino), NULL );
 
    vg_audio_lock();
    air_audio_data.channel_id = vg_audio_get_first_idle_channel();
index 12c16b5fd40750f58cee9301a58376843d80409c..81d80ffc34bda96816b4ae9f92dca44d178e7abb 100644 (file)
@@ -53,6 +53,8 @@ struct
    const cs_subtitle *subtitles;
    i32 sub_index;
    v3f sub_position;
+
+   audio_channel_id aud_gino;
 }
 _npc;
 
@@ -379,6 +381,34 @@ void _ent_npc_preupdate(void)
          else
             _npc.gino.spark_t -= vg.time_delta;
       }
+
+      vg_audio_lock();
+      if( !_npc.aud_gino )
+      {
+         _npc.aud_gino = vg_audio_get_first_idle_channel();
+         if( _npc.aud_gino )
+         {
+            vg_audio_set_channel_clip( _npc.aud_gino, &audio_gino[0] );
+            vg_audio_set_channel_spacial_falloff( _npc.aud_gino, _npc.gino.co, 40.0f );
+            vg_audio_set_channel_volume( _npc.aud_gino, 1.0, 1 );
+            vg_audio_add_channel_flags( _npc.aud_gino, AUDIO_FLAG_LOOP );
+            vg_audio_start_channel( _npc.aud_gino );
+         }
+      }
+      else
+      {
+         vg_audio_set_channel_spacial_falloff( _npc.aud_gino, _npc.gino.co, 40.0f );
+      }
+      vg_audio_unlock();
+   }
+   else
+   {
+      if( _npc.aud_gino )
+      {
+         vg_audio_lock();
+         _npc.aud_gino = vg_audio_crossfade( _npc.aud_gino, NULL, 0.1f );
+         vg_audio_unlock();
+      }
    }
 
    for( u32 i=0; i<4; i ++ )
index 228c3e63a6a68f068b3a35fc679e40ab0468b7db..c29f4cb829701e7bf8566b5a08fb2262060cec64 100644 (file)
@@ -10,6 +10,7 @@ _ent_script;
 #include "scripts/explode.c"
 #include "scripts/tutorial_island.c"
 #include "scripts/board_maker.c"
+#include "scripts/l1_speed.c"
 
 struct ent_script_table_entry _ent_script_table[] =
 {
@@ -17,6 +18,7 @@ struct ent_script_table_entry _ent_script_table[] =
    { "volc_main", _skaterift_script_volc },
    { "board_maker", _skaterift_script_board_maker },
    { "generic", _skaterift_script_generic },
+   { "l1_speed", _script_l1_speed },
    { NULL }
 };
 
index 0497c700e254cea01f6f4258803148959ef9e9ec..c270fa68b43956f23919bb7e87b5808dad3a29a2 100644 (file)
@@ -131,14 +131,17 @@ static void skateshop_playermod( bool immobile )
 
 static void skateshop_accept_board( addon_cache_id cache_id )
 {
-   vg_info( "chose board from skateshop (%u)\n", _skateshop.selected_board_index );
-   addon_cache_unwatch( k_addon_type_board, localplayer.board_view_slot );
-   addon_cache_watch( k_addon_type_board, cache_id );
-   localplayer.board_view_slot = cache_id;
-   network_send_item( k_netmsg_playeritem_board );
-   gui_helper_reset( k_gui_helper_mode_clear );
-   skateshop_playermod( 0 );
-   _skateshop.open = 0;
+   if( world_clear_event( k_world_event_shop ) )
+   {
+      vg_info( "chose board from skateshop (%u)\n", _skateshop.selected_board_index );
+      addon_cache_unwatch( k_addon_type_board, localplayer.board_view_slot );
+      addon_cache_watch( k_addon_type_board, cache_id );
+      localplayer.board_view_slot = cache_id;
+      network_send_item( k_netmsg_playeritem_board );
+      gui_helper_reset( k_gui_helper_mode_clear );
+      skateshop_playermod( 0 );
+      _skateshop.open = 0;
+   }
 }
 
 static void skateshop_accept_playermodel(void)
index bd627d015b6d14b79d9de9e8f111f17b1eef7aab..802f8fdcd73be6f434921332722894a39c4dbc01 100644 (file)
@@ -74,6 +74,7 @@ enum entity_alias{
    k_ent_script      = 29, 
    k_ent_atom        = 30,
    k_ent_cutscene    = 31,
+   k_ent_light       = 32,
    k_ent_max
 };
 
@@ -109,7 +110,8 @@ const char *_entity_alias_str[] =
    [k_ent_armature] = "mdl_armature",
    [k_ent_script] = "ent_script",
    [k_ent_atom] = "ent_atom",
-   [k_ent_cutscene] = "ent_cutscene"
+   [k_ent_cutscene] = "ent_cutscene",
+   [k_ent_light] = "ent_light"
 };
 
 static inline u32 mdl_entity_id_type( u32 entity_id )
diff --git a/src/scripts/l1_speed.c b/src/scripts/l1_speed.c
new file mode 100644 (file)
index 0000000..6b929f3
--- /dev/null
@@ -0,0 +1,35 @@
+struct script_speed
+{
+   bool ok, init;
+};
+
+static bool _script_l1_speed( ent_script_event *event )
+{
+   if( event->type == k_escript_event_allocate )
+   {
+      struct script_event_allocate *event_info = event->info;
+      struct script_speed *s = vg_linear_alloc( event_info->heap, sizeof(struct script_speed) );
+      s->ok = 0;
+      s->init = 0;
+      event_info->userdata = s;
+      return 1;
+   }
+   struct script_speed *s = event->userdata;
+
+   if( event->type == k_escript_event_update )
+   {
+      bool new_state = 0;
+      f32 speed = v3_length( localplayer.rb.v );
+      if( speed > 50.0f )
+         new_state = 1;
+
+      if( (new_state != s->ok) || (s->init == 0) )
+      {
+         _world_raise_event( event->script_entity_id, new_state? "yes": "no" );
+         s->ok = new_state;
+         s->init = 1;
+      }
+   }
+   
+   return 1;
+}
index 1b34a81eebe48661e2d506ed7712cbbb5f06a576..dabece9d90ad6b182ff316557f42d55b94a2726d 100644 (file)
@@ -390,6 +390,31 @@ entity_event_result ent_audio_event( ent_event *event )
    return k_entity_event_result_OK;
 }
 
+entity_event_result ent_light_event( ent_event *event )
+{
+   world_instance *world = &_world.main;
+   ent_light *light = af_arritm( &world->ent_light, mdl_entity_id_id( event->recieve_entity_id ) );
+
+   if( AF_STR_EQ( &world->meta.af, event->pstr_recieve_event, "on" ) )
+   {
+      if( event->flags & k_ent_event_data_const_i32 )
+      {
+         v3f colour;
+         if( event->data.const_i32 )
+            v3_muls( light->colour, light->colour[3] * 2.0f, colour );
+         else
+            v3_fill( colour, 0.0f );
+
+         u32 offset = mdl_entity_id_id( event->recieve_entity_id ) * sizeof(f32)*4*3;
+         glBindBuffer( GL_TEXTURE_BUFFER, world->tbo_light_entities );
+         glBufferSubData( GL_TEXTURE_BUFFER, offset, sizeof(f32)*3, colour );
+      }
+      else return k_entity_event_result_invalid;
+   }
+   else return k_entity_event_result_unhandled;
+   return k_entity_event_result_OK;
+}
+
 entity_event_result ent_ccmd_event( ent_event *event )
 {
    world_instance *world = &_world.main;
@@ -811,6 +836,7 @@ static void _event_trigger( ent_event *event )
       [k_ent_skateshop] = ent_skateshop_event,
       [k_ent_objective] = ent_objective_event,
       [k_ent_ccmd]      = ent_ccmd_event,
+      [k_ent_light]     = ent_light_event,
       [k_ent_gate]      = ent_gate_event,
       [k_ent_challenge] = ent_challenge_event,
       [k_ent_route]     = ent_route_event,