summaryrefslogtreecommitdiffstats
path: root/src/jake2/game/M_Medic.java
blob: 322cc4d0429bdb4c97193f1d07ed345ba8092a2f (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
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
/*
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_Medic.java,v 1.1 2004-07-07 19:59:17 hzi Exp $

package jake2.game;

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

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

	public final static int FRAME_walk1 = 0;
	public final static int FRAME_walk2 = 1;
	public final static int FRAME_walk3 = 2;
	public final static int FRAME_walk4 = 3;
	public final static int FRAME_walk5 = 4;
	public final static int FRAME_walk6 = 5;
	public final static int FRAME_walk7 = 6;
	public final static int FRAME_walk8 = 7;
	public final static int FRAME_walk9 = 8;
	public final static int FRAME_walk10 = 9;
	public final static int FRAME_walk11 = 10;
	public final static int FRAME_walk12 = 11;
	public final static int FRAME_wait1 = 12;
	public final static int FRAME_wait2 = 13;
	public final static int FRAME_wait3 = 14;
	public final static int FRAME_wait4 = 15;
	public final static int FRAME_wait5 = 16;
	public final static int FRAME_wait6 = 17;
	public final static int FRAME_wait7 = 18;
	public final static int FRAME_wait8 = 19;
	public final static int FRAME_wait9 = 20;
	public final static int FRAME_wait10 = 21;
	public final static int FRAME_wait11 = 22;
	public final static int FRAME_wait12 = 23;
	public final static int FRAME_wait13 = 24;
	public final static int FRAME_wait14 = 25;
	public final static int FRAME_wait15 = 26;
	public final static int FRAME_wait16 = 27;
	public final static int FRAME_wait17 = 28;
	public final static int FRAME_wait18 = 29;
	public final static int FRAME_wait19 = 30;
	public final static int FRAME_wait20 = 31;
	public final static int FRAME_wait21 = 32;
	public final static int FRAME_wait22 = 33;
	public final static int FRAME_wait23 = 34;
	public final static int FRAME_wait24 = 35;
	public final static int FRAME_wait25 = 36;
	public final static int FRAME_wait26 = 37;
	public final static int FRAME_wait27 = 38;
	public final static int FRAME_wait28 = 39;
	public final static int FRAME_wait29 = 40;
	public final static int FRAME_wait30 = 41;
	public final static int FRAME_wait31 = 42;
	public final static int FRAME_wait32 = 43;
	public final static int FRAME_wait33 = 44;
	public final static int FRAME_wait34 = 45;
	public final static int FRAME_wait35 = 46;
	public final static int FRAME_wait36 = 47;
	public final static int FRAME_wait37 = 48;
	public final static int FRAME_wait38 = 49;
	public final static int FRAME_wait39 = 50;
	public final static int FRAME_wait40 = 51;
	public final static int FRAME_wait41 = 52;
	public final static int FRAME_wait42 = 53;
	public final static int FRAME_wait43 = 54;
	public final static int FRAME_wait44 = 55;
	public final static int FRAME_wait45 = 56;
	public final static int FRAME_wait46 = 57;
	public final static int FRAME_wait47 = 58;
	public final static int FRAME_wait48 = 59;
	public final static int FRAME_wait49 = 60;
	public final static int FRAME_wait50 = 61;
	public final static int FRAME_wait51 = 62;
	public final static int FRAME_wait52 = 63;
	public final static int FRAME_wait53 = 64;
	public final static int FRAME_wait54 = 65;
	public final static int FRAME_wait55 = 66;
	public final static int FRAME_wait56 = 67;
	public final static int FRAME_wait57 = 68;
	public final static int FRAME_wait58 = 69;
	public final static int FRAME_wait59 = 70;
	public final static int FRAME_wait60 = 71;
	public final static int FRAME_wait61 = 72;
	public final static int FRAME_wait62 = 73;
	public final static int FRAME_wait63 = 74;
	public final static int FRAME_wait64 = 75;
	public final static int FRAME_wait65 = 76;
	public final static int FRAME_wait66 = 77;
	public final static int FRAME_wait67 = 78;
	public final static int FRAME_wait68 = 79;
	public final static int FRAME_wait69 = 80;
	public final static int FRAME_wait70 = 81;
	public final static int FRAME_wait71 = 82;
	public final static int FRAME_wait72 = 83;
	public final static int FRAME_wait73 = 84;
	public final static int FRAME_wait74 = 85;
	public final static int FRAME_wait75 = 86;
	public final static int FRAME_wait76 = 87;
	public final static int FRAME_wait77 = 88;
	public final static int FRAME_wait78 = 89;
	public final static int FRAME_wait79 = 90;
	public final static int FRAME_wait80 = 91;
	public final static int FRAME_wait81 = 92;
	public final static int FRAME_wait82 = 93;
	public final static int FRAME_wait83 = 94;
	public final static int FRAME_wait84 = 95;
	public final static int FRAME_wait85 = 96;
	public final static int FRAME_wait86 = 97;
	public final static int FRAME_wait87 = 98;
	public final static int FRAME_wait88 = 99;
	public final static int FRAME_wait89 = 100;
	public final static int FRAME_wait90 = 101;
	public final static int FRAME_run1 = 102;
	public final static int FRAME_run2 = 103;
	public final static int FRAME_run3 = 104;
	public final static int FRAME_run4 = 105;
	public final static int FRAME_run5 = 106;
	public final static int FRAME_run6 = 107;
	public final static int FRAME_paina1 = 108;
	public final static int FRAME_paina2 = 109;
	public final static int FRAME_paina3 = 110;
	public final static int FRAME_paina4 = 111;
	public final static int FRAME_paina5 = 112;
	public final static int FRAME_paina6 = 113;
	public final static int FRAME_paina7 = 114;
	public final static int FRAME_paina8 = 115;
	public final static int FRAME_painb1 = 116;
	public final static int FRAME_painb2 = 117;
	public final static int FRAME_painb3 = 118;
	public final static int FRAME_painb4 = 119;
	public final static int FRAME_painb5 = 120;
	public final static int FRAME_painb6 = 121;
	public final static int FRAME_painb7 = 122;
	public final static int FRAME_painb8 = 123;
	public final static int FRAME_painb9 = 124;
	public final static int FRAME_painb10 = 125;
	public final static int FRAME_painb11 = 126;
	public final static int FRAME_painb12 = 127;
	public final static int FRAME_painb13 = 128;
	public final static int FRAME_painb14 = 129;
	public final static int FRAME_painb15 = 130;
	public final static int FRAME_duck1 = 131;
	public final static int FRAME_duck2 = 132;
	public final static int FRAME_duck3 = 133;
	public final static int FRAME_duck4 = 134;
	public final static int FRAME_duck5 = 135;
	public final static int FRAME_duck6 = 136;
	public final static int FRAME_duck7 = 137;
	public final static int FRAME_duck8 = 138;
	public final static int FRAME_duck9 = 139;
	public final static int FRAME_duck10 = 140;
	public final static int FRAME_duck11 = 141;
	public final static int FRAME_duck12 = 142;
	public final static int FRAME_duck13 = 143;
	public final static int FRAME_duck14 = 144;
	public final static int FRAME_duck15 = 145;
	public final static int FRAME_duck16 = 146;
	public final static int FRAME_death1 = 147;
	public final static int FRAME_death2 = 148;
	public final static int FRAME_death3 = 149;
	public final static int FRAME_death4 = 150;
	public final static int FRAME_death5 = 151;
	public final static int FRAME_death6 = 152;
	public final static int FRAME_death7 = 153;
	public final static int FRAME_death8 = 154;
	public final static int FRAME_death9 = 155;
	public final static int FRAME_death10 = 156;
	public final static int FRAME_death11 = 157;
	public final static int FRAME_death12 = 158;
	public final static int FRAME_death13 = 159;
	public final static int FRAME_death14 = 160;
	public final static int FRAME_death15 = 161;
	public final static int FRAME_death16 = 162;
	public final static int FRAME_death17 = 163;
	public final static int FRAME_death18 = 164;
	public final static int FRAME_death19 = 165;
	public final static int FRAME_death20 = 166;
	public final static int FRAME_death21 = 167;
	public final static int FRAME_death22 = 168;
	public final static int FRAME_death23 = 169;
	public final static int FRAME_death24 = 170;
	public final static int FRAME_death25 = 171;
	public final static int FRAME_death26 = 172;
	public final static int FRAME_death27 = 173;
	public final static int FRAME_death28 = 174;
	public final static int FRAME_death29 = 175;
	public final static int FRAME_death30 = 176;
	public final static int FRAME_attack1 = 177;
	public final static int FRAME_attack2 = 178;
	public final static int FRAME_attack3 = 179;
	public final static int FRAME_attack4 = 180;
	public final static int FRAME_attack5 = 181;
	public final static int FRAME_attack6 = 182;
	public final static int FRAME_attack7 = 183;
	public final static int FRAME_attack8 = 184;
	public final static int FRAME_attack9 = 185;
	public final static int FRAME_attack10 = 186;
	public final static int FRAME_attack11 = 187;
	public final static int FRAME_attack12 = 188;
	public final static int FRAME_attack13 = 189;
	public final static int FRAME_attack14 = 190;
	public final static int FRAME_attack15 = 191;
	public final static int FRAME_attack16 = 192;
	public final static int FRAME_attack17 = 193;
	public final static int FRAME_attack18 = 194;
	public final static int FRAME_attack19 = 195;
	public final static int FRAME_attack20 = 196;
	public final static int FRAME_attack21 = 197;
	public final static int FRAME_attack22 = 198;
	public final static int FRAME_attack23 = 199;
	public final static int FRAME_attack24 = 200;
	public final static int FRAME_attack25 = 201;
	public final static int FRAME_attack26 = 202;
	public final static int FRAME_attack27 = 203;
	public final static int FRAME_attack28 = 204;
	public final static int FRAME_attack29 = 205;
	public final static int FRAME_attack30 = 206;
	public final static int FRAME_attack31 = 207;
	public final static int FRAME_attack32 = 208;
	public final static int FRAME_attack33 = 209;
	public final static int FRAME_attack34 = 210;
	public final static int FRAME_attack35 = 211;
	public final static int FRAME_attack36 = 212;
	public final static int FRAME_attack37 = 213;
	public final static int FRAME_attack38 = 214;
	public final static int FRAME_attack39 = 215;
	public final static int FRAME_attack40 = 216;
	public final static int FRAME_attack41 = 217;
	public final static int FRAME_attack42 = 218;
	public final static int FRAME_attack43 = 219;
	public final static int FRAME_attack44 = 220;
	public final static int FRAME_attack45 = 221;
	public final static int FRAME_attack46 = 222;
	public final static int FRAME_attack47 = 223;
	public final static int FRAME_attack48 = 224;
	public final static int FRAME_attack49 = 225;
	public final static int FRAME_attack50 = 226;
	public final static int FRAME_attack51 = 227;
	public final static int FRAME_attack52 = 228;
	public final static int FRAME_attack53 = 229;
	public final static int FRAME_attack54 = 230;
	public final static int FRAME_attack55 = 231;
	public final static int FRAME_attack56 = 232;
	public final static int FRAME_attack57 = 233;
	public final static int FRAME_attack58 = 234;
	public final static int FRAME_attack59 = 235;
	public final static int FRAME_attack60 = 236;

	public final static float MODEL_SCALE = 1.000000f;

	static int sound_idle1;
	static int sound_pain1;
	static int sound_pain2;
	static int sound_die;
	static int sound_sight;
	static int sound_search;
	static int sound_hook_launch;
	static int sound_hook_hit;
	static int sound_hook_heal;
	static int sound_hook_retract;

	static edict_t medic_FindDeadMonster(edict_t self) {
		edict_t ent = null;
		edict_t best = null;
		EdictIterator edit = null;

		while ((edit = findradius(edit, self.s.origin, 1024)) != null) {
			ent = edit.o;
			if (ent == self)
				continue;
			if (0 == (ent.svflags & SVF_MONSTER))
				continue;
			if ((ent.monsterinfo.aiflags & AI_GOOD_GUY) != 0)
				continue;
			if (ent.owner == null)
				continue;
			if (ent.health > 0)
				continue;
			if (ent.nextthink == 0)
				continue;
			if (!visible(self, ent))
				continue;
			if (best == null) {
				best = ent;
				continue;
			}
			if (ent.max_health <= best.max_health)
				continue;
			best = ent;
		}

		return best;
	}

	static EntThinkAdapter medic_idle = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			edict_t ent;

			gi.sound(self, CHAN_VOICE, sound_idle1, 1, ATTN_IDLE, 0);

			ent = medic_FindDeadMonster(self);
			if (ent != null) {
				self.enemy = ent;
				self.enemy.owner = self;
				self.monsterinfo.aiflags |= AI_MEDIC;
				FoundTarget(self);
			}
			return true;
		}
	};

	static EntThinkAdapter medic_search = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			edict_t ent;

			gi.sound(self, CHAN_VOICE, sound_search, 1, ATTN_IDLE, 0);

			if (self.oldenemy == null) {
				ent = medic_FindDeadMonster(self);
				if (ent != null) {
					self.oldenemy = self.enemy;
					self.enemy = ent;
					self.enemy.owner = self;
					self.monsterinfo.aiflags |= AI_MEDIC;
					FoundTarget(self);
				}
			}
			return true;
		}
	};

	static EntInteractAdapter medic_sight = new EntInteractAdapter() {
		public boolean interact(edict_t self, edict_t other) {
			gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
			return true;
		}
	};

	static mframe_t medic_frames_stand[] =
		new mframe_t[] {
			new mframe_t(ai_stand, 0, medic_idle),
			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, 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, 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, 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),
			};
	static mmove_t medic_move_stand = new mmove_t(FRAME_wait1, FRAME_wait90, medic_frames_stand, null);

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

	static mframe_t medic_frames_walk[] =
		new mframe_t[] {
			new mframe_t(ai_walk, 6.2f, null),
			new mframe_t(ai_walk, 18.1f, null),
			new mframe_t(ai_walk, 1, null),
			new mframe_t(ai_walk, 9, null),
			new mframe_t(ai_walk, 10, null),
			new mframe_t(ai_walk, 9, null),
			new mframe_t(ai_walk, 11, null),
			new mframe_t(ai_walk, 11.6f, null),
			new mframe_t(ai_walk, 2, null),
			new mframe_t(ai_walk, 9.9f, null),
			new mframe_t(ai_walk, 14, null),
			new mframe_t(ai_walk, 9.3f, null)};
	static mmove_t medic_move_walk = new mmove_t(FRAME_walk1, FRAME_walk12, medic_frames_walk, null);

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

	static mframe_t medic_frames_run[] =
		new mframe_t[] {
			new mframe_t(ai_run, 18, null),
			new mframe_t(ai_run, 22.5f, null),
			new mframe_t(ai_run, 25.4f, null),
			new mframe_t(ai_run, 23.4f, null),
			new mframe_t(ai_run, 24, null),
			new mframe_t(ai_run, 35.6f, null)};
	static mmove_t medic_move_run = new mmove_t(FRAME_run1, FRAME_run6, medic_frames_run, null);

	static EntThinkAdapter medic_run = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if (0 == (self.monsterinfo.aiflags & AI_MEDIC)) {
				edict_t ent;

				ent = medic_FindDeadMonster(self);
				if (ent != null) {
					self.oldenemy = self.enemy;
					self.enemy = ent;
					self.enemy.owner = self;
					self.monsterinfo.aiflags |= AI_MEDIC;
					FoundTarget(self);
					return true;
				}
			}

			if ((self.monsterinfo.aiflags & AI_STAND_GROUND) != 0)
				self.monsterinfo.currentmove = medic_move_stand;
			else
				self.monsterinfo.currentmove = medic_move_run;
			return true;
		}
	};

	static mframe_t medic_frames_pain1[] =
		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)};
	static mmove_t medic_move_pain1 = new mmove_t(FRAME_paina1, FRAME_paina8, medic_frames_pain1, medic_run);

	static mframe_t medic_frames_pain2[] =
		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)};
	static mmove_t medic_move_pain2 = new mmove_t(FRAME_painb1, FRAME_painb15, medic_frames_pain2, medic_run);
	static EntPainAdapter medic_pain = new EntPainAdapter() {
		public void pain(edict_t self, edict_t other, float kick, int damage) {

			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;

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

			if (Lib.random() < 0.5) {
				self.monsterinfo.currentmove = medic_move_pain1;
				gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
			} else {
				self.monsterinfo.currentmove = medic_move_pain2;
				gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
			}
		}
	};

	static EntThinkAdapter medic_fire_blaster = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			float[] start={0,0,0};
			float[] forward={0,0,0}, right={0,0,0};
			float[] end={0,0,0};
			float[] dir={0,0,0};
			int effect;

			if ((self.s.frame == FRAME_attack9) || (self.s.frame == FRAME_attack12))
				effect = EF_BLASTER;
			else if (
				(self.s.frame == FRAME_attack19)
					|| (self.s.frame == FRAME_attack22)
					|| (self.s.frame == FRAME_attack25)
					|| (self.s.frame == FRAME_attack28))
				effect = EF_HYPERBLASTER;
			else
				effect = 0;

			Math3D.AngleVectors(self.s.angles, forward, right, null);
			Math3D.G_ProjectSource(self.s.origin, monster_flash_offset[MZ2_MEDIC_BLASTER_1], forward, right, start);

			Math3D.VectorCopy(self.enemy.s.origin, end);
			end[2] += self.enemy.viewheight;
			Math3D.VectorSubtract(end, start, dir);

			Monster.monster_fire_blaster(self, start, dir, 2, 1000, MZ2_MEDIC_BLASTER_1, effect);
			return true;
		}
	};

	static EntThinkAdapter medic_dead = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			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 mframe_t medic_frames_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),
			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 medic_move_death = new mmove_t(FRAME_death1, FRAME_death30, medic_frames_death, medic_dead);

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

			int n;

			// if we had a pending patient, free him up for another medic
			if ((self.enemy != null) && (self.enemy.owner == self))
				self.enemy.owner = null;

			//	check for gib
			if (self.health <= self.gib_health) {
				gi.sound(self, CHAN_VOICE, gi.soundindex("misc/udeath.wav"), 1, ATTN_NORM, 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;

			//	regular death
			gi.sound(self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
			self.deadflag = DEAD_DEAD;
			self.takedamage = DAMAGE_YES;

			self.monsterinfo.currentmove = medic_move_death;
		}
	};

	static EntThinkAdapter medic_duck_down = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if ((self.monsterinfo.aiflags & AI_DUCKED) != 0)
				return true;
			self.monsterinfo.aiflags |= AI_DUCKED;
			self.maxs[2] -= 32;
			self.takedamage = DAMAGE_YES;
			self.monsterinfo.pausetime = level.time + 1;
			gi.linkentity(self);
			return true;
		}
	};

	static EntThinkAdapter medic_duck_hold = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if (level.time >= self.monsterinfo.pausetime)
				self.monsterinfo.aiflags &= ~AI_HOLD_FRAME;
			else
				self.monsterinfo.aiflags |= AI_HOLD_FRAME;
			return true;
		}
	};

	static EntThinkAdapter medic_duck_up = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			self.monsterinfo.aiflags &= ~AI_DUCKED;
			self.maxs[2] += 32;
			self.takedamage = DAMAGE_AIM;
			gi.linkentity(self);
			return true;
		}
	};

	static mframe_t medic_frames_duck[] =
		new mframe_t[] {
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, medic_duck_down),
			new mframe_t(ai_move, -1, medic_duck_hold),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, medic_duck_up),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null),
			new mframe_t(ai_move, -1, null)};
	static mmove_t medic_move_duck = new mmove_t(FRAME_duck1, FRAME_duck16, medic_frames_duck, medic_run);

	static EntDodgeAdapter medic_dodge = new EntDodgeAdapter() {
		public void dodge(edict_t self, edict_t attacker, float eta) {
			if (Lib.random() > 0.25)
				return;

			if (self.enemy == null)
				self.enemy = attacker;

			self.monsterinfo.currentmove = medic_move_duck;
		}
	};

	static mframe_t medic_frames_attackHyperBlaster[] =
		new mframe_t[] {
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, medic_fire_blaster)};
	static mmove_t medic_move_attackHyperBlaster =
		new mmove_t(FRAME_attack15, FRAME_attack30, medic_frames_attackHyperBlaster, medic_run);

	static EntThinkAdapter medic_continue = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if (visible(self, self.enemy))
				if (Lib.random() <= 0.95)
					self.monsterinfo.currentmove = medic_move_attackHyperBlaster;
			return true;
		}
	};

	static mframe_t medic_frames_attackBlaster[] =
		{
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 5, null),
			new mframe_t(ai_charge, 5, null),
			new mframe_t(ai_charge, 3, null),
			new mframe_t(ai_charge, 2, null),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, medic_fire_blaster),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_charge, 0, medic_continue) // Change to medic_continue... Else, go to frame 32
	};
	static mmove_t medic_move_attackBlaster = new mmove_t(FRAME_attack1, FRAME_attack14, medic_frames_attackBlaster, medic_run);

	static EntThinkAdapter medic_hook_launch = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			gi.sound(self, CHAN_WEAPON, sound_hook_launch, 1, ATTN_NORM, 0);
			return true;
		}
	};

	static float medic_cable_offsets[][] = { { 45.0f, -9.2f, 15.5f }, {
			48.4f, -9.7f, 15.2f }, {
			47.8f, -9.8f, 15.8f }, {
			47.3f, -9.3f, 14.3f }, {
			45.4f, -10.1f, 13.1f }, {
			41.9f, -12.7f, 12.0f }, {
			37.8f, -15.8f, 11.2f }, {
			34.3f, -18.4f, 10.7f }, {
			32.7f, -19.7f, 10.4f }, {
			32.7f, -19.7f, 10.4f }
	};

	static EntThinkAdapter medic_cable_attack = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			float[] offset={0,0,0}, start={0,0,0}, end={0,0,0}, f={0,0,0}, r={0,0,0};
			trace_t tr;
			float[] dir={0,0,0}, angles={0,0,0};
			float distance;

			if (!self.enemy.inuse)
				return true;

			Math3D.AngleVectors(self.s.angles, f, r, null);
			Math3D.VectorCopy(medic_cable_offsets[self.s.frame - FRAME_attack42], offset);
			Math3D.G_ProjectSource(self.s.origin, offset, f, r, start);

			// check for max distance
			Math3D.VectorSubtract(start, self.enemy.s.origin, dir);
			distance = Math3D.VectorLength(dir);
			if (distance > 256)
				return true;

			// check for min/max pitch
			Math3D.vectoangles(dir, angles);
			if (angles[0] < -180)
				angles[0] += 360;
			if (Math.abs(angles[0]) > 45)
				return true;

			tr = gi.trace(start, null, null, self.enemy.s.origin, self, MASK_SHOT);
			if (tr.fraction != 1.0 && tr.ent != self.enemy)
				return true;

			if (self.s.frame == FRAME_attack43) {
				gi.sound(self.enemy, CHAN_AUTO, sound_hook_hit, 1, ATTN_NORM, 0);
				self.enemy.monsterinfo.aiflags |= AI_RESURRECTING;
			} else if (self.s.frame == FRAME_attack50) {
				self.enemy.spawnflags = 0;
				self.enemy.monsterinfo.aiflags = 0;
				self.enemy.target = null;
				self.enemy.targetname = null;
				self.enemy.combattarget = null;
				self.enemy.deathtarget = null;
				self.enemy.owner = self;
				GameSpawn.ED_CallSpawn(self.enemy);
				self.enemy.owner = null;
				if (self.enemy.think != null) {
					self.enemy.nextthink = level.time;
					self.enemy.think.think(self.enemy);
				}
				self.enemy.monsterinfo.aiflags |= AI_RESURRECTING;
				if (self.oldenemy != null && self.oldenemy.client != null) {
					self.enemy.enemy = self.oldenemy;
					FoundTarget(self.enemy);
				}
			} else {
				if (self.s.frame == FRAME_attack44)
					gi.sound(self, CHAN_WEAPON, sound_hook_heal, 1, ATTN_NORM, 0);
			}

			// adjust start for beam origin being in middle of a segment
			Math3D.VectorMA(start, 8, f, start);

			// adjust end z for end spot since the monster is currently dead
			Math3D.VectorCopy(self.enemy.s.origin, end);
			end[2] = self.enemy.absmin[2] + self.enemy.size[2] / 2;

			gi.WriteByte(svc_temp_entity);
			gi.WriteByte(TE_MEDIC_CABLE_ATTACK);
			gi.WriteShort(self.index);
			gi.WritePosition(start);
			gi.WritePosition(end);
			gi.multicast(self.s.origin, MULTICAST_PVS);
			return true;
		}
	};

	static EntThinkAdapter medic_hook_retract = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			gi.sound(self, CHAN_WEAPON, sound_hook_retract, 1, ATTN_NORM, 0);
			self.enemy.monsterinfo.aiflags &= ~AI_RESURRECTING;
			return true;
		}
	};

	static mframe_t medic_frames_attackCable[] =
		new mframe_t[] {
			new mframe_t(ai_move, 2, null),
			new mframe_t(ai_move, 3, null),
			new mframe_t(ai_move, 5, null),
			new mframe_t(ai_move, 4.4f, null),
			new mframe_t(ai_charge, 4.7f, null),
			new mframe_t(ai_charge, 5, null),
			new mframe_t(ai_charge, 6, null),
			new mframe_t(ai_charge, 4, null),
			new mframe_t(ai_charge, 0, null),
			new mframe_t(ai_move, 0, medic_hook_launch),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, 0, medic_cable_attack),
			new mframe_t(ai_move, -15, medic_hook_retract),
			new mframe_t(ai_move, -1.5f, null),
			new mframe_t(ai_move, -1.2f, null),
			new mframe_t(ai_move, -3, null),
			new mframe_t(ai_move, -2, null),
			new mframe_t(ai_move, 0.3f, null),
			new mframe_t(ai_move, 0.7f, null),
			new mframe_t(ai_move, 1.2f, null),
			new mframe_t(ai_move, 1.3f, null)};
	static mmove_t medic_move_attackCable = new mmove_t(FRAME_attack33, FRAME_attack60, medic_frames_attackCable, medic_run);

	static EntThinkAdapter medic_attack = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if ((self.monsterinfo.aiflags & AI_MEDIC) != 0)
				self.monsterinfo.currentmove = medic_move_attackCable;
			else
				self.monsterinfo.currentmove = medic_move_attackBlaster;
			return true;
		}
	};

	static EntThinkAdapter medic_checkattack = new EntThinkAdapter() {
		public boolean think(edict_t self) {
			if ((self.monsterinfo.aiflags & AI_MEDIC) != 0) {
				medic_attack.think(self);
				return true;
			}

			return M_CheckAttack.think(self);

		}
	};

	/*QUAKED monster_medic (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
	*/
	static void SP_monster_medic(edict_t self) {
		if (deathmatch.value != 0) {
			G_FreeEdict(self);
			return;
		}

		sound_idle1 = gi.soundindex("medic/idle.wav");
		sound_pain1 = gi.soundindex("medic/medpain1.wav");
		sound_pain2 = gi.soundindex("medic/medpain2.wav");
		sound_die = gi.soundindex("medic/meddeth1.wav");
		sound_sight = gi.soundindex("medic/medsght1.wav");
		sound_search = gi.soundindex("medic/medsrch1.wav");
		sound_hook_launch = gi.soundindex("medic/medatck2.wav");
		sound_hook_hit = gi.soundindex("medic/medatck3.wav");
		sound_hook_heal = gi.soundindex("medic/medatck4.wav");
		sound_hook_retract = gi.soundindex("medic/medatck5.wav");

		gi.soundindex("medic/medatck1.wav");

		self.movetype = MOVETYPE_STEP;
		self.solid = SOLID_BBOX;
		self.s.modelindex = gi.modelindex("models/monsters/medic/tris.md2");
		Math3D.VectorSet(self.mins, -24, -24, -24);
		Math3D.VectorSet(self.maxs, 24, 24, 32);

		self.health = 300;
		self.gib_health = -130;
		self.mass = 400;

		self.pain = medic_pain;
		self.die = medic_die;

		self.monsterinfo.stand = medic_stand;
		self.monsterinfo.walk = medic_walk;
		self.monsterinfo.run = medic_run;
		self.monsterinfo.dodge = medic_dodge;
		self.monsterinfo.attack = medic_attack;
		self.monsterinfo.melee = null;
		self.monsterinfo.sight = medic_sight;
		self.monsterinfo.idle = medic_idle;
		self.monsterinfo.search = medic_search;
		self.monsterinfo.checkattack = medic_checkattack;

		gi.linkentity(self);

		self.monsterinfo.currentmove = medic_move_stand;
		self.monsterinfo.scale = MODEL_SCALE;

		walkmonster_start.think(self);
	}

}