#include "gui.h"
#include "audio.h"
+static bool ent_challenge_is_acceptable( world_instance *world, u32 challenge_index )
+{
+ ent_challenge *challenge = af_arritm( &world->ent_challenge, challenge_index );
+
+ if( challenge->flags & k_ent_challenge_is_story )
+ {
+ struct script_info *script = world->events[ challenge_index ].story_script;
+ if( script->viewed_time || !script->availible )
+ {
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
entity_call_result ent_challenge_call( world_instance *world, ent_call *call )
{
u32 index = mdl_entity_id_id( call->id );
{
if( localplayer.subsystem == k_player_subsystem_walk )
{
- if( world_set_event( k_world_event_challenge ) )
+ if( ent_challenge_is_acceptable( world, index ) )
{
- _world.challenge_state = k_challenge_state_none;
- _world.active_challenge_id = call->id;
- gui_helper_reset( 1 );
- vg_str text;
- if( gui_new_helper( input_button_list[k_srbind_maccept], &text ))
- vg_strcat( &text, (challenge->flags & k_ent_challenge_is_story)? "Play video": "View Challenge" );
+ if( world_set_event( k_world_event_challenge ) )
+ {
+ _world.challenge_state = k_challenge_state_none;
+ _world.active_challenge_id = call->id;
+ gui_helper_reset( 1 );
+ vg_str text;
+ if( gui_new_helper( input_button_list[k_srbind_maccept], &text ))
+ vg_strcat( &text, (challenge->flags & k_ent_challenge_is_story)? "Play video": "View Challenge" );
+ }
}
}
{
if( _world.challenge_state != k_challenge_state_running )
{
- if( world_clear_event( k_world_event_challenge ) )
+ if( ent_challenge_is_acceptable( world, index ) )
{
- _world.challenge_state = k_challenge_state_none;
- _world.active_challenge_id = 0;
- gui_helper_reset( k_gui_helper_mode_clear );
+ if( world_clear_event( k_world_event_challenge ) )
+ {
+ _world.challenge_state = k_challenge_state_none;
+ _world.active_challenge_id = 0;
+ gui_helper_reset( k_gui_helper_mode_clear );
+ }
}
}
return k_entity_call_result_OK;