-
Notifications
You must be signed in to change notification settings - Fork 2
/
float.qc
630 lines (571 loc) · 13.9 KB
/
float.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
#ifdef SINGLE_PLAYER
#include "m_float.h"
static int sound_attack2;
static int sound_attack3;
static int sound_death1;
static int sound_idle;
static int sound_pain1;
static int sound_pain2;
static int sound_sight;
static void floater_sight(entity self, entity other)
{
gi.sound(self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
}
static void floater_idle(entity self)
{
gi.sound(self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
}
static void floater_fire_blaster(entity self)
{
#ifdef GROUND_ZERO
if (!self.enemy || !self.enemy.inuse)
return;
#endif
vector start;
vector forward, right;
vector end;
vector dir;
int effect;
if ((self.s.frame == FRAME_attak104) || (self.s.frame == FRAME_attak107))
effect = EF_HYPERBLASTER;
else
effect = 0;
AngleVectors(self.s.angles, &forward, &right, 0);
start = G_ProjectSource(self.s.origin, monster_flash_offset[MZ2_FLOAT_BLASTER_1], forward, right);
end = self.enemy.s.origin;
end.z += self.enemy.viewheight;
dir = end - start;
monster_fire_blaster(self, start, dir, 1, 1000, MZ2_FLOAT_BLASTER_1, effect);
}
static mframe_t floater_frames_stand1 [] = {
{ 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 },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand }
};
static var mmove_t floater_move_stand1 = { FRAME_stand101, FRAME_stand152 };
static mframe_t floater_frames_stand2 [] = {
{ 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 },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand },
{ ai_stand }
};
static var mmove_t floater_move_stand2 = { FRAME_stand201, FRAME_stand252 };
static void floater_stand(entity self)
{
if (random() <= 0.5f)
self.monsterinfo.currentmove = &floater_move_stand1;
else
self.monsterinfo.currentmove = &floater_move_stand2;
}
static mframe_t floater_frames_run [] = {
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 },
{ ai_run, 13 }
};
static var mmove_t floater_move_run = { FRAME_stand101, FRAME_stand152 };
static void floater_run(entity self)
{
if (self.monsterinfo.aiflags & AI_STAND_GROUND)
self.monsterinfo.currentmove = &floater_move_stand1;
else
self.monsterinfo.currentmove = &floater_move_run;
}
static mframe_t floater_frames_attack1 [] = {
{ ai_charge }, // Blaster attack
{ ai_charge },
{ ai_charge },
{ ai_charge, 0, floater_fire_blaster }, // BOOM (0, -25.8, 32.5) -- LOOP Starts
{ ai_charge, 0, floater_fire_blaster },
{ ai_charge, 0, floater_fire_blaster },
{ ai_charge, 0, floater_fire_blaster },
{ ai_charge, 0, floater_fire_blaster },
{ ai_charge, 0, floater_fire_blaster },
{ ai_charge, 0, floater_fire_blaster },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge } // -- LOOP Ends
};
static var mmove_t floater_move_attack1 = { FRAME_attak101, FRAME_attak114, floater_run };
#ifdef GROUND_ZERO
static mframe_t floater_frames_attack1a [] =
{
{ ai_charge, 10 }, // Blaster attack
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10, floater_fire_blaster }, // BOOM (0, -25.8, 32.5) -- LOOP Starts
{ ai_charge, 10, floater_fire_blaster },
{ ai_charge, 10, floater_fire_blaster },
{ ai_charge, 10, floater_fire_blaster },
{ ai_charge, 10, floater_fire_blaster },
{ ai_charge, 10, floater_fire_blaster },
{ ai_charge, 10, floater_fire_blaster },
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10 },
{ ai_charge, 10 } // -- LOOP Ends
};
static var mmove_t floater_move_attack1a = { FRAME_attak101, FRAME_attak114, floater_run };
#endif
static void floater_wham(entity self)
{
static const vector aim = [ MELEE_DISTANCE, 0, 0 ];
gi.sound(self, CHAN_WEAPON, sound_attack3, 1, ATTN_NORM, 0);
fire_hit(self, aim, 5 + Q_rand() % 6, -50);
}
static mframe_t floater_frames_attack2 [] = {
{ ai_charge }, // Claws
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge, 0, floater_wham }, // WHAM (0, -45, 29.6) -- LOOP Starts
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge }, // -- LOOP Ends
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge }
};
static var mmove_t floater_move_attack2 = {FRAME_attak201, FRAME_attak225, floater_run};
static void floater_zap(entity self)
{
vector forward, right;
vector origin;
vector dir;
vector offset;
dir = self.enemy.s.origin - self.s.origin;
AngleVectors(self.s.angles, &forward, &right, 0);
//FIXME use a flash and replace these two lines with the commented one
offset = '18.5 -0.9 10';
origin = G_ProjectSource(self.s.origin, offset, forward, right);
// G_ProjectSource (self.s.origin, monster_flash_offset[flash_number], forward, right, origin);
gi.sound(self, CHAN_WEAPON, sound_attack2, 1, ATTN_NORM, 0);
//FIXME use the flash, Luke
gi.WriteByte(svc_temp_entity);
gi.WriteByte(TE_SPLASH);
gi.WriteByte(32);
gi.WritePosition(origin);
gi.WriteDir(dir);
gi.WriteByte(1); //sparks
gi.multicast(origin, MULTICAST_PVS);
T_Damage(self.enemy, self, self, dir, self.enemy.s.origin, vec3_origin, 5 + Q_rand() % 6, -10, DAMAGE_ENERGY, MOD_UNKNOWN);
}
static mframe_t floater_frames_attack3 [] = {
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge, 0, floater_zap }, // -- LOOP Starts
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge }, // -- LOOP Ends
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge },
{ ai_charge }
};
static var mmove_t floater_move_attack3 = { FRAME_attak301, FRAME_attak334, floater_run };
static mframe_t floater_frames_pain1 [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t floater_move_pain1 = { FRAME_pain101, FRAME_pain107, floater_run };
static mframe_t floater_frames_pain2 [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t floater_move_pain2 = { FRAME_pain201, FRAME_pain208, floater_run };
static mframe_t floater_frames_pain3 [] = {
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move },
{ ai_move }
};
static var mmove_t floater_move_pain3 = { FRAME_pain301, FRAME_pain312, floater_run };
static mframe_t floater_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 },
{ 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 floater_move_walk = { FRAME_stand101, FRAME_stand152 };
static void floater_walk(entity self)
{
self.monsterinfo.currentmove = &floater_move_walk;
}
static void floater_attack(entity self)
{
#ifdef GROUND_ZERO
float chance = 0;
// 0% chance of circle in easy
// 50% chance in normal
// 75% chance in hard
// 86.67% chance in nightmare
if (skill.intVal)
chance = 1.0 - (0.5 / skill.intVal);
if (random() > chance)
{
self.monsterinfo.attack_state = AS_STRAIGHT;
#endif
self.monsterinfo.currentmove = &floater_move_attack1;
#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 = &floater_move_attack1a;
}
#endif
}
static void floater_melee(entity self)
{
if (random() < 0.5f)
self.monsterinfo.currentmove = &floater_move_attack3;
else
self.monsterinfo.currentmove = &floater_move_attack2;
}
static void floater_pain(entity self, entity other, float kick, int damage)
{
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() + 1) % 3;
if (n == 0) {
gi.sound(self, CHAN_VOICE, sound_pain1, 1, ATTN_NORM, 0);
self.monsterinfo.currentmove = &floater_move_pain1;
} else {
gi.sound(self, CHAN_VOICE, sound_pain2, 1, ATTN_NORM, 0);
self.monsterinfo.currentmove = &floater_move_pain2;
}
}
static void(entity self, entity inflictor, entity attacker, int damage, vector point) floater_die =
{
gi.sound(self, CHAN_VOICE, sound_death1, 1, ATTN_NORM, 0);
BecomeExplosion1(self);
}
#ifdef GROUND_ZERO
static bool floater_blocked (entity self, float dist)
{
if(blocked_checkshot(self, 0.25 + (0.05 * skill.intVal)))
return true;
return false;
}
#endif
/*QUAKED monster_floater (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
*/
API_FUNC static void SP_monster_floater(entity self)
{
if (deathmatch.intVal) {
G_FreeEdict(self);
return;
}
if (!floater_move_stand1.frame)
{
floater_move_stand1.frame = &floater_frames_stand1;
floater_move_stand2.frame = &floater_frames_stand2;
floater_move_run.frame = &floater_frames_run;
floater_move_attack1.frame = &floater_frames_attack1;
floater_move_attack2.frame = &floater_frames_attack2;
floater_move_attack3.frame = &floater_frames_attack3;
floater_move_pain1.frame = &floater_frames_pain1;
floater_move_pain2.frame = &floater_frames_pain2;
floater_move_pain3.frame = &floater_frames_pain3;
floater_move_walk.frame = &floater_frames_walk;
#ifdef GROUND_ZERO
floater_move_attack1a.frame = &floater_frames_attack1a;
#endif
}
sound_attack2 = gi.soundindex("floater/fltatck2.wav");
sound_attack3 = gi.soundindex("floater/fltatck3.wav");
sound_death1 = gi.soundindex("floater/fltdeth1.wav");
sound_idle = gi.soundindex("floater/fltidle1.wav");
sound_pain1 = gi.soundindex("floater/fltpain1.wav");
sound_pain2 = gi.soundindex("floater/fltpain2.wav");
sound_sight = gi.soundindex("floater/fltsght1.wav");
gi.soundindex("floater/fltatck1.wav");
self.s.sound = gi.soundindex("floater/fltsrch1.wav");
self.movetype = MOVETYPE_STEP;
self.solid = SOLID_BBOX;
self.s.modelindex = gi.modelindex("models/monsters/float/tris.md2");
self.mins = '-24 -24 -24';
self.maxs = '24 24 32';
self.health = 200;
self.gib_health = -80;
self.mass = 300;
self.pain = floater_pain;
self.die = floater_die;
self.monsterinfo.stand = floater_stand;
self.monsterinfo.walk = floater_walk;
self.monsterinfo.run = floater_run;
self.monsterinfo.attack = floater_attack;
self.monsterinfo.melee = floater_melee;
self.monsterinfo.sight = floater_sight;
self.monsterinfo.idle = floater_idle;
#ifdef GROUND_ZERO
self.monsterinfo.blocked = floater_blocked;
#endif
gi.linkentity(self);
if (random() <= 0.5f)
self.monsterinfo.currentmove = &floater_move_stand1;
else
self.monsterinfo.currentmove = &floater_move_stand2;
self.monsterinfo.scale = MODEL_SCALE;
flymonster_start(self);
}
#endif