#{
_fields_ = [("transform",mdl_transform),
("pstr_id",c_uint32),
- ("pstr_context_id",c_uint32)]
+ ("pstr_context_id",c_uint32),
+ ("pstr_anim",c_uint32),
+ ("none0",c_uint32)]
sr_functions = { 'proximity': 0x00, 'interact': 0x00 }
#}
class SR_OBJECT_ENT_NPC(bpy.types.PropertyGroup):#{
id: bpy.props.StringProperty()
context_id: bpy.props.StringProperty()
+ anim: bpy.props.StringProperty()
# old, unused.
# au: bpy.props.IntProperty()
gi = checkpoints[i].target
gj = checkpoints[(i+1)%len(checkpoints)].target
+ cc1 = cc
+ if bpy.context.active_object == route:
+ if route.SR_data.ent_route[0].gates_index == i:
+ cc1 = (1,1,1)
+
if gi:
#{
if gi.SR_data.ent_gate[0].tipo != 'passive':
#{
dest = gi.SR_data.ent_gate[0].target
if dest:
- cv_draw_line_dotted( gi.location, dest.location, cc )
+ cv_draw_line_dotted( gi.location, dest.location, cc1 )
gi = dest
#}
#}
if path:
#{
- cv_draw_arrow(gi.location,dij.points[path[0]],cc,1.5,False)
- cv_draw_arrow(dij.points[path[len(path)-1]],gj.location,cc,1.5,False)
+ cv_draw_arrow(gi.location,dij.points[path[0]],cc1,1.5,False)
+ cv_draw_arrow(dij.points[path[len(path)-1]],gj.location,cc1,1.5,False)
for j in range(len(path)-1):#{
i0 = path[j]
i1 = path[j+1]
o0 = dij.points[ i0 ]
o1 = dij.points[ i1 ]
- cv_draw_arrow(o0,o1,cc,1.5,False)
+ cv_draw_arrow(o0,o1,cc1,1.5,False)
#}
#}
- else:#{
- cv_draw_line_dotted( gi.location, gj.location, cc )
- #}
+ else:
+ cv_draw_line_dotted( gi.location, gj.location, cc1 )
#}
#}
npc = ent_npc()
compile_obj_transform( obj, npc.transform )
npc.pstr_id = _af_pack_string( obj_data.id )
- npc.pstr_context_id = _af_pack_string( obj_data.context_id )
+ npc.pstr_context_id = _af_pack_string( obj_data.context_id )
+ npc.pstr_anim = _af_pack_string( obj_data.anim )
sr_ent_push( npc )
#}
elif ent_type == 'ent_script':#{
class ms_strip(Structure):
#{
_fields_ = [("mode",c_uint8),
- ("offset",c_uint32),
+ ("offset",c_int32),
("anon",ms_strip_data_union)]
#}
kf.q[2] = -rq[2]
kf.q[3] = rq[0]
kf.s[0] = sca[0]
- kf.s[1] = sca[2]
- kf.s[2] = sca[1]
+ kf.s[1] = sca[1]
+ kf.s[2] = sca[2]
+
+ print( kf.s[0], kf.s[1], kf.s[2] )
_ms_compiler.keyframes.append(kf)
#}
_metascene_compile_action_curves( out_strip, NLAStrip.action )
out_strip.anon.strip.instance_id = 0xffffffff
out_strip.anon.strip.object_id = entity_id
- out_strip.anon.strip.offset = math.floor( NLAStrip.frame_start )
+ out_strip.offset = math.floor( NLAStrip.frame_start )
out_strip.anon.strip.timing_offset = NLAStrip.action_frame_start
out_strip.anon.strip.length = math.ceil( NLAStrip.frame_end - out_strip.offset )
out_strip.anon.strip.pstr_name = _af_pack_string( NLAStrip.name )
_metascene_compile_action_curves( out_strip, NLAStrip.action )
out_strip.anon.strip.instance_id = 0xffffffff
out_strip.anon.strip.object_id = entity_id
- out_strip.anon.strip.offset = math.floor( NLAStrip.frame_start )
+ out_strip.offset = math.floor( NLAStrip.frame_start )
out_strip.anon.strip.timing_offset = NLAStrip.action_frame_start
out_strip.anon.strip.length = math.ceil( NLAStrip.frame_end - out_strip.offset )
out_strip.anon.strip.pstr_name = _af_pack_string( NLAStrip.name )
{
ent_route *route = af_arritm( &world->ent_route, i );
- if( !(route->flags & (k_ent_route_flag_achieve_gold|k_ent_route_flag_achieve_silver)) )
- {
- if( compass_co( projection, route->board_transform[3], 0.0f ) )
- mdl_draw_submesh( &mdl->submeshes[ _compass.sm_comp_objective ] );
- }
-
if( route->active_checkpoint != 0xffff )
{
v4f colour;
}
}
}
+ else
+ {
+ shader_compass_uColour( (v4f){ 1,1,1,1 } );
+ for( u32 i=0; i<af_arrcount(&world->ent_route); i++ )
+ {
+ ent_route *route = af_arritm( &world->ent_route, i );
+ if( !(route->flags & (k_ent_route_flag_achieve_gold|k_ent_route_flag_achieve_silver)) )
+ {
+ if( compass_co( projection, route->board_transform[3], 0.0f ) )
+ mdl_draw_submesh( &mdl->submeshes[ _compass.sm_comp_objective ] );
+ }
+ }
+ }
}
void compass_render_imgui( ui_context *ctx )
world_instance *world = &_world.main;
ent_challenge *challenge = af_arritm( &world->ent_challenge, mdl_entity_id_id( _world.active_challenge_id ) );
+
+ if( !challenge->status )
+ {
+ gui_notify( "\xb3 Challenge complete!", 5.0f, k_ui_fg );
+ }
+
_ent_challenge_clear( challenge );
challenge->status = 1;
- ent_region_re_eval( world );
+ ent_region_re_eval( world, 0 );
struct ent_script_event event;
struct script_event_completion_changed inf = {
if( argc==2 )
{
challenge->status = atoi( argv[1] );
- ent_region_re_eval( world );
+ ent_region_re_eval( world, 0 );
struct ent_script_event event;
struct script_event_completion_changed inf = {
route->flags |= (u32)(k_ent_route_flag_achieve_silver);
if( !strcmp( argv[1], "gold" ) )
route->flags |= (u32)(k_ent_route_flag_achieve_gold|k_ent_route_flag_achieve_silver);
- ent_region_re_eval( world );
+ ent_region_re_eval( world, 0 );
struct ent_script_event event;
struct script_event_completion_changed inf = {
struct player_effects_data effect_data;
player_pose pose;
m4x3f *final_mtx;
+
+ enum
+ {
+ k_npc_idle,
+ k_npc_stand,
+ k_npc_sit
+ }
+ anim;
}
humans[4];
- struct skeleton_anim anim_idle;
+ struct skeleton_anim anim_idle, anim_stand, anim_sit;
enum npc_sub_state
{
human->final_mtx = vg_linear_alloc( alloc, mtx_size );
}
player_get_anim( &_npc.anim_idle, "idle_lean+y" );
+ player_get_anim( &_npc.anim_stand, "idle_cycle+y" );
+ player_get_anim( &_npc.anim_sit, "sit" );
}
void _ent_npc_reset(void)
pose->board.lean = 0.0f;
v3_copy( human->co, pose->root_co );
v4_copy( human->q, pose->root_q );
- skeleton_sample_anim( sk, &_npc.anim_idle, vg.time*0.1f+0.4f, apose );
+
+ if( human->anim == k_npc_sit )
+ skeleton_sample_anim( sk, &_npc.anim_sit, 1.6f, apose );
+ else if( human->anim == k_npc_stand )
+ skeleton_sample_anim( sk, &_npc.anim_stand, vg.time*0.5f+0.4f, apose );
+ else
+ skeleton_sample_anim( sk, &_npc.anim_idle, vg.time*0.1f+0.4f, apose );
+
skeleton_copy_pose( sk, apose, pose->keyframes );
// no for JC.
if( i != (k_npc_jc-1) )
}
else if( AF_STR_EQ( &world->meta.af, event->pstr_recieve_event, "proximity" ) )
{
+ human->anim = 0;
+ if( AF_STR_EQ( &world->meta.af, npc->pstr_anim, "sit" ) )
+ human->anim = k_npc_sit;
+ else if( AF_STR_EQ( &world->meta.af, npc->pstr_anim, "stand" ) )
+ human->anim = k_npc_stand;
+
if( human->alive == 0 )
{
const char *addons[] =
/*
* reevaluate all achievements to calculate the compiled achievement
*/
-void ent_region_re_eval( world_instance *world )
+void ent_region_re_eval( world_instance *world, bool init )
{
u32 world_total = k_ent_route_flag_achieve_gold | k_ent_route_flag_achieve_silver;
}
}
+ u32 original_flags = region->flags;
region->flags = combined;
world_total &= combined;
-
if( region->flags & k_ent_route_flag_achieve_silver )
_world_raise_event( mdl_entity_id( k_ent_region, j ), "silver" );
if( region->flags & k_ent_route_flag_achieve_gold )
_world_raise_event( mdl_entity_id( k_ent_region, j ), "gold" );
+
+ if( !init )
+ {
+ if( !(original_flags & (k_ent_route_flag_achieve_silver|k_ent_route_flag_achieve_gold)) &&
+ region->flags & (k_ent_route_flag_achieve_silver|k_ent_route_flag_achieve_gold) )
+ {
+ gui_notify( "\xb3 Region completed!", 6.0f, k_ui_fg );
+ }
+ }
}
}
};
u32 region_spark_colour( u32 flags );
-void ent_region_re_eval( world_instance *world );
+void ent_region_re_eval( world_instance *world, bool init );
entity_event_result ent_region_event( ent_event *event );
}
_ent_script;
+#include "scripts/generic.c"
#include "scripts/explode.c"
#include "scripts/tutorial_island.c"
#include "scripts/board_maker.c"
{ "explode", _skaterift_script_explode },
{ "volc_main", _skaterift_script_volc },
{ "board_maker", _skaterift_script_board_maker },
+ { "generic", _skaterift_script_generic },
{ NULL }
};
struct ent_npc
{
mdl_transform transform;
- u32 pstr_id, pstr_context_id;
+ u32 pstr_id, pstr_context_id, pstr_anim, none1;
};
typedef enum entity_event_result entity_event_result;
}
helper_mode;
+ struct gui_notifier
+ {
+ const char *string;
+ f32 duration, time_left; /* seconds */
+ u32 colour;
+ }
+ notifiers[ 4 ];
+
struct icon_call
{
enum gui_icon icon;
}
static gui = {.cur_icon_colour = {1.0f,1.0f,1.0f,1.0f},.colour_changed=1};
+void gui_notify( const char *string, f32 duration, u32 colour )
+{
+ // JINGLE SOME KEYS HERE
+ // JINGLE SOME KEYS HERE
+ // JINGLE SOME KEYS HERE
+ // JINGLE SOME KEYS HERE
+ // JINGLE SOME KEYS HERE
+ struct gui_notifier *notifier = NULL;
+ for( u32 i=0; i<VG_ARRAY_LEN(gui.notifiers); i ++ )
+ {
+ notifier = &gui.notifiers[i];
+ if( notifier->time_left > 0.0f )
+ {
+ notifier = NULL;
+ continue;
+ }
+ else break;
+ }
+
+ if( !notifier )
+ return;
+
+ notifier->string = string;
+ notifier->duration = duration;
+ notifier->time_left = duration;
+ notifier->colour = colour;
+}
+
static void gui_helper_reset( enum gui_helper_mode mode )
{
gui.helper_count = 0;
/* helpers
* ----------------------------------------------------------------- */
+ gui.factive = vg_lerpf( gui.factive, gui.helper_count?1.0f:0.0f, vg.time_frame_delta*2.0f );
+
+ {
+ ui_px y = 80;
+ ui_px w = 360, h = 60;
+ ctx->font = &vgf_default_large;
+ for( u32 i=0; i<VG_ARRAY_LEN(gui.notifiers); i ++ )
+ {
+ struct gui_notifier *notifier = &gui.notifiers[i];
+ notifier->time_left -= vg.time_frame_delta;
+ if( notifier->time_left > 0.0f )
+ {
+ const float k_trans = 0.2;
+ float t0 = notifier->time_left,
+ t1 = notifier->duration - t0,
+ t = vg_smoothstepf( vg_minf( vg_minf( k_trans, t0 ), t1 ) / k_trans ),
+ x = (f32)(w+8) * t;
+ ui_rect box = { vg.window_x - (ui_px)x, y, w, h };
+ ui_fill( ctx, box, ui_opacity( GUI_COL_DARK, t*0.6f ) );
+ ui_outline( ctx, box, 1, ui_opacity( GUI_COL_NORM, t*0.6f ), 0 );
+ ui_text( ctx, box, notifier->string, 1, k_ui_align_middle_center, ui_colour( ctx, notifier->colour ) );
+ }
+ y += h + 8;
+ }
+ }
+
if( _cutscene.state >= k_cutscene_state_ready )
+ {
+ ctx->font = &vgf_default_small;
return;
-
- gui.factive = vg_lerpf( gui.factive, gui.helper_count?1.0f:0.0f, vg.time_frame_delta*2.0f );
+ }
ctx->font = &vgf_default_title;
ui_px height = ctx->font->ch + 16;
if( _cutscene.freeze_player )
localplayer.immobile = 1;
- _cutscene.state = k_cutscene_state_playing;
vg_audio_lock();
for( u32 j=0; j<af_arrcount( &_cutscene.meta.audios ); j++ )
{
}
}
vg_audio_unlock();
+
+ _cutscene.state = k_cutscene_state_playing;
_world_raise_event( _cutscene.raiser_entity, "start" );
}
_cutscene.marker_this_frame = NULL;
_cutscene.time += delta;
- u32 frame = _cutscene.time * _cutscene.meta.info.framerate;
+ i32 frame = _cutscene.time * _cutscene.meta.info.framerate;
/* clear out finished samplers */
bool move = 0;
{
struct cs_sampler *si = &_cutscene.samplers[i];
- if( frame > (si->strip->offset + si->strip->strip.length) )
+ if( frame > (si->strip->offset + (i32)si->strip->strip.length) )
move = 1;
else
{
if( strip->mode & k_ms_strip_mode_animation )
{
- if( frame > strip->offset + strip->strip.length )
+ if( frame > strip->offset + (i32)strip->strip.length )
{
vg_warn( "Skipping?\n" );
_cutscene.strip ++;
return;
}
+ if( _cutscene.state == k_cutscene_state_unloading )
+ {
+ ui_text( ctx, rect, "Cutscene UN-loading..", 1, k_ui_align_middle_center, 0 );
+ return;
+ }
+
ms_strip *usage[8];
for( u32 i=0; i<VG_ARRAY_LEN(usage); i ++ ) usage[i] = NULL;
for( u32 k=0; k<VG_ARRAY_LEN(usage); k ++ )
{
if( usage[k] )
- if( usage[k]->offset + usage[k]->strip.length < strip->offset )
+ if( usage[k]->offset + (i32)usage[k]->strip.length < strip->offset )
usage[k] = NULL;
if( !usage[k] )
}
}
- ui_rect box = { strip->offset, layer*32, strip->strip.length, 30 };
+ ui_rect box = { strip->offset, layer*32, (i32)strip->strip.length, 30 };
box[0] += root[0];
box[1] += root[1];
}
}
+static int cmd_cutscene_play( int argc, const char *argv[] )
+{
+ if( argc == 1 )
+ _cutscene_load_and_play( argv[0], 0, 0 );
+ return 1;
+}
+
static int cmd_cutscene_inspector( int argc, const char *argv[] )
{
ui_px w = 800, h = 400;
void cutscene_init(void)
{
- //vg_console_reg_cmd( "cutscene", cmd_cutscene_load, NULL );
+ vg_console_reg_cmd( "cutscene_play", cmd_cutscene_play, NULL );
vg_console_reg_cmd( "cutscene_inspector", cmd_cutscene_inspector, NULL );
}
struct ms_strip
{
u8 mode;
- u32 offset;
+ i32 offset;
union
{
joystick_state( k_srjoystick_steer, steer );
v2_normalize_clamp( steer );
- if( (fabsf(steer[1]) > 0.5f) && (state->land_dist >= 1.5f) ){
- state->flip_rate = (1.0f/state->land_dist) * vg_signf(steer[1]) *
- state->reverse ;
+ if( (fabsf(steer[1]) > 0.5f) && (state->land_dist >= 1.5f) )
+ {
+ state->flip_rate = (1.0f/state->land_dist) * vg_signf(steer[1]) * state->reverse;
state->flip_time = 0.0f;
v3_copy( localplayer.rb.to_world[0], state->flip_axis );
}
- else{
+ else
+ {
state->flip_rate = 0.0f;
v3_zero( state->flip_axis );
}
/*
* Air control, no real physics
*/
-static void skate_apply_air_model(void){
+static void skate_apply_air_model(void)
+{
struct player_skate_state *state = &player_skate.state;
-
if( state->activity_prev > k_skate_activity_air_to_grind )
player__approximate_best_trajectory();
/* flip angle */
- if( (state->activity <= k_skate_activity_air_to_grind) &&
- (fabsf(state->flip_rate) > 0.01f) ){
+ if( (state->activity <= k_skate_activity_air_to_grind) && (fabsf(state->flip_rate) > 0.01f) )
+ {
float substep = vg.time_fixed_extrapolate;
float t = state->flip_time+state->flip_rate*substep*vg.time_fixed_delta;
sign = vg_signf( t );
-
-struct board_maker_unlock_waiter
+static bool _skaterift_script_generic( ent_script_event *event )
{
- bool changed;
- bool unlocked;
-};
-
-static bool _skaterift_script_board_maker_unlock( ent_script_event *event )
-{
-#if 0
- if( event->type == k_escript_event_allocate )
- {
- struct script_event_allocate *event_info = event->info;
- struct board_maker_unlock_waiter *waiter = vg_linear_alloc( event_info->heap, sizeof(struct board_maker_unlock_waiter) );
- waiter->changed = 0;
- waiter->unlocked = 0;
- event_info->userdata = waiter;
- }
-
- u64 status;
- if( on_atom_changed( event, "board_maker_unlock", &status ) )
+ if( event->type == k_escript_event_world_event )
{
- struct board_maker_unlock_waiter *waiter = event->userdata;
- waiter->changed = 1;
- waiter->unlocked = status;
- }
-
- if( event->type == k_escript_event_update || event->type == k_escript_event_world_start )
- {
- if( _cutscene.state == k_cutscene_state_none )
+ struct script_event_world_io *inf = event->info;
+ world_instance *world = &_world.main;
+ if( AF_STR_EQ( &world->meta.af, inf->event->pstr_recieve_event, "unlock_mtzero" ) )
{
- struct board_maker_unlock_waiter *waiter = event->userdata;
- if( waiter->changed )
- {
- _ent_list_set_visible( event->entity_list, waiter->unlocked );
- waiter->changed = 0;
- }
+ gui_notify( "\xb8 Mt.Zero Unlocked!", 8.0f, k_ui_green );
}
- }
-#endif
- return 1;
-}
-
-#if 0
-static bool _skaterift_script_board_maker( ent_script_event *event )
-{
- if( on_function_trigger( event, 0 ) )
- {
- if( world_set_event( k_world_event_board_maker ) )
+ if( AF_STR_EQ( &world->meta.af, inf->event->pstr_recieve_event, "unlock_city" ) )
+ {
+ gui_notify( "\xb8 Downtown Unlocked!", 8.0f, k_ui_green );
+ }
+ if( AF_STR_EQ( &world->meta.af, inf->event->pstr_recieve_event, "unlock_valley" ) )
{
- struct ent_list_iter iter;
- _ent_list_iter_start( &iter, event->entity_list, k_ent_marker );
- while( _ent_list_iter( &iter ) )
- {
- ent_marker *marker = af_arritm( &event->world->ent_marker, iter.index );
- const char *alias = af_str( &event->world->meta.af, marker->pstr_alias );
-
- if( !strcmp( alias, "$board_position" ) )
- v3_copy( marker->transform.co, _board_maker.origin );
- else if( !strcmp( alias, "$camera_position" ) )
- v3_copy( marker->transform.co, _board_maker.camera_pos );
- }
- _board_maker_open();
+ gui_notify( "\xb8 Valley Unlocked!", 8.0f, k_ui_green );
}
}
return 1;
}
-#endif
}
}
+ _atom_list_clear( k_atom_list_world );
+
vg_msg_cursor orig = sav->cur;
if( vg_msg_seekframe( sav, "atoms" ) )
{
}
}
- ent_region_re_eval( world );
+ ent_region_re_eval( world, 1 );
/* true/false initializers
* ----------------------------------------------------------------------------------- */
vg_str folder_str;
vg_strnull( &folder_str, info->path, sizeof(info->path) );
info->OK = addon_get_content_folder( _world.load_addon, &folder_str );
- _atom_list_clear( k_atom_list_world );
vg_async_task_dispatch( task, skaterift_world_load_t1 );
}
if( (route->best_laptime == 0.0) || (lap_time < route->best_laptime) )
route->best_laptime = lap_time;
+ u32 original_flags = route->flags;
+
route->flags |= k_ent_route_flag_achieve_silver;
if( clean ) route->flags |= k_ent_route_flag_achieve_gold;
- ent_region_re_eval( world );
+ ent_region_re_eval( world, 0 );
+
+ if( (route->flags & k_ent_route_flag_achieve_gold) && !(original_flags & k_ent_route_flag_achieve_gold) )
+ {
+ gui_notify( "\xb3 Route completed in gold!", 5.0f, k_ui_yellow );
+ }
+ else if( (route->flags & k_ent_route_flag_achieve_silver) && !(original_flags & k_ent_route_flag_achieve_silver) )
+ {
+ gui_notify( "\xb3 Route completed in silver!", 5.0f, k_ui_fg );
+ }
struct ent_script_event event;
struct script_event_completion_changed inf = {