1 #ifndef ENT_OBJECTIVE_C
2 #define ENT_OBJECTIVE_C
5 #include "world_load.h"
8 VG_STATIC
void ent_objective_pass( world_instance
*world
,
9 ent_objective
*objective
){
10 if( objective
->id_next
){
11 world
->challenge_timer
+= objective
->filter
;
13 u32 index
= mdl_entity_id_id( objective
->id_next
);
14 ent_objective
*next
= mdl_arritm( &world
->ent_objective
, index
);
15 world
->challenge_target
= next
;
17 if( next
->filter
& k_ent_objective_filter_passthrough
)
18 ent_objective_pass( world
, next
);
20 vg_info( "pass challenge point\n" );
23 vg_success( "NYU Film school graduate SUCKAH\n" );
24 world
->challenge_target
= NULL
;
25 world
->challenge_timer
= 0.0f
;
27 if( objective
->id_win
){
30 call
.function
= objective
->win_event
;
31 call
.id
= objective
->id_win
;
32 entity_call( world
, &call
);
37 VG_STATIC
int ent_objective_check_filter( ent_objective
*objective
){
38 if( objective
->filter
){
39 struct player_skate_state
*s
= &localplayer
._skate
.state
;
40 enum trick_type trick
= s
->trick_type
;
44 if( trick
== k_trick_type_shuvit
)
45 state
|= k_ent_objective_filter_trick_shuvit
;
46 if( trick
== k_trick_type_treflip
)
47 state
|= k_ent_objective_filter_trick_treflip
;
48 if( trick
== k_trick_type_kickflip
)
49 state
|= k_ent_objective_filter_trick_kickflip
;
51 if( s
->flip_rate
< -0.0001f
) state
|= k_ent_objective_filter_flip_back
;
52 if( s
->flip_rate
> 0.0001f
) state
|= k_ent_objective_filter_flip_front
;
54 if( s
->activity
== k_skate_activity_grind_5050
||
55 s
->activity
== k_skate_activity_grind_back50
||
56 s
->activity
== k_skate_activity_grind_front50
)
57 state
|= k_ent_objective_filter_grind_truck_any
;
59 if( s
->activity
== k_skate_activity_grind_boardslide
)
60 state
|= k_ent_objective_filter_grind_board_any
;
62 return ((objective
->filter
& state
) || !objective
->filter
) &&
63 ((objective
->filter2
& state
) || !objective
->filter2
);
70 VG_STATIC
void ent_objective_call( world_instance
*world
, ent_call
*call
){
71 u32 index
= mdl_entity_id_id( call
->id
);
72 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
74 if( call
->function
== 0 ){
75 if( objective
->flags
& k_ent_objective_hidden
) return;
77 if( world
->challenge_target
){
78 if( (world
->challenge_target
== objective
) &&
79 ent_objective_check_filter( objective
)){
80 ent_objective_pass( world
, objective
);
83 vg_error( "womp womp\n" );
84 world
->challenge_target
= NULL
;
85 world
->challenge_timer
= 0.0f
;
90 else if( call
->function
== 1 ){
91 if( objective
->flags
& k_ent_objective_hidden
) return;
93 vg_info( "begin the challenge\n" );
94 world
->challenge_timer
= 0.0f
;
95 ent_objective_pass( world
, objective
);
98 else if( call
->function
== 2 ){
99 objective
->flags
&= ~k_ent_objective_hidden
;
101 if( mdl_entity_id_type( objective
->id_next
) == k_ent_objective
){
102 call
->id
= objective
->id_next
;
103 entity_call( world
, call
);
106 else if( call
->function
== 3 ){
107 objective
->flags
|= k_ent_objective_hidden
;
109 if( mdl_entity_id_type( objective
->id_next
) == k_ent_objective
){
110 call
->id
= objective
->id_next
;
111 entity_call( world
, call
);
115 vg_print_backtrace();
116 vg_error( "Unhandled function id: %u\n", call
->function
);
120 #endif /* ENT_OBJECTIVE_C */