forked from SimsOCallaghan/ArcaneDimensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mon_bossnour.qc
1244 lines (1092 loc) · 43.4 KB
/
mon_bossnour.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
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
/*==============================================================================
Nouronihar (Based on a monster by Lunaran)
==============================================================================*/
// Original wizard idle
$frame idle1 idle2 idle3 idle4 idle5 idle6 idle7 idle8
$frame idle9 idle10 idle11
// Leaning forward flying pose
$frame fly1 fly2 fly3 fly4 fly5 fly6 fly7 fly8
$frame fly9 fly10 fly11 fly12 fly13
// A = Short recoil to right, B = Long recoil to left
$frame paina1 paina2 paina3 paina4 paina5 paina6
$frame painb1 painb2 painb3 painb4 painb5 painb6 painb7 painb8 painb9
// Very quick fall down backward death
$frame death1 death2 death3 death4 death5 death6 death7 death8 death9
// A - Typical spit/spike firing from all arms
$frame shota1 shota2 shota3 shota4 shota5 shota6 shota7 shota8
$frame shota9 shota10 shota11
// B - Long spit/spike firing from all arms
$frame shotb1 shotb2 shotb3 shotb4 shotb5 shotb6 shotb7 shotb8
$frame shotb9 shotb10 shotb11 shotb12 shotb13 shotb14 shotb15 shotb16 shotb17
// C - Slowly flick all arms upward (big attack)
$frame shotc1 shotc2 shotc3 shotc4 shotc5 shotc6 shotc7 shotc8
$frame shotc9 shotc10 shotc11 shotc12 shotc13 shotc14 shotc15 shotc16
$frame shotc17 shotc18 shotc19 shotc20 shotc21 shotc22 shotc23
// Rise upward and flee from the scene
$frame flee1 flee2 flee3 flee4 flee5 flee6 flee7 flee8
$frame flee9 flee10 flee11 flee12 flee13 flee14 flee15 flee16
$frame flee17 flee18
// Long reveal of extra arms, pretending to be wizard at first
$frame reveal1 reveal2 reveal3 reveal4 reveal5 reveal6 reveal7 reveal8
$frame reveal9 reveal10 reveal11 reveal12 reveal13 reveal14 reveal15 reveal16
$frame reveal17 reveal18 reveal19 reveal20 reveal21 reveal22 reveal23 reveal24
$frame reveal25 reveal26 reveal27 reveal28 reveal29 reveal30 reveal31 reveal32
$frame reveal33 reveal34 reveal35 reveal36
float NOUR_PHASE0 = -1; // No boss wave/setup
float NOUR_PHASE1 = 1; // Intro = Burst through floor
float NOUR_PHASE2 = 2; // Fighting
float NOUR_PHASE3 = 3; // Summon mode
float NOUR_PHASE4 = 4; // Death
//======================================================================
// Global functions
//======================================================================
// Special streamlined player find function
//----------------------------------------------------------------------
float() nour_FindTarget =
{
local entity client;
// Get the obvious exception(s) done first
if (self.health < 1) return FALSE;
if (intermission_running > 0) return FALSE;
if (cinematic_running > 0) return FALSE;
// Find a client in current PVS
client = checkclient ();
// Go through all the exception(s)
if (!client) return FALSE;
if (!(client.flags & FL_CLIENT)) return FALSE;
if (client.flags & FL_NOTARGET) return FALSE;
if (client.items & IT_INVISIBILITY) return FALSE;
// Check range and visibility of player
enemy_vis = visible(client);
if (!enemy_vis) return FALSE;
//if (!infront(client)) return FALSE;
// Finally found something
self.enemy = client;
self.oldorigin = self.origin; // Save origin
self.goalentity = self.enemy; // Focus on enemy
// Setup turning angle towards new enemy
self.ideal_yaw = vectoyaw(self.enemy.origin - self.origin);
// We have a winner!
return TRUE;
};
//----------------------------------------------------------------------
// Setup wave HP and trigger boundaries
//----------------------------------------------------------------------
void() nour_WaveSetupHP =
{
// Is there anymore boss waves left?
if (self.bosswave >= self.bosswavetotal) {
// Only one wave left (death is final trigger)
self.health = self.bosswaveqty;
self.bosswavetrig = -1000;
}
else {
// Multiple waves are still left (reset hp+trigger)
// Always reset HP to stop high DPS weapons trashing waves boundaries
self.health = ((self.bosswavetotal - self.bosswave) + 1) * self.bosswaveqty;
// The wave trigger is always one wave lower
self.bosswavetrig = self.health - self.bosswaveqty;
}
// Debug messages for wave and health
dprint("\b[BOSS]\b Wave ("); dprint(ftos(self.bosswave));
dprint(" / "); dprint(ftos(self.bosswavetotal));
dprint(") HP ("); dprint(ftos(self.health));
dprint(") Trig ("); dprint(ftos(self.bosswavetrig));
dprint(")\n");
};
//----------------------------------------------------------------------
// Check if HP has reached next boss wave trigger event
//----------------------------------------------------------------------
float() nour_WaveCheck =
{
// Check for boss wave boundary event
if (self.health > 1 && self.health < self.bosswavetrig) {
// Check for wave boundary triggers
self.noise = "";
if (self.bosswave == 1) self.noise = self.noise1;
else if(self.bosswave == 2) self.noise = self.noise2;
else if(self.bosswave == 3) self.noise = self.noise3;
else if(self.bosswave == 4) self.noise = self.noise4;
// Is there any trigger for the wave boundary?
if (self.noise != "") trigger_strs(self.noise, self);
// Update Boss wave parameters (next wave!)
self.bosswave = self.bosswave + 1;
nour_WaveSetupHP();
self.style = NOUR_PHASE3; // Summon mode
return TRUE;
}
return FALSE;
};
//----------------------------------------------------------------------
// Check the tether system
//----------------------------------------------------------------------
float() nour_CheckTether =
{
local float currentdist;
// Check for boss mode
if (!(self.spawnflags & MON_NOUR_BOSS)) return FALSE;
currentdist = vlen(self.origin - self.movelast.origin);
// Check the most obvious first, inside tether range?
if (currentdist < self.tetherrange) return FALSE;
else {
// If player or tether close to each other?
if (infront(self.movelast) && infront(SUB_entEnemyTarget()) )
return FALSE;
// Stop moving around
else return TRUE;
}
};
//----------------------------------------------------------------------
// Nour game play logic
//----------------------------------------------------------------------
void() NourCheckAttack =
{
//----------------------------------------------------------------------
// setup enemytarget if one is not active
//----------------------------------------------------------------------
if (self.enemy.classtype != CT_ENEMYTARGET) {
if (SUB_setupEnemyTarget(self.enemy, self.height, MONAI_ABOVETIMER)) {
self.enemy = self.enemytarget;
}
}
//----------------------------------------------------------------------
// Check Melee range and constantly fire
//----------------------------------------------------------------------
if (self.enemydist < MONAI_MELEENOUR) {
self.attack_state = AS_MELEE;
return;
}
//----------------------------------------------------------------------
// Range attacks (Spit and Bomb)
// Attack_chance override (percentage 0-1 chance)
//----------------------------------------------------------------------
// Only range attack if cooldown has finished
if (time > self.attack_finished) {
// Fast/intense nail/spit attack
if (self.enemydist < MONAI_CLOSENOUR || self.attack_chance > random()) {
// Skill 0=3s, 1=2.25s, 2=1.5s, 3=0.75s
self.attack_speed = (4 - skill) * 0.75;
self.attack_finished = time + self.attack_speed + random();
self.attack_state = AS_MELEE;
return;
}
// Large rocket bomb attack with floor damage
else {
// Skill 0=4s, 1=3s, 2=2s, 3=1s
self.attack_speed = (4 - skill) * 1;
self.attack_finished = time + self.attack_speed + random();
self.attack_state = AS_MISSILE;
return;
}
}
//----------------------------------------------------------------------
// Maintain distance (strafe)
//----------------------------------------------------------------------
if (enemy_range >= RANGE_MID || !enemy_vis) {
if (self.attack_state != AS_STRAIGHT) self.attack_state = AS_STRAIGHT;
}
else self.attack_state = AS_SLIDING;
};
//======================================================================
// MONSTER STATES (stand, walk run, attack, pain and death!
//======================================================================
void() nour_stand1 =[ $idle1, nour_stand2] {monster_idle_sound();ai_stand();};
void() nour_stand2 =[ $idle2, nour_stand3] {ai_stand();};
void() nour_stand3 =[ $idle3, nour_stand4] {ai_stand();};
void() nour_stand4 =[ $idle4, nour_stand5] {ai_stand();};
void() nour_stand5 =[ $idle5, nour_stand6] {ai_stand();};
void() nour_stand6 =[ $idle6, nour_stand7] {ai_stand();};
void() nour_stand7 =[ $idle7, nour_stand8] {ai_stand();};
void() nour_stand8 =[ $idle8, nour_stand9] {ai_stand();};
void() nour_stand9 =[ $idle9, nour_stand10] {ai_stand();};
void() nour_stand10 =[ $idle10, nour_stand11] {ai_stand();};
void() nour_stand11 =[ $idle11, nour_stand1] {ai_stand();};
//======================================================================
void() nour_walk1 =[ $idle1, nour_walk2] {monster_idle_sound();ai_walk(8);};
void() nour_walk2 =[ $idle2, nour_walk3] {ai_walk(8);};
void() nour_walk3 =[ $idle3, nour_walk4] {ai_walk(8);};
void() nour_walk4 =[ $idle4, nour_walk5] {ai_walk(8);};
void() nour_walk5 =[ $idle5, nour_walk6] {ai_walk(8);};
void() nour_walk6 =[ $idle6, nour_walk7] {ai_walk(8);};
void() nour_walk7 =[ $idle7, nour_walk8] {ai_walk(8);};
void() nour_walk8 =[ $idle8, nour_walk9] {ai_walk(8);};
void() nour_walk9 =[ $idle9, nour_walk10] {ai_walk(8);};
void() nour_walk10 =[ $idle10, nour_walk11] {ai_walk(8);};
void() nour_walk11 =[ $idle11, nour_walk1] {ai_walk(8);};
//======================================================================
void() nour_slideframe =
{
// Check for boss mode (phase and wave check)
if (self.spawnflags & MON_NOUR_BOSS) {
if (self.style != NOUR_PHASE2) return;
// Check for boss wave trigger events
if (nour_WaveCheck() == TRUE) {self.th_summon(); return;}
}
// Dead monster?
if (self.health < 1) return;
if (self.walkframe == 0) monster_idle_sound();
// Move frame forward, check for conditions
self.walkframe = self.walkframe + 1;
if (self.walkframe > 10) self.walkframe = 0;
self.nextthink = time + 0.1;
self.think = nour_slideframe;
// Setup current animation frame
self.frame = $idle1 + self.walkframe;
self.ideal_yaw = vectoyaw(SUB_orgEnemyTarget() - self.origin);
// Check the BOSS tether system
if (nour_CheckTether()) ai_run(0);
else ai_run(8);
};
//----------------------------------------------------------------------
void() nour_slide1 = {self.walkframe = 0; nour_slideframe();};
//======================================================================
// RUN state - chasing the player
//======================================================================
void() nour_runframe =
{
// Check for boss mode (phase and wave check)
if (self.spawnflags & MON_NOUR_BOSS) {
if (self.style != NOUR_PHASE2) return;
// Check for boss wave trigger events
if (nour_WaveCheck() == TRUE) {self.th_summon(); return;}
}
if (self.health < 1) return;
if (self.walkframe == 0) monster_idle_sound();
// Move frame forward, check for conditions
self.walkframe = self.walkframe + 1;
if (self.walkframe > 12) self.walkframe = 0;
self.nextthink = time + 0.1;
self.think = nour_runframe;
// Setup current animation frame
self.frame = $fly1 + self.walkframe;
self.ideal_yaw = vectoyaw(SUB_orgEnemyTarget() - self.origin);
// Check the BOSS tether system
if (nour_CheckTether()) ai_run(0);
else ai_run(16);
};
//----------------------------------------------------------------------
void() nour_run1 = {self.walkframe = 0; nour_runframe();};
//============================================================================
// Attachment management (create, finish and delete)
//============================================================================
void() nour_create_attachment =
{
// Are the attachments setup yet?
if (!self.attachment) {
self.attachment = spawn();
self.attachment.owner = self;
self.attachment.classtype = CT_ATTACHMENT;
self.attachment.mdl = MODEL_PROJ_NOUR2B;
self.attachment.alpha = 0.85;
}
};
//----------------------------------------------------------------------
void() nour_finish_attachment =
{
if (self.attachment) {
setmodel(self.attachment, "");
self.attachment.state = STATE_OFF;
}
};
//----------------------------------------------------------------------
void() nour_remove_attachment =
{
if (self.attachment) {
self.attachment.think = SUB_Remove;
self.attachment.nextthink = time + 0.1;
}
}
//======================================================================
// ATTACK A - Fire multiple spit/spikes
// Block pain function from interrupting magic attack
//======================================================================
void(vector offset) nour_spike =
{
local vector dtarget, starget, ftarget, sorg, forg, dir;
if (!self.enemy) return;
if (self.health < 1) return;
self.effects = self.effects | EF_MUZZLEFLASH;
self.attack_speed = SPEED_NOURSPIKE + (skill * SPEED_NOURSKILL);
ai_face();
// Work out direction line from self to enemy
dtarget = SUB_orgEnemyTarget() - self.origin;
dtarget = vectoangles(dtarget);
makevectors (dtarget);
// Work out correct source/target origins
starget = self.origin + v_forward * 16 + v_up * offset_z;
ftarget = SUB_orgEnemyTarget() + '0 0 16';
// Add left/right offset
sorg = starget + v_right * offset_x;
forg = ftarget + v_right * offset_x;
dir = normalize(forg - sorg);
launch_projectile (sorg, dir, CT_PROJ_NOUR1, self.attack_speed);
sorg = starget - v_right * offset_x;
forg = ftarget - v_right * offset_x;
dir = normalize(forg - sorg);
launch_projectile (sorg, dir, CT_PROJ_NOUR1, self.attack_speed);
};
//----------------------------------------------------------------------
void() nour_atta1 =[ $shota1, nour_atta2] {ai_face();
self.pain_finished = time + 1;
sound (self, CHAN_WEAPON, "nour/attack1.wav", 1, ATTN_NORM);
};
void() nour_atta2 =[ $shota2, nour_atta3] {ai_face();};
void() nour_atta3 =[ $shota3, nour_atta4] {ai_face();};
void() nour_atta4 =[ $shota4, nour_atta5] {nour_spike('24,0,16');};
void() nour_atta5 =[ $shota5, nour_atta6] {nour_spike('20 0 8');};
void() nour_atta6 =[ $shota6, nour_atta7] {nour_spike('16 0 0');};
void() nour_atta7 =[ $shota7, nour_atta8] {nour_spike('12 0 -8');};
void() nour_atta8 =[ $shota8, nour_atta9] {nour_spike('8 0 -16');};
void() nour_atta9 =[ $shota9, nour_atta10] {};
void() nour_atta10 =[ $shota10, nour_atta11] {};
void() nour_atta11 =[ $shota11, nour_run1] {};
//======================================================================
// ATTACK B - Fire one large blob (grenade) of spit
//======================================================================
void(vector bombofs) Fire_NourBomb =
{
local vector org, torg, ang, dir, avel;
// Finished with bomb effect
nour_finish_attachment();
if (!self.enemy) return;
if (self.health < 1) return;
self.effects = self.effects | EF_MUZZLEFLASH;
sound (self, CHAN_WEAPON, "nour/attack1.wav", 1, ATTN_NORM);
ai_face();
makevectors(self.angles);
org = self.origin + attack_vector(bombofs);
torg = SUB_orgEnemyTarget();
self.attack_speed = SPEED_NOURBOMB;
self.attack_elev = SUB_Elevation(ELEV_DEFAULT, org, torg, self.attack_speed);
ang = vectoangles(torg - org);
ang_x = -self.attack_elev;
makevectors (ang);
dir = v_forward * self.attack_speed;
avel = vecrand(100,200,FALSE);
Launch_Grenade(org, dir, avel, CT_PROJ_NOUR2);
};
//----------------------------------------------------------------------
void(vector bombofs, float bombframe) Setup_NourBomb =
{
local vector org;
if (self.health < 1) return;
// Check if attachment has been setup yet
if (!self.attachment) nour_create_attachment();
// Frame 0 is start of the sequence (move everything into place)
if (bombframe == 0) {
self.attachment.state = STATE_ON;
setorigin(self.attachment, self.origin);
setmodel(self.attachment, self.attachment.mdl);
setsize (self.attachment, VEC_ORIGIN, VEC_ORIGIN);
self.attachment.movetype = MOVETYPE_NONE;
self.attachment.solid = SOLID_NOT;
self.attachment.skin = 0;
// Start growing bomb sound
sound (self, CHAN_WEAPON, "nour/attack2.wav", 1, ATTN_NORM);
}
// Turn towards enemy and update model attachment
// The offset is based on the nour facing forward
ai_face();
makevectors(self.angles);
org = self.origin + attack_vector(bombofs);
setorigin(self.attachment, org);
self.attachment.angles = self.angles;
self.attachment.angles_x = random()*360;
self.attachment.frame = bombframe;
// Random explosion like particles from ball as it grows
particle_explode(self.attachment.origin, 10+random()*10, 0.5+random(), PARTICLE_BURST_YELLOW, 0);
};
//----------------------------------------------------------------------
void() nour_attb1 =[ $shotb1, nour_attb2] {ai_face();
self.pain_finished = time + 1.5;
};
void() nour_attb2 =[ $shotb2, nour_attb3] {ai_face();};
void() nour_attb3 =[ $shotb3, nour_attb4] {ai_face();};
void() nour_attb4 =[ $shotb4, nour_attb5] {ai_face();};
void() nour_attb5 =[ $shotb5, nour_attb6] {Setup_NourBomb('24 0 0',0);};
void() nour_attb6 =[ $shotb6, nour_attb7] {Setup_NourBomb('24 0 -2',1);};
void() nour_attb7 =[ $shotb7, nour_attb8] {Setup_NourBomb('24 0 -4',2);};
void() nour_attb8 =[ $shotb8, nour_attb9] {Setup_NourBomb('24 0 -8',3);};
void() nour_attb9 =[ $shotb9, nour_attb10] {Setup_NourBomb('24 0 -12',4);};
void() nour_attb10 =[ $shotb10, nour_attb11] {Setup_NourBomb('24 0 -16',5);};
void() nour_attb11 =[ $shotb11, nour_attb12] {Setup_NourBomb('24 0 -12',6);};
void() nour_attb12 =[ $shotb12, nour_attb13] {Fire_NourBomb('24 0 -12');};
void() nour_attb13 =[ $shotb13, nour_attb14] {};
void() nour_attb14 =[ $shotb14, nour_attb15] {};
void() nour_attb15 =[ $shotb15, nour_attb16] {};
void() nour_attb16 =[ $shotb16, nour_attb17] {ai_face();};
void() nour_attb17 =[ $shotb17, nour_run1] {ai_face();};
//======================================================================
// ATTACK C - Summon wizards around boss
//======================================================================
void() Spawn_NourFog =
{
// Randomly pick from teleport sounds
self.lip = random() * 5;
if (self.lip < 1) self.noise = "misc/r_tele1.wav";
else if (self.lip < 2) self.noise = "misc/r_tele2.wav";
else if (self.lip < 3) self.noise = "misc/r_tele3.wav";
else if (self.lip < 4) self.noise = "misc/r_tele4.wav";
else self.noise = "misc/r_tele5.wav";
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
// Show ID teleport particle effect
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_TELEPORT);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
};
//----------------------------------------------------------------------
// Fire random plasma spikes while summoning wizard minions
//----------------------------------------------------------------------
void(vector minofs) Fire_NourPlasma =
{
local vector org;
makevectors(self.angles);
org = self.origin + attack_vector(minofs);
self.pos2 = vecrand(0,50,TRUE);
self.pos3 = normalize(self.pos2);
launch_plasma(org, self.pos3, CT_SUMMONLIGHT, SPEED_REFLECTION);
};
//----------------------------------------------------------------------
void(vector minofs) Spawn_NourMin =
{
// Finished with bomb effect
nour_finish_attachment();
Fire_NourPlasma(minofs);
// Cycle through spawn targets and spawn Tfog + Wizard
self.lip = self.attack_summon;
while(self.lip > 0) {
self.bossminchain.think = Spawn_NourFog;
self.bossminchain.nextthink = time + 0.01 + random()*0.3;
// If the spawn locaiton all clear, spawn something!
self.pos1 = self.bossminchain.origin;
self.aflag = find_minionspace(self.pos1);
if (self.aflag == TRUE) {
// Check for any spawnflags on spawn point
if (random() < 0.5)
minion_wizard(self.pos1, self.enemy, MON_WIZARD_ABOVE);
else minion_wizard(self.pos1, self.enemy, 0);
}
// Next spawn point
self.bossminchain = self.bossminchain.entchain;
self.lip = self.lip - 1;
}
};
//----------------------------------------------------------------------
void(vector minofs, float minframe) Setup_NourMin =
{
local vector org;
// Re-use the energy ball attachment for spawning lightning from
if (!self.attachment) nour_create_attachment();
// Frame 0 is start of the sequence (move everything into place)
if (minframe == 0) {
self.attachment.state = STATE_ON;
setorigin(self.attachment, self.origin);
setmodel(self.attachment, self.attachment.mdl);
setsize (self.attachment, VEC_ORIGIN, VEC_ORIGIN);
self.attachment.movetype = MOVETYPE_NONE;
self.attachment.solid = SOLID_NOT;
self.attachment.skin = 1;
// Start Spawning sound
sound (self, CHAN_WEAPON, "nour/attack2.wav", 1, ATTN_NORM);
}
// Move the energy ball into position infront of the nour
makevectors(self.angles);
org = self.origin + attack_vector(minofs);
setorigin(self.attachment, org);
self.attachment.angles = self.angles;
self.attachment.angles_x = random()*360;
self.attachment.frame = minframe;
// Slowly suck in particles to energy ball
particle_implode(org, 20+random()*20, 75, 75, PARTICLE_BURST_BLUE);
// Cycle through spawn targets and fire Lightning per frame
self.lip = self.attack_summon;
while(self.lip > 0) {
// Traceline from spawn point to random direction
self.pos1 = self.bossminchain.origin - org;
self.pos2 = vecrand(0,50,TRUE);
self.pos3 = normalize(self.pos1 + self.pos2);
traceline(org, org + self.pos3 * 600, FALSE, self);
// Create lightning bolt from source to target
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
WriteEntity (MSG_BROADCAST, self.bossminchain);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
WriteCoord (MSG_BROADCAST, trace_endpos_x);
WriteCoord (MSG_BROADCAST, trace_endpos_y);
WriteCoord (MSG_BROADCAST, trace_endpos_z);
// Play some arching lightning sounds
if (random() < 0.5) {
if (random() < 0.5) sound (self.bossminchain, CHAN_BODY, "nour/elec_arch1.wav", 1, ATTN_NORM);
else sound (self.bossminchain, CHAN_BODY, "nour/elec_arch2.wav", 1, ATTN_NORM);
}
// Next spawn point
self.bossminchain = self.bossminchain.entchain;
self.lip = self.lip - 1;
}
// Generate a random bolt of electricity
Fire_NourPlasma(minofs);
};
//----------------------------------------------------------------------
void() nour_attc1 =[ $shotc1, nour_attc2] {ai_face();
// Make sure boss mode active for this attack
if (!(self.spawnflags & MON_NOUR_BOSS)) { self.think = self.th_run; return; }
// Block all damage while summoning stuff
Resist_ChangeType(self, TRUE);
// Reset attack state so it does not keep spawning
self.attack_state = AS_STRAIGHT;
self.lip = self.attack_summon;
while (self.lip > 0) {
self.cnt = 4; // Try 4 times, no infinite loops
while (self.cnt > 0) {
// Work out 2 empty spaces around Nour for minions
self.pos2 = vecrand(self.bossminbase, self.bossminrnd, TRUE);
// Always spawn higher than boss
if (self.pos2_z < self.maxs_z) self.pos2_z = self.maxs_z;
self.pos1 = self.origin + self.pos2;
// Check for available space for mininon
self.aflag = find_minionspace(self.pos1);
self.cnt = self.cnt - 1;
// Space is right, save origin
if (self.aflag == TRUE) self.cnt = -10;
}
// Found space, store origin for later
if (self.cnt == -10) self.bossminchain.origin = self.pos1;
else self.bossminchain.origin = self.origin;
// Next spawn point
self.bossminchain = self.bossminchain.entchain;
self.lip = self.lip - 1;
}
};
void() nour_attc2 =[ $shotc2, nour_attc3] {ai_face();};
void() nour_attc3 =[ $shotc3, nour_attc4] {ai_face();};
void() nour_attc4 =[ $shotc4, nour_attc5] {Setup_NourMin('24 0 -24',0);};
void() nour_attc5 =[ $shotc5, nour_attc6] {Setup_NourMin('24 0 -24',1);};
void() nour_attc6 =[ $shotc6, nour_attc7] {Setup_NourMin('24 0 -22',2);};
void() nour_attc7 =[ $shotc7, nour_attc8] {Setup_NourMin('24 0 -20',3);};
void() nour_attc8 =[ $shotc8, nour_attc9] {Setup_NourMin('24 0 -16',4);};
void() nour_attc9 =[ $shotc9, nour_attc10] {Setup_NourMin('24 0 -16',5);};
void() nour_attc10 =[ $shotc10, nour_attc11] {Setup_NourMin('24 0 -12',6);};
void() nour_attc11 =[ $shotc11, nour_attc12] {Setup_NourMin('24 0 -8',6);};
void() nour_attc12 =[ $shotc12, nour_attc13] {Setup_NourMin('24 0 -4',7);};
void() nour_attc13 =[ $shotc13, nour_attc14] {Setup_NourMin('24 0 -2',7);};
void() nour_attc14 =[ $shotc14, nour_attc15] {Spawn_NourMin('24 0 0');};
void() nour_attc15 =[ $shotc15, nour_attc16] {Fire_NourPlasma('24 0 0');};
void() nour_attc16 =[ $shotc16, nour_attc17] {};
void() nour_attc17 =[ $shotc17, nour_attc18] {};
void() nour_attc18 =[ $shotc18, nour_attc19] {};
void() nour_attc19 =[ $shotc19, nour_attc20] {};
void() nour_attc20 =[ $shotc20, nour_attc21] {};
void() nour_attc21 =[ $shotc21, nour_attc22] {};
void() nour_attc22 =[ $shotc22, nour_attc23] {ai_face();};
void() nour_attc23 =[ $shotc23, nour_run1] {ai_face();
// Restore ammo resistance to default
Resist_ChangeType(self, FALSE);
self.style = NOUR_PHASE2; // Fight mode
};
//============================================================================
// PAIN and DEATH
//============================================================================
void() nour_paina1 = [ $paina1, nour_paina2 ] {};
void() nour_paina2 = [ $paina2, nour_paina3 ] {};
void() nour_paina3 = [ $paina3, nour_paina4 ] {};
void() nour_paina4 = [ $paina4, nour_paina5 ] {};
void() nour_paina5 = [ $paina5, nour_paina6 ] {};
void() nour_paina6 = [ $paina6, nour_run1 ] {};
//----------------------------------------------------------------------
void() nour_painb1 = [ $painb1, nour_painb2 ] {};
void() nour_painb2 = [ $painb2, nour_painb3 ] {};
void() nour_painb3 = [ $painb3, nour_painb4 ] {};
void() nour_painb4 = [ $painb4, nour_painb5 ] {};
void() nour_painb5 = [ $painb5, nour_painb6 ] {};
void() nour_painb6 = [ $painb6, nour_painb7 ] {};
void() nour_painb7 = [ $painb7, nour_painb8 ] {};
void() nour_painb8 = [ $painb8, nour_painb9 ] {};
void() nour_painb9 = [ $painb9, nour_run1 ] {};
//----------------------------------------------------------------------
void(entity inflictor, entity attacker, float damage) nour_pain =
{
// Finish with all attachments
nour_finish_attachment();
if (self.spawnflags & MON_NOUR_BOSS) {
// Check for boss wave trigger events
if (nour_WaveCheck() == TRUE) {self.th_summon(); return;}
}
// Check all pain conditions and set up what to do next
monster_pain_check(attacker, damage);
// Any pain animation/sound required?
if (self.pain_check > 0) {
sound (self, CHAN_VOICE, self.pain_sound, 1, ATTN_NORM);
if (self.pain_check == 1 || self.pain_check == 2) {
// Randomly pick which pain animation to play
if (random() < 0.8) nour_paina1 (); // Short recoil right
else {
nour_painb1 (); // Long recoil left
self.pain_finished = time + 2; // long animation
}
}
}
};
//============================================================================
// Death comes to us all, even Nour!
//============================================================================
void() nour_explode =
{
// Check for any final trigger events
if (self.message2 != "") trigger_strs(self.message2,self);
// No more Nour!
entity_hide(self);
// Blue ID particle explosion
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_EXPLOSION2);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
WriteByte (MSG_BROADCAST, 35);
WriteByte (MSG_BROADCAST, 8);
// Check for any death radius damage
if (self.death_dmg > 0)
T_RadiusDamage (self, self, self.death_dmg, world, DAMAGEALL);
// Classic sprite/DP explosion
SpawnExplosion(EXPLODE_PLASMA_BIG, self.origin, "nour/explode_death.wav");
// Gib explosive fountain!?!
self.max_health = MON_GIBEXPLOSION;
ThrowGib(11, 2); // Left Arm
ThrowGib(12, 2); // Right Arm
ThrowGib(13, 1); // Tail
ThrowGib(4, 10 + rint(random()*3));
ThrowGib(5, 10 + rint(random()*3));
};
//----------------------------------------------------------------------
void() nour_die1 = [ $death1, nour_die2 ] {};
void() nour_die2 = [ $death2, nour_die3 ] {};
void() nour_die3 = [ $death3, nour_die4 ] {self.solid = SOLID_NOT;};
void() nour_die4 = [ $death4, nour_die5 ] {};
void() nour_die5 = [ $death5, nour_die6 ] {};
void() nour_die6 = [ $death6, nour_die7 ] {};
void() nour_die7 = [ $death7, nour_die8 ] {};
void() nour_die8 = [ $death8, nour_die9 ] {self.lip = 0;};
void() nour_die9 = [ $death9, nour_die9 ] {
// Spawn implosion effect
if (random() < 0.5)
particle_implode(self.origin, 20+random()*20, 100, 100, PARTICLE_BURST_BLUE);
// Spawn particle smoke and explosive smoke
else {
SpawnProjectileSmoke(self.origin, 150, 100, 300);
particle_dust(self.origin, 10+random()*10, 16, PARTICLE_BURST_BLUE);
}
// Check for any random lightning strikes outward
if (random() < 0.5) {
self.pos1 = self.origin - '0 0 16';
self.pos2 = vecrand(0,50,TRUE);
self.pos2_z = 25 + random()*25; // Always up!
self.pos3 = normalize(self.pos2);
traceline(self.pos1, self.pos1 + self.pos3 * 600, FALSE, self);
// Create lightning bolt
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
WriteEntity (MSG_BROADCAST, self);
WriteCoord (MSG_BROADCAST, self.origin_x);
WriteCoord (MSG_BROADCAST, self.origin_y);
WriteCoord (MSG_BROADCAST, self.origin_z);
WriteCoord (MSG_BROADCAST, trace_endpos_x);
WriteCoord (MSG_BROADCAST, trace_endpos_y);
WriteCoord (MSG_BROADCAST, trace_endpos_z);
// Play some arching lightning sounds
if (random() < 0.5) {
if (random() < 0.5) sound (self, CHAN_BODY, "nour/elec_arch1.wav", 1, ATTN_NORM);
else sound (self, CHAN_BODY, "nour/elec_arch2.wav", 1, ATTN_NORM);
}
}
// Check for a random bolt of plasma
if (random() < 0.2) Fire_NourPlasma('0 0 -16');
// Cycle through end phase
self.lip = self.lip + 1;
if (self.lip == 26) sound (self, CHAN_AUTO, "nour/implode_death.wav", 1, ATTN_NONE);
if (self.lip == 40) nour_explode();
};
//----------------------------------------------------------------------
void() nour_die =
{
dprint("[NOUR] Dying State ("); dprint(ftos(self.style));
dprint(") HP ("); dprint(ftos(self.health));
dprint(")\n");
self.deadflag = DEAD_DEAD; // Nour bites the dust
self.effects = 0; // Remove effects on death
nour_finish_attachment(); // Remove any attachments
nour_remove_attachment();
sound (self, CHAN_VOICE, "nour/death.wav", 1, ATTN_NORM);
self.velocity_x = -200 + 400*random();
self.velocity_y = -200 + 400*random();
self.velocity_z = 100 + 100*random();
self.flags = self.flags - (self.flags & FL_ONGROUND);
nour_die1 ();
};
//======================================================================
// Create wizard minion entity chain
// Entities are created so that the spawning space can be tested
// before spawning the minions for possible collisions
//======================================================================
float() nour_minionsetup =
{
local entity min_prev, min_first;
self.lip = self.attack_summon;
min_prev = min_first = world;
// Cycle through minion list
while(self.lip > 0) {
newmis = spawn();
newmis.origin = self.origin;
newmis.owner = self;
// Is this the first pass through loop?
if (!min_first) min_first = newmis;
// Any previous entities created?
if (!min_prev) min_prev = newmis;
else {
// Link previous to current entity
// and move previous forward in chain
min_prev.entchain = newmis;
min_prev = newmis;
}
// Keep on looping
self.lip = self.lip - 1;
}
// Close loop
if (min_first) {
newmis.entchain = min_first;
self.bossminchain = min_first;
return FALSE;
}
else return TRUE;
};
//----------------------------------------------------------------------
void() nour_spawntether =
{
// temporary tether point
self.movelast = spawn();
self.movelast.owner = self;
self.movelast.classtype = CT_TETHERENT;
self.movelast.movetype = MOVETYPE_NONE;
self.movelast.solid = SOLID_NOT;
self.movelast.origin = self.origin;
setsize (self.movelast, VEC_ORIGIN, VEC_ORIGIN);
};
//======================================================================
// REVEAL PHASE (coming out of the ground)
//======================================================================
void() nour_readyframe =
{
self.walkframe = 0; // Reset just in case
self.height = MONAI_ABOVEDIST; // Enemytarget distance above
self.movetype = MOVETYPE_STEP; // back to regular movement
self.takedamage = DAMAGE_AIM; // Can take damage
self.style = NOUR_PHASE2; // Time to fight!
Resist_ChangeType(self,FALSE); // restore resistance
if (self.enemy) self.th_run(); // Hunt the player
else self.th_stand(); // Wait for the player
};
//----------------------------------------------------------------------
void() nour_revealframe =
{
// Beginning of animation block
if (self.walkframe == 3)
sound (self, CHAN_BODY, "nour/reveal.wav", 1, ATTN_NORM);
else if (self.walkframe == 23)
sound (self, CHAN_VOICE, self.idle_sound, 1, ATTN_NORM);
if (self.movetarget2 != world) {
// Work out remaining distance to go
self.movedir = self.movetarget2.origin - self.origin;
self.t_length = vlen(self.movedir);
// Calc initial velocity boast (burst action)
self.lip = (self.pausetime - time) / 3.6;
self.t_width = 1 + (self.lip/2);
// If time or distance too small, stop moving
if (self.lip < 0.1 || self.t_length < 2) {
self.velocity = '0 0 0';
}
// Update velocity every frame
else self.velocity = self.movedir * self.t_width;
}
// Turn towards player
if (self.enemy) ai_face();
// Move frame forward, check for conditions
self.walkframe = self.walkframe + 1;
self.nextthink = time + 0.1;
// Time to exit reveal?
if (self.walkframe > 35) nour_readyframe();
else {
self.think = nour_revealframe;
// Setup current animation frame
self.frame = $reveal1 + self.walkframe;
}
};
//======================================================================
// Setup BOSS Nour after trigger event
//======================================================================
void() nour_awake =
{
// make sure boss mode selected
if (!(self.spawnflags & MON_NOUR_BOSS)) return;
self.use = SUB_Null; // No more triggers
self.style = NOUR_PHASE1; // Bursting intro sequence
self.flags = FL_MONSTER | FL_FLY; // Reset flag (no user settings)
self.frame = $idle1; self.skin = self.exactskin;
monster_bbox(); // Setup bounding box
self.noinfighting = TRUE; // No infighting
self.takedamage = DAMAGE_NO; // Still immune to damage
self.yaw_speed = 20; // Average Speed
self.velocity = '0 0 0'; // Make sure stationary
self.walkframe = 0; // reset for animation
self.attack_summon = skill + 1; // Total amount of minions
if (self.tetherrange < 32) self.tetherrange = MONAI_MAXNOUR;
if (self.bossminbase <= 64) self.bossminbase = MONAI_BOSS_SUMDIST;
if (self.bossminrnd <= 64) self.bossminrnd = MONAI_BOSS_SUMRND;
// skill modifier : Easy = 1, Normal = 2, Hard/NM = 3
if (self.attack_summon > 3) self.attack_summon = 3;
// Setup minion chain entity system
if (nour_minionsetup()) {
dprint("\b[NOUR]\b Cannot create minion chain!\n");
spawn_marker(self.origin+'0 0 32', SPNMARK_YELLOW);
entity_hide(self);
return;
}
// Check for tether system (special target field)
if (self.tethertarget == "") {
dprint("\b[NOUR]\b Generated tetherpoint!\n");
nour_spawntether();
}
// Find the defined tether marker
else self.movelast = find(world,targetname,self.tethertarget);
// Does the tether entity exist?
if (!self.movelast) {
dprint("\b[NOUR]\b Tether target not found!\n");
spawn_marker(self.origin, SPNMARK_YELLOW);
entity_hide(self);
return;
}
// Show BOSS tetherpoint
spawn_marker(self.movelast.origin+'0 0 8', SPNMARK_RED);
// If message2 is not defined?
if (self.message2 == "") {
// No movement towards a reveal location
self.movetarget2 = world;