aboutsummaryrefslogtreecommitdiffstats
path: root/src/jake2/game/M_Insane.java
blob: a11e990800b267ddd736709dee77297f9c630970 (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
/*
Copyright (C) 1997-2001 Id Software, Inc.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  

See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

// Created on 13.11.2003 by RST.
// $Id: M_Insane.java,v 1.1 2004-07-07 19:59:16 hzi Exp $

package jake2.game;

import jake2.util.*;
import jake2.util.*;

public class M_Insane extends Game {
	//	This file generated by ModelGen - Do NOT Modify

	public final static int FRAME_stand1 = 0;
	public final static int FRAME_stand2 = 1;
	public final static int FRAME_stand3 = 2;
	public final static int FRAME_stand4 = 3;
	public final static int FRAME_stand5 = 4;
	public final static int FRAME_stand6 = 5;
	public final static int FRAME_stand7 = 6;
	public final static int FRAME_stand8 = 7;
	public final static int FRAME_stand9 = 8;
	public final static int FRAME_stand10 = 9;
	public final static int FRAME_stand11 = 10;
	public final static int FRAME_stand12 = 11;
	public final static int FRAME_stand13 = 12;
	public final static int FRAME_stand14 = 13;
	public final static int FRAME_stand15 = 14;
	public final static int FRAME_stand16 = 15;
	public final static int FRAME_stand17 = 16;
	public final static int FRAME_stand18 = 17;
	public final static int FRAME_stand19 = 18;
	public final static int FRAME_stand20 = 19;
	public final static int FRAME_stand21 = 20;
	public final static int FRAME_stand22 = 21;
	public final static int FRAME_stand23 = 22;
	public final static int FRAME_stand24 = 23;
	public final static int FRAME_stand25 = 24;
	public final static int FRAME_stand26 = 25;
	public final static int FRAME_stand27 = 26;
	public final static int FRAME_stand28 = 27;
	public final static int FRAME_stand29 = 28;
	public final static int FRAME_stand30 = 29;
	public final static int FRAME_stand31 = 30;
	public final static int FRAME_stand32 = 31;
	public final static int FRAME_stand33 = 32;
	public final static int FRAME_stand34 = 33;
	public final static int FRAME_stand35 = 34;
	public final static int FRAME_stand36 = 35;
	public final static int FRAME_stand37 = 36;
	public final static int FRAME_stand38 = 37;
	public final static int FRAME_stand39 = 38;
	public final static int FRAME_stand40 = 39;
	public final static int FRAME_stand41 = 40;
	public final static int FRAME_stand42 = 41;
	public final static int FRAME_stand43 = 42;
	public final static int FRAME_stand44 = 43;
	public final static int FRAME_stand45 = 44;
	public final static int FRAME_stand46 = 45;
	public final static int FRAME_stand47 = 46;
	public final static int FRAME_stand48 = 47;
	public final static int FRAME_stand49 = 48;
	public final static int FRAME_stand50 = 49;
	public final static int FRAME_stand51 = 50;
	public final static int FRAME_stand52 = 51;
	public final static int FRAME_stand53 = 52;
	public final static int FRAME_stand54 = 53;
	public final static int FRAME_stand55 = 54;
	public final static int FRAME_stand56 = 55;
	public final static int FRAME_stand57 = 56;
	public final static int FRAME_stand58 = 57;
	public final static int FRAME_stand59 = 58;
	public final static int FRAME_stand60 = 59;
	public final static int FRAME_stand61 = 60;
	public final static int FRAME_stand62 = 61;
	public final static int FRAME_stand63 = 62;
	public final static int FRAME_stand64 = 63;
	public final static int FRAME_stand65 = 64;
	public final static int FRAME_stand66 = 65;
	public final static int FRAME_stand67 = 66;
	public final static int FRAME_stand68 = 67;
	public final static int FRAME_stand69 = 68;
	public final static int FRAME_stand70 = 69;
	public final static int FRAME_stand71 = 70;
	public final static int FRAME_stand72 = 71;
	public final static int FRAME_stand73 = 72;
	public final static int FRAME_stand74 = 73;
	public final static int FRAME_stand75 = 74;
	public final static int FRAME_stand76 = 75;
	public final static int FRAME_stand77 = 76;
	public final static int FRAME_stand78 = 77;
	public final static int FRAME_stand79 = 78;
	public final static int FRAME_stand80 = 79;
	public final static int FRAME_stand81 = 80;
	public final static int FRAME_stand82 = 81;
	public final static int FRAME_stand83 = 82;
	public final static int FRAME_stand84 = 83;
	public final static int FRAME_stand85 = 84;
	public final static int FRAME_stand86 = 85;
	public final static int FRAME_stand87 = 86;
	public final static int FRAME_stand88 = 87;
	public final static int FRAME_stand89 = 88;
	public final static int FRAME_stand90 = 89;
	public final static int FRAME_stand91 = 90;
	public final static int FRAME_stand92 = 91;
	public final static int FRAME_stand93 = 92;
	public final static int FRAME_stand94 = 93;
	public final static int FRAME_stand95 = 94;
	public final static int FRAME_stand96 = 95;
	public final static int FRAME_stand97 = 96;
	public final static int FRAME_stand98 = 97;
	public final static int FRAME_stand99 = 98;
	public final static int FRAME_stand100 = 99;
	public final static int FRAME_stand101 = 100;
	public final static int FRAME_stand102 = 101;
	public final static int FRAME_stand103 = 102;
	public final static int FRAME_stand104 = 103;
	public final static int FRAME_stand105 = 104;
	public final static int FRAME_stand106 = 105;
	public final static int FRAME_stand107 = 106;
	public final static int FRAME_stand108 = 107;
	public final static int FRAME_stand109 = 108;
	public final static int FRAME_stand110 = 109;
	public final static int FRAME_stand111 = 110;
	public final static int FRAME_stand112 = 111;
	public final static int FRAME_stand113 = 112;
	public final static int FRAME_stand114 = 113;
	public final static int FRAME_stand115 = 114;
	public final static int FRAME_stand116 = 115;
	public final static int FRAME_stand117 = 116;
	public final static int FRAME_stand118 = 117;
	public final static int FRAME_stand119 = 118;
	public final static int FRAME_stand120 = 119;
	public final static int FRAME_stand121 = 120;
	public final static int FRAME_stand122 = 121;
	public final static int FRAME_stand123 = 122;
	public final static int FRAME_stand124 = 123;
	public final static int FRAME_stand125 = 124;
	public final static int FRAME_stand126 = 125;
	public final static int FRAME_stand127 = 126;
	public final static int FRAME_stand128 = 127;
	public final static int FRAME_stand129 = 128;
	public final static int FRAME_stand130 = 129;
	public final static int FRAME_stand131 = 130;
	public final static int FRAME_stand132 = 131;
	public final static int FRAME_stand133 = 132;
	public final static int FRAME_stand134 = 133;
	public final static int FRAME_stand135 = 134;
	public final static int FRAME_stand136 = 135;
	public final static int FRAME_stand137 = 136;
	public final static int FRAME_stand138 = 137;
	public final static int FRAME_stand139 = 138;
	public final static int FRAME_stand140 = 139;
	public final static int FRAME_stand141 = 140;
	public final static int FRAME_stand142 = 141;
	public final static int FRAME_stand143 = 142;
	public final static int FRAME_stand144 = 143;
	public final static int FRAME_stand145 = 144;
	public final static int FRAME_stand146 = 145;
	public final static int FRAME_stand147 = 146;
	public final static int FRAME_stand148 = 147;
	public final static int FRAME_stand149 = 148;
	public final static int FRAME_stand150 = 149;
	public final static int FRAME_stand151 = 150;
	public final static int FRAME_stand152 = 151;
	public final static int FRAME_stand153 = 152;
	public final static int FRAME_stand154 = 153;
	public final static int FRAME_stand155 = 154;
	public final static int FRAME_stand156 = 155;
	public final static int FRAME_stand157 = 156;
	public final static int FRAME_stand158 = 157;
	public final static int FRAME_stand159 = 158;
	public final static int FRAME_stand160 = 159;
	public final static int FRAME_walk27 = 160;
	public final static int FRAME_walk28 = 161;
	public final static int FRAME_walk29 = 162;
	public final static int FRAME_walk30 = 163;
	public final static int FRAME_walk31 = 164;
	public final static int FRAME_walk32 = 165;
	public final static int FRAME_walk33 = 166;
	public final static int FRAME_walk34 = 167;
	public final static int FRAME_walk35 = 168;
	public final static int FRAME_walk36 = 169;
	public final static int FRAME_walk37 = 170;
	public final static int FRAME_walk38 = 171;
	public final static int FRAME_walk39 = 172;
	public final static int FRAME_walk1 = 173;
	public final static int FRAME_walk2 = 174;
	public final static int FRAME_walk3 = 175;
	public final static int FRAME_walk4 = 176;
	public final static int FRAME_walk5 = 177;
	public final static int FRAME_walk6 = 178;
	public final static int FRAME_walk7 = 179;
	public final static int FRAME_walk8 = 180;
	public final static int FRAME_walk9 = 181;
	public final static int FRAME_walk10 = 182;
	public final static int FRAME_walk11 = 183;
	public final static int FRAME_walk12 = 184;
	public final static int FRAME_walk13 = 185;
	public final static int FRAME_walk14 = 186;
	public final static int FRAME_walk15 = 187;
	public final static int FRAME_walk16 = 188;
	public final static int FRAME_walk17 = 189;
	public final static int FRAME_walk18 = 190;
	public final static int FRAME_walk19 = 191;
	public final static int FRAME_walk20 = 192;
	public final static int FRAME_walk21 = 193;
	public final static int FRAME_walk22 = 194;
	public final static int FRAME_walk23 = 195;
	public final static int FRAME_walk24 = 196;
	public final static int FRAME_walk25 = 197;
	public final static int FRAME_walk26 = 198;
	public final static int FRAME_st_pain2 = 199;
	public final static int FRAME_st_pain3 = 200;
	public final static int FRAME_st_pain4 = 201;
	public final static int FRAME_st_pain5 = 202;
	public final static int FRAME_st_pain6 = 203;
	public final static int FRAME_st_pain7 = 204;
	public final static int FRAME_st_pain8 = 205;
	public final static int FRAME_st_pain9 = 206;
	public final static int FRAME_st_pain10 = 207;
	public final static int FRAME_st_pain11 = 208;
	public final static int FRAME_st_pain12 = 209;
	public final static int FRAME_st_death2 = 210;
	public final static int FRAME_st_death3 = 211;
	public final static int FRAME_st_death4 = 212;
	public final static int FRAME_st_death5 = 213;
	public final static int FRAME_st_death6 = 214;
	public final static int FRAME_st_death7 = 215;
	public final static int FRAME_st_death8 = 216;
	public final static int FRAME_st_death9 = 217;
	public final static int FRAME_st_death10 = 218;
	public final static int FRAME_st_death11 = 219;
	public final static int FRAME_st_death12 = 220;
	public final static int FRAME_st_death13 = 221;
	public final static int FRAME_st_death14 = 222;
	public final static int FRAME_st_death15 = 223;
	public final static int FRAME_st_death16 = 224;
	public final static int FRAME_st_death17 = 225;
	public final static int FRAME_st_death18 = 226;
	public final static int FRAME_crawl1 = 227;
	public final static int FRAME_crawl2 = 228;
	public final static int FRAME_crawl3 = 229;
	public final static int FRAME_crawl4 = 230;
	public final static int FRAME_crawl5 = 231;
	public final static int FRAME_crawl6 = 232;
	public final static int FRAME_crawl7 = 233;
	public final static int FRAME_crawl8 = 234;
	public final static int FRAME_crawl9 = 235;
	public final static int FRAME_cr_pain2 = 236;
	public final static int FRAME_cr_pain3 = 237;
	public final static int FRAME_cr_pain4 = 238;
	public final static int FRAME_cr_pain5 = 239;
	public final static int FRAME_cr_pain6 = 240;
	public final static int FRAME_cr_pain7 = 241;
	public final static int FRAME_cr_pain8 = 242;
	public final static int FRAME_cr_pain9 = 243;
	public final static int FRAME_cr_pain10 = 244;
	public final static int FRAME_cr_death10 = 245;
	public final static int FRAME_cr_death11 = 246;
	public final static int FRAME_cr_death12 = 247;
	public final static int FRAME_cr_death13 = 248;
	public final static int FRAME_cr_death14 = 249;
	public final static int FRAME_cr_death15 = 250;
	public final static int FRAME_cr_death16 = 251;
	public final static int FRAME_cross1 = 252;
	public final static int FRAME_cross2 = 253;
	public final static int FRAME_cross3 = 254;
	public final static int FRAME_cross4 = 255;
	public final static int FRAME_cross5 = 256;
	public final static int FRAME_cross6 = 257;
	public final static int FRAME_cross7 = 258;
	public final static int FRAME_cross8 = 259;
	public final static int FRAME_cross9 = 260;
	public final static int FRAME_cross10 = 261;
	public final static int FRAME_cross11 = 262;
	public final static int FRAME_cross12 = 263;
	public final static int FRAME_cross13 = 264;
	public final static int FRAME_cross14 = 265;
	public final static int FRAME_cross15 = 266;
	public final static int FRAME_cross16 = 267;
	public final static int FRAME_cross17 = 268;
	public final static int FRAME_cross18 = 269;
	public final static int FRAME_cross19 = 270;
	public final static int FRAME_cross20 = 271;
	public final static int FRAME_cross21 = 272;
	public final static int FRAME_cross22 = 273;
	public final static int FRAME_cross23 = 274;
	public final static int FRAME_cross24 = 275;
	public final static int FRAME_cross25 = 276;
	public final static int FRAME_cross26 = 277;
	public final static int FRAME_cross27 = 278;
	public final static int FRAME_cross28 = 279;
	public final static int FRAME_cross29 = 280;
	public final static int FRAME_cross30 = 281;

	public final static float MODEL_SCALE = 1.000000f;

	static int sound_fist;
	static int sound_shake;
	static int sound_moan;
	static int sound_scream[] = { 0, 0, 0, 0, 0, 0, 0, 0 };

	static EntThinkAdapter insane_fist = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			gi.sound(self, CHAN_VOICE, sound_fist, 1, ATTN_IDLE, 0);
			return true;
		}
	};

	static EntThinkAdapter insane_shake = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			gi.sound(self, CHAN_VOICE, sound_shake, 1, ATTN_IDLE, 0);
			return true;
		}
	};

	static EntThinkAdapter insane_moan = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			gi.sound(self, CHAN_VOICE, sound_moan, 1, ATTN_IDLE, 0);
			return true;
		}
	};

	static EntThinkAdapter insane_scream = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			gi.sound(self, CHAN_VOICE, sound_scream[Lib.rand() % 8], 1, ATTN_IDLE, 0);
			return true;
		}
	};

	static EntThinkAdapter insane_cross = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if (Lib.random() < 0.8)
				self.monsterinfo.currentmove = insane_move_cross;
			else
				self.monsterinfo.currentmove = insane_move_struggle_cross;
			return true;
		}
	};

	static EntThinkAdapter insane_walk = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if ((self.spawnflags & 16) != 0) // Hold Ground?
				if (self.s.frame == FRAME_cr_pain10) {
					self.monsterinfo.currentmove = insane_move_down;
					return true;
				}
			if ((self.spawnflags & 4) != 0)
				self.monsterinfo.currentmove = insane_move_crawl;
			else if (Lib.random() <= 0.5)
				self.monsterinfo.currentmove = insane_move_walk_normal;
			else
				self.monsterinfo.currentmove = insane_move_walk_insane;
			return true;
		}
	};

	static EntThinkAdapter insane_run = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if ((self.spawnflags & 16) != 0) // Hold Ground?
				if (self.s.frame == FRAME_cr_pain10) {
					self.monsterinfo.currentmove = insane_move_down;
					return true;
				}
			if ((self.spawnflags & 4) != 0) // Crawling?
				self.monsterinfo.currentmove = insane_move_runcrawl;
			else if (Lib.random() <= 0.5) // Else, mix it up
				self.monsterinfo.currentmove = insane_move_run_normal;
			else
				self.monsterinfo.currentmove = insane_move_run_insane;
			return true;
		}
	};

	static EntPainAdapter insane_pain = new EntPainAdapter() {
		public void pain(edict_t self, edict_t other, float kick, int damage) {
			int l, r;

			//	 if (self.health < (self.max_health / 2))
			//		 self.s.skinnum = 1;

			if (level.time < self.pain_debounce_time)
				return;

			self.pain_debounce_time = level.time + 3;

			r = 1 + (Lib.rand() & 1);
			if (self.health < 25)
				l = 25;
			else if (self.health < 50)
				l = 50;
			else if (self.health < 75)
				l = 75;
			else
				l = 100;
			gi.sound(self, CHAN_VOICE, gi.soundindex("player/male/pain" + l + "_" + r + ".wav"), 1, ATTN_IDLE, 0);

			if (skill.value == 3)
				return; // no pain anims in nightmare

			// Don't go into pain frames if crucified.
			if ((self.spawnflags & 8) != 0) {
				self.monsterinfo.currentmove = insane_move_struggle_cross;
				return;
			}

			if (((self.s.frame >= FRAME_crawl1) && (self.s.frame <= FRAME_crawl9))
				|| ((self.s.frame >= FRAME_stand99) && (self.s.frame <= FRAME_stand160))) {
				self.monsterinfo.currentmove = insane_move_crawl_pain;
			} else
				self.monsterinfo.currentmove = insane_move_stand_pain;
		}
	};

	static EntThinkAdapter insane_onground = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			self.monsterinfo.currentmove = insane_move_down;
			return true;
		}
	};

	static EntThinkAdapter insane_checkdown = new EntThinkAdapter() {
		public boolean think(edict_t self) {
				//			if ( (self.s.frame == FRAME_stand94) || (self.s.frame == FRAME_stand65) )
	if ((self.spawnflags & 32) != 0) // Always stand
				return true;
			if (Lib.random() < 0.3)
				if (Lib.random() < 0.5)
					self.monsterinfo.currentmove = insane_move_uptodown;
				else
					self.monsterinfo.currentmove = insane_move_jumpdown;
			return true;
		}
	};

	static EntThinkAdapter insane_checkup = new EntThinkAdapter() {
		public boolean think(edict_t self) {
				//			If Hold_Ground and Crawl are set
	if ((self.spawnflags & 4) != 0 && (self.spawnflags & 16) != 0)
				return true;
			if (Lib.random() < 0.5)
				self.monsterinfo.currentmove = insane_move_downtoup;
			return true;
		}
	};

	static EntThinkAdapter insane_stand = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if ((self.spawnflags & 8) != 0) // If crucified
				{
				self.monsterinfo.currentmove = insane_move_cross;
				self.monsterinfo.aiflags |= AI_STAND_GROUND;
			}
			// If Hold_Ground and Crawl are set
			else if ((self.spawnflags & 4) != 0 && (self.spawnflags & 16) != 0)
				self.monsterinfo.currentmove = insane_move_down;
			else if (Lib.random() < 0.5)
				self.monsterinfo.currentmove = insane_move_stand_normal;
			else
				self.monsterinfo.currentmove = insane_move_stand_insane;
			return true;
		}
	};

	static EntThinkAdapter insane_dead = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if ((self.spawnflags & 8) != 0) {
				self.flags |= FL_FLY;
			} else {
				Math3D.VectorSet(self.mins, -16, -16, -24);
				Math3D.VectorSet(self.maxs, 16, 16, -8);
				self.movetype = MOVETYPE_TOSS;
			}
			self.svflags |= SVF_DEADMONSTER;
			self.nextthink = 0;
			gi.linkentity(self);
			return true;
		}
	};

	static EntDieAdapter insane_die = new EntDieAdapter() {
		public void die(edict_t self, edict_t inflictor, edict_t attacker, int damage, float[] point) {
			int n;

			if (self.health <= self.gib_health) {
				gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_IDLE, 0);
				for (n = 0; n < 2; n++)
					ThrowGib(self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC);
				for (n = 0; n < 4; n++)
					ThrowGib(self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC);
				ThrowHead(self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC);
				self.deadflag = DEAD_DEAD;
				return;
			}

			if (self.deadflag == DEAD_DEAD)
				return;

			gi.sound(self, CHAN_VOICE, gi.soundindex("player/male/death" + ((Lib.rand() % 4) + 1) + ".wav"), 1, ATTN_IDLE, 0);

			self.deadflag = DEAD_DEAD;
			self.takedamage = DAMAGE_YES;

			if ((self.spawnflags & 8) != 0) {
				insane_dead.think(self);
			} else {
				if (((self.s.frame >= FRAME_crawl1) && (self.s.frame <= FRAME_crawl9))
					|| ((self.s.frame >= FRAME_stand99) && (self.s.frame <= FRAME_stand160)))
					self.monsterinfo.currentmove = insane_move_crawl_death;
				else
					self.monsterinfo.currentmove = insane_move_stand_death;
			}
		}

	};

	static mframe_t insane_frames_stand_normal[] =
		new mframe_t[] {
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, insane_checkdown)};

	static mmove_t insane_move_stand_normal = new mmove_t(FRAME_stand60, FRAME_stand65, insane_frames_stand_normal, insane_stand);

	static mframe_t insane_frames_stand_insane[] =
		new mframe_t[] {
			new mframe_t(ai_stand, 0, insane_shake),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, null),
			new mframe_t(ai_stand, 0, insane_checkdown)};
	static mmove_t insane_move_stand_insane = new mmove_t(FRAME_stand65, FRAME_stand94, insane_frames_stand_insane, insane_stand);

	static mframe_t insane_frames_uptodown[] =
		new mframe_t[] {
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, insane_moan),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 2.7f, null),
			new mframe_t(ai_move, 4.1f, null),
			new mframe_t(ai_move, 6f, null),
			new mframe_t(ai_move, 7.6f, null),
			new mframe_t(ai_move, 3.6f, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, insane_fist),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, insane_fist),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null)};
	static mmove_t insane_move_uptodown = new mmove_t(FRAME_stand1, FRAME_stand40, insane_frames_uptodown, insane_onground);

	static mframe_t insane_frames_downtoup[] = new mframe_t[] { new mframe_t(ai_move, -0.7f, null), // 41
		new mframe_t(ai_move, -1.2f, null), // 42
		new mframe_t(ai_move, -1.5f, null), // 43
		new mframe_t(ai_move, -4.5f, null), // 44
		new mframe_t(ai_move, -3.5f, null), // 45
		new mframe_t(ai_move, -0.2f, null), // 46
		new mframe_t(ai_move, 0, null), // 47
		new mframe_t(ai_move, -1.3f, null), // 48
		new mframe_t(ai_move, -3, null), // 49
		new mframe_t(ai_move, -2, null), // 50
		new mframe_t(ai_move, 0, null), // 51
		new mframe_t(ai_move, 0, null), // 52
		new mframe_t(ai_move, 0, null), // 53
		new mframe_t(ai_move, -3.3f, null), // 54
		new mframe_t(ai_move, -1.6f, null), // 55
		new mframe_t(ai_move, -0.3f, null), // 56
		new mframe_t(ai_move, 0, null), // 57
		new mframe_t(ai_move, 0, null), // 58
		new mframe_t(ai_move, 0, null) // 59
	};
	static mmove_t insane_move_downtoup = new mmove_t(FRAME_stand41, FRAME_stand59, insane_frames_downtoup, insane_stand);

	static mframe_t insane_frames_jumpdown[] =
		new mframe_t[] {
			new mframe_t(ai_move, 0.2f, null),
			new mframe_t(ai_move, 11.5f, null),
			new mframe_t(ai_move, 5.1f, null),
			new mframe_t(ai_move, 7.1f, null),
			new mframe_t(ai_move, 0, null)};
	static mmove_t insane_move_jumpdown = new mmove_t(FRAME_stand96, FRAME_stand100, insane_frames_jumpdown, insane_onground);

	static mframe_t insane_frames_down[] = new mframe_t[] { new mframe_t(ai_move, 0, null), // 100)
		new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
		// 110)
		new mframe_t(ai_move, -1.7f, null),
			new mframe_t(ai_move, -1.6f, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, insane_fist),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
		// 120)
		new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
		// 130
		new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, insane_moan),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
		// 140
		new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
		// 150
		new mframe_t(ai_move, 0.5f, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, -0.2f, insane_scream),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0.2f, null),
			new mframe_t(ai_move, 0.4f, null),
			new mframe_t(ai_move, 0.6f, null),
			new mframe_t(ai_move, 0.8f, null),
			new mframe_t(ai_move, 0.7f, null),
			new mframe_t(ai_move, 0, insane_checkup) // 160
	};
	static mmove_t insane_move_down = new mmove_t(FRAME_stand100, FRAME_stand160, insane_frames_down, insane_onground);

	static mframe_t insane_frames_walk_normal[] =
		new mframe_t[] {
			new mframe_t(ai_walk, 0, insane_scream),
			new mframe_t(ai_walk, 2.5f, null),
			new mframe_t(ai_walk, 3.5f, null),
			new mframe_t(ai_walk, 1.7f, null),
			new mframe_t(ai_walk, 2.3f, null),
			new mframe_t(ai_walk, 2.4f, null),
			new mframe_t(ai_walk, 2.2f, null),
			new mframe_t(ai_walk, 4.2f, null),
			new mframe_t(ai_walk, 5.6f, null),
			new mframe_t(ai_walk, 3.3f, null),
			new mframe_t(ai_walk, 2.4f, null),
			new mframe_t(ai_walk, 0.9f, null),
			new mframe_t(ai_walk, 0, null)};
	static mmove_t insane_move_walk_normal = new mmove_t(FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_walk);

	static mmove_t insane_move_run_normal = new mmove_t(FRAME_walk27, FRAME_walk39, insane_frames_walk_normal, insane_run);

	static mframe_t insane_frames_walk_insane[] = new mframe_t[] { new mframe_t(ai_walk, 0, insane_scream), // walk 1
		new mframe_t(ai_walk, 3.4f, null), // walk 2
		new mframe_t(ai_walk, 3.6f, null), // 3
		new mframe_t(ai_walk, 2.9f, null), // 4
		new mframe_t(ai_walk, 2.2f, null), // 5
		new mframe_t(ai_walk, 2.6f, null), // 6
		new mframe_t(ai_walk, 0, null), // 7
		new mframe_t(ai_walk, 0.7f, null), // 8
		new mframe_t(ai_walk, 4.8f, null), // 9
		new mframe_t(ai_walk, 5.3f, null), // 10
		new mframe_t(ai_walk, 1.1f, null), // 11
		new mframe_t(ai_walk, 2, null), // 12
		new mframe_t(ai_walk, 0.5f, null), // 13
		new mframe_t(ai_walk, 0, null), // 14
		new mframe_t(ai_walk, 0, null), // 15
		new mframe_t(ai_walk, 4.9f, null), // 16
		new mframe_t(ai_walk, 6.7f, null), // 17
		new mframe_t(ai_walk, 3.8f, null), // 18
		new mframe_t(ai_walk, 2, null), // 19
		new mframe_t(ai_walk, 0.2f, null), // 20
		new mframe_t(ai_walk, 0, null), // 21
		new mframe_t(ai_walk, 3.4f, null), // 22
		new mframe_t(ai_walk, 6.4f, null), // 23
		new mframe_t(ai_walk, 5, null), // 24
		new mframe_t(ai_walk, 1.8f, null), // 25
		new mframe_t(ai_walk, 0, null) // 26
	};
	static mmove_t insane_move_walk_insane = new mmove_t(FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_walk);

	static mmove_t insane_move_run_insane = new mmove_t(FRAME_walk1, FRAME_walk26, insane_frames_walk_insane, insane_run);

	static mframe_t insane_frames_stand_pain[] =
		new mframe_t[] {
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null)};
	static mmove_t insane_move_stand_pain = new mmove_t(FRAME_st_pain2, FRAME_st_pain12, insane_frames_stand_pain, insane_run);

	static mframe_t insane_frames_stand_death[] =
		new mframe_t[] {
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null)};
	static mmove_t insane_move_stand_death = new mmove_t(FRAME_st_death2, FRAME_st_death18, insane_frames_stand_death, insane_dead);

	static mframe_t insane_frames_crawl[] =
		new mframe_t[] {
			new mframe_t(ai_walk, 0, insane_scream),
			new mframe_t(ai_walk, 1.5f, null),
			new mframe_t(ai_walk, 2.1f, null),
			new mframe_t(ai_walk, 3.6f, null),
			new mframe_t(ai_walk, 2f, null),
			new mframe_t(ai_walk, 0.9f, null),
			new mframe_t(ai_walk, 3f, null),
			new mframe_t(ai_walk, 3.4f, null),
			new mframe_t(ai_walk, 2.4f, null)};
	static mmove_t insane_move_crawl = new mmove_t(FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, null);

	static mmove_t insane_move_runcrawl = new mmove_t(FRAME_crawl1, FRAME_crawl9, insane_frames_crawl, null);

	static mframe_t insane_frames_crawl_pain[] =
		new mframe_t[] {
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null)};
	static mmove_t insane_move_crawl_pain = new mmove_t(FRAME_cr_pain2, FRAME_cr_pain10, insane_frames_crawl_pain, insane_run);

	static mframe_t insane_frames_crawl_death[] =
		new mframe_t[] {
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null)};
	static mmove_t insane_move_crawl_death = new mmove_t(FRAME_cr_death10, FRAME_cr_death16, insane_frames_crawl_death, insane_dead);

	static mframe_t insane_frames_cross[] =
		new mframe_t[] {
			new mframe_t(ai_move, 0, insane_moan),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null)};
	static mmove_t insane_move_cross = new mmove_t(FRAME_cross1, FRAME_cross15, insane_frames_cross, insane_cross);

	static mframe_t insane_frames_struggle_cross[] =
		new mframe_t[] {
			new mframe_t(ai_move, 0, insane_scream),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null),
			new mframe_t(ai_move, 0, null)};
	static mmove_t insane_move_struggle_cross = new mmove_t(FRAME_cross16, FRAME_cross30, insane_frames_struggle_cross, insane_cross);

	/*QUAKED misc_insane (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn CRAWL CRUCIFIED STAND_GROUND ALWAYS_STAND
	*/
	static void SP_misc_insane(edict_t self) {
		//	 static int skin = 0;	//@@

		if (deathmatch.value != 0) {
			G_FreeEdict(self);
			return;
		}

		sound_fist = gi.soundindex("insane/insane11.wav");
		sound_shake = gi.soundindex("insane/insane5.wav");
		sound_moan = gi.soundindex("insane/insane7.wav");
		sound_scream[0] = gi.soundindex("insane/insane1.wav");
		sound_scream[1] = gi.soundindex("insane/insane2.wav");
		sound_scream[2] = gi.soundindex("insane/insane3.wav");
		sound_scream[3] = gi.soundindex("insane/insane4.wav");
		sound_scream[4] = gi.soundindex("insane/insane6.wav");
		sound_scream[5] = gi.soundindex("insane/insane8.wav");
		sound_scream[6] = gi.soundindex("insane/insane9.wav");
		sound_scream[7] = gi.soundindex("insane/insane10.wav");

		self.movetype = MOVETYPE_STEP;
		self.solid = SOLID_BBOX;
		self.s.modelindex = gi.modelindex("models/monsters/insane/tris.md2");

		Math3D.VectorSet(self.mins, -16, -16, -24);
		Math3D.VectorSet(self.maxs, 16, 16, 32);

		self.health = 100;
		self.gib_health = -50;
		self.mass = 300;

		self.pain = insane_pain;
		self.die = insane_die;

		self.monsterinfo.stand = insane_stand;
		self.monsterinfo.walk = insane_walk;
		self.monsterinfo.run = insane_run;
		self.monsterinfo.dodge = null;
		self.monsterinfo.attack = null;
		self.monsterinfo.melee = null;
		self.monsterinfo.sight = null;
		self.monsterinfo.aiflags |= AI_GOOD_GUY;

		// @@
		//	 self.s.skinnum = skin;
		//	 skin++;
		//	 if (skin > 12)
		//		 skin = 0;

		gi.linkentity(self);

		if ((self.spawnflags & 16) != 0) // Stand Ground
			self.monsterinfo.aiflags |= AI_STAND_GROUND;

		self.monsterinfo.currentmove = insane_move_stand_normal;

		self.monsterinfo.scale = MODEL_SCALE;
		if ((self.spawnflags & 8) != 0) // Crucified ?
			{
			Math3D.VectorSet(self.mins, -16, 0, 0);
			Math3D.VectorSet(self.maxs, 16, 8, 32);
			self.flags |= FL_NO_KNOCKBACK;
			flymonster_start.think(self);
		} else {
			walkmonster_start.think(self);
			self.s.skinnum = Lib.rand() % 3;
		}
	}

}