revision 2
[carveJwlIkooP6JGAAIwe30JlM.git] / player_effects.c
1 #include "player_effects.h"
2 #include "player_render.h"
3 #include "particle.h"
4
5 void effect_blink_apply( effect_blink *ef, player_pose *pose, f32 dt )
6 {
7 if( ef->t < 0.0f ){
8 ef->t = (1.0f-powf(vg_randf64(&vg.rand),4.0f))*4.0f;
9 ef->l = 0.08f;
10 }
11
12 pose->keyframes[ localplayer.id_eyes-1 ].s[1] = ef->l > 0.0f? 0.2f: 1.0f;
13
14 ef->t -= dt;
15 ef->l -= dt;
16 }
17
18 void effect_spark_apply( effect_spark *ef, v3f co, v3f v, f32 dt )
19 {
20 if( !ef->colour ) return;
21
22 if( ef->t < 0.0f ){
23 ef->t += 0.05f+vg_randf64(&vg.rand)*0.1f;
24
25 v3f dir;
26 v3_copy( v, dir );
27 dir[1] += 1.0f;
28 f32 l = v3_length(dir);
29 v3_muls( dir, 1.0f/l, dir );
30
31 particle_spawn_cone( &particles_grind, co, dir, VG_PIf/2.0f, l,
32 4.0f, ef->colour );
33 }
34 else
35 ef->t -= dt;
36 }