From: hgn Date: Mon, 10 Feb 2025 17:51:50 +0000 (+0000) Subject: mark only certain scripts as story events X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=508c10a195bf12d5d4b8e737f7b27fda0c9242db;p=carveJwlIkooP6JGAAIwe30JlM.git mark only certain scripts as story events --- diff --git a/content_skaterift/maps/dev_heaven/main.mdl b/content_skaterift/maps/dev_heaven/main.mdl index 30f138c..6aadd05 100644 Binary files a/content_skaterift/maps/dev_heaven/main.mdl and b/content_skaterift/maps/dev_heaven/main.mdl differ diff --git a/content_skaterift/models/rs_icons.mdl b/content_skaterift/models/rs_icons.mdl index 4d303dd..ecbe3bc 100644 Binary files a/content_skaterift/models/rs_icons.mdl and b/content_skaterift/models/rs_icons.mdl differ diff --git a/src/entity.h b/src/entity.h index 5c4570d..aec5420 100644 --- a/src/entity.h +++ b/src/entity.h @@ -563,9 +563,11 @@ struct ent_objective{ f32 time_limit; }; -enum ent_challenge_flag { +enum ent_challenge_flag +{ k_ent_challenge_timelimit = 0x1, - k_ent_challenge_is_story = 0x2 + k_ent_challenge_is_story = 0x2, + k_ent_challenge_locked = 0x4, }; struct ent_challenge{ diff --git a/src/gui.h b/src/gui.h index 53dfbcc..dc38d32 100644 --- a/src/gui.h +++ b/src/gui.h @@ -28,6 +28,8 @@ enum gui_icon { k_gui_icon_glider, k_gui_icon_spawn, k_gui_icon_spawn_select, + k_gui_icon_story2d, + k_gui_icon_story_done2d, k_gui_icon_count, }; @@ -314,10 +316,10 @@ static void gui_init(void) gui.icons[ k_gui_icon_glider ] = gui_find_icon( "icon_glider" ); gui.icons[ k_gui_icon_spawn ] = gui_find_icon( "icon_spawn" ); gui.icons[ k_gui_icon_spawn_select ] = gui_find_icon( "icon_spawn_select" ); - gui.icons[ k_gui_icon_rift_run_gold ] = - gui_find_icon("icon_rift_run_medal_gold"); - gui.icons[ k_gui_icon_rift_run_silver]= - gui_find_icon("icon_rift_run_medal_silver"); + gui.icons[ k_gui_icon_rift_run_gold ] = gui_find_icon("icon_rift_run_medal_gold"); + gui.icons[ k_gui_icon_rift_run_silver]= gui_find_icon("icon_rift_run_medal_silver"); + gui.icons[ k_gui_icon_story2d ]= gui_find_icon("icon_story2d"); + gui.icons[ k_gui_icon_story_done2d ]= gui_find_icon("icon_story_done2d"); vg_linear_clear( vg_mem.scratch ); if( !gui.model_icons.texture_count ) diff --git a/src/skaterift_script.c b/src/skaterift_script.c index 30f3bad..23a0347 100644 --- a/src/skaterift_script.c +++ b/src/skaterift_script.c @@ -11,12 +11,8 @@ #define KCOL_FBI KGRN #define KCOL_JESUS KMAG -enum escript_event -{ - k_escript_event_call = 0, - k_escript_event_update = 1, - k_escript_event_cutscene_marker = 2 -}; +#include "entity.h" +#include "ent_challenge.h" /* you can add anything you want to this. */ enum escript_state @@ -1774,8 +1770,7 @@ enum escript_script_id 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_ch4s2, k_escript_script_id_ch4s3, k_escript_script_id_max }; @@ -1784,40 +1779,43 @@ struct enum escript_script_id script_id; } static _script = { .script_id = k_escript_script_id_max }; - -struct script_info +static struct script_info _script_infos[] = { - const char *alias; - bool( *jump )( enum escript_event ev, const char *inf ); + [k_escript_script_id_test] = { "test", _skaterift_script_test }, + [k_escript_script_id_intro] = { "intro", _skaterift_script_intro, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch1s2] = { "ch1s2", _skaterift_script_ch1s2, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch1s3] = { "ch1s3", _skaterift_script_ch1s3, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch1s3b] = {"ch1s3b",_skaterift_script_ch1s3b, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch1s4] = { "ch1s4", _skaterift_script_ch1s4, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch1s5] = { "ch1s5", _skaterift_script_ch1s5, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch1s6a] = {"ch1s6a",_skaterift_script_ch1s6a, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch2s1] = { "ch2s1", _skaterift_script_ch2s1, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch2s2] = { "ch2s2", _skaterift_script_ch2s2, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch2s3a] = {"ch2s3a",_skaterift_script_ch2s3a, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch2s4] = { "ch2s4", _skaterift_script_ch2s4, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch2e1] = { "ch2e1", _skaterift_script_ch2e1, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch2s5] = { "ch2s5", _skaterift_script_ch2s5, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch2s6] = { "ch2s6", _skaterift_script_ch2s6, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch3s1] = { "ch3s1", _skaterift_script_ch3s1, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch3s2] = { "ch3s2", _skaterift_script_ch3s2, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch3s3] = { "ch3s3", _skaterift_script_ch3s3, SCRIPT_FLAG_STORY_EVENT }, + [k_escript_script_id_ch4s1a]= { "ch4s1a",_skaterift_script_ch4s1a, SCRIPT_FLAG_STORY_EVENT }, + [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 }, +}; - bool availible; - u64 viewed_time; -} -_script_infos[] = +struct script_info *skaterift_script_get_info( const char *alias ) { - [k_escript_script_id_test] = { "test", _skaterift_script_test }, - [k_escript_script_id_intro] = { "intro", _skaterift_script_intro }, - [k_escript_script_id_ch1s2] = { "ch1s2", _skaterift_script_ch1s2 }, - [k_escript_script_id_ch1s3] = { "ch1s3", _skaterift_script_ch1s3 }, - [k_escript_script_id_ch1s3b] = { "ch1s3b", _skaterift_script_ch1s3b }, - [k_escript_script_id_ch1s4] = { "ch1s4", _skaterift_script_ch1s4 }, - [k_escript_script_id_ch1s5] = { "ch1s5", _skaterift_script_ch1s5 }, - [k_escript_script_id_ch1s6a] = { "ch1s6a", _skaterift_script_ch1s6a }, - [k_escript_script_id_ch2s1] = { "ch2s1", _skaterift_script_ch2s1 }, - [k_escript_script_id_ch2s2] = { "ch2s2", _skaterift_script_ch2s2 }, - [k_escript_script_id_ch2s3a] = { "ch2s3a", _skaterift_script_ch2s3a }, - [k_escript_script_id_ch2s4] = { "ch2s4", _skaterift_script_ch2s4 }, - [k_escript_script_id_ch2e1] = { "ch2e1", _skaterift_script_ch2e1 }, - [k_escript_script_id_ch2s5] = { "ch2s5", _skaterift_script_ch2s5 }, - [k_escript_script_id_ch2s6] = { "ch2s6", _skaterift_script_ch2s6 }, - [k_escript_script_id_ch3s1] = { "ch3s1", _skaterift_script_ch3s1 }, - [k_escript_script_id_ch3s2] = { "ch3s2", _skaterift_script_ch3s2 }, - [k_escript_script_id_ch3s3] = { "ch3s3", _skaterift_script_ch3s3 }, - [k_escript_script_id_ch4s1a]= { "ch4s1a",_skaterift_script_ch4s1a }, - [k_escript_script_id_ch4s1] = { "ch4s1", _skaterift_script_ch4s1 }, - [k_escript_script_id_ch4s2] = { "ch4s2", _skaterift_script_ch4s2 }, - [k_escript_script_id_ch4s3] = { "ch4s3", _skaterift_script_ch4s3 }, -}; + for( u32 i=0; ialias ); + if( info->flags & SCRIPT_FLAG_STORY_EVENT ) { - vg_msg_wkvnum( sav, "viewed_time", - k_vg_msg_u64, 1, &info->viewed_time ); + vg_msg_frame( sav, info->alias ); + { + 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 ); + u8 availible = info->availible; + vg_msg_wkvnum( sav, "availible", k_vg_msg_u8, 1, &availible ); + } + vg_msg_end_frame( sav ); } - vg_msg_end_frame( sav ); } } @@ -1846,14 +1847,17 @@ void skaterift_script_load_savedata( vg_msg *sav ) sav->cur = orig; struct script_info *info = &_script_infos[i]; - if( vg_msg_seekframe( sav, info->alias ) ) + if( info->flags & SCRIPT_FLAG_STORY_EVENT ) { - vg_msg_getkvintg( sav, "viewed_time", k_vg_msg_u64, - &info->viewed_time, NULL ); + if( vg_msg_seekframe( sav, info->alias ) ) + { + 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 ); - info->availible = availible? 1: 0; + u8 availible; + vg_msg_getkvintg( sav, "availible", k_vg_msg_u8, &availible, NULL ); + info->availible = availible? 1: 0; + } } } } @@ -1873,12 +1877,20 @@ static void _skaterift_script_hook_apply_action( u32 script_id, struct script_info *info = &_script_infos[ script_id ]; if( action == k_script_action_unlock ) + { info->availible = 1; + if( info->linked_challenge ) + info->linked_challenge->flags &= ~((u32)k_ent_challenge_locked); + } + if( action == k_script_action_reset ) { info->availible = 0; info->viewed_time = 0; + + if( info->linked_challenge ) + info->linked_challenge->flags |= (u32)k_ent_challenge_locked; } if( action == k_script_action_play ) @@ -1940,17 +1952,17 @@ static int _skaterift_script_hook( int argc, const char *argv[] ) } else { - for( u32 i=0; ient_challenge); i++ ){ + for( u32 i=0; ient_challenge); i++ ) + { ent_challenge *challenge = af_arritm( &world->ent_challenge, i ); const char *alias = af_str( &world->meta.af, challenge->pstr_alias ); - u32 result; - vg_msg_getkvintg( sav, alias, k_vg_msg_u32, &result, NULL ); + if( challenge->flags & k_ent_challenge_is_story ) + { + struct script_info *script = skaterift_script_get_info( alias ); + world->events[i].story_script = script; - if( result ){ - ent_call call; - call.data = NULL; - call.function = 0; - call.id = mdl_entity_id( k_ent_challenge, i ); - entity_call( world, &call ); + if( script ) + { + script->linked_challenge = challenge; + + if( !script->availible ) + { + challenge->flags |= k_ent_challenge_locked; + } + } + } + else + { + u32 result; + vg_msg_getkvintg( sav, alias, k_vg_msg_u32, &result, NULL ); + + if( result ) + { + ent_call call; + call.data = NULL; + call.function = 0; + call.id = mdl_entity_id( k_ent_challenge, i ); + entity_call( world, &call ); + } } } diff --git a/src/world_load.c b/src/world_load.c index 66fed1c..9abcd14 100644 --- a/src/world_load.c +++ b/src/world_load.c @@ -103,6 +103,9 @@ static void world_instance_load_mdl( world_instance *world, const char *path, world->info.flags = 0; } + world->events = vg_linear_alloc( heap, + af_arrcount(&world->ent_challenge)*sizeof(struct event_info) ); + vg_loader_set_user_information( "Compiling world details" ); time_t seconds = time(NULL) % ((u32)vg_maxf(1.0f,k_day_length)*60); @@ -368,7 +371,8 @@ void world_switcher_update(void) if( !all_world_audio_stopped ) return; - + + _skaterift_script_unlink_all_challenges(); world_instance_free_graphics_data( &_world.main ); _world.loader_state = k_world_loader_ready; vg_loader_set_user_information( "Waiting for loading thread" ); diff --git a/src/world_map.c b/src/world_map.c index 4dbacfd..9752533 100644 --- a/src/world_map.c +++ b/src/world_map.c @@ -229,10 +229,26 @@ void world_map_pre_update(void) for( u32 i=0; ient_challenge); i++ ) { ent_challenge *challenge = af_arritm( &world->ent_challenge, i ); + if( challenge->flags & k_ent_challenge_locked ) + continue; enum gui_icon icon = k_gui_icon_exclaim_2d; - if( challenge->status ) - icon = k_gui_icon_tick_2d; + if( challenge->flags & k_ent_challenge_is_story ) + { + icon = k_gui_icon_story2d; + if( world->events[i].story_script ) + { + if( world->events[i].story_script->viewed_time ) + { + icon = k_gui_icon_story_done2d; + } + } + } + else + { + if( challenge->status ) + icon = k_gui_icon_tick_2d; + } respawn_map_draw_icon( cam, icon, challenge->transform.co, 1.0f ); }