-
Notifications
You must be signed in to change notification settings - Fork 2
/
flyer.qc
664 lines (577 loc) · 15 KB
/
flyer.qc
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
#ifdef SINGLE_PLAYER
#include "m_flyer.h"
static int sound_sight;
static int sound_idle;
static int sound_pain1;
static int sound_pain2;
static int sound_slash;
static int sound_sproing;
static int sound_die;
static void(entity self, entity other) flyer_sight =
{
gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
}
static void(entity self) flyer_idle =
{
gi.sound(self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
}
static void(entity self) flyer_pop_blades =
{
gi.sound(self, CHAN_VOICE, sound_sproing, 1, ATTN_NORM, 0);
}
static mframe_t flyer_frames_stand [] = {
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand }
};
static var mmove_t flyer_move_stand = { FRAME_stand01, FRAME_stand45 };
static mframe_t flyer_frames_walk [] = {
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 },
{ ai_walk, 5 }
};
static var mmove_t flyer_move_walk = { FRAME_stand01, FRAME_stand45 };
static mframe_t flyer_frames_run [] = {
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 },
{ ai_run, 10 }
};
static var mmove_t flyer_move_run = { FRAME_stand01, FRAME_stand45 };
#ifdef GROUND_ZERO
var mmove_t flyer_move_kamikaze = { FRAME_rollr02, FRAME_rollr06 };
static void(entity self, entity inflictor, entity attacker, int damage, vector point) flyer_die;
static void flyer_kamikaze_explode (entity self)
{
vector dir = vec3_origin;
if (self.monsterinfo.commander && self.monsterinfo.commander.inuse &&
self.monsterinfo.commander.classname == "monster_carrier")
self.monsterinfo.commander.monsterinfo.monster_slots++;
if (self.enemy)
{
dir = self.enemy.s.origin - self.s.origin;
T_Damage (self.enemy, self, self, dir, self.s.origin, vec3_origin, 50, 50, DAMAGE_RADIUS, MOD_UNKNOWN);
}
flyer_die (self, 0, 0, 0, dir);
}
static void flyer_kamikaze (entity self)
{
self.monsterinfo.currentmove = &flyer_move_kamikaze;
}
static void flyer_kamikaze_check (entity self)
{
float dist;
// PMM - this needed because we could have gone away before we get here (blocked code)
if (!self.inuse)
return;
if ((!self.enemy) || (!self.enemy.inuse))
{
flyer_kamikaze_explode (self);
return;
}
self.goalentity = self.enemy;
dist = realrange (self, self.enemy);
if (dist < 90)
flyer_kamikaze_explode (self);
}
static mframe_t flyer_frames_kamizake [] =
{
{ ai_charge, 40, flyer_kamikaze_check },
{ ai_charge, 40, flyer_kamikaze_check },
{ ai_charge, 40, flyer_kamikaze_check },
{ ai_charge, 40, flyer_kamikaze_check },
{ ai_charge, 40, flyer_kamikaze_check }
};
#endif
static void(entity self) flyer_run =
{
#ifdef GROUND_ZERO
if (self.mass > 50)
self.monsterinfo.currentmove = &flyer_move_kamikaze;
else
#endif
if (self.monsterinfo.aiflags & AI_STAND_GROUND)
self.monsterinfo.currentmove = &flyer_move_stand;
else
self.monsterinfo.currentmove = &flyer_move_run;
}
static void(entity self) flyer_walk =
{
#ifdef GROUND_ZERO
if (self.mass > 50)
flyer_run (self);
else
#endif
self.monsterinfo.currentmove = &flyer_move_walk;
}
static void(entity self) flyer_stand =
{
#ifdef GROUND_ZERO
if (self.mass > 50)
flyer_run (self);
else
#endif
self.monsterinfo.currentmove = &flyer_move_stand;
}
static mframe_t flyer_frames_pain3 [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t flyer_move_pain3 = { FRAME_pain301, FRAME_pain304, flyer_run };
static mframe_t flyer_frames_pain2 [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t flyer_move_pain2 = { FRAME_pain201, FRAME_pain204, flyer_run };
static mframe_t flyer_frames_pain1 [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t flyer_move_pain1 = { FRAME_pain101, FRAME_pain109, flyer_run };
static void(entity self, int flash_number) flyer_fire =
{
vector start;
vector forward, right;
vector end;
vector dir;
int effect;
#ifdef GROUND_ZERO
if (!self.enemy || !self.enemy.inuse)
return;
#endif
if ((self.s.frame == FRAME_attak204) || (self.s.frame == FRAME_attak207) || (self.s.frame == FRAME_attak210))
effect = EF_HYPERBLASTER;
else
effect = 0;
AngleVectors(self.s.angles, &forward, &right, 0);
start = G_ProjectSource(self.s.origin, monster_flash_offset[flash_number], forward, right);
end = self.enemy.s.origin;
end.z += self.enemy.viewheight;
dir = end - start;
monster_fire_blaster(self, start, dir, 1, 1000, flash_number, effect);
}
static void(entity self) flyer_fireleft =
{
flyer_fire(self, MZ2_FLYER_BLASTER_1);
}
static void(entity self) flyer_fireright =
{
flyer_fire(self, MZ2_FLYER_BLASTER_2);
}
static mframe_t flyer_frames_attack2 [] = {
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge, -10, flyer_fireleft }, // left gun
{ ai_charge, -10, flyer_fireright }, // right gun
{ ai_charge, -10, flyer_fireleft }, // left gun
{ ai_charge, -10, flyer_fireright }, // right gun
{ ai_charge, -10, flyer_fireleft }, // left gun
{ ai_charge, -10, flyer_fireright }, // right gun
{ ai_charge, -10, flyer_fireleft }, // left gun
{ ai_charge, -10, flyer_fireright }, // right gun
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge }
};
static var mmove_t flyer_move_attack2 = { FRAME_attak201, FRAME_attak217, flyer_run };
#ifdef GROUND_ZERO
static mframe_t flyer_frames_attack3 [] =
{
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10, flyer_fireleft }, // left gun
{ ai_charge, 10, flyer_fireright }, // right gun
{ ai_charge, 10, flyer_fireleft }, // left gun
{ ai_charge, 10, flyer_fireright }, // right gun
{ ai_charge, 10, flyer_fireleft }, // left gun
{ ai_charge, 10, flyer_fireright }, // right gun
{ ai_charge, 10, flyer_fireleft }, // left gun
{ ai_charge, 10, flyer_fireright }, // right gun
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10 }
};
var mmove_t flyer_move_attack3 = { FRAME_attak201, FRAME_attak217, flyer_run };
#endif
static void(entity self) flyer_slash_left =
{
const vector aim = [ MELEE_DISTANCE, self.mins.x, 0 ];
fire_hit(self, aim, 5, 0);
gi.sound(self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0);
}
static void(entity self) flyer_slash_right =
{
const vector aim = [ MELEE_DISTANCE, self.maxs.x, 0 ];
fire_hit(self, aim, 5, 0);
gi.sound(self, CHAN_WEAPON, sound_slash, 1, ATTN_NORM, 0);
}
static mframe_t flyer_frames_start_melee [] = {
{ ai_charge, 0, flyer_pop_blades },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge }
};
static var mmove_t flyer_move_start_melee = { FRAME_attak101, FRAME_attak106 };
static mframe_t flyer_frames_end_melee [] = {
{ ai_charge },
{ ai_charge },
{ ai_charge }
};
static var mmove_t flyer_move_end_melee = { FRAME_attak119, FRAME_attak121, flyer_run };
static mframe_t flyer_frames_loop_melee [] = {
{ ai_charge }, // Loop Start
{ ai_charge },
{ ai_charge, 0, flyer_slash_left }, // Left Wing Strike
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge, 0, flyer_slash_right }, // Right Wing Strike
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge } // Loop Ends
};
static var mmove_t flyer_move_loop_melee = { FRAME_attak107, FRAME_attak118 };
static void(entity self) flyer_loop_melee =
{
self.monsterinfo.currentmove = &flyer_move_loop_melee;
}
static void(entity self) flyer_attack =
{
#ifdef GROUND_ZERO
// 0% chance of circle in easy
// 50% chance in normal
// 75% chance in hard
// 86.67% chance in nightmare
if (self.mass > 50)
{
flyer_run (self);
return;
}
float chance = 0;
if (skill.intVal)
chance = 1.0 - (0.5 / skill.floatVal);
if (random() > chance)
{
self.monsterinfo.attack_state = AS_STRAIGHT;
#endif
self.monsterinfo.currentmove = &flyer_move_attack2;
#ifdef GROUND_ZERO
}
else // circle strafe
{
if (random () <= 0.5) // switch directions
self.monsterinfo.lefty = !self.monsterinfo.lefty;
self.monsterinfo.attack_state = AS_SLIDING;
self.monsterinfo.currentmove = &flyer_move_attack3;
}
#endif
}
static void(entity self) flyer_melee =
{
#ifdef GROUND_ZERO
if (self.mass > 50)
flyer_run (self);
else
#endif
self.monsterinfo.currentmove = &flyer_move_start_melee;
}
static void(entity self) flyer_check_melee =
{
if (range(self, self.enemy) == RANGE_MELEE)
if (random() <= 0.8f)
self.monsterinfo.currentmove = &flyer_move_loop_melee;
else
self.monsterinfo.currentmove = &flyer_move_end_melee;
else
self.monsterinfo.currentmove = &flyer_move_end_melee;
}
static void(entity self, entity other, float kick, int damage) flyer_pain =
{
#ifdef GROUND_ZERO
// kamikaze's don't feel pain
if (self.mass != 50)
return;
#endif
int n;
if (self.health < (self.max_health / 2))
self.s.skinnum = 1;
if (level.framenum < self.pain_debounce_framenum)
return;
self.pain_debounce_framenum = level.framenum + 3 * BASE_FRAMERATE;
if (skill.intVal == 3)
return; // no pain anims in nightmare
n = Q_rand() % 3;
if (n == 0) {
gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
self.monsterinfo.currentmove = &flyer_move_pain1;
} else if (n == 1) {
gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
self.monsterinfo.currentmove = &flyer_move_pain2;
} else {
gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
self.monsterinfo.currentmove = &flyer_move_pain3;
}
}
static void(entity self, entity inflictor, entity attacker, int damage, vector point) flyer_die =
{
gi.sound(self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
BecomeExplosion1(self);
}
#ifdef GROUND_ZERO
// PMM - kamikaze code .. blow up if blocked
static bool flyer_blocked (entity self, float dist)
{
vector origin;
// kamikaze = 100, normal = 50
if (self.mass == 100)
{
flyer_kamikaze_check(self);
// if the above didn't blow us up (i.e. I got blocked by the player)
if (self.inuse)
{
if (self.monsterinfo.commander && self.monsterinfo.commander.inuse &&
self.monsterinfo.commander.classname == "monster_carrier")
self.monsterinfo.commander.monsterinfo.monster_slots++;
origin = self.s.origin + (-0.02 * self.velocity);
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_ROCKET_EXPLOSION);
gi.WritePosition (origin);
gi.multicast (self.s.origin, MULTICAST_PHS);
G_FreeEdict (self);
}
return true;
}
// we're a normal flyer
if (blocked_checkshot(self, 0.25 + (0.05 * skill.intVal)))
return true;
return false;
}
#endif
/*QUAKED monster_flyer (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
*/
API_FUNC static void(entity self) SP_monster_flyer =
{
if (deathmatch.intVal) {
G_FreeEdict(self);
return;
}
if (!flyer_move_stand.frame)
{
flyer_move_stand.frame = &flyer_frames_stand;
flyer_move_walk.frame = &flyer_frames_walk;
flyer_move_run.frame = &flyer_frames_run;
flyer_move_pain3.frame = &flyer_frames_pain3;
flyer_move_pain2.frame = &flyer_frames_pain2;
flyer_move_pain1.frame = &flyer_frames_pain1;
flyer_move_attack2.frame = &flyer_frames_attack2;
flyer_move_start_melee.frame = &flyer_frames_start_melee;
flyer_move_start_melee.endfunc = flyer_loop_melee;
flyer_move_end_melee.frame = &flyer_frames_end_melee;
flyer_move_loop_melee.frame = &flyer_frames_loop_melee;
flyer_move_loop_melee.endfunc = flyer_check_melee;
#ifdef GROUND_ZERO
flyer_move_kamikaze.frame = &flyer_frames_kamizake;
flyer_move_kamikaze.endfunc = flyer_kamikaze;
flyer_move_attack3.frame = &flyer_frames_attack3;
#endif
}
// fix a map bug in jail5.bsp
if (striequals(level.mapname, "jail5") && (self.s.origin[2] == -104)) {
self.targetname = self.target;
self.target = 0;
}
sound_sight = gi.soundindex("flyer/flysght1.wav");
sound_idle = gi.soundindex("flyer/flysrch1.wav");
sound_pain1 = gi.soundindex("flyer/flypain1.wav");
sound_pain2 = gi.soundindex("flyer/flypain2.wav");
sound_slash = gi.soundindex("flyer/flyatck2.wav");
sound_sproing = gi.soundindex("flyer/flyatck1.wav");
sound_die = gi.soundindex("flyer/flydeth1.wav");
gi.soundindex("flyer/flyatck3.wav");
self.s.modelindex = gi.modelindex("models/monsters/flyer/tris.md2");
self.mins = '-16 -16 -24';
#ifdef GROUND_ZERO
self.maxs = '16 16 16';
#else
self.maxs = '16 16 32';
#endif
self.movetype = MOVETYPE_STEP;
self.solid = SOLID_BBOX;
self.s.sound = gi.soundindex("flyer/flyidle1.wav");
self.health = 50;
self.mass = 50;
self.pain = flyer_pain;
self.die = flyer_die;
self.monsterinfo.stand = flyer_stand;
self.monsterinfo.walk = flyer_walk;
self.monsterinfo.run = flyer_run;
self.monsterinfo.attack = flyer_attack;
self.monsterinfo.melee = flyer_melee;
self.monsterinfo.sight = flyer_sight;
self.monsterinfo.idle = flyer_idle;
#ifdef GROUND_ZERO
self.monsterinfo.blocked = flyer_blocked;
#endif
gi.linkentity(self);
self.monsterinfo.currentmove = &flyer_move_stand;
self.monsterinfo.scale = MODEL_SCALE;
flymonster_start(self);
}
#ifdef GROUND_ZERO
API_FUNC static void SP_monster_kamikaze (entity self)
{
SP_monster_flyer(self);
self.s.sound = gi.soundindex ("flyer/flyidle1.wav");
self.s.effects |= EF_ROCKET;
self.mass = 100;
}
#endif
#endif