1 /*
2 ==============================================================================
3
4 chick
5
6 ==============================================================================
7 */
8
9 #include "g_local.h"
10 #include "m_chick.h"
11
12 qboolean visible (edict_t *self, edict_t *other);
13
14 void chick_stand (edict_t *self);
15 void chick_run (edict_t *self);
16 void chick_reslash(edict_t *self);
17 void chick_rerocket(edict_t *self);
18 void chick_attack1(edict_t *self);
19
20 static int sound_missile_prelaunch;
21 static int sound_missile_launch;
22 static int sound_melee_swing;
23 static int sound_melee_hit;
24 static int sound_missile_reload;
25 static int sound_death1;
26 static int sound_death2;
27 static int sound_fall_down;
28 static int sound_idle1;
29 static int sound_idle2;
30 static int sound_pain1;
31 static int sound_pain2;
32 static int sound_sight;
33 static int sound_search;
34
35
ChickMoan(edict_t * self)36 void ChickMoan (edict_t *self)
37 {
38 if (random() < 0.5)
39 gi.sound (self, CHAN_VOICE, sound_idle1, 1, ATTN_IDLE, 0);
40 else
41 gi.sound (self, CHAN_VOICE, sound_idle2, 1, ATTN_IDLE, 0);
42 }
43
44 mframe_t chick_frames_fidget [] =
45 {
46 ai_stand, 0, NULL,
47 ai_stand, 0, NULL,
48 ai_stand, 0, NULL,
49 ai_stand, 0, NULL,
50 ai_stand, 0, NULL,
51 ai_stand, 0, NULL,
52 ai_stand, 0, NULL,
53 ai_stand, 0, NULL,
54 ai_stand, 0, ChickMoan,
55 ai_stand, 0, NULL,
56 ai_stand, 0, NULL,
57 ai_stand, 0, NULL,
58 ai_stand, 0, NULL,
59 ai_stand, 0, NULL,
60 ai_stand, 0, NULL,
61 ai_stand, 0, NULL,
62 ai_stand, 0, NULL,
63 ai_stand, 0, NULL,
64 ai_stand, 0, NULL,
65 ai_stand, 0, NULL,
66 ai_stand, 0, NULL,
67 ai_stand, 0, NULL,
68 ai_stand, 0, NULL,
69 ai_stand, 0, NULL,
70 ai_stand, 0, NULL,
71 ai_stand, 0, NULL,
72 ai_stand, 0, NULL,
73 ai_stand, 0, NULL,
74 ai_stand, 0, NULL,
75 ai_stand, 0, NULL
76 };
77 mmove_t chick_move_fidget = {FRAME_stand201, FRAME_stand230, chick_frames_fidget, chick_stand};
78
chick_fidget(edict_t * self)79 void chick_fidget (edict_t *self)
80 {
81 if (self->monsterinfo.aiflags & AI_STAND_GROUND)
82 return;
83 if (random() <= 0.3)
84 self->monsterinfo.currentmove = &chick_move_fidget;
85 }
86
87 mframe_t chick_frames_stand [] =
88 {
89 ai_stand, 0, NULL,
90 ai_stand, 0, NULL,
91 ai_stand, 0, NULL,
92 ai_stand, 0, NULL,
93 ai_stand, 0, NULL,
94 ai_stand, 0, NULL,
95 ai_stand, 0, NULL,
96 ai_stand, 0, NULL,
97 ai_stand, 0, NULL,
98 ai_stand, 0, NULL,
99 ai_stand, 0, NULL,
100 ai_stand, 0, NULL,
101 ai_stand, 0, NULL,
102 ai_stand, 0, NULL,
103 ai_stand, 0, NULL,
104 ai_stand, 0, NULL,
105 ai_stand, 0, NULL,
106 ai_stand, 0, NULL,
107 ai_stand, 0, NULL,
108 ai_stand, 0, NULL,
109 ai_stand, 0, NULL,
110 ai_stand, 0, NULL,
111 ai_stand, 0, NULL,
112 ai_stand, 0, NULL,
113 ai_stand, 0, NULL,
114 ai_stand, 0, NULL,
115 ai_stand, 0, NULL,
116 ai_stand, 0, NULL,
117 ai_stand, 0, NULL,
118 ai_stand, 0, chick_fidget,
119
120 };
121 mmove_t chick_move_stand = {FRAME_stand101, FRAME_stand130, chick_frames_stand, NULL};
122
chick_stand(edict_t * self)123 void chick_stand (edict_t *self)
124 {
125 self->monsterinfo.currentmove = &chick_move_stand;
126 }
127
128 mframe_t chick_frames_start_run [] =
129 {
130 ai_run, 1, NULL,
131 ai_run, 0, NULL,
132 ai_run, 0, NULL,
133 ai_run, -1, NULL,
134 ai_run, -1, NULL,
135 ai_run, 0, NULL,
136 ai_run, 1, NULL,
137 ai_run, 3, NULL,
138 ai_run, 6, NULL,
139 ai_run, 3, NULL
140 };
141 mmove_t chick_move_start_run = {FRAME_walk01, FRAME_walk10, chick_frames_start_run, chick_run};
142
143 mframe_t chick_frames_run [] =
144 {
145 ai_run, 6, NULL,
146 ai_run, 8, NULL,
147 ai_run, 13, NULL,
148 ai_run, 5, NULL,
149 ai_run, 7, NULL,
150 ai_run, 4, NULL,
151 ai_run, 11, NULL,
152 ai_run, 5, NULL,
153 ai_run, 9, NULL,
154 ai_run, 7, NULL
155
156 };
157
158 mmove_t chick_move_run = {FRAME_walk11, FRAME_walk20, chick_frames_run, NULL};
159
160 mframe_t chick_frames_walk [] =
161 {
162 ai_walk, 6, NULL,
163 ai_walk, 8, NULL,
164 ai_walk, 13, NULL,
165 ai_walk, 5, NULL,
166 ai_walk, 7, NULL,
167 ai_walk, 4, NULL,
168 ai_walk, 11, NULL,
169 ai_walk, 5, NULL,
170 ai_walk, 9, NULL,
171 ai_walk, 7, NULL
172 };
173
174 mmove_t chick_move_walk = {FRAME_walk11, FRAME_walk20, chick_frames_walk, NULL};
175
chick_walk(edict_t * self)176 void chick_walk (edict_t *self)
177 {
178 self->monsterinfo.currentmove = &chick_move_walk;
179 }
180
chick_run(edict_t * self)181 void chick_run (edict_t *self)
182 {
183 if (self->monsterinfo.aiflags & AI_STAND_GROUND)
184 {
185 self->monsterinfo.currentmove = &chick_move_stand;
186 return;
187 }
188
189 if (self->monsterinfo.currentmove == &chick_move_walk ||
190 self->monsterinfo.currentmove == &chick_move_start_run)
191 {
192 self->monsterinfo.currentmove = &chick_move_run;
193 }
194 else
195 {
196 self->monsterinfo.currentmove = &chick_move_start_run;
197 }
198 }
199
200 mframe_t chick_frames_pain1 [] =
201 {
202 ai_move, 0, NULL,
203 ai_move, 0, NULL,
204 ai_move, 0, NULL,
205 ai_move, 0, NULL,
206 ai_move, 0, NULL
207 };
208 mmove_t chick_move_pain1 = {FRAME_pain101, FRAME_pain105, chick_frames_pain1, chick_run};
209
210 mframe_t chick_frames_pain2 [] =
211 {
212 ai_move, 0, NULL,
213 ai_move, 0, NULL,
214 ai_move, 0, NULL,
215 ai_move, 0, NULL,
216 ai_move, 0, NULL
217 };
218 mmove_t chick_move_pain2 = {FRAME_pain201, FRAME_pain205, chick_frames_pain2, chick_run};
219
220 mframe_t chick_frames_pain3 [] =
221 {
222 ai_move, 0, NULL,
223 ai_move, 0, NULL,
224 ai_move, -6, NULL,
225 ai_move, 3, NULL,
226 ai_move, 11, NULL,
227 ai_move, 3, NULL,
228 ai_move, 0, NULL,
229 ai_move, 0, NULL,
230 ai_move, 4, NULL,
231 ai_move, 1, NULL,
232 ai_move, 0, NULL,
233 ai_move, -3, NULL,
234 ai_move, -4, NULL,
235 ai_move, 5, NULL,
236 ai_move, 7, NULL,
237 ai_move, -2, NULL,
238 ai_move, 3, NULL,
239 ai_move, -5, NULL,
240 ai_move, -2, NULL,
241 ai_move, -8, NULL,
242 ai_move, 2, NULL
243 };
244 mmove_t chick_move_pain3 = {FRAME_pain301, FRAME_pain321, chick_frames_pain3, chick_run};
245
chick_pain(edict_t * self,edict_t * other,float kick,int damage)246 void chick_pain (edict_t *self, edict_t *other, float kick, int damage)
247 {
248 float r;
249
250 if (self->health < (self->max_health / 2))
251 self->s.skinnum = 1;
252
253 if (level.time < self->pain_debounce_time)
254 return;
255
256 self->pain_debounce_time = level.time + 3;
257
258 r = random();
259 if (r < 0.5)
260 gi.sound (self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
261 else
262 gi.sound (self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
263
264 if (skill->value == 3)
265 return; // no pain anims in nightmare
266
267 if (damage <= 10)
268 self->monsterinfo.currentmove = &chick_move_pain1;
269 else if (damage <= 25)
270 self->monsterinfo.currentmove = &chick_move_pain2;
271 else
272 self->monsterinfo.currentmove = &chick_move_pain3;
273 }
274
chick_dead(edict_t * self)275 void chick_dead (edict_t *self)
276 {
277 VectorSet (self->mins, -16, -16, 0);
278 VectorSet (self->maxs, 16, 16, 16);
279 self->movetype = MOVETYPE_TOSS;
280 self->svflags |= SVF_DEADMONSTER;
281 self->nextthink = 0;
282 gi.linkentity (self);
283 }
284
285 mframe_t chick_frames_death2 [] =
286 {
287 ai_move, -6, NULL,
288 ai_move, 0, NULL,
289 ai_move, -1, NULL,
290 ai_move, -5, NULL,
291 ai_move, 0, NULL,
292 ai_move, -1, NULL,
293 ai_move, -2, NULL,
294 ai_move, 1, NULL,
295 ai_move, 10, NULL,
296 ai_move, 2, NULL,
297 ai_move, 3, NULL,
298 ai_move, 1, NULL,
299 ai_move, 2, NULL,
300 ai_move, 0, NULL,
301 ai_move, 3, NULL,
302 ai_move, 3, NULL,
303 ai_move, 1, NULL,
304 ai_move, -3, NULL,
305 ai_move, -5, NULL,
306 ai_move, 4, NULL,
307 ai_move, 15, NULL,
308 ai_move, 14, NULL,
309 ai_move, 1, NULL
310 };
311 mmove_t chick_move_death2 = {FRAME_death201, FRAME_death223, chick_frames_death2, chick_dead};
312
313 mframe_t chick_frames_death1 [] =
314 {
315 ai_move, 0, NULL,
316 ai_move, 0, NULL,
317 ai_move, -7, NULL,
318 ai_move, 4, NULL,
319 ai_move, 11, NULL,
320 ai_move, 0, NULL,
321 ai_move, 0, NULL,
322 ai_move, 0, NULL,
323 ai_move, 0, NULL,
324 ai_move, 0, NULL,
325 ai_move, 0, NULL,
326 ai_move, 0, NULL
327
328 };
329 mmove_t chick_move_death1 = {FRAME_death101, FRAME_death112, chick_frames_death1, chick_dead};
330
chick_die(edict_t * self,edict_t * inflictor,edict_t * attacker,int damage,vec3_t point)331 void chick_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
332 {
333 int n;
334
335 // check for gib
336 if (self->health <= self->gib_health)
337 {
338 gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_NORM, 0);
339 for (n= 0; n < 2; n++)
340 ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
341 for (n= 0; n < 4; n++)
342 ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
343 ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
344 self->deadflag = DEAD_DEAD;
345 return;
346 }
347
348 if (self->deadflag == DEAD_DEAD)
349 return;
350
351 // regular death
352 self->deadflag = DEAD_DEAD;
353 self->takedamage = DAMAGE_YES;
354
355 n = rand() % 2;
356 if (n == 0)
357 {
358 self->monsterinfo.currentmove = &chick_move_death1;
359 gi.sound (self, CHAN_VOICE, sound_death1, 1, ATTN_NORM, 0);
360 }
361 else
362 {
363 self->monsterinfo.currentmove = &chick_move_death2;
364 gi.sound (self, CHAN_VOICE, sound_death2, 1, ATTN_NORM, 0);
365 }
366 }
367
368
chick_duck_down(edict_t * self)369 void chick_duck_down (edict_t *self)
370 {
371 if (self->monsterinfo.aiflags & AI_DUCKED)
372 return;
373 self->monsterinfo.aiflags |= AI_DUCKED;
374 self->maxs[2] -= 32;
375 self->takedamage = DAMAGE_YES;
376 self->monsterinfo.pausetime = level.time + 1;
377 gi.linkentity (self);
378 }
379
chick_duck_hold(edict_t * self)380 void chick_duck_hold (edict_t *self)
381 {
382 if (level.time >= self->monsterinfo.pausetime)
383 self->monsterinfo.aiflags &= ~AI_HOLD_FRAME;
384 else
385 self->monsterinfo.aiflags |= AI_HOLD_FRAME;
386 }
387
chick_duck_up(edict_t * self)388 void chick_duck_up (edict_t *self)
389 {
390 self->monsterinfo.aiflags &= ~AI_DUCKED;
391 self->maxs[2] += 32;
392 self->takedamage = DAMAGE_AIM;
393 gi.linkentity (self);
394 }
395
396 mframe_t chick_frames_duck [] =
397 {
398 ai_move, 0, chick_duck_down,
399 ai_move, 1, NULL,
400 ai_move, 4, chick_duck_hold,
401 ai_move, -4, NULL,
402 ai_move, -5, chick_duck_up,
403 ai_move, 3, NULL,
404 ai_move, 1, NULL
405 };
406 mmove_t chick_move_duck = {FRAME_duck01, FRAME_duck07, chick_frames_duck, chick_run};
407
chick_dodge(edict_t * self,edict_t * attacker,float eta)408 void chick_dodge (edict_t *self, edict_t *attacker, float eta)
409 {
410 if (random() > 0.25)
411 return;
412
413 if (!self->enemy)
414 self->enemy = attacker;
415
416 self->monsterinfo.currentmove = &chick_move_duck;
417 }
418
ChickSlash(edict_t * self)419 void ChickSlash (edict_t *self)
420 {
421 vec3_t aim;
422
423 VectorSet (aim, MELEE_DISTANCE, self->mins[0], 10);
424 gi.sound (self, CHAN_WEAPON, sound_melee_swing, 1, ATTN_NORM, 0);
425 fire_hit (self, aim, (10 + (rand() %6)), 100);
426 }
427
428
ChickRocket(edict_t * self)429 void ChickRocket (edict_t *self)
430 {
431 vec3_t forward, right;
432 vec3_t start;
433 vec3_t dir;
434 vec3_t vec;
435
436 AngleVectors (self->s.angles, forward, right, NULL);
437 G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_CHICK_ROCKET_1], forward, right, start);
438
439 VectorCopy (self->enemy->s.origin, vec);
440 vec[2] += self->enemy->viewheight;
441 VectorSubtract (vec, start, dir);
442 VectorNormalize (dir);
443
444 monster_fire_rocket (self, start, dir, 50, 500, MZ2_CHICK_ROCKET_1);
445 }
446
Chick_PreAttack1(edict_t * self)447 void Chick_PreAttack1 (edict_t *self)
448 {
449 gi.sound (self, CHAN_VOICE, sound_missile_prelaunch, 1, ATTN_NORM, 0);
450 }
451
ChickReload(edict_t * self)452 void ChickReload (edict_t *self)
453 {
454 gi.sound (self, CHAN_VOICE, sound_missile_reload, 1, ATTN_NORM, 0);
455 }
456
457
458 mframe_t chick_frames_start_attack1 [] =
459 {
460 ai_charge, 0, Chick_PreAttack1,
461 ai_charge, 0, NULL,
462 ai_charge, 0, NULL,
463 ai_charge, 4, NULL,
464 ai_charge, 0, NULL,
465 ai_charge, -3, NULL,
466 ai_charge, 3, NULL,
467 ai_charge, 5, NULL,
468 ai_charge, 7, NULL,
469 ai_charge, 0, NULL,
470 ai_charge, 0, NULL,
471 ai_charge, 0, NULL,
472 ai_charge, 0, chick_attack1
473 };
474 mmove_t chick_move_start_attack1 = {FRAME_attak101, FRAME_attak113, chick_frames_start_attack1, NULL};
475
476
477 mframe_t chick_frames_attack1 [] =
478 {
479 ai_charge, 19, ChickRocket,
480 ai_charge, -6, NULL,
481 ai_charge, -5, NULL,
482 ai_charge, -2, NULL,
483 ai_charge, -7, NULL,
484 ai_charge, 0, NULL,
485 ai_charge, 1, NULL,
486 ai_charge, 10, ChickReload,
487 ai_charge, 4, NULL,
488 ai_charge, 5, NULL,
489 ai_charge, 6, NULL,
490 ai_charge, 6, NULL,
491 ai_charge, 4, NULL,
492 ai_charge, 3, chick_rerocket
493
494 };
495 mmove_t chick_move_attack1 = {FRAME_attak114, FRAME_attak127, chick_frames_attack1, NULL};
496
497 mframe_t chick_frames_end_attack1 [] =
498 {
499 ai_charge, -3, NULL,
500 ai_charge, 0, NULL,
501 ai_charge, -6, NULL,
502 ai_charge, -4, NULL,
503 ai_charge, -2, NULL
504 };
505 mmove_t chick_move_end_attack1 = {FRAME_attak128, FRAME_attak132, chick_frames_end_attack1, chick_run};
506
chick_rerocket(edict_t * self)507 void chick_rerocket(edict_t *self)
508 {
509 if (self->enemy->health > 0)
510 {
511 if (range (self, self->enemy) > RANGE_MELEE)
512 if ( visible (self, self->enemy) )
513 if (random() <= 0.6)
514 {
515 self->monsterinfo.currentmove = &chick_move_attack1;
516 return;
517 }
518 }
519 self->monsterinfo.currentmove = &chick_move_end_attack1;
520 }
521
chick_attack1(edict_t * self)522 void chick_attack1(edict_t *self)
523 {
524 self->monsterinfo.currentmove = &chick_move_attack1;
525 }
526
527 mframe_t chick_frames_slash [] =
528 {
529 ai_charge, 1, NULL,
530 ai_charge, 7, ChickSlash,
531 ai_charge, -7, NULL,
532 ai_charge, 1, NULL,
533 ai_charge, -1, NULL,
534 ai_charge, 1, NULL,
535 ai_charge, 0, NULL,
536 ai_charge, 1, NULL,
537 ai_charge, -2, chick_reslash
538 };
539 mmove_t chick_move_slash = {FRAME_attak204, FRAME_attak212, chick_frames_slash, NULL};
540
541 mframe_t chick_frames_end_slash [] =
542 {
543 ai_charge, -6, NULL,
544 ai_charge, -1, NULL,
545 ai_charge, -6, NULL,
546 ai_charge, 0, NULL
547 };
548 mmove_t chick_move_end_slash = {FRAME_attak213, FRAME_attak216, chick_frames_end_slash, chick_run};
549
550
chick_reslash(edict_t * self)551 void chick_reslash(edict_t *self)
552 {
553 if (self->enemy->health > 0)
554 {
555 if (range (self, self->enemy) == RANGE_MELEE)
556 if (random() <= 0.9)
557 {
558 self->monsterinfo.currentmove = &chick_move_slash;
559 return;
560 }
561 else
562 {
563 self->monsterinfo.currentmove = &chick_move_end_slash;
564 return;
565 }
566 }
567 self->monsterinfo.currentmove = &chick_move_end_slash;
568 }
569
chick_slash(edict_t * self)570 void chick_slash(edict_t *self)
571 {
572 self->monsterinfo.currentmove = &chick_move_slash;
573 }
574
575
576 mframe_t chick_frames_start_slash [] =
577 {
578 ai_charge, 1, NULL,
579 ai_charge, 8, NULL,
580 ai_charge, 3, NULL
581 };
582 mmove_t chick_move_start_slash = {FRAME_attak201, FRAME_attak203, chick_frames_start_slash, chick_slash};
583
584
585
chick_melee(edict_t * self)586 void chick_melee(edict_t *self)
587 {
588 self->monsterinfo.currentmove = &chick_move_start_slash;
589 }
590
591
chick_attack(edict_t * self)592 void chick_attack(edict_t *self)
593 {
594 self->monsterinfo.currentmove = &chick_move_start_attack1;
595 }
596
chick_sight(edict_t * self,edict_t * other)597 void chick_sight(edict_t *self, edict_t *other)
598 {
599 gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
600 }
601
602
SP_monster_chick_precache(void)603 void SP_monster_chick_precache(void)
604 {
605 sound_missile_prelaunch = gi.soundindex ("chick/chkatck1.wav");
606 sound_missile_launch = gi.soundindex ("chick/chkatck2.wav");
607 sound_melee_swing = gi.soundindex ("chick/chkatck3.wav");
608 sound_melee_hit = gi.soundindex ("chick/chkatck4.wav");
609 sound_missile_reload = gi.soundindex ("chick/chkatck5.wav");
610 sound_death1 = gi.soundindex ("chick/chkdeth1.wav");
611 sound_death2 = gi.soundindex ("chick/chkdeth2.wav");
612 sound_fall_down = gi.soundindex ("chick/chkfall1.wav");
613 sound_idle1 = gi.soundindex ("chick/chkidle1.wav");
614 sound_idle2 = gi.soundindex ("chick/chkidle2.wav");
615 sound_pain1 = gi.soundindex ("chick/chkpain1.wav");
616 sound_pain2 = gi.soundindex ("chick/chkpain2.wav");
617 sound_sight = gi.soundindex ("chick/chksght1.wav");
618 sound_search = gi.soundindex ("chick/chksrch1.wav");
619 }
620
621 /*QUAKED monster_chick (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
622 */
SP_monster_chick(edict_t * self)623 void SP_monster_chick (edict_t *self)
624 {
625 if (deathmatch->value)
626 {
627 G_FreeEdict (self);
628 return;
629 }
630
631 SP_monster_chick_precache();
632
633 self->movetype = MOVETYPE_STEP;
634 self->solid = SOLID_BBOX;
635 self->s.modelindex = gi.modelindex ("models/monsters/bitch/tris.md2");
636 VectorSet (self->mins, -16, -16, 0);
637 VectorSet (self->maxs, 16, 16, 56);
638
639 self->health = 175;
640 self->gib_health = -70;
641 self->mass = 200;
642
643 self->pain = chick_pain;
644 self->die = chick_die;
645
646 self->monsterinfo.stand = chick_stand;
647 self->monsterinfo.walk = chick_walk;
648 self->monsterinfo.run = chick_run;
649 self->monsterinfo.dodge = chick_dodge;
650 self->monsterinfo.attack = chick_attack;
651 self->monsterinfo.melee = chick_melee;
652 self->monsterinfo.sight = chick_sight;
653
654 gi.linkentity (self);
655
656 self->monsterinfo.currentmove = &chick_move_stand;
657 self->monsterinfo.scale = MODEL_SCALE;
658
659 walkmonster_start (self);
660 }
661