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