1 #ifndef ENT_OBJECTIVE_C
2 #define ENT_OBJECTIVE_C
5 #include "world_load.h"
9 VG_STATIC
void ent_objective_pass( world_instance
*world
,
10 ent_objective
*objective
){
11 if( objective
->id_next
){
12 world_static
.challenge_timer
+= objective
->filter
;
14 u32 index
= mdl_entity_id_id( objective
->id_next
);
15 ent_objective
*next
= mdl_arritm( &world
->ent_objective
, index
);
16 world_static
.challenge_target
= next
;
17 objective
->flags
|= k_ent_objective_passed
;
19 if( next
->filter
& k_ent_objective_filter_passthrough
)
20 ent_objective_pass( world
, next
);
22 vg_info( "pass challenge point\n" );
23 audio_oneshot_3d( &audio_challenge
[0], localplayer
.rb
.co
,
28 vg_success( "challenge win\n" );
29 audio_oneshot( &audio_challenge
[2], 1.0f
, 0.0f
);
30 world_static
.challenge_target
= NULL
;
31 world_static
.challenge_timer
= 0.0f
;
33 if( objective
->id_win
){
36 call
.function
= objective
->win_event
;
37 call
.id
= objective
->id_win
;
38 entity_call( world
, &call
);
43 VG_STATIC
int ent_objective_check_filter( ent_objective
*objective
){
44 if( objective
->filter
){
45 struct player_skate_state
*s
= &localplayer
._skate
.state
;
46 enum trick_type trick
= s
->trick_type
;
50 if( trick
== k_trick_type_shuvit
)
51 state
|= k_ent_objective_filter_trick_shuvit
;
52 if( trick
== k_trick_type_treflip
)
53 state
|= k_ent_objective_filter_trick_treflip
;
54 if( trick
== k_trick_type_kickflip
)
55 state
|= k_ent_objective_filter_trick_kickflip
;
57 if( s
->flip_rate
< -0.0001f
) state
|= k_ent_objective_filter_flip_back
;
58 if( s
->flip_rate
> 0.0001f
) state
|= k_ent_objective_filter_flip_front
;
60 if( s
->activity
== k_skate_activity_grind_5050
||
61 s
->activity
== k_skate_activity_grind_back50
||
62 s
->activity
== k_skate_activity_grind_front50
)
63 state
|= k_ent_objective_filter_grind_truck_any
;
65 if( s
->activity
== k_skate_activity_grind_boardslide
)
66 state
|= k_ent_objective_filter_grind_board_any
;
68 return ((objective
->filter
& state
) || !objective
->filter
) &&
69 ((objective
->filter2
& state
) || !objective
->filter2
);
76 VG_STATIC
void ent_objective_call( world_instance
*world
, ent_call
*call
){
77 u32 index
= mdl_entity_id_id( call
->id
);
78 ent_objective
*objective
= mdl_arritm( &world
->ent_objective
, index
);
80 if( call
->function
== 0 ){
81 if( objective
->flags
& (k_ent_objective_hidden
|
82 k_ent_objective_passed
)) return;
84 if( world_static
.challenge_target
){
85 if( (world_static
.challenge_target
== objective
) &&
86 ent_objective_check_filter( objective
)){
87 ent_objective_pass( world
, objective
);
90 audio_oneshot_3d( &audio_challenge
[6], localplayer
.rb
.co
,
92 vg_error( "challenge fialed\n" );
93 world_static
.challenge_target
= NULL
;
94 world_static
.challenge_timer
= 0.0f
;
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 */