X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=inline;f=ent_objective.c;fp=ent_objective.c;h=330e60fcb97524075020360909c37be6a1dcf848;hb=6190deb68aa1c9e92ede62ea05c2a755bf5516de;hp=0000000000000000000000000000000000000000;hpb=296560179b19451468030f202b17492b1c71b9d0;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/ent_objective.c b/ent_objective.c new file mode 100644 index 0000000..330e60f --- /dev/null +++ b/ent_objective.c @@ -0,0 +1,120 @@ +#ifndef ENT_OBJECTIVE_C +#define ENT_OBJECTIVE_C + +#include "world.h" +#include "world_load.h" +#include "entity.h" + +VG_STATIC void ent_objective_pass( world_instance *world, + ent_objective *objective ){ + if( objective->id_next ){ + world->challenge_timer += objective->filter; + + u32 index = mdl_entity_id_id( objective->id_next ); + ent_objective *next = mdl_arritm( &world->ent_objective, index ); + world->challenge_target = next; + + if( next->filter & k_ent_objective_filter_passthrough ) + ent_objective_pass( world, next ); + else + vg_info( "pass challenge point\n" ); + } + else { + vg_success( "NYU Film school graduate SUCKAH\n" ); + world->challenge_target = NULL; + world->challenge_timer = 0.0f; + + if( objective->id_win ){ + ent_call call; + call.data = NULL; + call.function = objective->win_event; + call.id = objective->id_win; + entity_call( world, &call ); + } + } +} + +VG_STATIC int ent_objective_check_filter( ent_objective *objective ){ + if( objective->filter ){ + struct player_skate_state *s = &localplayer._skate.state; + enum trick_type trick = s->trick_type; + + u32 state = 0x00; + + if( trick == k_trick_type_shuvit ) + state |= k_ent_objective_filter_trick_shuvit; + if( trick == k_trick_type_treflip ) + state |= k_ent_objective_filter_trick_treflip; + if( trick == k_trick_type_kickflip ) + state |= k_ent_objective_filter_trick_kickflip; + + if( s->flip_rate < -0.0001f ) state |= k_ent_objective_filter_flip_back; + if( s->flip_rate > 0.0001f ) state |= k_ent_objective_filter_flip_front; + + if( s->activity == k_skate_activity_grind_5050 || + s->activity == k_skate_activity_grind_back50 || + s->activity == k_skate_activity_grind_front50 ) + state |= k_ent_objective_filter_grind_truck_any; + + if( s->activity == k_skate_activity_grind_boardslide ) + state |= k_ent_objective_filter_grind_board_any; + + return ((objective->filter & state) || !objective->filter) && + ((objective->filter2 & state) || !objective->filter2); + } + else { + return 1; + } +} + +VG_STATIC void 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 ) return; + + if( world->challenge_target ){ + if( (world->challenge_target == objective) && + ent_objective_check_filter( objective )){ + ent_objective_pass( world, objective ); + } + else { + vg_error( "womp womp\n" ); + world->challenge_target = NULL; + world->challenge_timer = 0.0f; + } + } + } +#if 0 + else if( call->function == 1 ){ + if( objective->flags & k_ent_objective_hidden ) return; + + vg_info( "begin the challenge\n" ); + world->challenge_timer = 0.0f; + ent_objective_pass( world, objective ); + } +#endif + 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 ); + } + } + 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 ); + } + } + else { + vg_print_backtrace(); + vg_error( "Unhandled function id: %u\n", call->function ); + } +} + +#endif /* ENT_OBJECTIVE_C */