Repository navigation
Expand file tree
/
Copy pathwl_act2.cpp
More file actions
3567 lines (3027 loc) · 113 KB
/
Copy pathwl_act2.cpp
File metadata and controls
3567 lines (3027 loc) · 113 KB
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
// WL_ACT2.C
#include <stdio.h>
#include <math.h>
#include "wl_def.h"
#pragma hdrstop
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#define PROJECTILESIZE 0xc000l
#define BJROCKETSIZE 0x6000l
#define ROCKETEXPLSIZE 0x20000l
#define BARRELEXPLSIZE 0x35000l
#define BJRUNSPEED 2048
#define BJJUMPSPEED 680
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
dirtype dirtable[9] = {northwest,north,northeast,west,nodir,east,
southwest,south,southeast};
short starthitpoints[5][NUMENEMIES] =
//
// BABY MODE
//
{
{
40, // Guard
80, // Officer
140, // SS
20, // Suicide Clone
80, // Regular Clone
5, // Spectre (snowman, ghost flame)
2150, // Angel of Death
1450, // Grau (hell)
1150, // Superclone
1450, // Otto
1650, // Baron Von Schmitt (hell)
1150, // Ultraclone
1250, // Robot
1650, // Heinrich
400, // Turret
35, // Expl. Barrel
50 // Breakable Column
},
//
// DON'T HURT ME MODE
//
{
45, // Guard
85, // Officer
155, // SS
20, // Suicide Clone
90, // Mutants
10, // Spectre (snowman, ghost flame)
2250, // Angel of Death
1550, // Grau (hell)
1250, // Superclone
1550, // Otto
1750, // Baron Von Schmitt (hell)
1250, // Ultraclone
1350, // Robot
1750, // Heinrich
400, // Turret
35, // Expl. Barrel
50 // Breakable Column
},
//
// BRING 'EM ON MODE
//
{
55, // Guard
95, // Officer
165, // SS
35, // Suicide Clone
105, // Mutants
15, // Spectre (snowman, ghost flame)
2350, // Angel of Death
1650, // Grau (hell)
1350, // Superclone
1550, // Otto
1850, // Baron Von Schmitt (hell)
1350, // Ultraclone
1450, // Robot
1850, // Heinrich
400, // Turret
35, // Expl. Barrel
50 // Breakable Column
},
//
// DEATH INCARNATE MODE
//
{
65, // Guard
105, // Officer
175, // SS
50, // Suicide Clone
115, // Mutants
25, // Spectre (snowman, ghost flame)
3825, // Angel of Death
1550, // Grau (hell)
1250, // Superclone
1650, // Otto
1750, // Baron Von Schmitt (hell)
1250, // Ultraclone
1350, // Robot
1750, // Heinrich
400, // Turret
35, // Expl. Barrel
50 // Breakable Column
},
//
// Tournament
//
{
65, // Guard
105, // Officer
175, // SS
50, // Suicide Clone
115, // Mutants
25, // Spectre (snowman, ghost flame)
3825, // Angel of Death
1550, // Grau (hell)
1250, // Superclone
1650, // Otto
1750, // Baron Von Schmitt (hell)
1250, // Ultraclone
1350, // Robot
1750, // Heinrich
400, // Turret
35, // Expl. Barrel
50 // Breakable Column
}
};
// --- [ TRANSFORMATIONS ] --------------------------------
void T_Path (objtype *ob);
void T_Shoot (objtype *ob);
void T_Launch (objtype *ob);
void T_SuicideChase (objtype *ob);
void T_Chase (objtype *ob);
void T_Otto (objtype *ob);
void T_Projectile (objtype *ob);
void T_Stand (objtype *ob);
void T_Scan (objtype *ob);
void T_Blink (objtype *ob);
void T_BlinkReset (objtype *ob);
void T_Ghosts (objtype *ob);
void T_ResFlags(objtype *ob);
void T_Trigger (objtype *ob);
void T_Defuse (objtype *ob);
// --- [ ACTIONS ] ----------------------------------------
void A_Dormant (objtype *ob);
void A_DeathScream (objtype *ob);
void A_Explode (objtype *ob);
void A_Splat (objtype *ob);
void A_Smoke (objtype *ob);
void A_Slurpie (objtype *ob);
// --- [ ENEMY BONUS OBJECTS ] ----------------------------
void CheckEnemyTile (objtype *ob);
void RemoveObject (statobj_t *check);
void GetEnemyBonus (statobj_t *objpos, objtype *ob);
// --- [ ENEMY SPAWN TRIGGERS ] ---------------------------
void SpawnTriggeredActors(enemy_t which, int targetTile);
void A_SpawnNextBoss(objtype *ob);
// --- [ FIREWALL ROUTINE ] -------------------------------
void ShootFireballs(int tilex, int tiley, int dir);
#ifdef EODSPECIAL
void CheckGong(void);
#endif
/*
=================================================================================
=
= Projectile & Explosion statetypes
=
=================================================================================
*/
extern statetype s_rocket;
extern statetype s_smoke1;
extern statetype s_smoke2;
extern statetype s_smoke3;
extern statetype s_smoke4;
extern statetype s_boom2;
extern statetype s_boom3;
extern statetype s_fireball;
extern statetype s_firetrail1;
extern statetype s_firetrail2;
extern statetype s_firetrail3;
extern statetype s_firetrail4;
extern statetype s_fireexpl1;
extern statetype s_fireexpl2;
extern statetype s_fireexpl3;
extern statetype s_spearproj;
extern statetype s_speartrail1;
extern statetype s_speartrail2;
extern statetype s_speartrail3;
extern statetype s_speartrail4;
extern statetype s_spearexpl1;
extern statetype s_spearexpl2;
extern statetype s_spearexpl3;
extern statetype s_flametrail1;
extern statetype s_flametrail2;
extern statetype s_flametrail3;
extern statetype s_flametrail4;
// --- [ REGULAR ROCKET STATETYPES ]
statetype s_rocket = {true,SPR_ROCKET_1,3,(statefunc)T_Projectile,(statefunc)A_Smoke,&s_rocket,true};
statetype s_smoke1 = {false,SPR_SMOKE_1,3,NULL,NULL,&s_smoke2,false};
statetype s_smoke2 = {false,SPR_SMOKE_2,3,NULL,NULL,&s_smoke3,false};
statetype s_smoke3 = {false,SPR_SMOKE_3,3,NULL,NULL,&s_smoke4,false};
statetype s_smoke4 = {false,SPR_SMOKE_4,3,NULL,NULL,NULL,false};
statetype s_boom1 = {false,SPR_BOOM_1,6,NULL,NULL,&s_boom2,true};
statetype s_boom2 = {false,SPR_BOOM_2,6,NULL,NULL,&s_boom3,true};
statetype s_boom3 = {false,SPR_BOOM_3,6,NULL,NULL,NULL,true};
// --- [ FIREBALL STATETYPES ]
statetype s_fireball = {true,SPR_FIREBALL_1,3,(statefunc)T_Projectile,(statefunc)A_Smoke,&s_fireball,true};
statetype s_firetrail1 = {false,SPR_FIREBALL_TRAIL1,3,NULL,NULL,&s_firetrail2,true};
statetype s_firetrail2 = {false,SPR_FIREBALL_TRAIL2,3,NULL,NULL,&s_firetrail3,true};
statetype s_firetrail3 = {false,SPR_FIREBALL_TRAIL3,3,NULL,NULL,&s_firetrail4,true};
statetype s_firetrail4 = {false,SPR_FIREBALL_TRAIL4,3,NULL,NULL,NULL,true};
statetype s_fireexpl1 = {false,SPR_FIREBALL_EXP1,6,NULL,NULL,&s_fireexpl2,true};
statetype s_fireexpl2 = {false,SPR_FIREBALL_EXP2,6,NULL,NULL,&s_fireexpl3,true};
statetype s_fireexpl3 = {false,SPR_FIREBALL_EXP3,6,NULL,NULL,NULL,true};
// --- [ SPEAR STATETYPES ]
statetype s_spearproj = {true,SPR_SPEARPROJ_1,3,(statefunc)T_Projectile,(statefunc)A_Smoke,&s_spearproj,true};
statetype s_speartrail1 = {false,SPR_SPEARPROJ_TRAIL1,3,NULL,NULL,&s_speartrail2,true};
statetype s_speartrail2 = {false,SPR_SPEARPROJ_TRAIL2,3,NULL,NULL,&s_speartrail3,true};
statetype s_speartrail3 = {false,SPR_SPEARPROJ_TRAIL3,3,NULL,NULL,&s_speartrail4,true};
statetype s_speartrail4 = {false,SPR_SPEARPROJ_TRAIL4,3,NULL,NULL,NULL,true};
statetype s_spearexpl1 = {false,SPR_SPEARPROJ_EXP1,6,NULL,NULL,&s_spearexpl2,true};
statetype s_spearexpl2 = {false,SPR_SPEARPROJ_EXP2,6,NULL,NULL,&s_spearexpl3,true};
statetype s_spearexpl3 = {false,SPR_SPEARPROJ_EXP3,6,NULL,NULL,NULL,true};
// --- [ FLAME TRAIL STATETYPES ]
statetype s_flametrail1 = {false,SPR_FLAME2_DIE1,3,NULL,NULL,&s_flametrail2,true};
statetype s_flametrail2 = {false,SPR_FLAME2_DIE2,3,NULL,NULL,&s_flametrail3,true};
statetype s_flametrail3 = {false,SPR_FLAME2_DIE3,3,NULL,NULL,&s_flametrail4,true};
statetype s_flametrail4 = {false,SPR_FLAME2_DIE4,3,NULL,NULL,NULL,true};
// --- [ HIGH FIREBALL STATETYPES ]
extern statetype s_hrocket;
extern statetype s_hsmoke1;
extern statetype s_hsmoke2;
extern statetype s_hsmoke3;
extern statetype s_hsmoke4;
extern statetype s_hboom2;
extern statetype s_hboom3;
statetype s_hrocket = {true,SPR_HROCKET_1,3,(statefunc)T_Projectile,(statefunc)A_Smoke,&s_hrocket,true};
statetype s_hsmoke1 = {false,SPR_HSMOKE_1,3,NULL,NULL,&s_hsmoke2,true};
statetype s_hsmoke2 = {false,SPR_HSMOKE_2,3,NULL,NULL,&s_hsmoke3,true};
statetype s_hsmoke3 = {false,SPR_HSMOKE_3,3,NULL,NULL,&s_hsmoke4,true};
statetype s_hsmoke4 = {false,SPR_HSMOKE_4,3,NULL,NULL,NULL,true};
statetype s_hboom1 = {false,SPR_HBOOM_1,6,NULL,NULL,&s_hboom2,true};
statetype s_hboom2 = {false,SPR_HBOOM_2,6,NULL,NULL,&s_hboom3,true};
statetype s_hboom3 = {false,SPR_HBOOM_3,6,NULL,NULL,NULL,true};
/*
=================================================================================
=
= Projectile & Explosion Stuff
=
=================================================================================
*/
int Damage (int32_t dx, int32_t dy, int32_t range, int32_t max)
{
double ddx = (double) dx ;
double ddy = (double) dy ;
double drange = (double) range ;
double dmax = (double) max ;
double distance = sqrt (ddx * ddx + ddy * ddy) ;
if (distance > drange)
return 0 ;
else
return (int) (dmax - distance / drange * dmax) ;
}
/*
==================
=
= A_Explode
=
==================
*/
void A_Explode(objtype *ob)
{
int32_t explosionSize;
int32_t deltax, deltay;
objtype *extracheck;
int damage;
switch (ob->obclass) {
case barrelobj:
explosionSize = BARRELEXPLSIZE;
PlaySoundLocActor(BARRELEXPSND,ob);
break;
case rocketobj:
explosionSize = ROCKETEXPLSIZE;
PlaySoundLocActor(LANDMINESND,ob);
break;
case suicideobj:
gamestate.killcount++;
ob->flags &= ~FL_SHOOTABLE;
explosionSize = BARRELEXPLSIZE;
PlaySoundLocActor(LONGEXPLOSIONSND,ob);
break;
default:
explosionSize = ROCKETEXPLSIZE;
break;
}
//madenoise = true;
extracheck = objlist;
while (extracheck)
{
if ( extracheck != ob // skip the projectile // skip bosses (doesnt skip superclones)
&& (extracheck->flags & FL_SHOOTABLE)
&& ( (ob->creator != playerobj && !(extracheck->flags & FL_BOSS) ) || ( (ob->creator == playerobj) && CheckLine2(extracheck,ob) ) ) // player created explosions use checkline, actor created explosions don't - this is for ACTOR damage, not player damage.
)
{
deltax = LABS(ob->x - extracheck->x);
deltay = LABS(ob->y - extracheck->y);
if (deltax < explosionSize * 2 && deltay < explosionSize * 2) {
damage = Damage (deltax, deltay, explosionSize, 300);
if (damage > 0)
DamageActor (extracheck, damage);
}
}
extracheck = extracheck->next;
}
deltax = LABS(ob->x - player->x);
deltay = LABS(ob->y - player->y);
if (deltax < explosionSize * 2 && deltay < explosionSize * 2 && CheckLine(ob)) {
damage = Damage (deltax, deltay, explosionSize, (US_RndT()>>3) + 30);
damage += (ob->obclass == barrelobj ? 15 : 0);
if (damage > 0)
TakeDamage (damage, ob);
}
}
/*
=================
=
= A_Smoke
=
=================
*/
void A_Smoke (objtype *ob)
{
GetNewActor ();
switch (ob->obclass) {
case rocketobj:
newobj->state = &s_smoke1;
break;
case hrocketobj:
newobj->state = &s_hsmoke1;
break;
case fireballobj:
newobj->state = &s_firetrail1;
break;
case spearprojobj:
newobj->state = &s_speartrail1;
break;
case sparkobj:
newobj->state = &s_flametrail1;
break;
}
newobj->ticcount = 6;
newobj->tilex = ob->tilex;
newobj->tiley = ob->tiley;
newobj->x = ob->x;
newobj->y = ob->y;
newobj->obclass = inertobj;
newobj->active = ac_yes;
newobj->flags = FL_NEVERMARK;
}
/*
===================
=
= ProjectileTryMove
=
= returns true if move ok
===================
*/
#define PROJSIZE 0x2000
boolean ProjectileTryMove (objtype *ob)
{
int xl,yl,xh,yh,x,y;
objtype *check;
int32_t deltax, deltay;
xl = (ob->x-PROJSIZE) >> TILESHIFT;
yl = (ob->y-PROJSIZE) >> TILESHIFT;
xh = (ob->x+PROJSIZE) >> TILESHIFT;
yh = (ob->y+PROJSIZE) >> TILESHIFT;
//
// check for solid walls
//
for (y=yl;y<=yh;y++)
for (x=xl;x<=xh;x++)
{
check = actorat[x][y];
if (ob->obclass == fireballobj && check == (objtype *)(uintptr_t)SHOOTERTILE)
return true; // fireballs emerge from the wall
if (check && !ISPOINTER(check))
return false;
}
//
// check for actors
//
for (check=player->next;check;check=check->next)
if (check->flags & FL_SHOOTABLE && ob->creator != check->obclass)
{
if (check->flags & FL_IMMUNE)
return true;
deltax = check->x - ob->x;
deltay = check->y - ob->y;
if ((LABS(deltax)<PROJECTILESIZE)&&(LABS(deltay)<PROJECTILESIZE)) {
switch (ob->obclass) {
case fireballobj:
check->flags |= FL_GIB;
KillActor(check);
if ((check->flags & FL_BOSS) || check->obclass == supercloneobj || check->obclass == columnobj || check->obclass == barrelobj)
return true;
else
return false;
case spearprojobj:
DamageActor(check,100);
return false;
default:
if (ob->creator != playerobj && !(check->flags & FL_BOSS)) { // enemy created projectiles
check->flags |= FL_GIB;
KillActor(check);
if (check->obclass == columnobj)
return true;
else
return false;
} else if (ob->creator != playerobj) { // Boss
return true;
} else
return false; // A_Explode will deal damage
}
}
}
return true;
}
/*
=================
=
= T_Projectile
=
=================
*/
void T_Projectile (objtype *ob)
{
int32_t deltax,deltay;
int damage;
int32_t speed;
speed = (int32_t)ob->speed*tics;
deltax = FixedMul(speed,costable[ob->angle]);
deltay = -FixedMul(speed,sintable[ob->angle]);
if (deltax>0x10000l)
deltax = 0x10000l;
if (deltay>0x10000l)
deltay = 0x10000l;
ob->x += deltax;
ob->y += deltay;
// Hit a wall or actor (NOT PLAYER)
if (!ProjectileTryMove (ob))
{
switch (ob->obclass) {
case rocketobj:
ob->state = &s_boom1;
A_Explode(ob);
break;
case hrocketobj: // fireballs
PlaySoundLocActor(MISSILEHITSND,ob);
ob->state = &s_hboom1;
break;
case fireballobj:
ob->state = &s_fireexpl1;
break;
case spearprojobj:
PlaySoundLocActor(MISSILEHITSND,ob);
ob->state = &s_spearexpl1;
break;
default:
ob->state = NULL;
break;
}
return;
}
// Check if player hit by anything
deltax = LABS(ob->x - player->x);
deltay = LABS(ob->y - player->y);
if (deltax < PROJECTILESIZE && deltay < PROJECTILESIZE && ob->creator != playerobj)
{ // hit the player
damage = (US_RndT() >> 3) + 30;
TakeDamage (damage,ob);
ob->state = NULL; // mark for removal
return;
}
ob->tilex = ob->x >> TILESHIFT;
ob->tiley = ob->y >> TILESHIFT;
}
/*
===============
=
= ShootFireballs
=
===============
*/
int sdirs[4][2]={{0,-1},{1,0},{0,1},{-1,0}};
void ShootFireballs() {
for (int i = 0; i < MAXFIREWALLS; i++)
{
if (!fwall[i].active || MAPSPOT(fwall[i].tilex, fwall[i].tiley, 0) != SHOOTERTILE)
continue;
if (fwall[i].tics > 0) {
fwall[i].tics -= tics;
continue;
}
for (int d = NORTH; d <= WEST; d++) { // these walls are 4 way shooters
if (MAPSPOT(fwall[i].tilex + sdirs[d][0],fwall[i].tiley + sdirs[d][1],0) >= AREATILE)
{
GetNewActor ();
newobj->state = &s_fireball;
newobj->ticcount = 1;
newobj->tilex = fwall[i].tilex;
newobj->tiley = fwall[i].tiley;
newobj->x = ((int32_t)fwall[i].tilex<<TILESHIFT)+(TILEGLOBAL>>1);
newobj->y = ((int32_t)fwall[i].tiley<<TILESHIFT)+(TILEGLOBAL>>1);
newobj->obclass = fireballobj;
switch (d) {
case EAST:
newobj->angle = 0;
break;
case NORTH:
newobj->angle = 90;
break;
case WEST:
newobj->angle = 180;
break;
case SOUTH:
newobj->angle = 270;
break;
}
newobj->speed = 0x2500l;
newobj->flags = FL_NEVERMARK;
newobj->active = ac_yes;
}
}
fwall[i].tics = FIREWALLDELAY;
}
}
// ------------------------------------------------------------------
/*
====================
=
= TakeRandomDamage (FROM SR CODE)
=
====================
*/
void TakeRandomDamage (int x, int y)
{
switch (gamestate.difficulty)
{
case gd_easy:
TakeDamage (x + (US_RndT()%y),NULL);
break;
case gd_medium:
TakeDamage ((x + 5) + (US_RndT()%y),NULL);
break;
default: //MCS: skill level 1 damage will be divided by 4
TakeDamage ((x + 10) + (US_RndT()%(y*2)),NULL);
}
return;
}
/*
===========================================
=
= GUARD
=
===========================================
*/
extern statetype s_grdstand;
extern statetype s_grdpath1;
extern statetype s_grdpath1s;
extern statetype s_grdpath2;
extern statetype s_grdpath3;
extern statetype s_grdpath3s;
extern statetype s_grdpath4;
extern statetype s_grdpain;
extern statetype s_grdpain1;
extern statetype s_grdshoot1;
extern statetype s_grdshoot2;
extern statetype s_grdshoot3;
extern statetype s_grdshoot4;
extern statetype s_grdchase1;
extern statetype s_grdchase1s;
extern statetype s_grdchase2;
extern statetype s_grdchase3;
extern statetype s_grdchase3s;
extern statetype s_grdchase4;
extern statetype s_grddie1;
extern statetype s_grddie1d;
extern statetype s_grddie2;
extern statetype s_grddie3;
extern statetype s_grddie4;
statetype s_grdstand = {true,SPR_GRD_S_1,0,(statefunc)T_Stand,NULL,&s_grdstand,false};
statetype s_grdpath1 = {true,SPR_GRD_W1_1,20,(statefunc)T_Path,NULL,&s_grdpath1s,false};
statetype s_grdpath1s = {true,SPR_GRD_W1_1,5,NULL,NULL,&s_grdpath2,false};
statetype s_grdpath2 = {true,SPR_GRD_W2_1,15,(statefunc)T_Path,NULL,&s_grdpath3,false};
statetype s_grdpath3 = {true,SPR_GRD_W3_1,20,(statefunc)T_Path,NULL,&s_grdpath3s,false};
statetype s_grdpath3s = {true,SPR_GRD_W3_1,5,NULL,NULL,&s_grdpath4,false};
statetype s_grdpath4 = {true,SPR_GRD_W4_1,15,(statefunc)T_Path,NULL,&s_grdpath1,false};
statetype s_grdpain = {2,SPR_GRD_PAIN_1,10,NULL,NULL,&s_grdchase1,false};
statetype s_grdpain1 = {2,SPR_GRD_PAIN_2,10,NULL,NULL,&s_grdchase1,false};
statetype s_grdshoot1 = {false,SPR_GRD_SHOOT1,20,NULL,NULL,&s_grdshoot2,false};
statetype s_grdshoot2 = {false,SPR_GRD_SHOOT2,20,NULL,(statefunc)T_Shoot,&s_grdshoot3,false};
statetype s_grdshoot3 = {false,SPR_GRD_SHOOT3,20,NULL,NULL,&s_grdchase1,true};
statetype s_grdchase1 = {true,SPR_GRD_W1_1,10,(statefunc)T_Chase,NULL,&s_grdchase1s,false};
statetype s_grdchase1s = {true,SPR_GRD_W1_1,3,NULL,NULL,&s_grdchase2,false};
statetype s_grdchase2 = {true,SPR_GRD_W2_1,8,(statefunc)T_Chase,NULL,&s_grdchase3,false};
statetype s_grdchase3 = {true,SPR_GRD_W3_1,10,(statefunc)T_Chase,NULL,&s_grdchase3s,false};
statetype s_grdchase3s = {true,SPR_GRD_W3_1,3,NULL,NULL,&s_grdchase4,false};
statetype s_grdchase4 = {true,SPR_GRD_W4_1,8,(statefunc)T_Chase,NULL,&s_grdchase1,false};
statetype s_grddie1 = {false,SPR_GRD_DIE_1,15,NULL,(statefunc)A_DeathScream,&s_grddie2,false};
statetype s_grddie2 = {false,SPR_GRD_DIE_2,15,NULL,NULL,&s_grddie3,false};
statetype s_grddie3 = {false,SPR_GRD_DIE_3,15,NULL,NULL,&s_grddie4,false};
statetype s_grddie4 = {false,SPR_GRD_DEAD,0,NULL,NULL,&s_grddie4,false};
// ----------------------------------------
/*
===========================================
=
= SUICIDE CLONES
=
===========================================
*/
extern statetype s_suicidestand;
extern statetype s_suicidepath1;
extern statetype s_suicidepath1s;
extern statetype s_suicidepath2;
extern statetype s_suicidepath3;
extern statetype s_suicidepath3s;
extern statetype s_suicidepath4;
extern statetype s_suicidetrigger1;
extern statetype s_suicidetrigger2;
extern statetype s_suicidetrigger3;
extern statetype s_suicidetrigger4;
extern statetype s_suicidetrigger5;
extern statetype s_suicidechase1;
extern statetype s_suicidechase1s;
extern statetype s_suicidechase2;
extern statetype s_suicidechase3;
extern statetype s_suicidechase3s;
extern statetype s_suicidechase4;
extern statetype s_suicidedie0;
extern statetype s_suicidedie1;
extern statetype s_suicidedie2;
extern statetype s_suicidedie3;
extern statetype s_suicidedead;
statetype s_suicidestand = {true,SPR_SCLONE_W1_1,0,(statefunc)T_Stand,NULL,&s_suicidestand,false};
statetype s_suicidepath1 = {true,SPR_SCLONE_W1_1,20,(statefunc)T_Path,NULL,&s_suicidepath1s,false};
statetype s_suicidepath1s = {true,SPR_SCLONE_W1_1,5,NULL,NULL,&s_suicidepath2,false};
statetype s_suicidepath2 = {true,SPR_SCLONE_W2_1,15,(statefunc)T_Path,NULL,&s_suicidepath3,false};
statetype s_suicidepath3 = {true,SPR_SCLONE_W3_1,20,(statefunc)T_Path,NULL,&s_suicidepath3s,false};
statetype s_suicidepath3s = {true,SPR_SCLONE_W3_1,5,NULL,NULL,&s_suicidepath4,false};
statetype s_suicidepath4 = {true,SPR_SCLONE_W4_1,15,(statefunc)T_Path,NULL,&s_suicidepath1,false};
statetype s_suicidetrigger1 = {false,SPR_SCLONE_JUMP1,10,NULL,NULL,&s_suicidetrigger2,false};
statetype s_suicidetrigger2 = {false,SPR_SCLONE_JUMP2,10,NULL,(statefunc)T_Trigger,&s_suicidetrigger3,false};
statetype s_suicidetrigger3 = {false,SPR_SCLONE_JUMP3,10,NULL,NULL,&s_suicidetrigger4,false};
statetype s_suicidetrigger4 = {false,SPR_SCLONE_JUMP1,10,(statefunc)T_Defuse,NULL,&s_suicidedie1,false};
statetype s_suicidechase1 = {true,SPR_SCLONE_W1_1,10,(statefunc)T_SuicideChase,NULL,&s_suicidechase1s,false};
statetype s_suicidechase1s = {true,SPR_SCLONE_W1_1,3,NULL,NULL,&s_suicidechase2,false};
statetype s_suicidechase2 = {true,SPR_SCLONE_W2_1,8,(statefunc)T_SuicideChase,NULL,&s_suicidechase3,false};
statetype s_suicidechase3 = {true,SPR_SCLONE_W3_1,10,(statefunc)T_SuicideChase,NULL,&s_suicidechase3s,false};
statetype s_suicidechase3s = {true,SPR_SCLONE_W3_1,3,NULL,NULL,&s_suicidechase4,false};
statetype s_suicidechase4 = {true,SPR_SCLONE_W4_1,8,(statefunc)T_SuicideChase,NULL,&s_suicidechase1,false};
statetype s_suicidedie1 = {false,SPR_SCLONE_DIE_1,10,NULL,(statefunc)A_Explode,&s_suicidedie2,true};
statetype s_suicidedie2 = {false,SPR_SCLONE_DIE_2,10,NULL,NULL,&s_suicidedie3,false};
statetype s_suicidedie3 = {false,SPR_SCLONE_DIE_3,10,NULL,NULL,&s_suicidedead,false};
statetype s_suicidedead = {false,SPR_SCLONE_DEAD,0,NULL,NULL,&s_suicidedead,false};
/*
=================
=
= T_SuicideChase
=
=================
*/
void T_SuicideChase (objtype *ob)
{
int32_t move;
int dx,dy;
boolean dodge;
if (gamestate.victoryflag)
return;
dodge = false;
if (CheckLine(ob)) // got a shot at player?
{
ob->hidden = false;
dodge = true;
}
else
ob->hidden = true;
if (ob->dir == nodir)
{
if (dodge)
SelectDodgeDir (ob);
else
SelectChaseDir (ob);
if (ob->dir == nodir)
return; // object is blocked in
}
move = ob->speed*tics;
while (move)
{
dx = player->x - ob->x;
if (dx<0)
dx = -dx;
dx -= move;
if (dx <= MINACTORDIST)
{
dy = player->y - ob->y;
if (dy<0)
dy = -dy;
dy -= move;
if (dy <= MINACTORDIST)
{
if (ob->temp2 == -1)
NewState(ob,&s_suicidedie1);
else
NewState (ob,&s_suicidetrigger1);
return;
}
}
if (move < ob->distance)
{
MoveObj (ob,move);
break;
}
//
// reached goal tile, so select another one
//
//
// fix position to account for round off during moving
//
ob->x = ((int32_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
ob->y = ((int32_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
move -= ob->distance;
CheckEnemyTile(ob);
#ifdef EODSPECIAL
if (gamestate.mapon == 30 && !gamestate.gong) {
SelectLootDir(ob);
} else {
#endif
if (dodge)
SelectDodgeDir (ob);
else
SelectChaseDir (ob);
#ifdef EODSPECIAL
}
#endif
if (ob->dir == nodir)
return; // object is blocked in
}
}
/*
================
=
= T_Trigger
=
================
*/
void T_Trigger (objtype *ob) {
SD_PlaySound(BOMBTRIGGERSND);
}
/*
================
=
= T_Defuse
=
================
*/
void T_Defuse (objtype *ob) {
int32_t deltax = abs(player->x - ob->x) - TILEGLOBAL;
int32_t deltay = abs(player->y - ob->y) - TILEGLOBAL;
if (deltax > MINACTORDIST || deltay > MINACTORDIST) {
ob->temp2 = -1;
NewState(ob,&s_suicidechase1);
}
}
// ----------------------------------------
/*
===========================================
=
= OFFICER
=
===========================================
*/
extern statetype s_ofcstand;
extern statetype s_ofcpath1;
extern statetype s_ofcpath1s;
extern statetype s_ofcpath2;
extern statetype s_ofcpath3;
extern statetype s_ofcpath3s;
extern statetype s_ofcpath4;
extern statetype s_ofcpain;
extern statetype s_ofcpain1;
extern statetype s_ofcgiveup;
extern statetype s_ofcshoot1;
extern statetype s_ofcshoot2;
extern statetype s_ofcshoot3;
extern statetype s_ofcshoot4;
extern statetype s_ofcchase1;
extern statetype s_ofcchase1s;
extern statetype s_ofcchase2;
extern statetype s_ofcchase3;
extern statetype s_ofcchase3s;
extern statetype s_ofcchase4;
extern statetype s_ofcdie1;
extern statetype s_ofcdie2;
extern statetype s_ofcdie3;
extern statetype s_ofcdie4;
extern statetype s_ofcdie5;
statetype s_ofcstand = {true,SPR_OFC_S_1,0,(statefunc)T_Stand,NULL,&s_ofcstand,false};
statetype s_ofcpath1 = {true,SPR_OFC_W1_1,20,(statefunc)T_Path,NULL,&s_ofcpath1s,false};
statetype s_ofcpath1s = {true,SPR_OFC_W1_1,5,NULL,NULL,&s_ofcpath2,false};
statetype s_ofcpath2 = {true,SPR_OFC_W2_1,15,(statefunc)T_Path,NULL,&s_ofcpath3,false};
statetype s_ofcpath3 = {true,SPR_OFC_W3_1,20,(statefunc)T_Path,NULL,&s_ofcpath3s,false};
statetype s_ofcpath3s = {true,SPR_OFC_W3_1,5,NULL,NULL,&s_ofcpath4,false};
statetype s_ofcpath4 = {true,SPR_OFC_W4_1,15,(statefunc)T_Path,NULL,&s_ofcpath1,false};
statetype s_ofcpain = {2,SPR_OFC_PAIN_1,10,NULL,NULL,&s_ofcchase1,false};
statetype s_ofcpain1 = {2,SPR_OFC_PAIN_2,10,NULL,NULL,&s_ofcchase1,false};
statetype s_ofcshoot1 = {false,SPR_OFC_SHOOT1,6,NULL,NULL,&s_ofcshoot2,false};
statetype s_ofcshoot2 = {false,SPR_OFC_SHOOT2,20,NULL,(statefunc)T_Shoot,&s_ofcshoot3,false};
statetype s_ofcshoot3 = {false,SPR_OFC_SHOOT3,10,NULL,NULL,&s_ofcchase1,true};
statetype s_ofcchase1 = {true,SPR_OFC_W1_1,10,(statefunc)T_Chase,NULL,&s_ofcchase1s,false};
statetype s_ofcchase1s = {true,SPR_OFC_W1_1,3,NULL,NULL,&s_ofcchase2,false};
statetype s_ofcchase2 = {true,SPR_OFC_W2_1,8,(statefunc)T_Chase,NULL,&s_ofcchase3,false};
statetype s_ofcchase3 = {true,SPR_OFC_W3_1,10,(statefunc)T_Chase,NULL,&s_ofcchase3s,false};
statetype s_ofcchase3s = {true,SPR_OFC_W3_1,3,NULL,NULL,&s_ofcchase4,false};
statetype s_ofcchase4 = {true,SPR_OFC_W4_1,8,(statefunc)T_Chase,NULL,&s_ofcchase1,false};
statetype s_ofcdie1 = {false,SPR_OFC_DIE_1,11,NULL,(statefunc)A_DeathScream,&s_ofcdie2,false};
statetype s_ofcdie2 = {false,SPR_OFC_DIE_2,11,NULL,NULL,&s_ofcdie3,false};
statetype s_ofcdie3 = {false,SPR_OFC_DIE_3,11,NULL,NULL,&s_ofcdie4,false};
statetype s_ofcdie4 = {false,SPR_OFC_DIE_4,11,NULL,NULL,&s_ofcdie5,false};
statetype s_ofcdie5 = {false,SPR_OFC_DEAD,0,NULL,NULL,&s_ofcdie5,false};
// ----------------------------------------
/*
===========================================
=
= REGULAR CLONE
=