1 #ifndef ENT_CHALLENGE_C
2 #define ENT_CHALLENGE_C
5 #include "world_load.h"
8 VG_STATIC
void ent_challenge_pass( world_instance
*world
,
9 ent_challenge
*challenge
){
10 if( challenge
->id_next
){
11 world
->challenge_timer
+= challenge
->filter
;
13 u32 index
= mdl_entity_id_id( challenge
->id_next
);
14 ent_challenge
*next
= mdl_arritm( &world
->ent_challenge
, index
);
15 world
->challenge_target
= next
;
17 vg_info( "pass challenge point\n" );
20 vg_success( "NYU Film school graduate SUCKAH\n" );
21 world
->challenge_target
= NULL
;
22 world
->challenge_timer
= 0.0f
;
24 if( challenge
->id_win
){
27 call
.function
= challenge
->win_event
;
28 call
.id
= challenge
->id_win
;
29 entity_call( world
, &call
);
34 VG_STATIC
int ent_challenge_check_filter( ent_challenge
*challenge
){
35 if( challenge
->filter
){
36 struct player_skate_state
*s
= &localplayer
._skate
.state
;
37 enum trick_type trick
= s
->trick_type
;
41 if( trick
== k_trick_type_shuvit
)
42 state
|= k_ent_challenge_filter_trick_shuvit
;
43 if( trick
== k_trick_type_treflip
)
44 state
|= k_ent_challenge_filter_trick_treflip
;
45 if( trick
== k_trick_type_kickflip
)
46 state
|= k_ent_challenge_filter_trick_kickflip
;
48 if( s
->flip_rate
< -0.0001f
) state
|= k_ent_challenge_filter_flip_back
;
49 if( s
->flip_rate
> 0.0001f
) state
|= k_ent_challenge_filter_flip_front
;
51 if( s
->activity
== k_skate_activity_grind_5050
||
52 s
->activity
== k_skate_activity_grind_back50
||
53 s
->activity
== k_skate_activity_grind_front50
)
54 state
|= k_ent_challenge_filter_grind_truck_any
;
56 if( s
->activity
== k_skate_activity_grind_boardslide
)
57 state
|= k_ent_challenge_filter_grind_board_any
;
59 return ((challenge
->filter
& state
) || !challenge
->filter
) &&
60 ((challenge
->filter2
& state
) || !challenge
->filter2
);
67 VG_STATIC
void ent_challenge_call( world_instance
*world
, ent_call
*call
){
68 u32 index
= mdl_entity_id_id( call
->id
);
69 ent_challenge
*challenge
= mdl_arritm( &world
->ent_challenge
, index
);
71 if( call
->function
== 0 ){
72 if( challenge
->flags
& k_ent_challenge_hidden
) return;
74 if( world
->challenge_target
){
75 if( (world
->challenge_target
== challenge
) &&
76 ent_challenge_check_filter( challenge
)){
77 ent_challenge_pass( world
, challenge
);
80 vg_error( "womp womp\n" );
81 world
->challenge_target
= NULL
;
82 world
->challenge_timer
= 0.0f
;
86 else if( call
->function
== 1 ){
87 if( challenge
->flags
& k_ent_challenge_hidden
) return;
89 vg_info( "begin the challenge\n" );
90 world
->challenge_timer
= 0.0f
;
91 ent_challenge_pass( world
, challenge
);
93 else if( call
->function
== 2 ){
94 challenge
->flags
&= ~k_ent_challenge_hidden
;
96 else if( call
->function
== 3 ){
97 challenge
->flags
|= k_ent_challenge_hidden
;
100 vg_print_backtrace();
101 vg_error( "Unhandled function id: %u\n", call
->function
);
105 #endif /* ENT_CHALLENGE_C */