1 /*
2 ==============================================================================
3
4 FLIPPER
5
6 ==============================================================================
7 */
8
9 #include "g_local.h"
10 #include "m_flipper.h"
11
12
13 static int sound_chomp;
14 static int sound_attack;
15 static int sound_pain1;
16 static int sound_pain2;
17 static int sound_death;
18 static int sound_idle;
19 static int sound_search;
20 static int sound_sight;
21
22
23 void flipper_stand (edict_t *self);
24
25 mframe_t flipper_frames_stand [] =
26 {
27 ai_stand, 0, NULL
28 };
29
30 mmove_t flipper_move_stand = {FRAME_flphor01, FRAME_flphor01, flipper_frames_stand, NULL};
31
flipper_stand(edict_t * self)32 void flipper_stand (edict_t *self)
33 {
34 self->monsterinfo.currentmove = &flipper_move_stand;
35 }
36
37 #define FLIPPER_RUN_SPEED 24
38
39 mframe_t flipper_frames_run [] =
40 {
41 ai_run, FLIPPER_RUN_SPEED, NULL, // 6
42 ai_run, FLIPPER_RUN_SPEED, NULL,
43 ai_run, FLIPPER_RUN_SPEED, NULL,
44 ai_run, FLIPPER_RUN_SPEED, NULL,
45 ai_run, FLIPPER_RUN_SPEED, NULL, // 10
46
47 ai_run, FLIPPER_RUN_SPEED, NULL,
48 ai_run, FLIPPER_RUN_SPEED, NULL,
49 ai_run, FLIPPER_RUN_SPEED, NULL,
50 ai_run, FLIPPER_RUN_SPEED, NULL,
51 ai_run, FLIPPER_RUN_SPEED, NULL,
52 ai_run, FLIPPER_RUN_SPEED, NULL,
53 ai_run, FLIPPER_RUN_SPEED, NULL,
54 ai_run, FLIPPER_RUN_SPEED, NULL,
55 ai_run, FLIPPER_RUN_SPEED, NULL,
56 ai_run, FLIPPER_RUN_SPEED, NULL, // 20
57
58 ai_run, FLIPPER_RUN_SPEED, NULL,
59 ai_run, FLIPPER_RUN_SPEED, NULL,
60 ai_run, FLIPPER_RUN_SPEED, NULL,
61 ai_run, FLIPPER_RUN_SPEED, NULL,
62 ai_run, FLIPPER_RUN_SPEED, NULL,
63 ai_run, FLIPPER_RUN_SPEED, NULL,
64 ai_run, FLIPPER_RUN_SPEED, NULL,
65 ai_run, FLIPPER_RUN_SPEED, NULL,
66 ai_run, FLIPPER_RUN_SPEED, NULL // 29
67 };
68 mmove_t flipper_move_run_loop = {FRAME_flpver06, FRAME_flpver29, flipper_frames_run, NULL};
69
flipper_run_loop(edict_t * self)70 void flipper_run_loop (edict_t *self)
71 {
72 self->monsterinfo.currentmove = &flipper_move_run_loop;
73 }
74
75 mframe_t flipper_frames_run_start [] =
76 {
77 ai_run, 8, NULL,
78 ai_run, 8, NULL,
79 ai_run, 8, NULL,
80 ai_run, 8, NULL,
81 ai_run, 8, NULL,
82 ai_run, 8, NULL
83 };
84 mmove_t flipper_move_run_start = {FRAME_flpver01, FRAME_flpver06, flipper_frames_run_start, flipper_run_loop};
85
flipper_run(edict_t * self)86 void flipper_run (edict_t *self)
87 {
88 self->monsterinfo.currentmove = &flipper_move_run_start;
89 }
90
91 /* Standard Swimming */
92 mframe_t flipper_frames_walk [] =
93 {
94 ai_walk, 4, NULL,
95 ai_walk, 4, NULL,
96 ai_walk, 4, NULL,
97 ai_walk, 4, NULL,
98 ai_walk, 4, NULL,
99 ai_walk, 4, NULL,
100 ai_walk, 4, NULL,
101 ai_walk, 4, NULL,
102 ai_walk, 4, NULL,
103 ai_walk, 4, NULL,
104 ai_walk, 4, NULL,
105 ai_walk, 4, NULL,
106 ai_walk, 4, NULL,
107 ai_walk, 4, NULL,
108 ai_walk, 4, NULL,
109 ai_walk, 4, NULL,
110 ai_walk, 4, NULL,
111 ai_walk, 4, NULL,
112 ai_walk, 4, NULL,
113 ai_walk, 4, NULL,
114 ai_walk, 4, NULL,
115 ai_walk, 4, NULL,
116 ai_walk, 4, NULL,
117 ai_walk, 4, NULL
118 };
119 mmove_t flipper_move_walk = {FRAME_flphor01, FRAME_flphor24, flipper_frames_walk, NULL};
120
flipper_walk(edict_t * self)121 void flipper_walk (edict_t *self)
122 {
123 self->monsterinfo.currentmove = &flipper_move_walk;
124 }
125
126 mframe_t flipper_frames_start_run [] =
127 {
128 ai_run, 8, NULL,
129 ai_run, 8, NULL,
130 ai_run, 8, NULL,
131 ai_run, 8, NULL,
132 ai_run, 8, flipper_run
133 };
134 mmove_t flipper_move_start_run = {FRAME_flphor01, FRAME_flphor05, flipper_frames_start_run, NULL};
135
flipper_start_run(edict_t * self)136 void flipper_start_run (edict_t *self)
137 {
138 self->monsterinfo.currentmove = &flipper_move_start_run;
139 }
140
141 mframe_t flipper_frames_pain2 [] =
142 {
143 ai_move, 0, NULL,
144 ai_move, 0, NULL,
145 ai_move, 0, NULL,
146 ai_move, 0, NULL,
147 ai_move, 0, NULL
148 };
149 mmove_t flipper_move_pain2 = {FRAME_flppn101, FRAME_flppn105, flipper_frames_pain2, flipper_run};
150
151 mframe_t flipper_frames_pain1 [] =
152 {
153 ai_move, 0, NULL,
154 ai_move, 0, NULL,
155 ai_move, 0, NULL,
156 ai_move, 0, NULL,
157 ai_move, 0, NULL
158 };
159 mmove_t flipper_move_pain1 = {FRAME_flppn201, FRAME_flppn205, flipper_frames_pain1, flipper_run};
160
flipper_bite(edict_t * self)161 void flipper_bite (edict_t *self)
162 {
163 vec3_t aim;
164
165 VectorSet (aim, MELEE_DISTANCE, 0, 0);
166 fire_hit (self, aim, 5, 0);
167 }
168
flipper_preattack(edict_t * self)169 void flipper_preattack (edict_t *self)
170 {
171 gi.sound (self, CHAN_WEAPON, sound_chomp, 1, ATTN_NORM, 0);
172 }
173
174 mframe_t flipper_frames_attack [] =
175 {
176 ai_charge, 0, flipper_preattack,
177 ai_charge, 0, NULL,
178 ai_charge, 0, NULL,
179 ai_charge, 0, NULL,
180 ai_charge, 0, NULL,
181 ai_charge, 0, NULL,
182 ai_charge, 0, NULL,
183 ai_charge, 0, NULL,
184 ai_charge, 0, NULL,
185 ai_charge, 0, NULL,
186 ai_charge, 0, NULL,
187 ai_charge, 0, NULL,
188 ai_charge, 0, NULL,
189 ai_charge, 0, flipper_bite,
190 ai_charge, 0, NULL,
191 ai_charge, 0, NULL,
192 ai_charge, 0, NULL,
193 ai_charge, 0, NULL,
194 ai_charge, 0, flipper_bite,
195 ai_charge, 0, NULL
196 };
197 mmove_t flipper_move_attack = {FRAME_flpbit01, FRAME_flpbit20, flipper_frames_attack, flipper_run};
198
flipper_melee(edict_t * self)199 void flipper_melee(edict_t *self)
200 {
201 self->monsterinfo.currentmove = &flipper_move_attack;
202 }
203
flipper_pain(edict_t * self,edict_t * other,float kick,int damage)204 void flipper_pain (edict_t *self, edict_t *other, float kick, int damage)
205 {
206 int n;
207
208 if (self->health < (self->max_health / 2))
209 self->s.skinnum = 1;
210
211 if (level.time < self->pain_debounce_time)
212 return;
213
214 self->pain_debounce_time = level.time + 3;
215
216 if (skill->value == 3)
217 return; // no pain anims in nightmare
218
219 n = (rand() + 1) % 2;
220 if (n == 0)
221 {
222 gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
223 self->monsterinfo.currentmove = &flipper_move_pain1;
224 }
225 else
226 {
227 gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
228 self->monsterinfo.currentmove = &flipper_move_pain2;
229 }
230 }
231
flipper_dead(edict_t * self)232 void flipper_dead (edict_t *self)
233 {
234 VectorSet (self->mins, -16, -16, -24);
235 VectorSet (self->maxs, 16, 16, -8);
236 self->movetype = MOVETYPE_TOSS;
237 self->svflags |= SVF_DEADMONSTER;
238 self->nextthink = 0;
239 gi.linkentity (self);
240 }
241
242 mframe_t flipper_frames_death [] =
243 {
244 ai_move, 0, NULL,
245 ai_move, 0, NULL,
246 ai_move, 0, NULL,
247 ai_move, 0, NULL,
248 ai_move, 0, NULL,
249 ai_move, 0, NULL,
250 ai_move, 0, NULL,
251 ai_move, 0, NULL,
252 ai_move, 0, NULL,
253 ai_move, 0, NULL,
254
255 ai_move, 0, NULL,
256 ai_move, 0, NULL,
257 ai_move, 0, NULL,
258 ai_move, 0, NULL,
259 ai_move, 0, NULL,
260 ai_move, 0, NULL,
261 ai_move, 0, NULL,
262 ai_move, 0, NULL,
263 ai_move, 0, NULL,
264 ai_move, 0, NULL,
265
266 ai_move, 0, NULL,
267 ai_move, 0, NULL,
268 ai_move, 0, NULL,
269 ai_move, 0, NULL,
270 ai_move, 0, NULL,
271 ai_move, 0, NULL,
272 ai_move, 0, NULL,
273 ai_move, 0, NULL,
274 ai_move, 0, NULL,
275 ai_move, 0, NULL,
276
277 ai_move, 0, NULL,
278 ai_move, 0, NULL,
279 ai_move, 0, NULL,
280 ai_move, 0, NULL,
281 ai_move, 0, NULL,
282 ai_move, 0, NULL,
283 ai_move, 0, NULL,
284 ai_move, 0, NULL,
285 ai_move, 0, NULL,
286 ai_move, 0, NULL,
287
288 ai_move, 0, NULL,
289 ai_move, 0, NULL,
290 ai_move, 0, NULL,
291 ai_move, 0, NULL,
292 ai_move, 0, NULL,
293 ai_move, 0, NULL,
294 ai_move, 0, NULL,
295 ai_move, 0, NULL,
296 ai_move, 0, NULL,
297 ai_move, 0, NULL,
298
299 ai_move, 0, NULL,
300 ai_move, 0, NULL,
301 ai_move, 0, NULL,
302 ai_move, 0, NULL,
303 ai_move, 0, NULL,
304 ai_move, 0, NULL
305 };
306 mmove_t flipper_move_death = {FRAME_flpdth01, FRAME_flpdth56, flipper_frames_death, flipper_dead};
307
flipper_sight(edict_t * self,edict_t * other)308 void flipper_sight (edict_t *self, edict_t *other)
309 {
310 gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
311 }
312
flipper_die(edict_t * self,edict_t * inflictor,edict_t * attacker,int damage,vec3_t point)313 void flipper_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
314 {
315 int n;
316
317 // check for gib
318 if (self->health <= self->gib_health)
319 {
320 gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
321 for (n= 0; n < 2; n++)
322 ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
323 for (n= 0; n < 2; n++)
324 ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
325 ThrowHead (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
326 self->deadflag = DEAD_DEAD;
327 return;
328 }
329
330 if (self->deadflag == DEAD_DEAD)
331 return;
332
333 // regular death
334 gi.sound (self, CHAN_VOICE, sound_death, 1, ATTN_NORM, 0);
335 self->deadflag = DEAD_DEAD;
336 self->takedamage = DAMAGE_YES;
337 self->monsterinfo.currentmove = &flipper_move_death;
338 }
339
340 /*QUAKED monster_flipper (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
341 */
SP_monster_flipper(edict_t * self)342 void SP_monster_flipper (edict_t *self)
343 {
344 if (deathmatch->value)
345 {
346 G_FreeEdict (self);
347 return;
348 }
349
350 sound_pain1 = gi.soundindex ("flipper/flppain1.wav");
351 sound_pain2 = gi.soundindex ("flipper/flppain2.wav");
352 sound_death = gi.soundindex ("flipper/flpdeth1.wav");
353 sound_chomp = gi.soundindex ("flipper/flpatck1.wav");
354 sound_attack = gi.soundindex ("flipper/flpatck2.wav");
355 sound_idle = gi.soundindex ("flipper/flpidle1.wav");
356 sound_search = gi.soundindex ("flipper/flpsrch1.wav");
357 sound_sight = gi.soundindex ("flipper/flpsght1.wav");
358
359 self->movetype = MOVETYPE_STEP;
360 self->solid = SOLID_BBOX;
361 self->s.modelindex = gi.modelindex ("models/monsters/flipper/tris.md2");
362 VectorSet (self->mins, -16, -16, 0);
363 VectorSet (self->maxs, 16, 16, 32);
364
365 self->health = 50;
366 self->gib_health = -30;
367 self->mass = 100;
368
369 self->pain = flipper_pain;
370 self->die = flipper_die;
371
372 self->monsterinfo.stand = flipper_stand;
373 self->monsterinfo.walk = flipper_walk;
374 self->monsterinfo.run = flipper_start_run;
375 self->monsterinfo.melee = flipper_melee;
376 self->monsterinfo.sight = flipper_sight;
377
378 gi.linkentity (self);
379
380 self->monsterinfo.currentmove = &flipper_move_stand;
381 self->monsterinfo.scale = MODEL_SCALE;
382
383 swimmonster_start (self);
384 }
385