1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 /*
21 ==============================================================================
22 
23 insane
24 
25 ==============================================================================
26 */
27 
28 #include "g_local.h"
29 #include "m_insane.h"
30 
31 
32 static int	sound_fist;
33 static int	sound_shake;
34 static int	sound_moan;
35 static int	sound_scream[8];
36 
insane_fist(edict_t * self)37 void insane_fist (edict_t *self)
38 {
39 	gi.sound (self, CHAN_VOICE, sound_fist, 1, ATTN_IDLE, 0);
40 }
41 
insane_shake(edict_t * self)42 void insane_shake (edict_t *self)
43 {
44 	gi.sound (self, CHAN_VOICE, sound_shake, 1, ATTN_IDLE, 0);
45 }
46 
insane_moan(edict_t * self)47 void insane_moan (edict_t *self)
48 {
49 	gi.sound (self, CHAN_VOICE, sound_moan, 1, ATTN_IDLE, 0);
50 }
51 
insane_scream(edict_t * self)52 void insane_scream (edict_t *self)
53 {
54 	gi.sound (self, CHAN_VOICE, sound_scream[rand()%8], 1, ATTN_IDLE, 0);
55 }
56 
57 
58 void insane_stand (edict_t *self);
59 void insane_dead (edict_t *self);
60 void insane_cross (edict_t *self);
61 void insane_walk (edict_t *self);
62 void insane_run (edict_t *self);
63 void insane_checkdown (edict_t *self);
64 void insane_checkup (edict_t *self);
65 void insane_onground (edict_t *self);
66 
67 
68 mframe_t insane_frames_stand_normal [] =
69 {
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, insane_checkdown}
76 };
77 mmove_t insane_move_stand_normal = {FRAME_stand60, FRAME_stand65, insane_frames_stand_normal, insane_stand};
78 
79 mframe_t insane_frames_stand_insane [] =
80 {
81 	{ai_stand,	0,	insane_shake},
82 	{ai_stand,	0,	NULL},
83 	{ai_stand,	0,	NULL},
84 	{ai_stand,	0,	NULL},
85 	{ai_stand,	0,	NULL},
86 	{ai_stand,	0,	NULL},
87 	{ai_stand,	0,	NULL},
88 	{ai_stand,	0,	NULL},
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,	insane_checkdown}
111 };
112 mmove_t insane_move_stand_insane = {FRAME_stand65, FRAME_stand94, insane_frames_stand_insane, insane_stand};
113 
114 mframe_t insane_frames_uptodown [] =
115 {
116 	{ai_move,	0,	NULL},
117 	{ai_move,	0,	NULL},
118 	{ai_move,	0,	NULL},
119 	{ai_move,	0,	NULL},
120 	{ai_move,	0,	NULL},
121 	{ai_move,	0,	NULL},
122 	{ai_move,	0,	NULL},
123 	{ai_move,	0,	insane_moan},
124 	{ai_move,	0,	NULL},
125 	{ai_move,	0,	NULL},
126 
127 	{ai_move,	0,	NULL},
128 	{ai_move,	0,	NULL},
129 	{ai_move,	0,	NULL},
130 	{ai_move,	0,	NULL},
131 	{ai_move,	0,	NULL},
132 	{ai_move,	0,	NULL},
133 	{ai_move,	0,	NULL},
134 	{ai_move,	0,	NULL},
135 	{ai_move,	0,	NULL},
136 	{ai_move,	0,	NULL},
137 
138 	{ai_move,	2.7,	NULL},
139 	{ai_move,	4.1,	NULL},
140 	{ai_move,	6,		NULL},
141 	{ai_move,	7.6,	NULL},
142 	{ai_move,	3.6,	NULL},
143 	{ai_move,	0,	NULL},
144 	{ai_move,	0,	NULL},
145 	{ai_move,	0,	insane_fist},
146 	{ai_move,	0,	NULL},
147 	{ai_move,	0,	NULL},
148 
149 	{ai_move,	0,	NULL},
150 	{ai_move,	0,	NULL},
151 	{ai_move,	0,	NULL},
152 	{ai_move,	0,	insane_fist},
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 	{ai_move,	0,	NULL}
159 };
160 mmove_t insane_move_uptodown = {FRAME_stand1, FRAME_stand40, insane_frames_uptodown, insane_onground};
161 
162 
163 mframe_t insane_frames_downtoup [] =
164 {
165 	{ai_move,	-0.7,	NULL},			// 41
166 	{ai_move,	-1.2,	NULL},			// 42
167 	{ai_move,	-1.5,		NULL},		// 43
168 	{ai_move,	-4.5,		NULL},		// 44
169 	{ai_move,	-3.5,	NULL},			// 45
170 	{ai_move,	-0.2,	NULL},			// 46
171 	{ai_move,	0,	NULL},			// 47
172 	{ai_move,	-1.3,	NULL},			// 48
173 	{ai_move,	-3,	NULL},				// 49
174 	{ai_move,	-2,	NULL},			// 50
175 	{ai_move,	0,	NULL},				// 51
176 	{ai_move,	0,	NULL},				// 52
177 	{ai_move,	0,	NULL},				// 53
178 	{ai_move,	-3.3,	NULL},			// 54
179 	{ai_move,	-1.6,	NULL},			// 55
180 	{ai_move,	-0.3,	NULL},			// 56
181 	{ai_move,	0,	NULL},				// 57
182 	{ai_move,	0,	NULL},				// 58
183 	{ai_move,	0,	NULL}				// 59
184 };
185 mmove_t insane_move_downtoup = {FRAME_stand41, FRAME_stand59, insane_frames_downtoup, insane_stand};
186 
187 mframe_t insane_frames_jumpdown [] =
188 {
189 	{ai_move,	0.2,	NULL},
190 	{ai_move,	11.5,	NULL},
191 	{ai_move,	5.1,	NULL},
192 	{ai_move,	7.1,	NULL},
193 	{ai_move,	0,	NULL}
194 };
195 mmove_t insane_move_jumpdown = {FRAME_stand96, FRAME_stand100, insane_frames_jumpdown, insane_onground};
196 
197 
198 mframe_t insane_frames_down [] =
199 {
200 	{ai_move,	0,		NULL},		// 100
201 	{ai_move,	0,		NULL},
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 	{ai_move,	0,		NULL},
208 	{ai_move,	0,		NULL},
209 	{ai_move,	0,		NULL},
210 	{ai_move,	0,		NULL},		// 110
211 	{ai_move,	-1.7,		NULL},
212 	{ai_move,	-1.6,		NULL},
213 	{ai_move,	0,		NULL},
214 	{ai_move,	0,		NULL},
215 	{ai_move,	0,		NULL},
216 	{ai_move,	0,		insane_fist},
217 	{ai_move,	0,		NULL},
218 	{ai_move,	0,		NULL},
219 	{ai_move,	0,		NULL},
220 	{ai_move,	0,		NULL},		// 120
221 	{ai_move,	0,		NULL},
222 	{ai_move,	0,		NULL},
223 	{ai_move,	0,		NULL},
224 	{ai_move,	0,		NULL},
225 	{ai_move,	0,		NULL},
226 	{ai_move,	0,		NULL},
227 	{ai_move,	0,		NULL},
228 	{ai_move,	0,		NULL},
229 	{ai_move,	0,		NULL},
230 	{ai_move,	0,		NULL},		// 130
231 	{ai_move,	0,		NULL},
232 	{ai_move,	0,		NULL},
233 	{ai_move,	0,		insane_moan},
234 	{ai_move,	0,		NULL},
235 	{ai_move,	0,		NULL},
236 	{ai_move,	0,		NULL},
237 	{ai_move,	0,		NULL},
238 	{ai_move,	0,		NULL},
239 	{ai_move,	0,		NULL},
240 	{ai_move,	0,		NULL},		// 140
241 	{ai_move,	0,		NULL},
242 	{ai_move,	0,		NULL},
243 	{ai_move,	0,		NULL},
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},		// 150
251 	{ai_move,	0.5,		NULL},
252 	{ai_move,	0,		NULL},
253 	{ai_move,	-0.2,		insane_scream},
254 	{ai_move,	0,		NULL},
255 	{ai_move,	0.2,		NULL},
256 	{ai_move,	0.4,		NULL},
257 	{ai_move,	0.6,		NULL},
258 	{ai_move,	0.8,		NULL},
259 	{ai_move,	0.7,		NULL},
260 	{ai_move,	0,		insane_checkup}		// 160
261 };
262 mmove_t insane_move_down = {FRAME_stand100, FRAME_stand160, insane_frames_down, insane_onground};
263 
264 mframe_t insane_frames_walk_normal [] =
265 {
266 	{ai_walk,	0,		insane_scream},
267 	{ai_walk,	2.5,	NULL},
268 	{ai_walk,	3.5,	NULL},
269 	{ai_walk,	1.7,	NULL},
270 	{ai_walk,	2.3,	NULL},
271 	{ai_walk,	2.4,	NULL},
272 	{ai_walk,	2.2,	NULL},
273 	{ai_walk,	4.2,	NULL},
274 	{ai_walk,	5.6,	NULL},
275 	{ai_walk,	3.3,	NULL},
276 	{ai_walk,	2.4,	NULL},
277 	{ai_walk,	0.9,	NULL},
278 	{ai_walk,	0,		NULL}
279 };
280 mmove_t insane_move_walk_normal = {FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_walk};
281 mmove_t insane_move_run_normal = {FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_run};
282 
283 mframe_t insane_frames_walk_insane [] =
284 {
285 	{ai_walk,	0,		insane_scream},		// walk 1
286 	{ai_walk,	3.4,	NULL},		// walk 2
287 	{ai_walk,	3.6,	NULL},		// 3
288 	{ai_walk,	2.9,	NULL},		// 4
289 	{ai_walk,	2.2,	NULL},		// 5
290 	{ai_walk,	2.6,	NULL},		// 6
291 	{ai_walk,	0,		NULL},		// 7
292 	{ai_walk,	0.7,	NULL},		// 8
293 	{ai_walk,	4.8,	NULL},		// 9
294 	{ai_walk,	5.3,	NULL},		// 10
295 	{ai_walk,	1.1,	NULL},		// 11
296 	{ai_walk,	2,		NULL},		// 12
297 	{ai_walk,	0.5,	NULL},		// 13
298 	{ai_walk,	0,		NULL},		// 14
299 	{ai_walk,	0,		NULL},		// 15
300 	{ai_walk,	4.9,	NULL},		// 16
301 	{ai_walk,	6.7,	NULL},		// 17
302 	{ai_walk,	3.8,	NULL},		// 18
303 	{ai_walk,	2,		NULL},		// 19
304 	{ai_walk,	0.2,	NULL},		// 20
305 	{ai_walk,	0,		NULL},		// 21
306 	{ai_walk,	3.4,	NULL},		// 22
307 	{ai_walk,	6.4,	NULL},		// 23
308 	{ai_walk,	5,		NULL},		// 24
309 	{ai_walk,	1.8,	NULL},		// 25
310 	{ai_walk,	0,		NULL}		// 26
311 };
312 mmove_t insane_move_walk_insane = {FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_walk};
313 mmove_t insane_move_run_insane = {FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_run};
314 
315 mframe_t insane_frames_stand_pain [] =
316 {
317 	{ai_move,	0,		NULL},
318 	{ai_move,	0,		NULL},
319 	{ai_move,	0,		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 	{ai_move,	0,		NULL}
328 };
329 mmove_t insane_move_stand_pain = {FRAME_st_pain2, FRAME_st_pain12, insane_frames_stand_pain, insane_run};
330 
331 mframe_t insane_frames_stand_death [] =
332 {
333 	{ai_move,	0,		NULL},
334 	{ai_move,	0,		NULL},
335 	{ai_move,	0,		NULL},
336 	{ai_move,	0,		NULL},
337 	{ai_move,	0,		NULL},
338 	{ai_move,	0,		NULL},
339 	{ai_move,	0,		NULL},
340 	{ai_move,	0,		NULL},
341 	{ai_move,	0,		NULL},
342 	{ai_move,	0,		NULL},
343 	{ai_move,	0,		NULL},
344 	{ai_move,	0,		NULL},
345 	{ai_move,	0,		NULL},
346 	{ai_move,	0,		NULL},
347 	{ai_move,	0,		NULL},
348 	{ai_move,	0,		NULL},
349 	{ai_move,	0,		NULL}
350 };
351 mmove_t insane_move_stand_death = {FRAME_st_death2, FRAME_st_death18, insane_frames_stand_death, insane_dead};
352 
353 mframe_t insane_frames_crawl [] =
354 {
355 	{ai_walk,	0,		insane_scream},
356 	{ai_walk,	1.5,	NULL},
357 	{ai_walk,	2.1,	NULL},
358 	{ai_walk,	3.6,	NULL},
359 	{ai_walk,	2,		NULL},
360 	{ai_walk,	0.9,	NULL},
361 	{ai_walk,	3,		NULL},
362 	{ai_walk,	3.4,	NULL},
363 	{ai_walk,	2.4,	NULL}
364 };
365 mmove_t insane_move_crawl = {FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, NULL};
366 mmove_t insane_move_runcrawl = {FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, NULL};
367 
368 mframe_t insane_frames_crawl_pain [] =
369 {
370 	{ai_move,	0,		NULL},
371 	{ai_move,	0,		NULL},
372 	{ai_move,	0,		NULL},
373 	{ai_move,	0,		NULL},
374 	{ai_move,	0,		NULL},
375 	{ai_move,	0,		NULL},
376 	{ai_move,	0,		NULL},
377 	{ai_move,	0,		NULL},
378 	{ai_move,	0,		NULL}
379 };
380 mmove_t insane_move_crawl_pain = {FRAME_cr_pain2, FRAME_cr_pain10, insane_frames_crawl_pain, insane_run};
381 
382 mframe_t insane_frames_crawl_death [] =
383 {
384 	{ai_move,	0,		NULL},
385 	{ai_move,	0,		NULL},
386 	{ai_move,	0,		NULL},
387 	{ai_move,	0,		NULL},
388 	{ai_move,	0,		NULL},
389 	{ai_move,	0,		NULL},
390 	{ai_move,	0,		NULL}
391 };
392 mmove_t insane_move_crawl_death = {FRAME_cr_death10, FRAME_cr_death16, insane_frames_crawl_death, insane_dead};
393 
394 mframe_t insane_frames_cross [] =
395 {
396 	{ai_move,	0,		insane_moan},
397 	{ai_move,	0,		NULL},
398 	{ai_move,	0,		NULL},
399 	{ai_move,	0,		NULL},
400 	{ai_move,	0,		NULL},
401 	{ai_move,	0,		NULL},
402 	{ai_move,	0,		NULL},
403 	{ai_move,	0,		NULL},
404 	{ai_move,	0,		NULL},
405 	{ai_move,	0,		NULL},
406 	{ai_move,	0,		NULL},
407 	{ai_move,	0,		NULL},
408 	{ai_move,	0,		NULL},
409 	{ai_move,	0,		NULL},
410 	{ai_move,	0,		NULL}
411 };
412 mmove_t insane_move_cross = {FRAME_cross1, FRAME_cross15, insane_frames_cross, insane_cross};
413 
414 mframe_t insane_frames_struggle_cross [] =
415 {
416 	{ai_move,	0,		insane_scream},
417 	{ai_move,	0,		NULL},
418 	{ai_move,	0,		NULL},
419 	{ai_move,	0,		NULL},
420 	{ai_move,	0,		NULL},
421 	{ai_move,	0,		NULL},
422 	{ai_move,	0,		NULL},
423 	{ai_move,	0,		NULL},
424 	{ai_move,	0,		NULL},
425 	{ai_move,	0,		NULL},
426 	{ai_move,	0,		NULL},
427 	{ai_move,	0,		NULL},
428 	{ai_move,	0,		NULL},
429 	{ai_move,	0,		NULL},
430 	{ai_move,	0,		NULL}
431 };
432 mmove_t insane_move_struggle_cross = {FRAME_cross16, FRAME_cross30, insane_frames_struggle_cross, insane_cross};
433 
insane_cross(edict_t * self)434 void insane_cross (edict_t *self)
435 {
436 	if (random() < 0.8)
437 		self->monsterinfo.currentmove = &insane_move_cross;
438 	else
439 		self->monsterinfo.currentmove = &insane_move_struggle_cross;
440 }
441 
insane_walk(edict_t * self)442 void insane_walk (edict_t *self)
443 {
444 	if ( self->spawnflags & 16 )			// Hold Ground?
445 		if (self->s.frame == FRAME_cr_pain10)
446 		{
447 			self->monsterinfo.currentmove = &insane_move_down;
448 			return;
449 		}
450 	if (self->spawnflags & 4)
451 		self->monsterinfo.currentmove = &insane_move_crawl;
452 	else
453 		if (random() <= 0.5)
454 			self->monsterinfo.currentmove = &insane_move_walk_normal;
455 		else
456 			self->monsterinfo.currentmove = &insane_move_walk_insane;
457 }
458 
insane_run(edict_t * self)459 void insane_run (edict_t *self)
460 {
461 	if ( self->spawnflags & 16 )			// Hold Ground?
462 		if (self->s.frame == FRAME_cr_pain10)
463 		{
464 			self->monsterinfo.currentmove = &insane_move_down;
465 			return;
466 		}
467 	if (self->spawnflags & 4)				// Crawling?
468 		self->monsterinfo.currentmove = &insane_move_runcrawl;
469 	else
470 		if (random() <= 0.5)				// Else, mix it up
471 			self->monsterinfo.currentmove = &insane_move_run_normal;
472 		else
473 			self->monsterinfo.currentmove = &insane_move_run_insane;
474 }
475 
476 
insane_pain(edict_t * self,edict_t * other,float kick,int damage)477 void insane_pain (edict_t *self, edict_t *other, float kick, int damage)
478 {
479 	int	l,r;
480 
481 //	if (self->health < (self->max_health / 2))
482 //		self->s.skinnum = 1;
483 
484 	if (level.time < self->pain_debounce_time)
485 		return;
486 
487 	self->pain_debounce_time = level.time + 3;
488 
489 	r = 1 + (rand()&1);
490 	if (self->health < 25)
491 		l = 25;
492 	else if (self->health < 50)
493 		l = 50;
494 	else if (self->health < 75)
495 		l = 75;
496 	else
497 		l = 100;
498 	gi.sound (self, CHAN_VOICE, gi.soundindex (va("player/male/pain%i_%i.wav", l, r)), 1, ATTN_IDLE, 0);
499 
500 	if (skill->value == 3)
501 		return;		// no pain anims in nightmare
502 
503 	// Don't go into pain frames if crucified.
504 	if (self->spawnflags & 8)
505 	{
506 		self->monsterinfo.currentmove = &insane_move_struggle_cross;
507 		return;
508 	}
509 
510 	if  ( ((self->s.frame >= FRAME_crawl1) && (self->s.frame <= FRAME_crawl9)) || ((self->s.frame >= FRAME_stand99) && (self->s.frame <= FRAME_stand160)) )
511 	{
512 		self->monsterinfo.currentmove = &insane_move_crawl_pain;
513 	}
514 	else
515 		self->monsterinfo.currentmove = &insane_move_stand_pain;
516 
517 }
518 
insane_onground(edict_t * self)519 void insane_onground (edict_t *self)
520 {
521 	self->monsterinfo.currentmove = &insane_move_down;
522 }
523 
insane_checkdown(edict_t * self)524 void insane_checkdown (edict_t *self)
525 {
526 //	if ( (self->s.frame == FRAME_stand94) || (self->s.frame == FRAME_stand65) )
527 	if (self->spawnflags & 32)				// Always stand
528 		return;
529 	if (random() < 0.3)
530 	{
531 		if (random() < 0.5)
532 			self->monsterinfo.currentmove = &insane_move_uptodown;
533 		else
534 			self->monsterinfo.currentmove = &insane_move_jumpdown;
535 	}
536 }
537 
insane_checkup(edict_t * self)538 void insane_checkup (edict_t *self)
539 {
540 	// If Hold_Ground and Crawl are set
541 	if ( (self->spawnflags & 4) && (self->spawnflags & 16) )
542 		return;
543 	if (random() < 0.5)
544 		self->monsterinfo.currentmove = &insane_move_downtoup;
545 
546 }
547 
insane_stand(edict_t * self)548 void insane_stand (edict_t *self)
549 {
550 	if (self->spawnflags & 8)			// If crucified
551 	{
552 		self->monsterinfo.currentmove = &insane_move_cross;
553 		self->monsterinfo.aiflags |= AI_STAND_GROUND;
554 	}
555 	// If Hold_Ground and Crawl are set
556 	else if ( (self->spawnflags & 4) && (self->spawnflags & 16) )
557 		self->monsterinfo.currentmove = &insane_move_down;
558 	else
559 		if (random() < 0.5)
560 			self->monsterinfo.currentmove = &insane_move_stand_normal;
561 		else
562 			self->monsterinfo.currentmove = &insane_move_stand_insane;
563 }
564 
insane_dead(edict_t * self)565 void insane_dead (edict_t *self)
566 {
567 	if (self->spawnflags & 8)
568 	{
569 		self->flags |= FL_FLY;
570 	}
571 	else
572 	{
573 		VectorSet (self->mins, -16, -16, -24);
574 		VectorSet (self->maxs, 16, 16, -8);
575 		self->movetype = MOVETYPE_TOSS;
576 	}
577 	self->svflags |= SVF_DEADMONSTER;
578 	self->nextthink = 0;
579 	gi.linkentity (self);
580 }
581 
582 
insane_die(edict_t * self,edict_t * inflictor,edict_t * attacker,int damage,vec3_t point)583 void insane_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
584 {
585 	int		n;
586 
587 	if (self->health <= self->gib_health)
588 	{
589 		gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_IDLE, 0);
590 		for (n= 0; n < 2; n++)
591 			ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
592 		for (n= 0; n < 4; n++)
593 			ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
594 		ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
595 		self->deadflag = DEAD_DEAD;
596 		return;
597 	}
598 
599 	if (self->deadflag == DEAD_DEAD)
600 		return;
601 
602 	gi.sound (self, CHAN_VOICE, gi.soundindex(va("player/male/death%i.wav", (rand()%4)+1)), 1, ATTN_IDLE, 0);
603 
604 	self->deadflag = DEAD_DEAD;
605 	self->takedamage = DAMAGE_YES;
606 
607 	if (self->spawnflags & 8)
608 	{
609 		insane_dead (self);
610 	}
611 	else
612 	{
613 		if ( ((self->s.frame >= FRAME_crawl1) && (self->s.frame <= FRAME_crawl9)) || ((self->s.frame >= FRAME_stand99) && (self->s.frame <= FRAME_stand160)) )
614 			self->monsterinfo.currentmove = &insane_move_crawl_death;
615 		else
616 			self->monsterinfo.currentmove = &insane_move_stand_death;
617 	}
618 }
619 
620 
621 /*QUAKED misc_insane (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn CRAWL CRUCIFIED STAND_GROUND ALWAYS_STAND
622 */
SP_misc_insane(edict_t * self)623 void SP_misc_insane (edict_t *self)
624 {
625 //	static int skin = 0;	//@@
626 
627 	if (deathmatch->value)
628 	{
629 		G_FreeEdict (self);
630 		return;
631 	}
632 
633 	sound_fist = gi.soundindex ("insane/insane11.wav");
634 	sound_shake = gi.soundindex ("insane/insane5.wav");
635 	sound_moan = gi.soundindex ("insane/insane7.wav");
636 	sound_scream[0] = gi.soundindex ("insane/insane1.wav");
637 	sound_scream[1] = gi.soundindex ("insane/insane2.wav");
638 	sound_scream[2] = gi.soundindex ("insane/insane3.wav");
639 	sound_scream[3] = gi.soundindex ("insane/insane4.wav");
640 	sound_scream[4] = gi.soundindex ("insane/insane6.wav");
641 	sound_scream[5] = gi.soundindex ("insane/insane8.wav");
642 	sound_scream[6] = gi.soundindex ("insane/insane9.wav");
643 	sound_scream[7] = gi.soundindex ("insane/insane10.wav");
644 
645 	self->movetype = MOVETYPE_STEP;
646 	self->solid = SOLID_BBOX;
647 	self->s.modelindex = gi.modelindex("models/monsters/insane/tris.md2");
648 
649 	VectorSet (self->mins, -16, -16, -24);
650 	VectorSet (self->maxs, 16, 16, 32);
651 
652 	self->health = 100;
653 	self->gib_health = -50;
654 	self->mass = 300;
655 
656 	self->pain = insane_pain;
657 	self->die = insane_die;
658 
659 	self->monsterinfo.stand = insane_stand;
660 	self->monsterinfo.walk = insane_walk;
661 	self->monsterinfo.run = insane_run;
662 	self->monsterinfo.dodge = NULL;
663 	self->monsterinfo.attack = NULL;
664 	self->monsterinfo.melee = NULL;
665 	self->monsterinfo.sight = NULL;
666 	self->monsterinfo.aiflags |= AI_GOOD_GUY;
667 
668 //@@
669 //	self->s.skinnum = skin;
670 //	skin++;
671 //	if (skin > 12)
672 //		skin = 0;
673 
674 	gi.linkentity (self);
675 
676 	if (self->spawnflags & 16)				// Stand Ground
677 		self->monsterinfo.aiflags |= AI_STAND_GROUND;
678 
679 	self->monsterinfo.currentmove = &insane_move_stand_normal;
680 
681 	self->monsterinfo.scale = MODEL_SCALE;
682 
683 	if (self->spawnflags & 8)					// Crucified ?
684 	{
685 		VectorSet (self->mins, -16, 0, 0);
686 		VectorSet (self->maxs, 16, 8, 32);
687 		self->flags |= FL_NO_KNOCKBACK;
688 		flymonster_start (self);
689 	}
690 	else
691 	{
692 		walkmonster_start (self);
693 		self->s.skinnum = rand()%3;
694 	}
695 }
696