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_static
.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_static
.challenge_target
= next
;
16 objective
->flags
|= k_ent_objective_passed
;
18 if( next
->filter
& k_ent_objective_filter_passthrough
)
19 ent_objective_pass( world
, next
);
21 vg_info( "pass challenge point\n" );
24 vg_success( "NYU Film school graduate SUCKAH\n" );
25 world_static
.challenge_target
= NULL
;
26 world_static
.challenge_timer
= 0.0f
;
28 if( objective
->id_win
){
31 call
.function
= objective
->win_event
;
32 call
.id
= objective
->id_win
;
33 entity_call( world
, &call
);
38 VG_STATIC
int ent_objective_check_filter( ent_objective
*objective
){
39 if( objective
->filter
){
40 struct player_skate_state
*s
= &localplayer
._skate
.state
;
41 enum trick_type trick
= s
->trick_type
;
45 if( trick
== k_trick_type_shuvit
)
46 state
|= k_ent_objective_filter_trick_shuvit
;
47 if( trick
== k_trick_type_treflip
)
48 state
|= k_ent_objective_filter_trick_treflip
;
49 if( trick
== k_trick_type_kickflip
)
50 state
|= k_ent_objective_filter_trick_kickflip
;
52 if( s
->flip_rate
< -0.0001f
) state
|= k_ent_objective_filter_flip_back
;
53 if( s
->flip_rate
> 0.0001f
) state
|= k_ent_objective_filter_flip_front
;
55 if( s
->activity
== k_skate_activity_grind_5050
||
56 s
->activity
== k_skate_activity_grind_back50
||
57 s
->activity
== k_skate_activity_grind_front50
)
58 state
|= k_ent_objective_filter_grind_truck_any
;
60 if( s
->activity
== k_skate_activity_grind_boardslide
)
61 state
|= k_ent_objective_filter_grind_board_any
;
63 return ((objective
->filter
& state
) || !objective
->filter
) &&
64 ((objective
->filter2
& state
) || !objective
->filter2
);
71 VG_STATIC
void ent_objective_call( world_instance
*world
, ent_call
*call
){
72 u32 index
= mdl_entity_id_id( call
->id
);
73 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
75 if( call
->function
== 0 ){
76 if( objective
->flags
& (k_ent_objective_hidden
|
77 k_ent_objective_passed
)) return;
79 if( world_static
.challenge_target
){
80 if( (world_static
.challenge_target
== objective
) &&
81 ent_objective_check_filter( objective
)){
82 ent_objective_pass( world
, objective
);
85 vg_error( "womp womp\n" );
86 world_static
.challenge_target
= NULL
;
87 world_static
.challenge_timer
= 0.0f
;
91 else if( call
->function
== 2 ){
92 objective
->flags
&= ~k_ent_objective_hidden
;
94 if( mdl_entity_id_type( objective
->id_next
) == k_ent_objective
){
95 call
->id
= objective
->id_next
;
96 entity_call( world
, call
);
99 else if( call
->function
== 3 ){
100 objective
->flags
|= k_ent_objective_hidden
;
102 if( mdl_entity_id_type( objective
->id_next
) == k_ent_objective
){
103 call
->id
= objective
->id_next
;
104 entity_call( world
, call
);
108 vg_print_backtrace();
109 vg_error( "Unhandled function id: %u\n", call
->function
);
113 #endif /* ENT_OBJECTIVE_C */