X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=ent_objective.c;h=6a8bbe5bef6a2afb3224cc388e1fd101fbbc97e7;hb=72f789aa46c913ec2ffa10907b2124f8d09670e5;hp=c037eaf5cbb5cb5afe1d55527a5c4c59317cc341;hpb=bd3a7e904be0fc97e70761cc957a28609d366586;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/ent_objective.c b/ent_objective.c index c037eaf..6a8bbe5 100644 --- a/ent_objective.c +++ b/ent_objective.c @@ -1,12 +1,13 @@ -#ifndef ENT_OBJECTIVE_C -#define ENT_OBJECTIVE_C - #include "world.h" #include "world_load.h" #include "entity.h" #include "audio.h" +#include "steam.h" +#include "ent_region.h" +#include "player.h" +#include "player_skate.h" -VG_STATIC void ent_objective_pass( world_instance *world, +static void ent_objective_pass( world_instance *world, ent_objective *objective ){ if( objective->id_next ){ world_static.challenge_timer += objective->filter; @@ -20,15 +21,20 @@ VG_STATIC void ent_objective_pass( world_instance *world, ent_objective_pass( world, next ); else{ vg_info( "pass challenge point\n" ); + audio_lock(); audio_oneshot_3d( &audio_challenge[0], localplayer.rb.co, 30.0f, 1.0f ); + audio_unlock(); } } else { vg_success( "challenge win\n" ); + audio_lock(); audio_oneshot( &audio_challenge[2], 1.0f, 0.0f ); + audio_unlock(); world_static.challenge_target = NULL; world_static.challenge_timer = 0.0f; + world_static.focused_entity = 0; if( objective->id_win ){ ent_call call; @@ -37,12 +43,14 @@ VG_STATIC void ent_objective_pass( world_instance *world, call.id = objective->id_win; entity_call( world, &call ); } + + ent_region_re_eval( world ); } } -VG_STATIC int ent_objective_check_filter( ent_objective *objective ){ +static int ent_objective_check_filter( ent_objective *objective ){ if( objective->filter ){ - struct player_skate_state *s = &localplayer._skate.state; + struct player_skate_state *s = &player_skate.state; enum trick_type trick = s->trick_type; u32 state = 0x00; @@ -73,49 +81,59 @@ VG_STATIC int ent_objective_check_filter( ent_objective *objective ){ } } -VG_STATIC void ent_objective_call( world_instance *world, ent_call *call ){ +entity_call_result ent_objective_call( world_instance *world, ent_call *call ) +{ u32 index = mdl_entity_id_id( call->id ); ent_objective *objective = mdl_arritm( &world->ent_objective, index ); - if( call->function == 0 ){ - if( objective->flags & (k_ent_objective_hidden| - k_ent_objective_passed)) return; + if( call->function == 0 ) + { + if( objective->flags & (k_ent_objective_hidden|k_ent_objective_passed)) + { + return k_entity_call_result_OK; + } - if( world_static.challenge_target ){ + if( world_static.challenge_target ) + { if( (world_static.challenge_target == objective) && ent_objective_check_filter( objective )){ ent_objective_pass( world, objective ); } - else { + else + { + audio_lock(); audio_oneshot_3d( &audio_challenge[6], localplayer.rb.co, 30.0f, 1.0f ); + audio_unlock(); vg_error( "challenge failed\n" ); world_static.challenge_target = NULL; world_static.challenge_timer = 0.0f; world_static.focused_entity = 0; } } + + return k_entity_call_result_OK; } - else if( call->function == 2 ){ + else if( call->function == 2 ) + { objective->flags &= ~k_ent_objective_hidden; if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){ call->id = objective->id_next; entity_call( world, call ); } + return k_entity_call_result_OK; } - else if( call->function == 3 ){ + else if( call->function == 3 ) + { objective->flags |= k_ent_objective_hidden; if( mdl_entity_id_type( objective->id_next ) == k_ent_objective ){ call->id = objective->id_next; entity_call( world, call ); } + return k_entity_call_result_OK; } - else { - vg_print_backtrace(); - vg_error( "Unhandled function id: %u\n", call->function ); - } + else + return k_entity_call_result_unhandled; } - -#endif /* ENT_OBJECTIVE_C */