-
Notifications
You must be signed in to change notification settings - Fork 173
/
kd_act2.c
1509 lines (1222 loc) · 31.9 KB
/
kd_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
/* Keen Dreams Source Code
* Copyright (C) 2014 Javier M. Chavez
*
* 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.
*/
// KD_ACT1.C
#include "KD_DEF.H"
#pragma hdrstop
/*
=============================================================================
LOCAL CONSTANTS
=============================================================================
*/
#define PLACESPRITE RF_PlaceSprite (&ob->sprite,ob->x,ob->y,ob->shapenum, \
spritedraw,0);
void ProjectileReact (objtype *ob);
/*
=============================================================================
TATER TROOPER
temp1 = chasing player
temp2 = nothink time
=============================================================================
*/
void TaterThink (objtype *ob);
void BackupReact (objtype *ob);
extern statetype s_taterwalk1;
extern statetype s_taterwalk2;
extern statetype s_taterwalk3;
extern statetype s_taterwalk4;
extern statetype s_taterattack1;
extern statetype s_taterattack2;
extern statetype s_taterattack3;
#pragma warn -sus
statetype s_taterwalk1 = {TATERTROOPWALKL1SPR,TATERTROOPWALKR1SPR,step,false,
true,10, 128,0, TaterThink, NULL, WalkReact, &s_taterwalk2};
statetype s_taterwalk2 = {TATERTROOPWALKL2SPR,TATERTROOPWALKR2SPR,step,false,
true,10, 128,0, TaterThink, NULL, WalkReact, &s_taterwalk3};
statetype s_taterwalk3 = {TATERTROOPWALKL3SPR,TATERTROOPWALKR3SPR,step,false,
true,10, 128,0, TaterThink, NULL, WalkReact, &s_taterwalk4};
statetype s_taterwalk4 = {TATERTROOPWALKL4SPR,TATERTROOPWALKR4SPR,step,false,
true,10, 128,0, TaterThink, NULL, WalkReact, &s_taterwalk1};
statetype s_taterattack1= {TATERTROOPLUNGEL1SPR,TATERTROOPLUNGER1SPR,step,false,
false,12, 0,0, NULL, NULL, BackupReact, &s_taterattack2};
statetype s_taterattack2= {TATERTROOPLUNGEL2SPR,TATERTROOPLUNGER2SPR,step,false,
false,20, 0,0, NULL, NULL, DrawReact, &s_taterattack3};
statetype s_taterattack3= {TATERTROOPLUNGEL1SPR,TATERTROOPLUNGER1SPR,step,false,
false,8, 0,0, NULL, NULL, DrawReact, &s_taterwalk1};
#pragma warn +sus
/*
====================
=
= SpawnTater
=
====================
*/
void SpawnTater (int tilex, int tiley)
{
GetNewObj (false);
new->obclass = taterobj;
new->x = tilex<<G_T_SHIFT;
new->y = (tiley<<G_T_SHIFT)-2*BLOCKSIZE + 15;
new->xdir = 1;
new->ydir = 1;
NewState (new,&s_taterwalk1);
new->hitnorth = 1;
}
/*
====================
=
= TaterThink
=
====================
*/
void TaterThink (objtype *ob)
{
int delta;
if (ob->top > player->bottom || ob->bottom < player->top)
return;
if ( ob->xdir == -1 )
{
delta = ob->left - player->right;
if (delta > TILEGLOBAL)
return;
if (delta < -8*PIXGLOBAL)
{
ob->xdir = 1;
return;
}
SD_PlaySound (TATERSWINGSND);
ob->state = &s_taterattack1;
return;
}
else
{
delta = player->left - ob->right;
if (delta > TILEGLOBAL)
return;
if (delta < -8*PIXGLOBAL)
{
ob->xdir = -1;
return;
}
SD_PlaySound (TATERSWINGSND);
ob->state = &s_taterattack1;
return;
}
}
/*
====================
=
= BackupReact
=
====================
*/
void BackupReact (objtype *ob)
{
if (!ob->hitnorth)
{
ob->x-=ob->xmove;
ob->y-=ob->ymove;
}
PLACESPRITE;
}
/*
=============================================================================
CANTELOUPE CART
=============================================================================
*/
extern statetype s_cartroll1;
extern statetype s_cartroll2;
void CartReact (objtype *ob);
#pragma warn -sus
statetype s_cartroll1 = {CANTCARTL1SPR,CANTCARTL1SPR,slide,true,
false,5, 32,0, NULL, NULL, CartReact, &s_cartroll2};
statetype s_cartroll2 = {CANTCARTL2SPR,CANTCARTL2SPR,slide,true,
false,5, 32,0, NULL, NULL, CartReact, &s_cartroll1};
#pragma warn +sus
/*
====================
=
= SpawnCart
=
====================
*/
void SpawnCart (int tilex, int tiley)
{
GetNewObj (false);
new->obclass = cartobj;
new->x = tilex<<G_T_SHIFT;
new->y = (tiley<<G_T_SHIFT)-3*PIXGLOBAL;
new->xdir = 1;
new->ydir = 1;
new->active = allways;
NewState (new,&s_cartroll1);
}
/*
====================
=
= CartReact
=
====================
*/
void CartReact (objtype *ob)
{
unsigned far *map;
if (ob->xdir == 1 && ob->hitwest)
{
ob->xdir = -1;
}
else if (ob->xdir == -1 && ob->hiteast)
{
ob->xdir = 1;
}
map = mapsegs[1] + mapbwidthtable[ob->tilebottom+1]/2;
if (ob->xdir == 1)
map += ob->tileright;
else
map += ob->tileleft;
if ( !tinf[NORTHWALL + *map] )
ob->xdir = -ob->xdir;
PLACESPRITE;
}
/*
=============================================================================
FRENCHY
=============================================================================
*/
#define FRYXSPEED 40
#define FRYYSPEED -20
void FrenchyThink (objtype *ob);
void FrenchyRunThink (objtype *ob);
void FrenchyThrow (objtype *ob);
extern statetype s_frenchywalk1;
extern statetype s_frenchywalk2;
extern statetype s_frenchywalk3;
extern statetype s_frenchywalk4;
extern statetype s_frenchyrun1;
extern statetype s_frenchyrun2;
extern statetype s_frenchyrun3;
extern statetype s_frenchyrun4;
extern statetype s_frenchythrow1;
extern statetype s_frenchythrow2;
extern statetype s_frenchythrow3;
extern statetype s_fry1;
extern statetype s_fry2;
#pragma warn -sus
statetype s_frenchywalk1 = {FRENCHYRUNL1SPR,FRENCHYRUNR1SPR,step,false,
true,10, 128,0, FrenchyThink, NULL, WalkReact, &s_frenchywalk2};
statetype s_frenchywalk2 = {FRENCHYRUNL2SPR,FRENCHYRUNR2SPR,step,false,
true,10, 128,0, FrenchyThink, NULL, WalkReact, &s_frenchywalk3};
statetype s_frenchywalk3 = {FRENCHYRUNL3SPR,FRENCHYRUNR3SPR,step,false,
true,10, 128,0, FrenchyThink, NULL, WalkReact, &s_frenchywalk4};
statetype s_frenchywalk4 = {FRENCHYRUNL4SPR,FRENCHYRUNR4SPR,step,false,
true,10, 128,0, FrenchyThink, NULL, WalkReact, &s_frenchywalk1};
statetype s_frenchyrun1 = {FRENCHYRUNL1SPR,FRENCHYRUNR1SPR,step,true,
true,5, 128,0, FrenchyRunThink, NULL, WalkReact, &s_frenchyrun2};
statetype s_frenchyrun2 = {FRENCHYRUNL2SPR,FRENCHYRUNR2SPR,step,true,
true,5, 128,0, FrenchyRunThink, NULL, WalkReact, &s_frenchyrun3};
statetype s_frenchyrun3 = {FRENCHYRUNL3SPR,FRENCHYRUNR3SPR,step,true,
true,5, 128,0, FrenchyRunThink, NULL, WalkReact, &s_frenchyrun4};
statetype s_frenchyrun4 = {FRENCHYRUNL4SPR,FRENCHYRUNR4SPR,step,true,
true,5, 128,0, FrenchyRunThink, NULL, WalkReact, &s_frenchyrun1};
statetype s_frenchythrow1 = {FRENCHYTHROWL1SPR,FRENCHYTHROWR1SPR,step,false,
false,10, 0,0, NULL, NULL, DrawReact, &s_frenchythrow2};
statetype s_frenchythrow2 = {FRENCHYTHROWL2SPR,FRENCHYTHROWR2SPR,step,false,
false,1, 0,0, FrenchyThrow, NULL, DrawReact, &s_frenchythrow3};
statetype s_frenchythrow3 = {FRENCHYTHROWL2SPR,FRENCHYTHROWR2SPR,step,false,
false,10, -128,0, NULL, NULL, DrawReact, &s_frenchywalk1};
statetype s_fry1 = {FRENCHFRY1SPR,FRENCHFRY1SPR,stepthink,false,
false,4, 0,0, ProjectileThink, NULL, ProjectileReact, &s_fry2};
statetype s_fry2 = {FRENCHFRY2SPR,FRENCHFRY2SPR,stepthink,false,
false,4, 0,0, ProjectileThink, NULL, ProjectileReact, &s_fry1};
#pragma warn +sus
/*
====================
=
= SpawnFrenchy
=
====================
*/
void SpawnFrenchy (int tilex, int tiley)
{
GetNewObj (false);
new->obclass = frenchyobj;
new->x = tilex<<G_T_SHIFT;
new->y = (tiley<<G_T_SHIFT)-2*BLOCKSIZE;
new->xdir = 1;
new->ydir = 1;
NewState (new,&s_frenchywalk1);
}
/*
====================
=
= FrenchyRunThink
=
====================
*/
void FrenchyRunThink (objtype *ob)
{
ob->state = &s_frenchywalk1;
}
/*
====================
=
= FrenchyThrow
=
====================
*/
void FrenchyThrow (objtype *ob)
{
GetNewObj (true);
new->obclass = shotobj;
if (ob->xdir == 1)
{
new->x = ob->x+24*16;
new->y = ob->y+8*16;
}
else
{
new->x = ob->x;
new->y = ob->y+8*16;
}
new->xdir = ob->xdir;
new->ydir = 1;
new->xspeed = ob->xdir * FRYXSPEED-(US_RndT()>>4);
new->yspeed = FRYYSPEED;
new->active = removable;
NewState (new,&s_fry1);
ob->nothink = 2;
}
/*
====================
=
= FrenchyThink
=
====================
*/
void FrenchyThink (objtype *ob)
{
int delta;
if ( abs(ob->y - player->y) > 3*TILEGLOBAL )
{
if (US_RndT()<8)
ob->xdir = -ob->xdir; // turn randomly
return;
}
delta = player->x - ob->x;
if (delta < -8*TILEGLOBAL)
{
// walk closer
ob->xdir = -1;
}
if (delta < -4*TILEGLOBAL)
{
// throw
ob->xdir = -1;
ob->state = &s_frenchythrow1;
}
else if (delta < 0)
{
// run away
ob->xdir = 1;
ob->state = &s_frenchyrun1;
ob->nothink = 8;
}
else if (delta < 4*TILEGLOBAL)
{
// run away
ob->xdir = -1;
ob->state = &s_frenchyrun1;
ob->nothink = 8;
}
else if (delta < 8*TILEGLOBAL)
{
// throw and walk closer
ob->xdir = 1;
ob->state = &s_frenchythrow1;
}
else
{
// walk closer
ob->xdir = 1;
}
}
/*
=============================================================================
MELON LIPS
ob->temp1 = direction : 0 = left, 1 = right, 2 = down
=============================================================================
*/
#define SPITXSPEED 48
#define SPITYSPEED -20
void MelonSpitThink (objtype *ob);
void ProjectileReact (objtype *ob);
extern statetype s_melonside;
extern statetype s_melonsidespit;
extern statetype s_melonsidespit2;
extern statetype s_melondown;
extern statetype s_melondownspit;
extern statetype s_melondownspit2;
extern statetype s_melonseed1;
extern statetype s_melonseed2;
extern statetype s_melonseedd1;
extern statetype s_melonseedd2;
#pragma warn -sus
statetype s_melonside = {MELONLIPSL1SPR,MELONLIPSR1SPR,step,false,
false,200, 0,0, NULL, NULL, DrawReact, &s_melonsidespit};
statetype s_melonsidespit= {MELONLIPSL2SPR,MELONLIPSR2SPR,step,false,
false,6, 0,0, MelonSpitThink, NULL, DrawReact, &s_melonsidespit2};
statetype s_melonsidespit2= {MELONLIPSL2SPR,MELONLIPSR2SPR,step,false,
false,6, 0,0, NULL, NULL, DrawReact, &s_melonside};
statetype s_melondown = {MELONLIPSD1SPR,MELONLIPSD1SPR,step,false,
false,200, 0,0, NULL, NULL, DrawReact, &s_melondownspit};
statetype s_melondownspit = {MELONLIPSD2SPR,MELONLIPSD2SPR,step,false,
false,6, 0,0, MelonSpitThink, NULL, DrawReact, &s_melondownspit2};
statetype s_melondownspit2 = {MELONLIPSD2SPR,MELONLIPSD2SPR,step,false,
false,6, 0,0, NULL, NULL, DrawReact, &s_melondown};
statetype s_melonseed1 = {MELONSEEDL1SPR,MELONSEEDR1SPR,think,false,
false,4, 0,0, ProjectileThink, NULL, ProjectileReact, &s_melonseed2};
statetype s_melonseed2 = {MELONSEEDL2SPR,MELONSEEDR2SPR,think,false,
false,4, 0,0, ProjectileThink, NULL, ProjectileReact, &s_melonseed1};
statetype s_melonseedd1 = {MELONSEEDD1SPR,MELONSEEDD1SPR,stepthink,false,
false,4, 0,0, ProjectileThink, NULL, ProjectileReact, &s_melonseedd2};
statetype s_melonseedd2 = {MELONSEEDD2SPR,MELONSEEDD2SPR,stepthink,false,
false,4, 0,0, ProjectileThink, NULL, ProjectileReact, &s_melonseedd1};
#pragma warn +sus
/*
====================
=
= SpawnMelon
=
====================
*/
void SpawnMelon (int tilex, int tiley,int dir)
{
GetNewObj (false);
new->obclass = melonobj;
new->x = tilex<<G_T_SHIFT;
new->y = tiley<<G_T_SHIFT;
if (dir)
new->xdir = 1;
else
new->xdir = -1;
if (dir <2)
NewState (new,&s_melonside);
else
NewState (new,&s_melondown);
new->ticcount = US_RndT()>>1;
new->temp1 = dir;
}
/*
====================
=
= MelonSpitThink
=
====================
*/
void MelonSpitThink (objtype *ob)
{
GetNewObj (false);
new->obclass = shotobj;
switch (ob->temp1)
{
case 0:
new->x = ob->x+24*16;
new->y = ob->y+8*16;
new->xdir = ob->xdir;
new->ydir = 1;
new->xspeed = -SPITXSPEED-(US_RndT()>>4);
new->yspeed = SPITYSPEED;
NewState (new,&s_melonseed1);
break;
case 1:
new->x = ob->x;
new->y = ob->y+8*16;
new->xdir = ob->xdir;
new->ydir = 1;
new->xspeed = SPITXSPEED+(US_RndT()>>4);
new->yspeed = SPITYSPEED;
NewState (new,&s_melonseed1);
break;
case 2:
new->x = ob->x+8*16;
new->y = ob->y+24*16;
new->ydir = 1;
new->yspeed = -SPITYSPEED;
NewState (new,&s_melonseedd1);
break;
}
new->active = removable;
}
/*
============================
=
= ProjectileReact
=
============================
*/
void ProjectileReact (objtype *ob)
{
unsigned wall,absx,absy,angle,newangle;
unsigned long speed;
PLACESPRITE;
if (ob->hiteast || ob->hitwest)
ob->xspeed= -ob->xspeed/2;
if (ob->hitsouth)
ob->yspeed= -ob->yspeed/2;
wall = ob->hitnorth;
if (wall)
{
if (ob->yspeed < 0)
ob->yspeed = 0;
absx = abs(ob->xspeed);
absy = ob->yspeed;
if (absx>absy)
{
if (absx>absy*2) // 22 degrees
{
angle = 0;
speed = absx*286; // x*sqrt(5)/2
}
else // 45 degrees
{
angle = 1;
speed = absx*362; // x*sqrt(2)
}
}
else
{
if (absy>absx*2) // 90 degrees
{
angle = 3;
speed = absy*256;
}
else
{
angle = 2; // 67 degrees
speed = absy*286; // y*sqrt(5)/2
}
}
if (ob->xspeed > 0)
angle = 7-angle;
speed >>= 1;
newangle = bounceangle[ob->hitnorth][angle];
switch (newangle)
{
case 0:
ob->xspeed = speed / 286;
ob->yspeed = -ob->xspeed / 2;
break;
case 1:
ob->xspeed = speed / 362;
ob->yspeed = -ob->xspeed;
break;
case 2:
ob->yspeed = -(speed / 286);
ob->xspeed = -ob->yspeed / 2;
break;
case 3:
case 4:
ob->xspeed = 0;
ob->yspeed = -(speed / 256);
break;
case 5:
ob->yspeed = -(speed / 286);
ob->xspeed = ob->yspeed / 2;
break;
case 6:
ob->xspeed = ob->yspeed = -(speed / 362);
break;
case 7:
ob->xspeed = -(speed / 286);
ob->yspeed = ob->xspeed / 2;
break;
case 8:
ob->xspeed = -(speed / 286);
ob->yspeed = -ob->xspeed / 2;
break;
case 9:
ob->xspeed = -(speed / 362);
ob->yspeed = -ob->xspeed;
break;
case 10:
ob->yspeed = speed / 286;
ob->xspeed = -ob->yspeed / 2;
break;
case 11:
case 12:
ob->xspeed = 0;
ob->yspeed = -(speed / 256);
break;
case 13:
ob->yspeed = speed / 286;
ob->xspeed = ob->yspeed / 2;
break;
case 14:
ob->xspeed = speed / 362;
ob->yspeed = speed / 362;
break;
case 15:
ob->xspeed = speed / 286;
ob->yspeed = ob->xspeed / 2;
break;
}
if (speed < 256*16)
RemoveObj (ob);
}
}
/*
=============================================================================
SQUASHER
=============================================================================
*/
#define SPDSQUASHLEAPY 50
void SquasherThink (objtype *ob);
void SquasherJumpReact (objtype *ob);
extern statetype s_squasherwalk1;
extern statetype s_squasherwalk2;
extern statetype s_squasherjump1;
extern statetype s_squasherjump2;
extern statetype s_squasherwait;
#pragma warn -sus
statetype s_squasherwalk1 = {SQUASHERWALKL1SPR,SQUASHERWALKR1SPR,step,false,
true,10, 128,0, SquasherThink, NULL, WalkReact, &s_squasherwalk2};
statetype s_squasherwalk2 = {SQUASHERWALKL2SPR,SQUASHERWALKR2SPR,step,false,
true,10, 128,0, SquasherThink, NULL, WalkReact, &s_squasherwalk1};
statetype s_squasherjump1 = {SQUASHERJUMPL1SPR,SQUASHERJUMPR1SPR,stepthink,false,
false,20, 0,0, ProjectileThink, NULL, SquasherJumpReact, &s_squasherjump2};
statetype s_squasherjump2 = {SQUASHERJUMPL2SPR,SQUASHERJUMPR2SPR,think,false,
false,0, 0,0, ProjectileThink, NULL, SquasherJumpReact, NULL};
statetype s_squasherwait = {SQUASHERJUMPL2SPR,SQUASHERJUMPR2SPR,step,false,
false,10, 0,0, ProjectileThink, NULL, DrawReact, &s_squasherwalk1};
#pragma warn +sus
/*
====================
=
= SpawnSquasher
=
====================
*/
void SpawnSquasher (int tilex, int tiley)
{
GetNewObj (false);
new->obclass = squashobj;
new->x = tilex<<G_T_SHIFT;
new->y = (tiley<<G_T_SHIFT)-2*BLOCKSIZE;
new->xdir = 1;
new->ydir = 1;
NewState (new,&s_squasherwalk1);
}
/*
====================
=
= SquasherThink
=
====================
*/
void SquasherThink (objtype *ob)
{
int delta;
if ( abs(ob->y - player->y) > 3*TILEGLOBAL )
{
if (US_RndT()<8)
ob->xdir = -ob->xdir; // turn randomly
return;
}
delta = player->x - ob->x;
if ( ob->xdir == -1 )
{
if (delta < -6*TILEGLOBAL)
return;
if (delta > 8*PIXGLOBAL)
{
ob->xdir = 1;
return;
}
}
else
{
if (delta > 6*TILEGLOBAL)
return;
if (delta < -8*PIXGLOBAL)
{
ob->xdir = 1;
return;
}
}
ob->yspeed = -SPDSQUASHLEAPY;
ob->xspeed = delta/60;
ob->state = &s_squasherjump1;
}
/*
====================
=
= SquasherJumpReact
=
====================
*/
void SquasherJumpReact (objtype *ob)
{
if (ob->hitsouth)
ob->yspeed = 0;
if (ob->hitnorth)
ChangeState (ob,&s_squasherwait);
PLACESPRITE;
}
/*
=============================================================================
APEL
temp4 = pole x coordinate
=============================================================================
*/
void ApelThink (objtype *ob);
void ApelClimbThink (objtype *ob);
void ApelSlideThink (objtype *ob);
void ApelFallThink (objtype *ob);
void ApelClimbReact (objtype *ob);
void ApelSlideReact (objtype *ob);
void ApelFallReact (objtype *ob);
extern statetype s_apelwalk1;
extern statetype s_apelwalk2;
extern statetype s_apelwalk3;
extern statetype s_apelclimb1;
extern statetype s_apelclimb2;
extern statetype s_apelslide1;
extern statetype s_apelslide2;
extern statetype s_apelslide3;
extern statetype s_apelslide4;
extern statetype s_apelfall;
#pragma warn -sus
statetype s_apelwalk1 = {APELWALKL1SPR,APELWALKR1SPR,step,false,
true,10, 128,0, ApelThink, NULL, WalkReact, &s_apelwalk2};
statetype s_apelwalk2 = {APELWALKL2SPR,APELWALKR2SPR,step,false,
true,10, 128,0, ApelThink, NULL, WalkReact, &s_apelwalk3};
statetype s_apelwalk3 = {APELWALKL3SPR,APELWALKR3SPR,step,false,
true,10, 128,0, ApelThink, NULL, WalkReact, &s_apelwalk1};
statetype s_apelclimb1 = {APELSHINNY1SPR,APELSHINNY1SPR,slide,false,
false,6, 0,-16, ApelClimbThink, NULL, ApelClimbReact, &s_apelclimb2};
statetype s_apelclimb2 = {APELSHINNY2SPR,APELSHINNY2SPR,slide,false,
false,6, 0,-16, ApelClimbThink, NULL, ApelClimbReact, &s_apelclimb1};
statetype s_apelslide1 = {APELSLIDE1SPR,APELSLIDE1SPR,slide,false,
false,6, 0,16, ApelSlideThink, NULL, ApelFallReact, &s_apelslide2};
statetype s_apelslide2 = {APELSLIDE2SPR,APELSLIDE2SPR,slide,false,
false,6, 0,16, ApelSlideThink, NULL, ApelFallReact, &s_apelslide3};
statetype s_apelslide3 = {APELSLIDE3SPR,APELSLIDE3SPR,slide,false,
false,6, 0,16, ApelSlideThink, NULL, ApelFallReact, &s_apelslide4};
statetype s_apelslide4 = {APELSLIDE4SPR,APELSLIDE4SPR,slide,false,
false,6, 0,16, ApelSlideThink, NULL, ApelFallReact, &s_apelslide1};
statetype s_apelfall = {APELWALKL1SPR,APELWALKR1SPR,think,false,
false,0, 0,0, ProjectileThink, NULL, ApelFallReact, NULL};
#pragma warn +sus
/*
====================
=
= SpawnApel
=
====================
*/
void SpawnApel (int tilex, int tiley)
{
GetNewObj (false);
new->obclass = apelobj;
new->x = tilex<<G_T_SHIFT;
new->y = (tiley<<G_T_SHIFT)-2*BLOCKSIZE;
new->xdir = 1;
new->ydir = 1;
NewState (new,&s_apelwalk1);
}
/*
====================
=
= ApelThink
=
====================
*/
void ApelThink (objtype *ob)
{
int x,y;
unsigned far *map;
if (ob->top > player->bottom || ob->bottom < player->top)
{
//
// try to climb a pole to reach player
//
if (ob->y < player->y)
y = ob->tilebottom;
else
y = ob->tiletop;
map = (unsigned _seg *)mapsegs[1]+
mapbwidthtable[y]/2 + ob->tilemidx;
if ((tinf[INTILE+*map]&0x7f) == 1)
{
ob->xmove = (ob->tilemidx<<G_T_SHIFT) - ob->x;
ob->ymove = 0;
ob->temp4 = ob->tilemidx; // for future reference
ob->needtoclip = false; // can climb through pole holes
if (ob->y < player->y)
ob->state = &s_apelslide1;
else
ob->state = &s_apelclimb1;
return;
}
}
if (US_RndT()>32) // don't turn around all the time
return;
if (ob->x < player->x)
ob->xdir = 1;
else
ob->xdir = -1;
}
/*
====================
=
= ApelClimbThink
=
====================
*/
void ApelClimbThink (objtype *ob)
{
unsigned far *map;
map = (unsigned _seg *)mapsegs[1]+
mapbwidthtable[ob->tiletop]/2 + ob->temp4;
if ((tinf[INTILE+*map]&0x7f) != 1)
{
ob->needtoclip = true;
ob->state = &s_apelfall;
}
}
/*
====================
=
= ApelSlideThink
=
====================
*/
void ApelSlideThink (objtype *ob)
{
unsigned far *map;
map = (unsigned _seg *)mapsegs[1]+
mapbwidthtable[ob->tilebottom]/2 + ob->temp4;