simple hub script
authorhgn <hgodden00@gmail.com>
Thu, 6 Mar 2025 11:47:09 +0000 (11:47 +0000)
committerhgn <hgodden00@gmail.com>
Thu, 6 Mar 2025 11:47:09 +0000 (11:47 +0000)
content_skaterift/maps/dev_hub/main.mdl
src/player_walk.c
src/skaterift_script.c
src/skaterift_script.h
src/world_entity.c

index 63c75ad454ca4ce2007f3b3de63f3cdcb20dd390..7bf820a4c0b944c4aa87bdb850c786cfe7c48a4c 100644 (file)
Binary files a/content_skaterift/maps/dev_hub/main.mdl and b/content_skaterift/maps/dev_hub/main.mdl differ
index 620d195f8fd9768caa5c0ed529690aefb28a6888..7fc7922b28620cc857f4c0418f2e9356d0a3b4ea 100644 (file)
@@ -523,6 +523,9 @@ static void player_walk_update_generic(void){
    for( u32 i=0; i<af_arrcount( &world->ent_prop ); i ++ )
    {
       ent_prop *prop = af_arritm( &world->ent_prop, i );
+      if( prop->flags & k_prop_flag_hidden )
+         continue;
+
       if( prop->flags & k_prop_flag_collider )
       {
          m4x3f mmdl, mmdl_inv;
index c18fa9e9bd594ac8f92fecc06d17ee07b3496a42..9ba1abebab9388c1ed853e63e6dffa5f8186cfce 100644 (file)
@@ -1747,31 +1747,57 @@ static bool _skaterift_script_test( enum escript_event ev, const char *inf )
    return 0;
 }
 
-enum escript_script_id
+static bool _skaterift_script_hub_setup( enum escript_event ev, const char *inf )
 {
-   k_escript_script_id_test = 0,
-   k_escript_script_id_intro,
-   k_escript_script_id_ch1s2,
-   k_escript_script_id_ch1s3,
-   k_escript_script_id_ch1s3b,
-   k_escript_script_id_ch1s4,
-   k_escript_script_id_ch1s5,
-   k_escript_script_id_ch1s6a,
-   k_escript_script_id_ch2s1,
-   k_escript_script_id_ch2s2,
-   k_escript_script_id_ch2s3a,
-   k_escript_script_id_ch2s4,
-   k_escript_script_id_ch2e1,
-   k_escript_script_id_ch2s5,
-   k_escript_script_id_ch2s6,
-   k_escript_script_id_ch3s1,
-   k_escript_script_id_ch3s2,
-   k_escript_script_id_ch3s3,
-   k_escript_script_id_ch4s1a,
-   k_escript_script_id_ch4s1, /* NOTE: 1 and 2 are backwards in order (accident) */
-   k_escript_script_id_ch4s2, k_escript_script_id_ch4s3,
-   k_escript_script_id_max 
-};
+   if( ev == k_escript_event_call )
+   {
+      world_instance *world = &_world.main;
+
+      bool unlock_mtzero = _skaterift_script_check_unlocked( k_escript_script_id_ch2s1 ),
+           unlock_city   = _skaterift_script_check_unlocked( k_escript_script_id_ch3s1 ),
+           unlock_valley = _skaterift_script_check_unlocked( k_escript_script_id_ch4s1a );
+
+      for( u32 i=0; i<af_arrcount( &world->ent_prop ); i ++ )
+      {
+         ent_prop *prop = af_arritm( &world->ent_prop, i );
+
+         if( AF_STR_EQ( &world->meta.af, prop->pstr_alias, "MARC" ) )
+            if( skaterift.achievements & 0x1 )
+               prop->flags &= ~0x1;
+
+         if( AF_STR_EQ( &world->meta.af, prop->pstr_alias, "ALBERT" ) )
+            if( skaterift.achievements & 0x2 )
+               prop->flags &= ~0x1;
+
+         if( AF_STR_EQ( &world->meta.af, prop->pstr_alias, "JANET" ) )
+            if( skaterift.achievements & 0x4 )
+               prop->flags &= ~0x1;
+
+         if( AF_STR_EQ( &world->meta.af, prop->pstr_alias, "BERNADETTA" ) )
+            if( skaterift.achievements & 0x8 )
+               prop->flags &= ~0x1;
+
+         if( AF_STR_EQ( &world->meta.af, prop->pstr_alias, "main_island_block" ) )
+            if( unlock_mtzero )
+               prop->flags |= k_prop_flag_hidden;
+
+         if( AF_STR_EQ( &world->meta.af, prop->pstr_alias, "mtzero_block" ) )
+            if( unlock_mtzero )
+               prop->flags |= k_prop_flag_hidden;
+
+         if( AF_STR_EQ( &world->meta.af, prop->pstr_alias, "city_block" ) )
+            if( unlock_city )
+               prop->flags |= k_prop_flag_hidden;
+
+         if( AF_STR_EQ( &world->meta.af, prop->pstr_alias, "valley_block" ) )
+            if( unlock_valley )
+               prop->flags |= k_prop_flag_hidden;
+      }
+      return 1;
+   }
+
+   return 0;
+}
 
 struct
 {
@@ -1802,8 +1828,15 @@ static struct script_info _script_infos[] =
    [k_escript_script_id_ch4s1] = { "ch4s1", _skaterift_script_ch4s1,  SCRIPT_FLAG_STORY_EVENT },
    [k_escript_script_id_ch4s2] = { "ch4s2", _skaterift_script_ch4s2,  SCRIPT_FLAG_STORY_EVENT },
    [k_escript_script_id_ch4s3] = { "ch4s3", _skaterift_script_ch4s3,  SCRIPT_FLAG_STORY_EVENT },
+   [k_escript_script_id_hub_setup] = { "hub_setup", _skaterift_script_hub_setup },
 };
 
+bool _skaterift_script_check_unlocked( enum escript_script_id id )
+{
+   struct script_info *info = &_script_infos[ id ];
+   return info->availible;
+}
+
 struct script_info *skaterift_script_get_info( const char *alias )
 {
    for( u32 i=0; i<k_escript_script_id_max; i ++ )
@@ -1826,8 +1859,7 @@ void skaterift_script_write_savedata( vg_msg *sav )
       {
          vg_msg_frame( sav, info->alias );
          {
-            vg_msg_wkvnum( sav, "viewed_time", 
-                           k_vg_msg_u64, 1, &info->viewed_time );
+            vg_msg_wkvnum( sav, "viewed_time", k_vg_msg_u64, 1, &info->viewed_time );
 
             u8 availible = info->availible;
             vg_msg_wkvnum( sav, "availible", k_vg_msg_u8, 1, &availible );
@@ -1850,8 +1882,7 @@ void skaterift_script_load_savedata( vg_msg *sav )
       {
          if( vg_msg_seekframe( sav, info->alias ) )
          {
-            vg_msg_getkvintg( sav, "viewed_time", k_vg_msg_u64, 
-                              &info->viewed_time, NULL );
+            vg_msg_getkvintg( sav, "viewed_time", k_vg_msg_u64, &info->viewed_time, NULL );
 
             u8 availible;
             vg_msg_getkvintg( sav, "availible", k_vg_msg_u8, &availible, NULL );
@@ -1999,8 +2030,7 @@ void _skaterift_script_update(void)
 {
    if( _script.script_id != k_escript_script_id_max )
    {
-      if( _script_infos[ _script.script_id ].jump( k_escript_event_update, 
-                                                      NULL ) )
+      if( _script_infos[ _script.script_id ].jump( k_escript_event_update, NULL ) )
          _script.script_id = k_escript_script_id_max;
    }
 }
@@ -2009,16 +2039,14 @@ void _skaterift_script_marker( const char *marker )
 {
    if( _script.script_id != k_escript_script_id_max )
    {
-      if( _script_infos[ _script.script_id ].jump( 
-               k_escript_event_cutscene_marker, marker) )
+      if( _script_infos[ _script.script_id ].jump( k_escript_event_cutscene_marker, marker) )
          _script.script_id = k_escript_script_id_max;
    }
 }
 
 void _skaterift_script_init(void)
 {
-   vg_console_reg_cmd( "script", _skaterift_script_hook, 
-                                 _skaterift_script_hook_poll );
+   vg_console_reg_cmd( "script", _skaterift_script_hook, _skaterift_script_hook_poll );
 }
 
 void _skaterift_script_unlink_all_challenges(void)
index b26c4a992673c0008fe135e333cd43b7a6fe2a76..c9d02a4e20abfc9fa4adef9d31663a36c43557cf 100644 (file)
@@ -30,3 +30,32 @@ static int _skaterift_script_hook( int argc, const char *argv[] );
 struct script_info *skaterift_script_get_info( const char *alias );
 
 void _skaterift_script_unlink_all_challenges(void);
+
+enum escript_script_id
+{
+   k_escript_script_id_test = 0,
+   k_escript_script_id_intro,
+   k_escript_script_id_ch1s2,
+   k_escript_script_id_ch1s3,
+   k_escript_script_id_ch1s3b,
+   k_escript_script_id_ch1s4,
+   k_escript_script_id_ch1s5,
+   k_escript_script_id_ch1s6a,
+   k_escript_script_id_ch2s1,
+   k_escript_script_id_ch2s2,
+   k_escript_script_id_ch2s3a,
+   k_escript_script_id_ch2s4,
+   k_escript_script_id_ch2e1,
+   k_escript_script_id_ch2s5,
+   k_escript_script_id_ch2s6,
+   k_escript_script_id_ch3s1,
+   k_escript_script_id_ch3s2,
+   k_escript_script_id_ch3s3,
+   k_escript_script_id_ch4s1a,
+   k_escript_script_id_ch4s1, /* NOTE: 1 and 2 are backwards in order (accident) */
+   k_escript_script_id_ch4s2, 
+   k_escript_script_id_ch4s3,
+   k_escript_script_id_hub_setup,
+   k_escript_script_id_max 
+};
+bool _skaterift_script_check_unlocked( enum escript_script_id id );
index 5184b11cf6ec25f82e74d768c7f3ca9ae319e70f..01360237c3052b1404260fdb19e67affaef4a814 100644 (file)
@@ -734,29 +734,6 @@ void update_ach_models(void)
 #if 0
    world_instance *hub = &_world.instances[k_world_purpose_hub];
    if( hub->status != k_world_status_loaded ) return;
-
-   for( u32 i=0; i<af_arrcount( &hub->ent_prop ); i ++ )
-   {
-      ent_prop *prop = af_arritm( &hub->ent_prop, i );
-      if( prop->flags & 0x2 )
-      {
-         if( AF_STR_EQ( &hub->meta.af, prop->pstr_alias, "MARC" ) )
-            if( skaterift.achievements & 0x1 )
-               prop->flags &= ~0x1;
-
-         if( AF_STR_EQ( &hub->meta.af, prop->pstr_alias, "ALBERT" ) )
-            if( skaterift.achievements & 0x2 )
-               prop->flags &= ~0x1;
-
-         if( AF_STR_EQ( &hub->meta.af, prop->pstr_alias, "JANET" ) )
-            if( skaterift.achievements & 0x4 )
-               prop->flags &= ~0x1;
-
-         if( AF_STR_EQ( &hub->meta.af, prop->pstr_alias, "BERNADETTA" ) )
-            if( skaterift.achievements & 0x8 )
-               prop->flags &= ~0x1;
-      }
-   }
 #endif
 }