forked from CatacombGames/CatacombArmageddon
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathC5_ACT3.C
1218 lines (947 loc) · 28 KB
/
C5_ACT3.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
/* Catacomb Armageddon Source Code
* Copyright (C) 1993-2014 Flat Rock Software
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// C3_PLAY.C
#include "DEF.H"
#pragma hdrstop
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#if 0
#define MSHOTDAMAGE 2
#define MSHOTSPEED 10000
#define ESHOTDAMAGE 1
#define ESHOTSPEED 5000
#define SSHOTDAMAGE 3
#define SSHOTSPEED 6500
#define RANDOM_ATTACK 20
#endif
/*
=============================================================================
GLOBAL VARIABLES
=============================================================================
*/
boolean ShootPlayer (objtype *ob, short obclass, short speed, statetype *state);
void T_ShootPlayer(objtype *ob);
/*
=============================================================================
LOCAL VARIABLES
=============================================================================
*/
/*
=============================================================================
RED DEMON
=============================================================================
*/
void T_RedDemon (objtype *ob);
void T_RedDemonCheckCnt (objtype *ob);
extern statetype s_red_demonpause;
extern statetype s_red_demon1;
extern statetype s_red_demon2;
extern statetype s_red_demon3;
extern statetype s_red_demon4;
extern statetype s_red_demonattack1;
extern statetype s_red_demonattack2;
extern statetype s_red_demonattack3;
extern statetype s_red_demonouch;
extern statetype s_red_demondie1;
extern statetype s_red_demondie2;
extern statetype s_red_demondie3;
extern statetype s_red_demondie4;
statetype s_red_demonpause = {RED_DEMON1PIC,30,NULL,&s_red_demon2};
statetype s_red_demon1 = {RED_DEMON1PIC,20,T_RedDemon,&s_red_demon2};
statetype s_red_demon2 = {RED_DEMON2PIC,20,T_RedDemon,&s_red_demon3};
statetype s_red_demon3 = {RED_DEMON3PIC,20,T_RedDemon,&s_red_demon4};
statetype s_red_demon4 = {RED_DEMON4PIC,20,T_RedDemon,&s_red_demon1};
statetype s_red_demonattack1 = {RED_DEMONATTACK1PIC,20,NULL,&s_red_demonattack2};
statetype s_red_demonattack2 = {RED_DEMONATTACK2PIC,20,NULL,&s_red_demonattack3};
statetype s_red_demonattack3 = {RED_DEMONATTACK3PIC,30,T_DoDamage,&s_red_demon2};
statetype s_red_demonouch = {RED_DEMONOUCHPIC,30,NULL,&s_red_demon1};
statetype s_red_demondie1 = {RED_DEMONOUCHPIC,9,NULL,&s_red_demondie2};
statetype s_red_demondie2 = {RED_DEMONDIE1PIC,9,T_RedDemonCheckCnt,&s_red_demondie1};
statetype s_red_demondie3 = {RED_DEMONDIE2PIC,20,NULL,&s_red_demondie4};
statetype s_red_demondie4 = {RED_DEMONDIE3PIC,10,NULL,&s_red_demondie4};
/*
===============
=
= SpawnRedDemon
=
===============
*/
void SpawnRedDemon (int tilex, int tiley)
{
SpawnNewObj(tilex,tiley,&s_red_demon1,PIXRADIUS*35);
new->obclass = reddemonobj;
new->speed = 2048;
new->flags |= of_shootable;
new->hitpoints = EasyHitPoints(50);
new->temp1 = 25;
}
/*
===============
=
= T_RedDemon
=
===============
*/
void T_RedDemon (objtype *ob)
{
if (Chase (ob,true) || (random(1000)<RANDOM_ATTACK))
{
ob->state = &s_red_demonattack1;
ob->ticcount = ob->state->tictime;
return;
}
}
/*
===============
=
= T_RedDemonCheckCnt
=
===============
*/
void T_RedDemonCheckCnt (objtype *ob)
{
ob->temp1--;
if (!ob->temp1)
{
ob->state = &s_red_demondie3;
ob->ticcount = ob->state->tictime;
}
}
/*
=============================================================================
GRELMINAR
=============================================================================
*/
void T_Grelminar (objtype *ob);
void T_GrelminarShoot (objtype *ob);
void T_Grelm_DropKey(objtype *ob);
extern statetype s_grelpause;
extern statetype s_grel1;
extern statetype s_grel2;
extern statetype s_grelattack1;
extern statetype s_grelattack2;
extern statetype s_grelattack3;
extern statetype s_grelouch;
extern statetype s_greldie1;
extern statetype s_greldie2;
extern statetype s_greldie3;
extern statetype s_greldie4;
extern statetype s_greldie5;
extern statetype s_greldie5a;
extern statetype s_greldie6;
statetype s_grelpause = {GREL1PIC,50,NULL,&s_grel2};
statetype s_grel1 = {GREL1PIC,20,T_Grelminar,&s_grel2};
statetype s_grel2 = {GREL2PIC,20,T_Grelminar,&s_grel1};
//statetype s_grelattack1 = {GRELATTACKPIC,20,NULL,&s_grelattack2};
//statetype s_grelattack2 = {GRELATTACKPIC,-1,T_GrelminarShoot,&s_grelattack3};
statetype s_grelattack3 = {GRELATTACKPIC,30,NULL,&s_grelpause};
statetype s_grelouch = {GRELHITPIC,6,NULL,&s_grel1};
statetype s_greldie1 = {GRELDIE1PIC,22,NULL,&s_greldie2};
statetype s_greldie2 = {GRELDIE2PIC,22,NULL,&s_greldie3};
statetype s_greldie3 = {GRELDIE3PIC,22,NULL,&s_greldie4};
statetype s_greldie4 = {GRELDIE4PIC,22,NULL,&s_greldie5};
statetype s_greldie5 = {GRELDIE5PIC,22,NULL,&s_greldie5a};
statetype s_greldie5a = {GRELDIE5PIC,1,T_Grelm_DropKey,&s_greldie6};
statetype s_greldie6 = {GRELDIE6PIC,0,NULL,&s_greldie6};
extern statetype s_gshot1;
statetype s_gshot1 = {SKULL_SHOTPIC,8,T_ShootPlayer,&s_gshot1};
/*
===============
=
= SpawnGrelminar
=
===============
*/
void SpawnGrelminar (int tilex, int tiley)
{
unsigned Grel_Hard;
unsigned DropKey;
SpawnNewObj(tilex,tiley,&s_grel1,PIXRADIUS*35);
new->obclass = grelmobj;
new->speed = 2048;
new->flags |= of_shootable;
//
// if Grelminar is to drop a key the info-plane byte to the right
// should have a 1 in the highbyte, else he will not drop the key.
//
DropKey = *(mapsegs[2]+farmapylookup[tiley]+tilex+1);
if (DropKey)
new->temp1 = DropKey>>8;
else
new->temp1 = 0;
//
// The info-plane byte below Grelminar will determine how powerful
// Grelminar is. If nothing is there, he is the most powerful.
// -- affected are the hit points and the shot damage.
// The hit points are controlled here, the shot damage is controlled
// within the spawning of the shot. See ShootPlayer for more info.
//
Grel_Hard = *(mapsegs[2]+farmapylookup[tiley+1]+tilex);
if (Grel_Hard)
{
new->temp2 = Grel_Hard>>8;
new->hitpoints = EasyHitPoints((new->temp2 * 10));
}
else
new->hitpoints = EasyHitPoints(100);
}
/*
===============
=
= T_Grelminar
=
===============
*/
void T_Grelminar (objtype *ob)
{
Chase (ob,false);
if (!random(10))
if (ShootPlayer(ob,gshotobj,ob->temp2,&s_gshot1))
{
ob->state = &s_grelattack3;
ob->ticcount = ob->state->tictime;
}
if (CheckHandAttack(ob))
TakeDamage (ob->temp2*3);
}
//=================================
//
// T_Grelm_DropKey
//
//=================================
void T_Grelm_DropKey(objtype *ob)
{
if (!(ob->temp1))
{
ob->state = NULL;
return;
}
SpawnBonus(ob->tilex,ob->tiley,B_RKEY);
SD_PlaySound(GRELM_DEADSND);
ob->temp1 = false;
}
/*
=============================================================================
BAT
=============================================================================
*/
void T_Bat (objtype *ob);
void T_BatPast (objtype *ob);
extern statetype s_bat1;
extern statetype s_bat2;
extern statetype s_bat3;
extern statetype s_bat4;
extern statetype s_batdie1;
extern statetype s_batdie2;
statetype s_bat1 = {BAT1PIC,6,T_Bat,&s_bat2};
statetype s_bat2 = {BAT2PIC,6,T_Bat,&s_bat3};
statetype s_bat3 = {BAT3PIC,6,T_Bat,&s_bat4};
statetype s_bat4 = {BAT4PIC,6,T_Bat,&s_bat1};
statetype s_batpast = {BAT4PIC,80,T_BatPast,&s_bat1};
statetype s_batdie1 = {BATDIE1PIC,18,NULL,&s_batdie2};
statetype s_batdie2 = {BATDIE2PIC,18,NULL,NULL};
/*
===============
=
= SpawnBat
=
===============
*/
void SpawnBat (int tilex, int tiley)
{
SpawnNewObj(tilex,tiley,&s_bat1,PIXRADIUS*35);
new->obclass = batobj;
new->flags |= of_shootable;
new->hitpoints = 1;
new->speed = 2000;
}
/*
==================================
=
= BatChaseThink
=
==================================
*/
void BatChaseThink (objtype *obj)
{
int deltax,deltay;
deltax=player->tilex - obj->tilex;
deltay=player->tiley - obj->tiley;
if (deltax>0)
deltax = 2;
else if (deltax<0)
deltax = 0;
else deltax = 1;
if (deltay>0)
deltay = 2;
else if (deltay<0)
deltay = 0;
else deltay = 1;
obj->dir = dirtable[deltay*3+deltax];
if (Walk(obj))
return;
obj->dir = dirtable[3+deltax];
if (Walk(obj))
return;
obj->dir = dirtable[deltay*3+1];
if (Walk(obj))
return;
obj->dir = nodir;
}
void BatRunThink (objtype *obj)
{
int deltax,deltay;
deltax=player->tilex - obj->tilex;
deltay=player->tiley - obj->tiley;
if (deltax>=0)
deltax = 0;
else
deltax = 2;
if (deltay>=0)
deltay = 0;
else
deltay = 2;
obj->dir = dirtable[deltay*3+deltax];
if (Walk(obj))
return;
obj->dir = dirtable[3+deltax];
if (Walk(obj))
return;
obj->dir = dirtable[deltay*3+1];
Walk(obj);
}
/*
===============
=
= T_Bat
=
===============
*/
void T_Bat (objtype *ob)
{
long move;
long deltax,deltay,size;
move = ob->speed*tics;
size = (long)ob->size + player->size + move;
do
{
deltax = ob->x - player->x;
deltay = ob->y - player->y;
if (deltax <= size && deltax >= -size
&& deltay <= size && deltay >= -size && !ob->temp1)
{
TakeDamage (4);
ob->temp1 = 2;
}
if (move < ob->distance)
{
MoveObj (ob,move);
break;
}
actorat[ob->tilex][ob->tiley] = 0; // pick up marker from goal
if (ob->dir == nodir)
ob->dir = north;
ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
move -= ob->distance;
if (ob->temp1)
{
Walk (ob); // go straight
if (!--ob->temp1)
{
ob->state = &s_batpast;
ob->ticcount = ob->state->tictime;
}
}
else
BatChaseThink (ob); // head towards player
actorat[ob->tilex][ob->tiley] = ob; // set down a new goal marker
} while (0); // just once
CalcBounds (ob);
}
/*
===============
=
= T_BatPast
=
===============
*/
void T_BatPast (objtype *ob)
{
long move;
long deltax,deltay,size;
move = ob->speed*tics;
do
{
if (move < ob->distance)
{
MoveObj (ob,move);
break;
}
actorat[ob->tilex][ob->tiley] = 0; // pick up marker from goal
ob->x = ((long)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
ob->y = ((long)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
move -= ob->distance;
BatRunThink (ob);
actorat[ob->tilex][ob->tiley] = ob; // set down a new goal marker
} while (0); //(move)
CalcBounds (ob);
}
void T_ChaseThink(objtype *obj);
void T_AwakeThink(objtype *obj);
/*
=============================================================================
GODESS
=============================================================================
*/
void T_Godess (objtype *ob);
extern statetype s_godesspause;
extern statetype s_godess_statue1;
extern statetype s_godess_statue2;
extern statetype s_godess1;
extern statetype s_godess2;
extern statetype s_godess3;
extern statetype s_godessattack1;
extern statetype s_godessattack2;
extern statetype s_godessattack3;
extern statetype s_godessouch;
extern statetype s_godessdie1;
extern statetype s_godessdie2;
extern statetype s_godessdie3;
statetype s_godesspause = {GODESS_WALK1PIC,25,NULL,&s_godess2};
statetype s_godess_statue1 = {GODESS_STATUEPIC,20,T_ChaseThink,&s_godess_statue1};
statetype s_godess_statue2 = {GODESS_STATUEPIC,1,T_AwakeThink,&s_godess1};
statetype s_godess1 = {GODESS_WALK1PIC,20,T_ChaseThink,&s_godess2};
statetype s_godess2 = {GODESS_WALK2PIC,20,T_ChaseThink,&s_godess3};
statetype s_godess3 = {GODESS_WALK3PIC,20,T_ChaseThink,&s_godess1};
statetype s_godessattack1 = {GODESS_ATTACK1PIC,10,NULL,&s_godessattack2};//20
statetype s_godessattack2 = {GODESS_ATTACK2PIC,8,NULL,&s_godessattack3};//20
statetype s_godessattack3 = {GODESS_ATTACK3PIC,10,T_DoDamage,&s_godesspause};//30
statetype s_godessouch = {GODESS_OUCHPIC,10,NULL,&s_godess1};
statetype s_godessdie1 = {GODESS_DEATH1PIC,65,NULL,&s_godessdie2};
statetype s_godessdie2 = {GODESS_DEATH2PIC,30,NULL,&s_godessdie2};
/*
===============
=
= SpawnGodess
=
===============
*/
void SpawnGodess (int tilex, int tiley)
{
objtype *ob;
short current_zombie_delay;
unsigned tile;
SpawnNewObj(tilex,tiley,&s_godess_statue1,PIXRADIUS*35);
ob = new;
zombie_mode = zm_wait_for_dark;
tile = *(mapsegs[2]+farmapylookup[tiley+1]+tilex);
if (tile)
zombie_delay = (tile>>8)*30;
else
{
current_zombie_delay = (2*60)+random(4*60);
zombie_delay = zombie_base_delay+current_zombie_delay;
zombie_base_delay += current_zombie_delay;
if (zombie_base_delay > 8*60)
zombie_base_delay = 0;
}
new->obclass = realsolidobj;//godessobj;
new->speed = 3000;
new->flags |= of_shootable;
new->flags &= ~of_tree;
// new->hitpoints = EasyHitPoints(10);
}
/*
=============================================================================
ANT
=============================================================================
*/
void T_Ant(objtype *ob);
statetype s_ant_wait = {ANT_EGG1PIC,10,T_ChaseThink,&s_ant_wait};
statetype s_ant_egg = {ANT_EGG2PIC,45,T_AwakeThink,&s_ant_walk1};
statetype s_ant_walk1 = {ANT_WALK1PIC,20,T_ChaseThink,&s_ant_walk2};
statetype s_ant_walk2 = {ANT_WALK2PIC,20,T_ChaseThink,&s_ant_walk3};
statetype s_ant_walk3 = {ANT_WALK3PIC,20,T_ChaseThink,&s_ant_walk1};
statetype s_ant_attack1 = {ANT_ATTACKPIC,20,NULL,&s_ant_pause};
statetype s_ant_pause = {ANT_WALK2PIC,15,T_DoDamage,&s_ant_walk1};
statetype s_ant_ouch = {ANT_WALK1PIC,15,NULL,&s_ant_walk1};
statetype s_ant_die1 = {ANT_DEATH1PIC,40,NULL,&s_ant_die2};
statetype s_ant_die2 = {ANT_DEATH2PIC,10,NULL,&s_ant_die3};
statetype s_ant_die3 = {ANT_DEATH3PIC,10,NULL,&s_ant_die2};
#define ant_mode ob->temp1
#define ant_delay ob->temp2
/*
===============
=
= SpawnAnt
=
===============
*/
void SpawnAnt(int tilex, int tiley)
{
objtype *ob;
unsigned tile;
SpawnNewObj(tilex,tiley,&s_ant_wait,PIXRADIUS*35);
ob = new;
tile = *(mapsegs[2]+farmapylookup[tiley+1]+tilex);
if (tile)
ant_delay = (tile>>8)*30;
else
ant_delay = 2*60+random(5*60);
ant_mode = zm_wait_for_dark;
new->obclass = antobj;
new->speed = 1900;
new->flags &= ~of_shootable;
new->hitpoints = EasyHitPoints(15);
}
/*
=============================================================================
ZOMBIE
=============================================================================
*/
extern statetype s_zombie_rise1;
extern statetype s_zombie_rise2;
extern statetype s_zombie_rise3;
extern statetype s_zombie_rise4;
extern statetype s_zombie_alive1;
extern statetype s_zombie_alive2;
extern statetype s_zombie_alive3;
//extern statetype s_zombie_attack1;
extern statetype s_zombie_death1;
extern statetype s_zombie_death2;
extern statetype s_zombie_death3;
void T_Zombie (objtype *ob);
void T_ZombieRisen(objtype *obj);
statetype s_zombie_risen = {ZOMB_WALK3PIC,1,T_AwakeThink,&s_zombie_alive1};
statetype s_zombie_pause = {ZOMB_WALK1PIC,20,NULL,&s_zombie_alive1};
statetype s_zombie_inground = {0,13,T_ChaseThink,&s_zombie_inground};
statetype s_zombie_rise1 = {ZOMB_APPEAR1PIC,24,NULL,&s_zombie_rise2};
statetype s_zombie_rise2 = {ZOMB_APPEAR2PIC,24,NULL,&s_zombie_rise3};
statetype s_zombie_rise3 = {ZOMB_APPEAR3PIC,24,NULL,&s_zombie_rise4};
statetype s_zombie_rise4 = {ZOMB_APPEAR4PIC,24,NULL,&s_zombie_risen};
statetype s_zombie_alive1 = {ZOMB_WALK1PIC,13,T_ChaseThink,&s_zombie_alive2};
statetype s_zombie_alive2 = {ZOMB_WALK2PIC,13,T_ChaseThink,&s_zombie_alive3};
statetype s_zombie_alive3 = {ZOMB_WALK3PIC,13,T_ChaseThink,&s_zombie_alive1};
statetype s_zombie_death1 = {ZOMB_DIE1PIC,16,NULL,&s_zombie_death2};
statetype s_zombie_death2 = {ZOMB_DIE2PIC,16,NULL,&s_zombie_death3};
statetype s_zombie_death3 = {ZOMB_DIE3PIC,16,NULL,&s_zombie_death3};
statetype s_zombie_attack = {ZOMB_ATTACKPIC,15,T_DoDamage,&s_zombie_pause};
//statetype s_zombie_attack1 = {ZOMB_ATTACKPIC,15,NULL,&s_zombie_pause};
statetype s_zombie_ouch = {ZOMB_OUCHPIC,15,NULL,&s_zombie_alive1};
//--------------------------------------------------------------------------
// SpawnZombie()
//--------------------------------------------------------------------------
void SpawnZombie (int tilex, int tiley)
{
objtype *ob;
short current_zombie_delay;
unsigned tile;
SpawnNewObj(tilex,tiley,&s_zombie_inground,35*PIXRADIUS);
ob = new;
zombie_mode = zm_wait_for_dark;
tile = *(mapsegs[2]+farmapylookup[tiley+1]+tilex);
if (tile)
zombie_delay = (tile>>8)*30;
else
{
current_zombie_delay = (2*60)+random(4*60);
zombie_delay = zombie_base_delay+current_zombie_delay;
zombie_base_delay += current_zombie_delay;
if (zombie_base_delay > 8*60)
zombie_base_delay = 0;
}
new->speed = 2500;
new->obclass = zombieobj;
new->hitpoints = EasyHitPoints(8);
new->active = yes;
new->flags &= ~of_shootable;
}
/*
=============================================================================
TREE
=============================================================================
*/
extern statetype s_tree_pause;
extern statetype s_tree_idle;
extern statetype s_tree_awakening1;
extern statetype s_tree_awakening2;
extern statetype s_tree_walk1;
extern statetype s_tree_walk2;
extern statetype s_tree_walk3;
extern statetype s_tree_death1;
extern statetype s_tree_death2;
extern statetype s_tree_death3;
extern statetype s_tree_death4;
extern statetype s_tree_death5;
extern statetype s_tree_attack1;
extern statetype s_tree_attack2;
extern statetype s_tree_attack3;
extern statetype s_tree_ouch;
void T_Tree (objtype *ob);
void T_DeathThink(objtype *ob);
statetype s_tree_pause = {TREE_WALK1PIC,25,NULL,&s_tree_walk2};
statetype s_tree_idle = {TREE_IDLEPIC,13,T_ChaseThink,&s_tree_idle};
statetype s_tree_awakening1 = {TREE_AWAKENINGPIC,1,T_AwakeThink,&s_tree_awakening2};
statetype s_tree_awakening2 = {TREE_AWAKENINGPIC,50,NULL,&s_tree_walk1};
statetype s_tree_walk1 = {TREE_WALK1PIC,13,T_ChaseThink,&s_tree_walk2};
statetype s_tree_walk2 = {TREE_WALK2PIC,13,T_ChaseThink,&s_tree_walk1};
statetype s_tree_death1 = {TREE_DEATH1PIC,45,NULL,&s_tree_death2};
statetype s_tree_death2 = {TREE_DEATH2PIC,25,NULL,&s_tree_death3};
statetype s_tree_death3 = {TREE_DEATH1PIC,15,T_DeathThink,&s_tree_death4};
statetype s_tree_death4 = {TREE_DEATH2PIC,15,T_DeathThink,&s_tree_death5};
statetype s_tree_death5 = {TREE_DEATH3PIC,15,T_DeathThink,&s_tree_death3};
statetype s_tree_attack1 = {TREE_ATTACK1PIC,15,T_DoDamage,&s_tree_attack2};
statetype s_tree_attack2 = {TREE_ATTACK2PIC,15,T_DoDamage,&s_tree_attack3};
statetype s_tree_attack3 = {TREE_ATTACK3PIC,15,T_DoDamage,&s_tree_pause};
statetype s_tree_ouch = {TREE_AWAKENINGPIC,15,NULL,&s_tree_walk1};
#define zombie_mode ob->temp1
#define zombie_delay ob->temp2
//--------------------------------------------------------------------------
// SpawnTree()
//--------------------------------------------------------------------------
void SpawnTree(int tilex, int tiley)
{
objtype *ob;
short current_zombie_delay;
unsigned tile;
SpawnNewObj(tilex,tiley,&s_tree_idle,35*PIXRADIUS);
ob = new;
zombie_mode = zm_wait_for_dark;
tile = *(mapsegs[2]+farmapylookup[tiley+1]+tilex);
if (tile)
zombie_delay = (tile>>8)*30;
else
{
current_zombie_delay = (2*60)+random(4*60);
zombie_delay = zombie_base_delay+current_zombie_delay;
zombie_base_delay += current_zombie_delay;
if (zombie_base_delay > 8*60)
zombie_base_delay = 0;
}
new->speed = 2500;
new->obclass = realsolidobj;
// new->hitpoints = EasyHitPoints(12);
new->active = yes;
new->flags |= of_shootable;
new->flags |= of_tree;
}
//--------------------------------------------------------------------------
// T_DeathThink()
//--------------------------------------------------------------------------
void T_DeathThink(objtype *ob)
{
char num;
if ((ob->ticcount - realtics) <= 0)
{
num = random(2);
switch (ob->temp1)
{
case 3:
if (num)
ob->state = &s_tree_death4;
else
ob->state = &s_tree_death5;
ob->temp1++;
break;
case 4:
if (num)
ob->state = &s_tree_death3;
else
ob->state = &s_tree_death5;
ob->temp1++;
break;
case 5:
if (num)
ob->state = &s_tree_death3;
else
ob->state = &s_tree_death4;
ob->temp1 = 3;
break;
}
ob->ticcount = ob->state->tictime;
}
if (CheckHandAttack(ob))
TakeDamage (1);
}
//////////////////////////////////////////////////////////////////////////
//
// GENERAL THINK ROUTINES USED BY THE ZOMBIE, TREE, ANT, AND GODESS
// ----trying to cut down on the code size----
//
//////////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------------
// T_ChaseThink()
//--------------------------------------------------------------------------
void T_ChaseThink(objtype *ob)
{
switch (zombie_mode)
{
case zm_wait_for_dark:
#if 0
if (gamestate.mapon == 0)
{
if (BGFLAGS & BGF_NIGHT)
zombie_mode = zm_wait_to_rise;
}
else
#endif
zombie_mode = zm_wait_to_rise;
break;
case zm_wait_to_rise:
if (zombie_delay < 0)
{
if ((ob->tilex == player->tilex) && (ob->tiley == player->tiley))
break;
if (CheckHandAttack(ob))
break;
ob->active = always;
switch (ob->obclass)
{
case zombieobj:
ob->state = &s_zombie_rise1;
break;
case antobj:
ob->state = &s_ant_egg;
break;
case realsolidobj: //tree and godess
if (ob->flags & of_tree)
ob->state = &s_tree_awakening1;
else
ob->state = &s_godess_statue2;
break;
}
ob->ticcount = ob->state->tictime;
zombie_mode = zm_active;
}
else
zombie_delay -= tics;
break;
case zm_active:
if (Chase (ob,true) || (random(1000)<RANDOM_ATTACK))
{
switch (ob->obclass)
{
case zombieobj:
ob->state = &s_zombie_attack;
break;
case antobj:
ob->state = &s_ant_attack1;
break;
case treeobj:
ob->state = &s_tree_attack1;
break;
case godessobj:
ob->state = &s_godessattack1;
break;
}
ob->ticcount = ob->state->tictime;
return;
}
break;
}
}
//--------------------------------------------------------------------------
// T_AwakeThink()
//--------------------------------------------------------------------------