-
Notifications
You must be signed in to change notification settings - Fork 0
/
entity_enemy_enforcer.c
107 lines (91 loc) · 2.64 KB
/
entity_enemy_enforcer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "entity.h"
#include "entity_enemy.h"
#include "entity_projectile_plasma.h"
#include "audio.h"
#include "map.h"
void entity_enemy_enforcer_init(entity_t * e);
void entity_enemy_enforcer_attack(entity_t * e);
animation_t enforcer_animations[] = {
{ // 0: Idle
.time = 1,
.num_frames = 1,
.frames = (animation_frame_t[]) {
{.name = "default"},
},
},
{ // 1: Walk
.time = 0.40f,
.num_frames = 4,
.frames = (animation_frame_t[]) {
{.name = "run_1"},
{.name = "run_2"},
{.name = "run_3"},
{.name = "run_4"},
},
},
{ // 2: Run
.time = 0.20f,
.num_frames = 4,
.frames = (animation_frame_t[]) {
{.name = "run_1"},
{.name = "run_2"},
{.name = "run_3"},
{.name = "run_4"},
},
},
{ // 3: Attack prepare
.time = 0.25f,
.num_frames = 4,
.frames = (animation_frame_t[]) {
{.name = "default"},
{.name = "shoot"},
{.name = "shoot"},
{.name = "shoot"},
},
},
{ // 4: Attack
.time = 0.25f,
.num_frames = 4,
.frames = (animation_frame_t[]) {
{.name = "shoot"},
{.name = "default"},
{.name = "default"},
{.name = "default"},
},
},
};
// hack for caching parsed frame names per-map
static ref_entt_t * last_ref_entt = NULL;
vec3_t entity_get_size(model_t * model) {
vec3_t size = { 0 };
for(size_t i = 0; i < model->nv; i++) {}
return size;
}
void entity_enemy_enforcer_constructor(entity_t *e) {
char * str_p1 = entity_param_lookup("patrol", e->_params->entity_generic_params.extras);
uint8_t patrol = 0;
if (str_p1)
patrol = atoi(str_p1);
entity_enemy_constructor(e, patrol);
e->_attack = entity_enemy_enforcer_attack;
entity_enemy_enforcer_init(e);
}
void entity_enemy_enforcer_init(entity_t * e) {
e->_health = 80;
e->s = vec3(14,44,14);
entity_parse_animation_frames(
e->_params->entity_generic_params.ref_entt,
enforcer_animations,
sizeof(enforcer_animations)/sizeof(enforcer_animations[0]),
&last_ref_entt
);
e->_animation_collection = (animation_collection_t) {
.animations = enforcer_animations,
.num_animations = sizeof(enforcer_animations)/sizeof(enforcer_animations[0]),
};
entity_set_model(e);
}
void entity_enemy_enforcer_attack(entity_t * e) {
e->_play_sound(e, sfx_plasma_shoot);
e->_spawn_projectile(e, ENTITY_ID_PROJECTILE_PLASMA, 800, 0, 0);
}