-
Notifications
You must be signed in to change notification settings - Fork 522
/
korax.zs
545 lines (486 loc) · 11.1 KB
/
korax.zs
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
//===========================================================================
// Korax Variables
// tracer last teleport destination
// special2 set if "below half" script not yet run
//
// Korax Scripts (reserved)
// 249 Tell scripts that we are below half health
// 250-254 Control scripts (254 is only used when less than half health)
// 255 Death script
//
// Korax TIDs (reserved)
// 245 Reserved for Korax himself
// 248 Initial teleport destination
// 249 Teleport destination
// 250-254 For use in respective control scripts
// 255 For use in death script (spawn spots)
//===========================================================================
class Korax : Actor
{
const KORAX_ARM_EXTENSION_SHORT = 40;
const KORAX_ARM_EXTENSION_LONG = 55;
const KORAX_ARM1_HEIGHT = 108;
const KORAX_ARM2_HEIGHT = 82;
const KORAX_ARM3_HEIGHT = 54;
const KORAX_ARM4_HEIGHT = 104;
const KORAX_ARM5_HEIGHT = 86;
const KORAX_ARM6_HEIGHT = 53;
const KORAX_FIRST_TELEPORT_TID = 248;
const KORAX_TELEPORT_TID = 249;
const KORAX_DELTAANGLE = 85;
const KORAX_COMMAND_HEIGHT = 120;
const KORAX_COMMAND_OFFSET = 27;
//const KORAX_SPIRIT_LIFETIME = 5*TICRATE/5; // 5 seconds
Default
{
Health 5000;
Painchance 20;
Speed 10;
Radius 65;
Height 115;
Mass 2000;
Damage 15;
Monster;
+BOSS
+FLOORCLIP
+TELESTOMP
+DONTMORPH
+NOTARGET
+NOICEDEATH
SeeSound "KoraxSight";
AttackSound "KoraxAttack";
PainSound "KoraxPain";
DeathSound "KoraxDeath";
ActiveSound "KoraxActive";
Obituary "$OB_KORAX";
Tag "$FN_KORAX";
}
States
{
Spawn:
KORX A 5 A_Look;
Loop;
See:
KORX AAA 3 A_KoraxChase;
KORX B 3 A_Chase;
KORX BBB 3 A_KoraxChase;
KORX C 3 A_KoraxStep;
KORX CCC 3 A_KoraxChase;
KORX D 3 A_Chase;
KORX DDD 3 A_KoraxChase;
KORX A 3 A_KoraxStep;
Loop;
Pain:
KORX H 5 A_Pain;
KORX H 5;
Goto See;
Missile:
KORX E 2 Bright A_FaceTarget;
KORX E 5 Bright A_KoraxDecide;
Wait;
Death:
KORX I 5;
KORX J 5 A_FaceTarget;
KORX K 5 A_Scream;
KORX LMNOP 5;
KORX Q 10;
KORX R 5 A_KoraxBonePop;
KORX S 5 A_NoBlocking;
KORX TU 5;
KORX V -1;
Stop;
Attack:
KORX E 4 Bright A_FaceTarget;
KORX F 8 Bright A_KoraxMissile;
KORX E 8 Bright;
Goto See;
Command:
KORX E 5 Bright A_FaceTarget;
KORX W 10 Bright A_FaceTarget;
KORX G 15 Bright A_KoraxCommand;
KORX W 10 Bright;
KORX E 5 Bright;
Goto See;
}
void A_KoraxStep()
{
A_StartSound("KoraxStep");
A_Chase();
}
//============================================================================
//
// A_KoraxChase
//
//============================================================================
void A_KoraxChase()
{
if ((!special2) && (health <= (SpawnHealth()/2)))
{
ActorIterator it = Level.CreateActorIterator(KORAX_FIRST_TELEPORT_TID);
Actor spot = it.Next ();
if (spot != null)
{
Teleport ((spot.pos.xy, ONFLOORZ), spot.angle, TELF_SOURCEFOG | TELF_DESTFOG);
}
ACS_Execute(249, 0);
special2 = 1; // Don't run again
return;
}
if (target == null)
{
return;
}
if (random[KoraxChase]() < 30)
{
SetState (MissileState);
}
else if (random[KoraxChase]() < 30)
{
A_StartSound("KoraxActive", CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE);
}
// Teleport away
if (health < (SpawnHealth() >> 1))
{
if (random[KoraxChase]() < 10)
{
ActorIterator it = Level.CreateActorIterator(KORAX_TELEPORT_TID);
Actor spot;
if (tracer != null)
{ // Find the previous teleport destination
do
{
spot = it.Next ();
} while (spot != null && spot != tracer);
}
// Go to the next teleport destination
spot = it.Next ();
tracer = spot;
if (spot)
{
Teleport ((spot.pos.xy, ONFLOORZ), spot.angle, TELF_SOURCEFOG | TELF_DESTFOG);
}
}
}
}
//============================================================================
//
// A_KoraxDecide
//
//============================================================================
void A_KoraxDecide()
{
if (random[KoraxDecide]() < 220)
{
SetStateLabel ("Attack");
}
else
{
SetStateLabel ("Command");
}
}
//============================================================================
//
// A_KoraxBonePop
//
//============================================================================
void A_KoraxBonePop()
{
// Spawn 6 spirits equalangularly
for (int i = 0; i < 6; ++i)
{
Actor mo = SpawnMissileAngle ("KoraxSpirit", 60.*i, 5.);
if (mo)
{
KSpiritInit (mo);
}
}
ACS_Execute(255, 0);
}
//============================================================================
//
// KSpiritInit
//
//============================================================================
private void KSpiritInit (Actor spirit)
{
spirit.health = (5*GameTicRate/5) /*KORAX_SPIRIT_LIFETIME*/;
spirit.tracer = self; // Swarm around korax
spirit.WeaveIndexZ = random[Kspiritnit](32, 39); // Float bob index
spirit.args[0] = 10; // initial turn value
spirit.args[1] = 0; // initial look angle
// Spawn a tail for spirit
HolyTail.SpawnSpiritTail (spirit);
}
//============================================================================
//
// A_KoraxMissile
//
//============================================================================
void A_KoraxMissile()
{
if (!target)
{
return;
}
static const class<Actor> choices[] =
{
"WraithFX1", "Demon1FX1", "Demon2FX1", "FireDemonMissile", "CentaurFX", "SerpentFX"
};
static const sound sounds[] =
{
"WraithMissileFire", "DemonMissileFire", "DemonMissileFire", "FireDemonAttack", "CentaurLeaderAttack", "SerpentLeaderAttack"
};
int type = random[KoraxMissile](0, 5);
A_StartSound("KoraxAttack", CHAN_VOICE);
// Fire all 6 missiles at once
A_StartSound(sounds[type], CHAN_WEAPON, CHANF_DEFAULT, 1., ATTN_NONE);
class<Actor> info = choices[type];
for (int i = 0; i < 6; ++i)
{
KoraxFire(info, i);
}
}
//============================================================================
//
// KoraxFire
//
// Arm projectiles
// arm positions numbered:
// 1 top left
// 2 middle left
// 3 lower left
// 4 top right
// 5 middle right
// 6 lower right
//
//============================================================================
void KoraxFire (Class<Actor> type, int arm)
{
if (!target)
{
return;
}
static const int extension[] =
{
KORAX_ARM_EXTENSION_SHORT,
KORAX_ARM_EXTENSION_LONG,
KORAX_ARM_EXTENSION_LONG,
KORAX_ARM_EXTENSION_SHORT,
KORAX_ARM_EXTENSION_LONG,
KORAX_ARM_EXTENSION_LONG
};
static const int armheight[] =
{
KORAX_ARM1_HEIGHT,
KORAX_ARM2_HEIGHT,
KORAX_ARM3_HEIGHT,
KORAX_ARM4_HEIGHT,
KORAX_ARM5_HEIGHT,
KORAX_ARM6_HEIGHT
};
double ang = angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE);
Vector3 pos = Vec3Angle(extension[arm], ang, armheight[arm] - Floorclip);
SpawnKoraxMissile (pos, target, type);
}
//============================================================================
//
// P_SpawnKoraxMissile
//
//============================================================================
private void SpawnKoraxMissile (Vector3 pos, Actor dest, Class<Actor> type)
{
Actor th = Spawn (type, pos, ALLOW_REPLACE);
if (th != null)
{
th.target = self; // Originator
double an = th.AngleTo(dest);
if (dest.bShadow)
{ // Invisible target
an += Random2[KoraxMissile]() * (45/256.);
}
th.angle = an;
th.VelFromAngle();
double dist = dest.DistanceBySpeed(th, th.Speed);
th.Vel.Z = (dest.pos.z - pos.Z + 30) / dist;
th.CheckMissileSpawn(radius);
}
}
//============================================================================
//
// A_KoraxCommand
//
// Call action code scripts (250-254)
//
//============================================================================
void A_KoraxCommand()
{
int numcommands;
A_StartSound("KoraxCommand", CHAN_VOICE);
// Shoot stream of lightning to ceiling
double ang = angle - 90;
Vector3 pos = Vec3Angle(KORAX_COMMAND_OFFSET, ang, KORAX_COMMAND_HEIGHT);
Spawn("KoraxBolt", pos, ALLOW_REPLACE);
if (health <= (SpawnHealth() >> 1))
{
numcommands = 4;
}
else
{
numcommands = 3;
}
ACS_Execute(250 + (random[KoraxCommand](0, numcommands)), 0);
}
}
class KoraxSpirit : Actor
{
Default
{
Speed 8;
Projectile;
+NOCLIP
-ACTIVATEPCROSS
-ACTIVATEIMPACT
RenderStyle "Translucent";
Alpha 0.4;
}
States
{
Spawn:
SPIR AB 5 A_KSpiritRoam;
Loop;
Death:
SPIR DEFGHI 5;
Stop;
}
//============================================================================
//
// A_KSpiritSeeker
//
//============================================================================
private void KSpiritSeeker (double thresh, double turnMax)
{
Actor target = tracer;
if (target == null)
{
return;
}
double dir = deltaangle(angle, AngleTo(target));
double delta = abs(dir);
if (delta > thresh)
{
delta /= 2;
if(delta > turnMax)
{
delta = turnMax;
}
}
if(dir > 0)
{ // Turn clockwise
angle += delta;
}
else
{ // Turn counter clockwise
angle -= delta;
}
VelFromAngle();
if (!(Level.maptime&15)
|| pos.z > target.pos.z + target.Default.Height
|| pos.z + height < target.pos.z)
{
double newZ = target.pos.z + random[KoraxRoam]() * target.Default.Height / 256;
double deltaZ = newZ - pos.z;
if (abs(deltaZ) > 15)
{
if(deltaZ > 0)
{
deltaZ = 15;
}
else
{
deltaZ = -15;
}
}
Vel.Z = deltaZ + DistanceBySpeed(target, Speed);
}
}
//============================================================================
//
// A_KSpiritRoam
//
//============================================================================
void A_KSpiritRoam()
{
if (health-- <= 0)
{
A_StartSound("SpiritDie", CHAN_VOICE);
SetStateLabel ("Death");
}
else
{
if (tracer)
{
KSpiritSeeker(args[0], args[0] * 2.);
}
int xyspeed = random[KoraxRoam](0, 4);
int zspeed = random[KoraxRoam](0, 4);
A_Weave(xyspeed, zspeed, 4., 2.);
if (random[KoraxRoam]() < 50)
{
A_StartSound("SpiritActive", CHAN_VOICE, CHANF_DEFAULT, 1., ATTN_NONE);
}
}
}
}
class KoraxBolt : Actor
{
const KORAX_BOLT_HEIGHT = 48.;
const KORAX_BOLT_LIFETIME = 3;
Default
{
Radius 15;
Height 35;
Projectile;
-ACTIVATEPCROSS
-ACTIVATEIMPACT
RenderStyle "Add";
}
States
{
Spawn:
MLFX I 2 Bright;
MLFX J 2 Bright A_KBoltRaise;
MLFX IJKLM 2 Bright A_KBolt;
Stop;
}
//============================================================================
//
// A_KBolt
//
//============================================================================
void A_KBolt()
{
// Countdown lifetime
if (special1-- <= 0)
{
Destroy ();
}
}
//============================================================================
//
// A_KBoltRaise
//
//============================================================================
void A_KBoltRaise()
{
// Spawn a child upward
double z = pos.z + KORAX_BOLT_HEIGHT;
if ((z + KORAX_BOLT_HEIGHT) < ceilingz)
{
Actor mo = Spawn("KoraxBolt", (pos.xy, z), ALLOW_REPLACE);
if (mo)
{
mo.special1 = KORAX_BOLT_LIFETIME;
}
}
}
}