-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path3D_ACT2.C
6007 lines (4902 loc) · 155 KB
/
3D_ACT2.C
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
// 3D_ACT2.C
#include "3D_DEF.H"
#pragma hdrstop
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#define EXPODE_STATIC_SCAN (true)
#define BFG_SHOT_STOPS (true)
#define TURNTICS 10
#define SPDPATROL 512
#define SPDPROJ 7168
#define PROJSIZE 0x8000l // collision with actor range
#define PROJCHECKSIZE 0x8000l // scan for actor range
#define PROJWALLSIZE 0x2000l // collision with wall range
#define PROJECTILESIZE 0xc000l
#define BJRUNSPEED 2048
#define BJJUMPSPEED 680
#define SEEK_TURN_DELAY 30 // tics
#define CLOSE_RANGE 1 // Tiles
#define ALIENSPEED (SPDPATROL)
#define ALIENAMMOINIT (30+(US_RndT()%60))
#define GR_DAMAGE (40+(US_RndT() & 0x7f)) // 20 & 3f
#define BFG_DAMAGE (GR_DAMAGE<<1) // Hit Point damage cause by BFG
#define PLASMA_DETONATOR_DAMAGE (500)
#define DETONATOR_FLASH_RATE (20)
#define EXPLODE_DAMAGE (20) // 5
#define OOZE_ANIMATE_SPEED (20)
#define VPOST_BARRIER_SPEED (7) // Tics per anim step
#define VPOST_WAIT_DELAY (90) // Tics delay in cycling
#define DR_MIN_STATICS (50) // Min number of statics avail
// before 50/50 chance of door rubble on exp. doors.
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
char detonators_spawned = 0;
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
int far starthitpoints[4][NUMHITENEMIES] =
//
// BABY MODE
//
{
{4, // Rent-A-Cop
4, // Hang Terrot
4, // general scientist
22, // pod alien
13, // Electro-Alien
1, // Electro-Sphere
33, // ProGuard
20, // Genetic Guard
24, // Mutant Human Type 1
24, // Mutant Human Type 2
1, // Large Canister Alien - CONTAINER HP
34, // Large Can-Alien - ALIEN HP
1, // Small Canister Alien - CONTAINER HP
25, // Small Can-Alien - ALIEN HP
1, // Gurney Mutant - Waiting HP
27, // Gurney Mutant - Spawned HP
30, // Liquid Alien -
78, // Swat Guards
90, // Goldstern
4000, // Morphed Goldstern
17, // Volatile Material Transport
15, // Floating Bomb
175, // Vital Defence Obj - DON'T CHANGE
60, // spider_mutant
65, // breather_beast
70, // cyborg_warror
65, // reptilian_warrior
60, // acid_dragon
65, // mech_guardian
1600, // final_boss 1
1700, // final_boss 2
1800, // final_boss 3
1900, // final_boss 4
1, // Crate 1
1, // Crate 2
1, // Crate 3
1, // Pod egg
1, // morphing_spider_mutant
1, // morphing_reptilian_warrior
1, // morphing_Mutant Human Type 2
},
//
// DON'T HURT ME MODE
//
{9, // Rent-A-Cop
9, // Hang Terrot
9, // general scientist
60, // pod alien
37, // Electro-Alien
1, // Electro-Sphere
63, // ProGuard
60, // Genetic Guard
50, // Mutant Human Type 1
50, // Mutant Human Type 2
1, // Large Canister Alien - CONTAINER HP
75, // Large Can-Alien - ALIEN HP
1, // Small Canister Alien - CONTAINER HP
60, // Small Can-Alien - ALIEN HP
1, // Gurney Mutant - Waiting HP
37, // Gurney Mutant - Spawned HP
66, // Liquid Alien -
112, // SWAT Guards
100, // Goldstern
4500, // Morphed Goldstern
25, // Volatile Material Transport
40, // Floating Bomb
175, // Vital Defence Obj - DON'T CHANGE
100, // spider_mutant
115, // breather_beast
100, // cyborg_warror
115, // reptilian_warrior
100, // acid_dragon
115, // mech_guardian
1700, // final_boss 1
1800, // final_boss 2
1900, // final_boss 3
2000, // final_boss 4
1, // Crate 1
1, // Crate 2
1, // Crate 3
1, // Pod egg
1, // morphing_spider_mutant
1, // morphing_reptilian_warrior
1, // morphing_Mutant Human Type 2
},
//
// BRING 'EM ON MODE
//
{25, // Rent-A-Cop
23, // Hang Terrot
23, // general scientist
160, // pod alien
112, // Electro-Alien
1, // Electro-Sphere
150, // ProGuard
180, // Genetic Guard
155, // Mutant Human Type 1
155, // Mutant Human Type 2
1, // Large Canister Alien - CONTAINER HP
225, // Large Can-Alien - ALIEN HP
1, // Small Canister Alien - CONTAINER HP
180, // Small Can-Alien - ALIEN HP
1, // Gurney Mutant - Waiting HP
150, // Gurney Mutant - Spawned HP
163, // Liquid Alien -
325, // SWAT Guards
150, // Goldstern
4800, // Morphed Goldstern
63, // Volatile Material Transport
60, // Floating Bomb
175, // Vital Defence Obj - DON'T CHANGE
150, // spider_mutant
165, // breather_beast
150, // cyborg_warror
165, // reptilian_warrior
150, // acid_dragon
165, // mech_guardian
1800, // final_boss 1
1900, // final_boss 2
2000, // final_boss 3
2100, // final_boss 4
1, // Crate 1
1, // Crate 2
1, // Crate 3
1, // Pod egg
1, // morphing_spider_mutant
1, // morphing_reptilian_warrior
1, // morphing_Mutant Human Type 2
},
//
// DEATH INCARNATE MODE
//
{38, // Rent-A-Cop
28, // Hang Terrot
28, // general scientist
210, // pod alien
150, // Electro-Alien
1, // Electro-Sphere
175, // ProGuard
240, // Genetic Guard
210, // Mutant Human Type 1
210, // Mutant Human Type 2
1, // Large Canister Alien - CONTAINER HP
300, // Large Can-Alien - ALIEN HP
1, // Small Canister Alien - CONTAINER HP
240, // Small Can-Alien - ALIEN HP
1, // Gurney Mutant - Waiting HP
200, // Gurney Mutant - Spawned HP
210, // Liquid Alien -
425, // SWAT Gaurds
250, // Goldstern
5400, // Morphed Goldstern
75, // Volatile Material Transport
85, // Floating Bomb
175, // Vital Defence Obj - DON'T CHANGE
200, // spider_mutant
225, // breather_beast
200, // cyborg_warror
225, // reptilian_warrior
200, // acid_dragon
225, // mech_guardian
1900, // final_boss 1
2000, // final_boss 2
2100, // final_boss 3
2200, // final_boss 4
1, // Crate 1
1, // Crate 2
1, // Crate 3
1, // Pod egg
1, // morphing_spider_mutant
1, // morphing_reptilian_warrior
1, // morphing_Mutant Human Type 2
}
};
unsigned far BossShotShapes[] = {SPR_BOSS1_PROJ1,0,0,0,SPR_BOSS5_PROJ1,0,0,SPR_BOSS10_SPIT1};
unsigned far BossShapes[] = {SPR_BOSS1_W1,SPR_BOSS2_W1,SPR_BOSS3_W1,SPR_BOSS4_W1,SPR_BOSS5_W1,SPR_BOSS6_W1,SPR_BOSS7_W1,SPR_BOSS8_W1,SPR_BOSS9_W1,SPR_BOSS10_W1};
unsigned far MorphShapes[] = {SPR_BOSS1_MORPH1, SPR_BOSS4_MORPH1, SPR_MUTHUM2_MORPH1};
unsigned far MorphClass[] = {spider_mutantobj,reptilian_warriorobj,mutant_human2obj};
unsigned far MorphEndShapes[] = {SPR_BOSS1_W1,SPR_BOSS4_W1,SPR_MUTHUM2_W1};
char far MorphSounds[] = {SCANHALTSND,GGUARDHALTSND,DOGBOYHALTSND};
unsigned bars_connected = 0;
unsigned SpecialSpawnFlags[] = {FL2_DROP_RKEY,FL2_DROP_YKEY,FL2_DROP_BKEY,
FL2_DROP_BFG,FL2_DROP_ION,FL2_DROP_DETONATOR};
void T_Path (objtype *ob);
void T_Shoot (objtype *ob);
void T_Shade(objtype *obj);
void T_Chase (objtype *ob);
void T_Projectile (objtype *ob);
void T_Stand (objtype *ob);
void T_OfsThink(objtype *obj);
void T_OfsChase(objtype *obj);
void A_DeathScream (objtype *ob);
int RandomSphereDir(enemy_t dir);
void CheckForcedMove(objtype *ob);
void T_SwatWound(objtype *ob);
void T_SpaceShip(objtype *ob);
void T_BlowBack(objtype *obj);
void DoAttack(objtype *ob);
boolean MoveTrappedDiag(objtype *ob);
boolean CheckTrappedDiag(objtype *ob);
void ChangeShootMode(objtype *ob);
//===========================================================================
//
// OFFSET OBJECT ROUTINES
//
// * NOTES: OffsetObjects require the use of TEMP1 of the object structure!
//
// * NOTES: THINK function AnimateOfsObj() requires the use of TEMP3 of the
// object structure!
//
//===========================================================================
//
// Local Externs
//
extern statetype s_ofs_stand;
extern statetype s_ofs_chase1;
extern statetype s_ofs_chase1s;
extern statetype s_ofs_chase2;
extern statetype s_ofs_chase3;
extern statetype s_ofs_chase3s;
extern statetype s_ofs_chase4;
extern statetype s_ofs_pain;
extern statetype s_ofs_die1;
extern statetype s_ofs_die1s;
extern statetype s_ofs_die2;
extern statetype s_ofs_die3;
extern statetype s_ofs_die4;
extern statetype s_ofs_die5;
extern statetype s_ofs_attack1;
extern statetype s_ofs_attack2;
extern statetype s_ofs_attack3;
extern statetype s_ofs_spit1;
extern statetype s_ofs_spit2;
extern statetype s_ofs_spit3;
extern statetype s_ofs_shoot1;
extern statetype s_ofs_shoot2;
extern statetype s_ofs_shoot3;
extern statetype s_ofs_shoot4;
extern statetype s_ofs_shoot5;
extern statetype s_ofs_shoot6;
extern statetype s_ofs_shoot7;
extern statetype s_ofs_smart_anim;
extern statetype s_ofs_smart_anim2;
extern statetype s_ofs_projectile1;
extern statetype s_ofs_projectile2;
extern statetype s_ofs_proj_exp1;
extern statetype s_ofs_proj_exp2;
extern statetype s_ofs_pod_spit1;
extern statetype s_ofs_pod_spit2;
extern statetype s_ofs_pod_spit3;
extern statetype s_ofs_pod_attack1;
extern statetype s_ofs_pod_attack1a;
extern statetype s_ofs_pod_attack2;
//extern statetype s_ofs_pod_attack1_2;
//extern statetype s_ofs_pod_attack2_2;
extern statetype s_ofs_pod_death1;
extern statetype s_ofs_pod_death2;
extern statetype s_ofs_pod_death3;
extern statetype s_ofs_roam;
extern statetype s_ofs_esphere_death1;
extern statetype s_ofs_esphere_death2;
extern statetype s_ofs_esphere_death3;
//
// Local Prototypes
//
void T_SmartThink(objtype *obj);
void T_SmartThought(objtype *obj);
void T_Action(objtype *obj);
boolean ProjectileTryMove(objtype *ob, fixed deltax, fixed deltay);
void T_Projectile(objtype *ob);
void T_OfsShoot(enemy_t which, objtype *ob);
void SphereStartDir(objtype *ob);
void T_OfsBounce(objtype *obj);
//
// Local Offset Anim Structures
//
statetype s_ofs_stand = {false,SPR_GENETIC_W1 - SPR_GENETIC_W1, 0, T_OfsThink,NULL,&s_ofs_stand};
statetype s_ofs_chase1 = {false,SPR_GENETIC_W1 - SPR_GENETIC_W1, 10, T_Chase,NULL,&s_ofs_chase1s};
statetype s_ofs_chase1s = {false,SPR_GENETIC_W1 - SPR_GENETIC_W1, 5,NULL,NULL,&s_ofs_chase2};
statetype s_ofs_chase2 = {false,SPR_GENETIC_W2 - SPR_GENETIC_W1, 8, T_Chase,NULL,&s_ofs_chase3};
statetype s_ofs_chase3 = {false,SPR_GENETIC_W3 - SPR_GENETIC_W1, 10, T_Chase,NULL,&s_ofs_chase3s};
statetype s_ofs_chase3s = {false,SPR_GENETIC_W3 - SPR_GENETIC_W1, 5, NULL,NULL,&s_ofs_chase4};
statetype s_ofs_chase4 = {false,SPR_GENETIC_W4 - SPR_GENETIC_W1, 8, T_Chase,NULL,&s_ofs_chase1};
statetype s_ofs_pain = {false,SPR_GENETIC_OUCH - SPR_GENETIC_W1, 15, NULL,NULL,&s_ofs_chase1};
statetype s_ofs_die1 = {false,SPR_GENETIC_OUCH - SPR_GENETIC_W1, 18, T_BlowBack,A_DeathScream,&s_ofs_die1s};
statetype s_ofs_die1s = {false,SPR_GENETIC_DIE1 - SPR_GENETIC_W1, 20, T_BlowBack,NULL,&s_ofs_die2};
statetype s_ofs_die2 = {false,SPR_GENETIC_DIE2 - SPR_GENETIC_W1, 22, T_BlowBack,NULL,&s_ofs_die3};
statetype s_ofs_die3 = {false,SPR_GENETIC_DIE3 - SPR_GENETIC_W1, 20, T_BlowBack,NULL,&s_ofs_die4};
statetype s_ofs_die4 = {false,SPR_GENETIC_DIE4 - SPR_GENETIC_W1, 18, T_BlowBack,NULL,&s_ofs_die5};
statetype s_ofs_die5 = {false,SPR_GENETIC_DEAD - SPR_GENETIC_W1, 0, NULL,NULL,&s_ofs_die5};
statetype s_ofs_attack1 = {false,SPR_GENETIC_SWING1 - SPR_GENETIC_W1, 20, NULL,NULL,&s_ofs_attack2};
statetype s_ofs_attack2 = {false,SPR_GENETIC_SWING2 - SPR_GENETIC_W1, 20, NULL,T_Hit,&s_ofs_attack3};
statetype s_ofs_attack3 = {false,SPR_GENETIC_SWING3 - SPR_GENETIC_W1, 30, NULL,NULL,&s_ofs_chase1};
statetype s_ofs_spit1 = {false,SPR_GENETIC_SHOOT1 - SPR_GENETIC_W1, 20, NULL,NULL,&s_ofs_spit2};
statetype s_ofs_spit2 = {false,SPR_GENETIC_SHOOT2 - SPR_GENETIC_W1, 20, NULL,T_Shoot,&s_ofs_spit3};
statetype s_ofs_spit3 = {false,SPR_GENETIC_SHOOT3 - SPR_GENETIC_W1, 10, NULL,T_Shade,&s_ofs_chase1};
statetype s_ofs_shoot1 = {false,SPR_GENETIC_SWING1 - SPR_GENETIC_W1, 10, NULL,NULL,&s_ofs_shoot2};
statetype s_ofs_shoot2 = {false,SPR_GENETIC_SWING2 - SPR_GENETIC_W1, 10, NULL,T_Shoot,&s_ofs_shoot3};
statetype s_ofs_shoot3 = {false,SPR_GENETIC_SWING3 - SPR_GENETIC_W1, 10, NULL,T_Shade,&s_ofs_chase1};
// General 'offset-object' states...
//
statetype s_ofs_pod_attack1 = {0,SPR_POD_ATTACK1 - SPR_POD_WALK1, 8, NULL,NULL,&s_ofs_pod_attack1a};
statetype s_ofs_pod_attack1a = {0,SPR_POD_ATTACK2 - SPR_POD_WALK1, 8, NULL,NULL,&s_ofs_attack2};
statetype s_ofs_pod_attack2 = {0,SPR_POD_ATTACK3 - SPR_POD_WALK1, 8, NULL,T_Hit,&s_ofs_chase1};
statetype s_ofs_pod_spit1 = {0,SPR_POD_SPIT1 - SPR_POD_WALK1, 8, NULL,NULL,&s_ofs_pod_spit2};
statetype s_ofs_pod_spit2 = {0,SPR_POD_SPIT2 - SPR_POD_WALK1, 8, NULL,NULL,&s_ofs_pod_spit3};
statetype s_ofs_pod_spit3 = {0,SPR_POD_SPIT3 - SPR_POD_WALK1, 8, NULL,T_Shoot,&s_ofs_chase1};
statetype s_ofs_pod_death1 = {0,0, 60, NULL,NULL,&s_ofs_pod_death2};
statetype s_ofs_pod_death2 = {0,1, 30, NULL,NULL,&s_ofs_pod_death3};
statetype s_ofs_pod_death3 = {0,2, 0, NULL,NULL,&s_ofs_pod_death3};
statetype s_ofs_pod_ouch = {0,SPR_POD_OUCH-SPR_POD_WALK1, 11, NULL,NULL,&s_ofs_chase1};
statetype s_ofs_bounce = {0,0,10,T_OfsBounce,T_OfsThink,&s_ofs_bounce};
statetype s_ofs_ouch = {0,0,15,T_OfsBounce,NULL,&s_ofs_bounce};
statetype s_ofs_esphere_death1 = {0,0, 15, NULL,A_DeathScream,&s_ofs_esphere_death2};
statetype s_ofs_esphere_death2 = {0,1, 15, NULL,NULL,&s_ofs_esphere_death3};
statetype s_ofs_esphere_death3 = {0,2, 15, NULL,NULL,NULL};
statetype s_ofs_random = {0,0,1,T_OfsThink,NULL,&s_ofs_random};
statetype s_ofs_static = {0,0,1,NULL,NULL,&s_ofs_static};
statetype s_hold = {0,0,1,NULL,NULL,&s_hold};
unsigned scan_value;
//---------------------------------------------------------------------------
// SpawnOffsetObj ()
//---------------------------------------------------------------------------
void SpawnOffsetObj (enemy_t which, int tilex, int tiley)
{
unsigned far *map,tile;
enemy_t dir_which;
switch (which)
{
case en_vertsphere:
case en_horzsphere:
case en_diagsphere:
dir_which = which;
which = en_electrosphere;
break;
case en_bloodvent:
case en_watervent:
dir_which = which;
which = en_ventdrip;
break;
}
SpawnNewObj (tilex,tiley,&s_ofs_stand);
new->flags |= FL_SHOOTABLE | FL_SOLID | FL_OFFSET_STATES;
new->obclass = rentacopobj+which;
switch (which)
{
case en_final_boss2:
new->lighting = NO_SHADING;
case en_spider_mutant:
case en_breather_beast:
case en_cyborg_warrior:
case en_reptilian_warrior:
case en_acid_dragon:
case en_mech_guardian:
case en_final_boss1:
case en_final_boss3:
case en_final_boss4:
new->temp1 = BossShapes[which-en_spider_mutant];
new->speed = ALIENSPEED;
new->ammo = ALIENAMMOINIT;
new->flags |= FL_PROJ_TRANSPARENT;
new->flags2 = FL2_BFG_SHOOTABLE|FL2_BFGSHOT_SOLID;
break;
case en_green_ooze:
InitSmartSpeedAnim(new,SPR_GREEN_OOZE1,US_RndT()%3,2,at_CYCLE,ad_FWD,5+(US_RndT()&2));
new->flags &= ~(FL_SHOOTABLE|FL_SOLID);
break;
case en_black_ooze:
InitSmartSpeedAnim(new,SPR_BLACK_OOZE1,US_RndT()%3,2,at_CYCLE,ad_FWD,5+(US_RndT()&2));
new->flags &= ~(FL_SHOOTABLE|FL_SOLID);
break;
case en_green2_ooze:
InitSmartSpeedAnim(new,SPR_GREEN2_OOZE1,US_RndT()%3,2,at_CYCLE,ad_FWD,5+(US_RndT()&2));
new->flags &= ~(FL_SHOOTABLE|FL_SOLID);
break;
case en_black2_ooze:
InitSmartSpeedAnim(new,SPR_BLACK2_OOZE1,US_RndT()%3,2,at_CYCLE,ad_FWD,5+(US_RndT()&2));
new->flags &= ~(FL_SHOOTABLE|FL_SOLID);
break;
case en_crate1:
case en_crate2:
case en_crate3:
new->temp1 = SPR_CRATE_1+which-en_crate1;
new->flags |= FL_NO_SLIDE|FL_FAKE_STATIC;
// NOTE : TEMP2 is modified in ScanInfoPlane to determine if
// this object is a "blastable" or not.
break;
case en_rotating_cube:
InitSmartSpeedAnim(new,SPR_CUBE1,0,9,at_CYCLE,ad_FWD,5);
new->flags2 = FL2_BFGSHOT_SOLID;
new->lighting = LAMP_ON_SHADING;
break;
case en_ventdrip:
if (dir_which == en_bloodvent)
new->temp1 = SPR_BLOOD_DRIP1;
else
new->temp1 = SPR_WATER_DRIP1;
new->temp2 = 5+(US_RndT()%10);
new->temp3 = 0;
NewState(new,&s_ofs_random);
new->flags &= ~(FL_SHOOTABLE|FL_SOLID);
break;
case en_plasma_detonator:
case en_plasma_detonator_reserve:
NewState(new,&s_ofs_random);
new->temp1 = SPR_DOORBOMB;
new->temp3 = PLASMA_DETONATORS_DELAY;
new->flags &= ~(FL_SOLID|FL_SHOOTABLE);
if (detonators_spawned++)
ACT2_ERROR(TOO_MANY_DETONATORS);
break;
case en_flickerlight:
new->temp1 = SPR_DECO_ARC_1;
new->temp2 = (2+(US_RndT()%3))*60;
NewState(new,&s_ofs_random);
new->flags |= FL_NONMARK|FL_NEVERMARK;
new->flags &= ~(FL_SOLID|FL_SHOOTABLE);
new->lighting = LAMP_ON_SHADING;
break;
case en_security_light:
new->flags &= ~(FL_SOLID | FL_SHOOTABLE); // ick - this is stupid...
NewState(new,&s_security_light);
break;
case en_electrosphere:
new->trydir = dir_which;
new->flags &= ~FL_SOLID;
new->temp1 = SPR_ELECTRO_SPHERE_ROAM1;
new->speed = 3096;
new->lighting = NO_SHADING; // NO shading
NewState(new,&s_ofs_bounce);
SphereStartDir(new);
break;
case en_podegg:
new->temp1 = SPR_POD_EGG;
if (scan_value == 0xffff)
new->temp2 = 60*5+(60*(US_RndT()%20));
else
new->temp2 = scan_value*60;
new->speed = ALIENSPEED;
new->ammo = ALIENAMMOINIT;
if (new->temp2==0xff*60)
new->flags &= ~FL_SHOOTABLE;
new->flags |= FL_PROJ_TRANSPARENT|FL_NO_SLIDE|FL_FAKE_STATIC;
new->flags2 = FL2_BFGSHOT_SOLID|FL2_BFG_SHOOTABLE;
break;
case en_pod:
new->temp1 = SPR_POD_WALK1;
new->speed = SPDPATROL;
new->ammo = -1;
new->flags |= FL_PROJ_TRANSPARENT|FL_NO_SLIDE;
new->flags2 = FL2_BFG_SHOOTABLE;
break;
case en_genetic_guard:
new->temp1 = SPR_GENETIC_W1;
new->speed = ALIENSPEED;
new->ammo = ALIENAMMOINIT;
new->flags |= FL_PROJ_TRANSPARENT|FL_NO_SLIDE;
new->flags2 = FL2_BFG_SHOOTABLE;
break;
case en_mutant_human1:
new->temp1 = SPR_MUTHUM1_W1;
new->speed = ALIENSPEED;
new->ammo = ALIENAMMOINIT;
new->flags |= FL_PROJ_TRANSPARENT|FL_NO_SLIDE;
new->flags2 = FL2_BFGSHOT_SOLID|FL2_BFG_SHOOTABLE;
break;
case en_mutant_human2:
new->temp1 = SPR_MUTHUM2_W1;
new->speed = ALIENSPEED;
new->ammo = ALIENAMMOINIT;
new->flags |= FL_PROJ_TRANSPARENT|FL_NO_SLIDE;
new->flags2 = FL2_BFGSHOT_SOLID|FL2_BFG_SHOOTABLE;
break;
case en_scan_wait_alien:
new->temp1 = SPR_SCAN_ALIEN_READY;
new->flags |= FL_STATIONARY|FL_NO_SLIDE|FL_FAKE_STATIC;
new->flags2 = FL2_BFGSHOT_SOLID|FL2_BFG_SHOOTABLE;
break;
case en_lcan_wait_alien:
new->temp1 = SPR_LCAN_ALIEN_READY;
new->flags |= FL_STATIONARY|FL_NO_SLIDE|FL_FAKE_STATIC;
new->flags2 = FL2_BFGSHOT_SOLID|FL2_BFG_SHOOTABLE;
break;
case en_morphing_spider_mutant:
case en_morphing_reptilian_warrior:
case en_morphing_mutanthuman2:
if (scan_value == 0xffff)
new->temp2 = 0xffff; // set to max! // 60*5+(60*(US_RndT()%20));
else
new->temp2 = scan_value*60;
if (new->temp2==0xff*60)
new->flags &= ~FL_SHOOTABLE;
new->speed = ALIENSPEED;
new->ammo = ALIENAMMOINIT;
new->temp1 = MorphShapes[which-en_morphing_spider_mutant];
new->flags |= FL_FAKE_STATIC;
new->flags2 = FL2_BFGSHOT_SOLID|FL2_BFG_SHOOTABLE;
NewState(new,&s_ofs_random);
break;
case en_gurney_wait:
if (scan_value == 0xffff)
new->temp3 = 0;
else
new->temp3 = (scan_value & 0xff)*60;
new->temp1 = SPR_GURNEY_MUT_READY;
new->flags |= FL_STATIONARY|FL_PROJ_TRANSPARENT|FL_NO_SLIDE|FL_FAKE_STATIC;
new->flags2 = FL2_BFGSHOT_SOLID|FL2_BFG_SHOOTABLE;
break;
case en_lcan_alien: // Large Canister Alien - Out of can.
new->temp1 = SPR_LCAN_ALIEN_W1;
new->speed = ALIENSPEED;
new->ammo = ALIENAMMOINIT;
new->flags |= FL_PROJ_TRANSPARENT|FL_NO_SLIDE;
new->flags2 = FL2_BFG_SHOOTABLE;
break;
case en_scan_alien: // Small Canister Alien - Out of can.
new->temp1 = SPR_SCAN_ALIEN_W1;
new->speed = ALIENSPEED;
new->ammo = ALIENAMMOINIT;
new->flags |= FL_PROJ_TRANSPARENT;
new->flags2 = FL2_BFG_SHOOTABLE;
break;
case en_gurney: // Gurney Mutant - Off of gurney.
new->temp1 = SPR_GURNEY_MUT_W1;
new->speed = ALIENSPEED;
new->flags |= FL_PROJ_TRANSPARENT|FL_NO_SLIDE;
new->ammo = ALIENAMMOINIT;
new->flags2 = FL2_BFG_SHOOTABLE;
break;
}
CheckForSpecialTile(new,tilex,tiley);
if (which < SPACER1_OBJ)
new->hitpoints = starthitpoints[gamestate.difficulty][which];
}
//---------------------------------------------------------------------------
// T_OfsThink() - Think for general Offset Objects
//
// NOTE: This think is used for NON-SmartAnim objects
//---------------------------------------------------------------------------
short far grenade_shapes[] = {SPR_GRENADE_FLY3,SPR_GRENADE_FLY3,SPR_GRENADE_FLY2,
SPR_GRENADE_FLY1,SPR_GRENADE_FLY2,SPR_GRENADE_FLY2,
SPR_GRENADE_FLY3,SPR_GRENADE_FLY4,0};
void T_OfsThink(objtype *obj)
{
char dx,dy,dist;
char oldofs,ofs=0;
switch (obj->obclass)
{
case plasma_detonator_reserveobj:
break;
case plasma_detonatorobj:
if (obj->temp3 < tics)
{
BlastNearDoors(obj->tilex, obj->tiley);
obj->lighting = NO_SHADING; // no shading
obj->flags &= ~FL_SHOOTABLE;
obj->obclass = pd_explosionobj;
A_DeathScream(obj);
InitSmartSpeedAnim(obj,SPR_DETONATOR_EXP1,0,7,at_ONCE,ad_FWD,3+(US_RndT()&3));
return;
}
else
obj->temp3-=tics;
if (obj->ammo >= tics)
obj->ammo -= tics;
else
{
obj->ammo = DETONATOR_FLASH_RATE;
if (obj->temp1 == SPR_DOORBOMB)
obj->temp1 = SPR_ALT_DOORBOMB;
else
obj->temp1 = SPR_DOORBOMB;
}
break;
case grenadeobj:
{
T_Projectile(obj);
// Check for range and update shape...
if (obj->obclass == grenadeobj)
{
//
// Has not exploded yet...
//
dx = obj->s_tilex - obj->tilex;
dx = ABS(dx);
dy = obj->s_tiley - obj->tiley;
dy = ABS(dy);
dist = dx>dy ? dx:dy;
// Reached end of range?
if (!(obj->temp1 = grenade_shapes[dist]))
{
obj->obclass = gr_explosionobj;
InitSmartSpeedAnim(obj,SPR_GRENADE_EXPLODE1,0,4,at_ONCE,ad_FWD,3+(US_RndT()&3));
}
}
if (obj->obclass != grenadeobj)
{
ExplodeRadius(obj,50+(US_RndT()&0x7f),false);
A_DeathScream(obj);
}
}
break;
case bfg_shotobj:
{
T_Projectile(obj);
if (obj->temp1 != SPR_BFG_WEAPON_SHOT3 && obj->obclass == bfg_shotobj)
{
//
// Has not exploded yet...
//
dx = obj->s_tilex - obj->tilex;
dx = ABS(dx);
dy = obj->s_tiley - obj->tiley;
dy = ABS(dy);
dist = dx>dy ? dx:dy;
obj->temp1 = SPR_BFG_WEAPON_SHOT2 + (dist>>2);
}
if (obj->obclass != bfg_shotobj)
{
ExplodeRadius(obj,50+(US_RndT()&0x7f),false);
A_DeathScream(obj);
}
}
break;
case ventdripobj:
// Decrement timer...
//
if (tics < obj->temp2)
{
obj->temp2 -= tics;
break;
}
// Assign random delay and next shape.
//
obj->temp2 = 5+(US_RndT()%10);
obj->temp1 -= obj->temp3;
obj->temp3 = (obj->temp3 + 1) % 4;
obj->temp1 += obj->temp3;
break;
case flickerlightobj:
if (tics < obj->temp2)
{
obj->temp2 -= tics;
break;
}
if ((obj->temp1 == SPR_DECO_ARC_1) || (US_RndT()&15))
{
// Becomes darker....
char t = (US_RndT()&1);
obj->lighting = LAMP_ON_SHADING+((t+3)<<2);
obj->temp1 = SPR_DECO_ARC_2+t;
obj->temp2 = 2+(US_RndT()%2);
}
else
{
obj->temp1 = SPR_DECO_ARC_1;
obj->temp2 = (4+US_RndT()%10)*60;
obj->lighting = LAMP_ON_SHADING;
}
break;
case electrosphereobj:
oldofs = obj->temp1 - SPR_ELECTRO_SPHERE_ROAM1;
ofs = US_RndT()&3;
if (ofs == oldofs)
ofs = (ofs+1) & 3;
obj->temp1 = SPR_ELECTRO_SPHERE_ROAM1+ofs;
break;
case podobj:
if (obj->flags & FL_VISABLE)
FirstSighting(obj);
break;
case podeggobj:
#if IN_DEVELOPMENT || TECH_SUPPORT_VERSION
if (!((Keyboard[sc_6] || Keyboard[sc_7]) && Keyboard[sc_8] && DebugOk))
if (!(obj->flags & FL_VISABLE))
break;
#else
if (!(obj->flags & FL_VISABLE))
break;
#endif
if (obj->temp2 == 0xff*60)
break;
#if IN_DEVELOPMENT || TECH_SUPPORT_VERSION
if ((Keyboard[sc_6] || Keyboard[sc_7]) && Keyboard[sc_8] && DebugOk)
obj->temp2 = 0;
#endif
if (obj->temp2 > tics)
{
obj->temp2 -= tics;
break;
}
PlaySoundLocActor(PODHATCHSND,obj);
InitSmartSpeedAnim(obj,SPR_POD_HATCH1,0,2,at_ONCE,ad_FWD,7);
break;
case morphing_spider_mutantobj:
case morphing_reptilian_warriorobj:
case morphing_mutanthuman2obj:
#if IN_DEVELOPMENT || TECH_SUPPORT_VERSION
if (!((Keyboard[sc_6] || Keyboard[sc_7]) && Keyboard[sc_8] && DebugOk))
if (!(obj->flags & FL_VISABLE))
break;
#else
if (!(obj->flags & FL_VISABLE))
break;
#endif
#if IN_DEVELOPMENT || TECH_SUPPORT_VERSION
if ((Keyboard[sc_6] || Keyboard[sc_7]) && Keyboard[sc_8] && DebugOk)
obj->temp2 = 0;
#endif
if (obj->temp2 > tics)
{
obj->temp2 -= tics;
break;
}
obj->flags &= ~FL_SHOOTABLE;
InitSmartSpeedAnim(obj,obj->temp1,0,8,at_ONCE,ad_FWD,2);
break;
case crate1obj:
case crate2obj:
case crate3obj:
case lcan_wait_alienobj: // These objs wait till they are destroyed
case scan_wait_alienobj: // before doing anything.
break;
case gurney_waitobj:
if (obj->flags & FL_VISABLE)
SightPlayer(obj);
break;
case spider_mutantshotobj:
case final_boss4shotobj:
case acid_dragonshotobj:
obj->temp1 = BossShotShapes[obj->obclass-spider_mutantshotobj]+(US_RndT()%3);
T_Projectile(obj);
break;
default:
T_Stand(obj);
break;
}
}
//---------------------------------------------------------------------------
// RandomSphereDir()
//---------------------------------------------------------------------------
int RandomSphereDir(enemy_t enemy)
{
int dir;
switch (enemy)
{
case en_vertsphere:
dir = ((US_RndT()%2) * 4) + 2;
break;
case en_horzsphere:
dir = (US_RndT()%2) * 4;
break;
case en_diagsphere:
dir = ((US_RndT()%4) * 2) + 1;
break;
}
return(dir);
}
//---------------------------------------------------------------------------
// SphereStartDir()
//---------------------------------------------------------------------------
void SphereStartDir(objtype *ob)
{
char loop;
actorat[ob->tilex][ob->tiley] = NULL;
for (loop=0; loop<3; loop++)
{
ob->dir=RandomSphereDir(en_vertsphere+((ob->trydir-en_vertsphere+loop)%3));
if (!TryWalk(ob,true))
{
ob->dir = opposite[ob->dir];
if (!TryWalk(ob,true))
ob->dir = nodir;
else
break;
}
else