/
game.h
2271 lines (1844 loc) · 71.7 KB
/
game.h
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
//-------------------------------------------------------------------------
/*
Copyright (C) 1997, 2005 - 3D Realms Entertainment
This file is part of Shadow Warrior version 1.2
Shadow Warrior 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.
Original Source: 1997 - Frank Maddin and Jim Norwood
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
*/
//-------------------------------------------------------------------------
#ifndef GAME_H
#define GAME_H
#ifndef DEBUG
#define DEBUG 0
#endif
#ifdef _MSC_VER
#pragma warning(disable:4101) // there's too many of these... :(
#endif
#include "build.h"
#include "compat.h"
#include "mmulti.h"
#include "mytypes.h"
#include "sounds.h"
#include "gamecvars.h"
#include "raze_sound.h"
#include "c_cvars.h"
#include "mapinfo.h"
#include "gamecontrol.h"
#include "gamestruct.h"
#include "packet.h"
#include "gameinput.h"
EXTERN_CVAR(Bool, sw_ninjahack)
EXTERN_CVAR(Bool, sw_darts)
EXTERN_CVAR(Bool, sw_bunnyrockets)
BEGIN_SW_NS
typedef struct
{
// Net Options from Menus
uint8_t NetGameType; // 0=DeathMatch [spawn], 1=Cooperative 2=DeathMatch [no spawn]
uint8_t NetMonsters; // Cycle skill levels
bool NetHurtTeammate; // Allow friendly kills
bool NetSpawnMarkers; // Respawn markers on/off
bool NetTeamPlay; // Team play
uint8_t NetKillLimit; // Number of frags at which game ends
uint8_t NetTimeLimit; // Limit time of game
uint8_t NetColor; // Chosen color for player
bool NetNuke;
} GAME_SET, * GAME_SETp;
extern const GAME_SET gs_defaults;
extern GAME_SET gs;
enum
{
DREALMSPAL = 1,
THREED_REALMS_PIC = 2325,
MAXMIRRORS = 8,
// This is just some, high, blank tile number not used
// by real graphics to put the MAXMIRRORS mirrors in
MIRRORLABEL = 6000,
};
//#define SW_SHAREWARE 1 // This determines whether game is shareware compile or not!
#define SW_SHAREWARE (!!(g_gameType & GAMEFLAG_SHAREWARE))
// Turn warning off for unreferenced variables.
// I really should fix them at some point
//#pragma off(unreferenced)
#define PRODUCTION_ASSERT(f) \
do { \
if (!(f)) \
I_FatalError("Assertion failed: %s %s, line %u", #f, __FILE__, __LINE__); \
} while (0)
#define ASSERT assert
#define MONO_PRINT(str)
#define HEAP_CHECK()
#define RANDOM_DEBUG 0
int RandomRange(int);
inline int RANDOM(void)
{
randomseed = ((randomseed * 21 + 1) & 65535);
return randomseed;
}
#define RANDOM_P2(pwr_of_2) (MOD_P2(RANDOM(),(pwr_of_2)))
#define RANDOM_RANGE(range) (RandomRange(range))
#define PRINT(line,str) DebugPrint(line,str)
//
// Map directions/degrees
//
#if 0
y--
^ 1536
|
|
|
|
|
| 2047
<---------------------------->
1024 | 0
x-- | x++
|
|
|
|
V 512
y++
#endif
//////////////////////////////////////////////////////
//
// KEYBOARD
//
//////////////////////////////////////////////////////
extern bool MenuInputMode;
//
// Defines
//
#define CIRCLE_CAMERA_DIST_MIN 12000
// dist at which actors will not move (unless shot?? to do)
#define MAX_ACTIVE_RANGE 42000
// dist at which actors roam about on their own
#define MIN_ACTIVE_RANGE 20000
// REDEFINABLE PLAYER KEYS NUMBERS
#define PK_FORWARD 0
#define PK_BACKWARD 1
#define PK_LEFT 2
#define PK_RIGHT 3
#define PK_RUN 4
#define PK_STRAFE 5
#define PK_SHOOT 6
#define PK_OPERATE 7
#define PK_JUMP 8
#define PK_CRAWL 9
#define PK_LOOK_UP 10
#define PK_LOOK_DOWN 11
#define PK_STRAFE_LEFT 12
#define PK_STRAFE_RIGHT 13
#define PK_MAP 14
#define PK_MULTI_VIEW 15
#define PK_ZOOM_IN 16
#define PK_ZOOM_OUT 17
#define PK_MESSAGE 18
inline int32_t FIXED(int32_t msw, int32_t lsw)
{
return IntToFixed(msw) | lsw;
}
// Ouch...
#if B_BIG_ENDIAN == 0
# define MSB_VAR(fixed) (*(((uint8_t*)&(fixed)) + 1))
# define LSB_VAR(fixed) (*((uint8_t*)&(fixed)))
#else
# define LSB_VAR(fixed) (*(((uint8_t*)&(fixed)) + 1))
# define MSB_VAR(fixed) (*((uint8_t*)&(fixed)))
#endif
#define MSW(fixed) ((fixed)>>16)
#define LSW(fixed) (((int16_t)(fixed)))
// Defines for reading in ST1 sprite tagging
#define SP_TAG1(sp) ((sp)->hitag)
#define SP_TAG2(sp) ((sp)->lotag)
#define SP_TAG3(sp) ((sp)->clipdist)
#define SP_TAG4(sp) ((sp)->ang)
#define SP_TAG5(sp) ((sp)->xvel)
#define SP_TAG6(sp) ((sp)->yvel)
#define SP_TAG7(sp) (MSB_VAR((sp)->zvel))
#define SP_TAG8(sp) (LSB_VAR((sp)->zvel))
#define SP_TAG9(sp) (MSB_VAR((sp)->owner))
#define SP_TAG10(sp) (LSB_VAR((sp)->owner))
#define SP_TAG11(sp) ((sp)->shade)
#define SP_TAG12(sp) ((sp)->pal)
#define SP_TAG13(sp) B_LITTLE16(*((short*)&(sp)->xoffset))
#define SP_TAG14(sp) B_LITTLE16(*((short*)&(sp)->xrepeat))
#define SP_TAG15(sp) ((sp)->z)
#define SET_SP_TAG13(sp,val) (*((short*)&(sp)->xoffset)) = B_LITTLE16((short)val)
#define SET_SP_TAG14(sp,val) (*((short*)&(sp)->xrepeat)) = B_LITTLE16((short)val)
#define SPRITE_TAG1(sp) (sprite[sp].hitag)
#define SPRITE_TAG2(sp) (sprite[sp].lotag)
#define SPRITE_TAG3(sp) (sprite[sp].clipdist)
#define SPRITE_TAG4(sp) (sprite[sp].ang)
#define SPRITE_TAG5(sp) (sprite[sp].xvel)
#define SPRITE_TAG6(sp) (sprite[sp].yvel)
#define SPRITE_TAG7(sp) (MSB_VAR(sprite[sp].zvel))
#define SPRITE_TAG8(sp) (LSB_VAR(sprite[sp].zvel))
#define SPRITE_TAG9(sp) (MSB_VAR(sprite[sp].owner))
#define SPRITE_TAG10(sp) (LSB_VAR(sprite[sp].owner))
#define SPRITE_TAG11(sp) (sprite[sp].shade)
#define SPRITE_TAG12(sp) (sprite[sp].pal)
#define SPRITE_TAG13(sp) B_LITTLE16(*((short*)&sprite[sp].xoffset))
#define SPRITE_TAG14(sp) B_LITTLE16(*((short*)&sprite[sp].xrepeat))
#define SPRITE_TAG15(sp) (sprite[sp].z)
#define SET_SPRITE_TAG13(sp,val) (*((short*)&sprite[sp].xoffset)) = B_LITTLE16((short)val)
#define SET_SPRITE_TAG14(sp,val) (*((short*)&sprite[sp].xrepeat)) = B_LITTLE16((short)val)
// OVER and UNDER water macros
#define SpriteInDiveArea(sp) (TEST(sector[(sp)->sectnum].extra, SECTFX_DIVE_AREA) ? true : false)
#define SpriteInUnderwaterArea(sp) (TEST(sector[(sp)->sectnum].extra, SECTFX_UNDERWATER|SECTFX_UNDERWATER2) ? true : false)
#define SectorIsDiveArea(sect) (TEST(sector[sect].extra, SECTFX_DIVE_AREA) ? true : false)
#define SectorIsUnderwaterArea(sect) (TEST(sector[sect].extra, SECTFX_UNDERWATER|SECTFX_UNDERWATER2) ? true : false)
#define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i])
#define NORM_ANGLE(ang) ((ang) & 2047)
#define ANGLE_2_PLAYER(pp,x,y) (NORM_ANGLE(getangle(pp->posx-(x), pp->posy-(y))))
#define NORM_Q16ANGLE(ang) ((ang) & 0x7FFFFFF)
int StdRandomRange(int range);
#define STD_RANDOM_P2(pwr_of_2) (MOD_P2(rand(),(pwr_of_2)))
#define STD_RANDOM_RANGE(range) (StdRandomRange(range))
#define STD_RANDOM() (rand())
#define RANDOM_NEG(x,y) ((RANDOM_P2(((x)<<(y))<<1) - (x))<<(y))
#define MOVEx(vel,ang) (MulScale(vel, bcos(ang), 14))
#define MOVEy(vel,ang) (MulScale(vel, bsin(ang), 14))
#define DIST(x1, y1, x2, y2) ksqrt( SQ((x1) - (x2)) + SQ((y1) - (y2)) )
inline int PIC_SIZY(int sn)
{
return tileHeight(sprite[sn].picnum);
}
// Distance macro - tx, ty, tmin are holding vars that must be declared in the routine
// that uses this macro
inline void DISTANCE(int x1, int y1, int x2, int y2, int& dist, int& tx, int& ty, int& tmin)
{
tx = abs(x2 - x1);
ty = abs(y2 - y1);
tmin = min(tx, ty);
dist = tx + ty - (tmin >> 1);
}
inline int SPRITEp_SIZE_X(const spritetype* sp)
{
return MulScale(tileWidth(sp->picnum), sp->xrepeat, 6);
}
inline int SPRITEp_SIZE_Y(const spritetype* sp)
{
return MulScale(tileHeight(sp->picnum), sp->yrepeat, 6);
}
inline int SPRITEp_SIZE_Z(const spritetype* sp)
{
return (tileHeight(sp->picnum) * sp->yrepeat) << 2;
}
// Given a z height and sprite return the correct y repeat value
inline int SPRITEp_SIZE_Z_2_YREPEAT(const spritetype* sp, int zh)
{
return zh / (4 * tileHeight(sp->picnum));
}
// Z size of top (TOS) and bottom (BOS) part of sprite
inline int SPRITEp_SIZE_TOS(const spritetype* sp)
{
return (DIV2(SPRITEp_SIZE_Z(sp)) + (tileTopOffset(sp->picnum) << 8));
}
inline int SPRITEp_SIZE_BOS(const spritetype* sp)
{
return (DIV2(SPRITEp_SIZE_Z(sp)) - (tileTopOffset(sp->picnum) << 8));
}
// actual Z for TOS and BOS - handles both WYSIWYG and old style
#define SPRITEp_TOS(sp) (TEST((sp)->cstat, CSTAT_SPRITE_YCENTER) ? \
((sp)->z - SPRITEp_SIZE_TOS(sp)) : \
((sp)->z - SPRITEp_SIZE_Z(sp)))
#define SPRITEp_BOS(sp) (TEST((sp)->cstat, CSTAT_SPRITE_YCENTER) ? \
((sp)->z + SPRITEp_SIZE_BOS(sp)) : \
(sp)->z)
// mid and upper/lower sprite calculations
#define SPRITEp_MID(sp) (DIV2(SPRITEp_TOS(sp) + SPRITEp_BOS(sp)))
#define SPRITEp_UPPER(sp) (SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp)))
#define SPRITEp_LOWER(sp) (SPRITEp_BOS(sp) - DIV4(SPRITEp_SIZE_Z(sp)))
#define Z(value) ((int)(value) << 8)
#define PIXZ(value) ((int)(value) >> 8)
#define SQ(val) ((val) * (val))
#define KENFACING_PLAYER(pp,sp) (bcos(sp->ang)*(pp->posy-sp->y) >= bsin(sp-ang)*(pp->posx-sp->x))
#define FACING_PLAYER(pp,sp) (abs(getincangle(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y), (sp)->ang)) < 512)
#define PLAYER_FACING(pp,sp) (abs(getincangle(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy), (pp)->angle.ang.asbuild())) < 320)
#define FACING(sp1,sp2) (abs(getincangle(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y), (sp2)->ang)) < 512)
#define FACING_PLAYER_RANGE(pp,sp,range) (abs(getincangle(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y), (sp)->ang)) < (range))
#define PLAYER_FACING_RANGE(pp,sp,range) (abs(getincangle(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy), (pp)->angle.ang.asbuild())) < (range))
#define FACING_RANGE(sp1,sp2,range) (abs(getincangle(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y), (sp2)->ang)) < (range))
// two vectors
// can determin direction
#define DOT_PRODUCT_2D(x1,y1,x2,y2) (MulScale((x1), (x2), 16) + MulScale((y1), (y2), 16))
#define DOT_PRODUCT_3D(x1,y1,z1,x2,y2,z2) (MulScale((x1), (x2), 16) + MulScale((y1), (y2), 16) + MulScale((z1), (z2), 16))
// just determine if the player is moving
#define PLAYER_MOVING(pp) ((pp)->xvect|(pp)->yvect)
#define TEST_GOTSECTOR(sect_num) (TEST(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7)))
#define RESET_GOTSECTOR(sect_num) (RESET(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7)))
#define SET_GOTSECTOR(sect_num) (SET(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7)))
#define TEST_GOTPIC(tile_num) (TEST(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7)))
#define RESET_GOTPIC(tile_num) (RESET(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7)))
#define SET_GOTPIC(tile_num) (SET(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7)))
#define LOW_TAG(sectnum) ( sector[sectnum].lotag )
#define HIGH_TAG(sectnum) ( sector[sectnum].hitag )
#define LOW_TAG_SPRITE(spnum) ( sprite[(spnum)].lotag )
#define HIGH_TAG_SPRITE(spnum) ( sprite[(spnum)].hitag )
#define LOW_TAG_WALL(wallnum) ( wall[(wallnum)].lotag )
#define HIGH_TAG_WALL(wallnum) ( wall[(wallnum)].hitag )
#define SEC(value) ((value)*120)
#define CEILING_DIST (Z(4))
#define FLOOR_DIST (Z(4))
// Attributes for monochrome text
#define MDA_BLANK 0x00
#define MDA_NORMAL 0x07
#define MDA_BLINK 0x87
#define MDA_HIGH 0x0F
#define MDA_HIGHBLINK 0x8F
#define MDA_UNDER 0x01
#define MDA_UNDERBLINK 0x81
#define MDA_UNDERHIGH 0x09
#define MDA_UNDERHIGHBLINK 0x89
#define MDA_REVERSE 0x70
#define MDA_REVERSEBLINK 0xF0
// defines for move_sprite return value
#define HIT_MASK (BIT(14)|BIT(15)|BIT(16))
#define HIT_SPRITE (BIT(14)|BIT(15))
#define HIT_WALL BIT(15)
#define HIT_SECTOR BIT(14)
#define HIT_PLAX_WALL BIT(16)
#define NORM_SPRITE(val) ((val) & (MAXSPRITES - 1))
#define NORM_WALL(val) ((val) & (MAXWALLS - 1))
#define NORM_SECTOR(val) ((val) & (MAXSECTORS - 1))
// overwritesprite flags
#define OVER_SPRITE_MIDDLE (BIT(0))
#define OVER_SPRITE_VIEW_CLIP (BIT(1))
#define OVER_SPRITE_TRANSLUCENT (BIT(2))
#define OVER_SPRITE_XFLIP (BIT(3))
#define OVER_SPRITE_YFLIP (BIT(4))
// system defines for status bits
#define CEILING_STAT_PLAX BIT(0)
#define CEILING_STAT_SLOPE BIT(1)
#define CEILING_STAT_SWAPXY BIT(2)
#define CEILING_STAT_SMOOSH BIT(3)
#define CEILING_STAT_XFLIP BIT(4)
#define CEILING_STAT_YFLIP BIT(5)
#define CEILING_STAT_RELATIVE BIT(6)
#define CEILING_STAT_TYPE_MASK (BIT(7)|BIT(8))
#define CEILING_STAT_MASKED BIT(7)
#define CEILING_STAT_TRANS BIT(8)
#define CEILING_STAT_TRANS_FLIP (BIT(7)|BIT(8))
#define CEILING_STAT_FAF_BLOCK_HITSCAN BIT(15)
#define FLOOR_STAT_PLAX BIT(0)
#define FLOOR_STAT_SLOPE BIT(1)
#define FLOOR_STAT_SWAPXY BIT(2)
#define FLOOR_STAT_SMOOSH BIT(3)
#define FLOOR_STAT_XFLIP BIT(4)
#define FLOOR_STAT_YFLIP BIT(5)
#define FLOOR_STAT_RELATIVE BIT(6)
#define FLOOR_STAT_TYPE_MASK (BIT(7)|BIT(8))
#define FLOOR_STAT_MASKED BIT(7)
#define FLOOR_STAT_TRANS BIT(8)
#define FLOOR_STAT_TRANS_FLIP (BIT(7)|BIT(8))
#define FLOOR_STAT_FAF_BLOCK_HITSCAN BIT(15)
#define CSTAT_WALL_BLOCK BIT(0)
#define CSTAT_WALL_BOTTOM_SWAP BIT(1)
#define CSTAT_WALL_ALIGN_BOTTOM BIT(2)
#define CSTAT_WALL_XFLIP BIT(3)
#define CSTAT_WALL_MASKED BIT(4)
#define CSTAT_WALL_1WAY BIT(5)
#define CSTAT_WALL_BLOCK_HITSCAN BIT(6)
#define CSTAT_WALL_TRANSLUCENT BIT(7)
#define CSTAT_WALL_YFLIP BIT(8)
#define CSTAT_WALL_TRANS_FLIP BIT(9)
#define CSTAT_WALL_BLOCK_ACTOR (BIT(14)) // my def
#define CSTAT_WALL_WARP_HITSCAN (BIT(15)) // my def
//cstat, bit 0: 1 = Blocking sprite (use with clipmove, getzrange) "B"
// bit 1: 1 = 50/50 transluscence, 0 = normal "T"
// bit 2: 1 = x-flipped, 0 = normal "F"
// bit 3: 1 = y-flipped, 0 = normal "F"
// bits 5-4: 00 = FACE sprite (default) "R"
// 01 = WALL sprite (like masked walls)
// 10 = FLOOR sprite (parallel to ceilings&floors)
// 11 = SPIN sprite (face sprite that can spin 2draw style - not done yet)
// bit 6: 1 = 1-sided sprite, 0 = normal "1"
// bit 7: 1 = Real centered centering, 0 = foot center "C"
// bit 8: 1 = Blocking sprite (use with hitscan) "H"
// bit 9: reserved
// bit 10: reserved
// bit 11: reserved
// bit 12: reserved
// bit 13: reserved
// bit 14: reserved
// bit 15: 1 = Invisible sprite, 0 = not invisible
#define CSTAT_SPRITE_RESTORE BIT(12) // my def
#define CSTAT_SPRITE_CLOSE_FLOOR BIT(13) // my def - tells whether a sprite
// started out close to a ceiling or floor
#define CSTAT_SPRITE_BLOCK_MISSILE BIT(14) // my def
#define CSTAT_SPRITE_BREAKABLE (CSTAT_SPRITE_BLOCK_HITSCAN|CSTAT_SPRITE_BLOCK_MISSILE)
#undef CLIPMASK0 // defined in build.h
#undef CLIPMASK1
// new define more readable defines
// Clip Sprite adjustment
#define CS(sprite_bit) IntToFixed(sprite_bit)
// for players to clip against walls
#define CLIPMASK_PLAYER (CS(CSTAT_SPRITE_BLOCK) | CSTAT_WALL_BLOCK)
// for actors to clip against walls
#define CLIPMASK_ACTOR \
( \
CS(CSTAT_SPRITE_BLOCK) | \
CSTAT_WALL_BLOCK | \
CSTAT_WALL_BLOCK_ACTOR \
)
// for missiles to clip against actors
#define CLIPMASK_MISSILE \
( \
CS(CSTAT_SPRITE_BLOCK_HITSCAN|CSTAT_SPRITE_BLOCK_MISSILE) | \
CSTAT_WALL_BLOCK_HITSCAN \
)
#define CLIPMASK_WARP_HITSCAN \
( \
CS(CSTAT_SPRITE_BLOCK_HITSCAN) | \
CSTAT_WALL_BLOCK_HITSCAN | \
CSTAT_WALL_WARP_HITSCAN \
)
#define SIZ countof
//
// Directions
//
#define DEGREE_45 256
#define DEGREE_90 512
////
//
// Directional enumerations
//
////
enum DirOrd
{
ORD_NORTH, ORD_NE, ORD_EAST, ORD_SE, ORD_SOUTH, ORD_SW, ORD_WEST, ORD_NW
};
enum Dir8
{
NORTH = ORD_NORTH * DEGREE_45,
NE = ORD_NE * DEGREE_45,
EAST = ORD_EAST * DEGREE_45,
SE = ORD_SE * DEGREE_45,
SOUTH = ORD_SOUTH * DEGREE_45,
SW = ORD_SW * DEGREE_45,
WEST = ORD_WEST * DEGREE_45,
NW = ORD_NW * DEGREE_45,
};
typedef enum Dir8 DIR8;
// Auto building enumerations
#define DIGI_ENUM
enum digi
{
#include "digi.h"
DIGI_MAX
};
#undef DIGI_ENUM
#define DAMAGE_ENUM
enum dam
{
#include "damage.h"
};
#undef DAMAGE_ENUM
////
//
// State declarations
//
////
// Forward declarations
struct STATEstruct;
typedef struct STATEstruct STATE, *STATEp, * *STATEpp;
//struct PIC_STATEstruct;
//typedef struct PIC_STATEstruct PIC_STATE, *PIC_STATEp;
struct PANEL_STATEstruct;
typedef struct PANEL_STATEstruct PANEL_STATE, *PANEL_STATEp;
struct PLAYERstruct;
typedef struct PLAYERstruct PLAYER, *PLAYERp;
struct PERSONALITYstruct;
typedef struct PERSONALITYstruct PERSONALITY, *PERSONALITYp;
struct ATTRIBUTEstruct;
typedef struct ATTRIBUTEstruct ATTRIBUTE, *ATTRIBUTEp;
struct SECTOR_OBJECTstruct;
typedef struct SECTOR_OBJECTstruct SECTOR_OBJECT, *SECTOR_OBJECTp;
struct PANEL_SPRITEstruct;
typedef struct PANEL_SPRITEstruct PANEL_SPRITE, *PANEL_SPRITEp;
struct ANIMstruct;
typedef struct ANIMstruct ANIM, *ANIMp;
typedef int ANIMATOR (int16_t SpriteNum);
typedef ANIMATOR *ANIMATORp;
typedef void pANIMATOR (PANEL_SPRITEp);
typedef pANIMATOR *pANIMATORp;
typedef void soANIMATOR (SECTOR_OBJECTp);
typedef soANIMATOR *soANIMATORp;
typedef spritetype SPRITE, *SPRITEp;
typedef sectortype SECTOR, *SECTORp;
typedef walltype WALL, *WALLp;
struct STATEstruct
{
short Pic;
int Tics;
ANIMATORp Animator;
STATEp NextState;
};
//
// State Flags
//
#define SF_TICS_MASK 0xFFFF
#define SF_QUICK_CALL BIT(16)
#define SF_PLAYER_FUNC BIT(17) // only for players to execute
#define SF_TIC_ADJUST BIT(18) // use tic adjustment for these frames
#define SF_WALL_STATE BIT(19) // use for walls instead of sprite
///////////////////////////////////////////////////////////////////////////////
// Jim's MISC declarations from other files
///////////////////////////////////////////////////////////////////////////////
typedef enum {WATER_FOOT, BLOOD_FOOT} FOOT_TYPE;
extern FOOT_TYPE FootMode;
int QueueFloorBlood(short hit_sprite); // Weapon.c
int QueueFootPrint(short hit_sprite); // Weapon.c
int QueueGeneric(short SpriteNum, short pic); // Weapon.c
int QueueLoWangs(short SpriteNum); // Weapon.c
int SpawnShell(short SpriteNum, short ShellNum); // Weapon.c
void UnlockKeyLock(short key_num, short hit_sprite); // JSector.c
#define MAX_PAIN 5
extern int PlayerPainVocs[MAX_PAIN];
extern int PlayerLowHealthPainVocs[MAX_PAIN];
#define MAX_TAUNTAI 33
extern int TauntAIVocs[MAX_TAUNTAI];
#define MAX_GETSOUNDS 5
extern int PlayerGetItemVocs[MAX_GETSOUNDS];
#define MAX_YELLSOUNDS 3
extern int PlayerYellVocs[MAX_YELLSOUNDS];
void BossHealthMeter(void);
// Global variables used for modifying variouse things from the Console
///////////////////////////////////////////////////////////////////////////////////////////
//
// CALLER - DLL handler
//
///////////////////////////////////////////////////////////////////////////////////////////
extern unsigned char DLL_Loaded;
extern int DLL_Handle; // Global DLL handle
extern char *DLL_path; // DLL path name
int DLL_Load(char *DLLpathname);
bool DLL_Unload(int procHandle);
bool DLL_ExecFunc(int procHandle, char *fName);
///////////////////////////////////////////////////////////////////////////////////////////
//
// JPlayer
//
///////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////
//
// Weapon
//
///////////////////////////////////////////////////////////////////////////////////////////
#define MAX_WEAPONS_KEYS 10
#define MAX_WEAPONS_EXTRA 4 // extra weapons like the two extra head attacks
#define MAX_WEAPONS (MAX_WEAPONS_KEYS + MAX_WEAPONS_EXTRA)
// weapons that not missile type sprites
#define WPN_NM_LAVA (-8)
#define WPN_NM_SECTOR_SQUISH (-9)
//#define WEAP_ENTRY(id, init_func, damage_lo, damage_hi, radius)
typedef struct
{
void (*Init)(PLAYERp);
int16_t damage_lo;
int16_t damage_hi;
unsigned int radius;
int16_t max_ammo;
int16_t min_ammo;
int16_t with_weapon;
int16_t weapon_pickup;
int16_t ammo_pickup;
} DAMAGE_DATA, *DAMAGE_DATAp;
extern DAMAGE_DATA DamageData[];
// bit arrays that determine if a) Weapon has no ammo b) Weapon is the ammo (no weapon exists)
extern int WeaponHasNoAmmo, WeaponIsAmmo;
void InitWeaponFist(PLAYERp);
void InitWeaponStar(PLAYERp);
void InitWeaponShotgun(PLAYERp);
void InitWeaponRocket(PLAYERp);
void InitWeaponRail(PLAYERp);
void InitWeaponMicro(PLAYERp);
void InitWeaponUzi(PLAYERp);
void InitWeaponSword(PLAYERp);
void InitWeaponHothead(PLAYERp);
void InitWeaponElectro(PLAYERp);
void InitWeaponHeart(PLAYERp);
void InitWeaponGrenade(PLAYERp);
void InitWeaponMine(PLAYERp);
void InitWeaponNapalm(PLAYERp);
void InitWeaponRing(PLAYERp);
extern void (*InitWeapon[MAX_WEAPONS]) (PLAYERp);
///////////////////////////////////////////////////////////////////////////////////////////
//
// Player
//
///////////////////////////////////////////////////////////////////////////////////////////
#define MAX_SW_PLAYERS_SW (4)
#define MAX_SW_PLAYERS_REG (8)
#define MAX_SW_PLAYERS (SW_SHAREWARE ? MAX_SW_PLAYERS_SW : MAX_SW_PLAYERS_REG)
extern int ThemeTrack[6]; // w
extern FString ThemeSongs[6]; //
#define MAX_EPISODE_NAME_LEN 24
extern char EpisodeNames[3][MAX_EPISODE_NAME_LEN+2];
enum
{
MAX_KEYS = 8,
MAX_FORTUNES = 16,
MAX_INVENTORY_Q = 11,//InvDecl_TOTAL
QUOTE_KEYMSG = 1,
QUOTE_DOORMSG = QUOTE_KEYMSG + MAX_KEYS,
// 23+24 are reserved.
QUOTE_COOKIE = 25,
QUOTE_INVENTORY = QUOTE_COOKIE + MAX_FORTUNES,
QUOTE_WPNFIST = QUOTE_INVENTORY + MAX_INVENTORY_Q,
QUOTE_WPNSWORD,
QUOTE_WPNSHURIKEN,
QUOTE_WPNSTICKY,
QUOTE_WPNUZI,
QUOTE_WPNLAUNCH,
QUOTE_WPNNUKE,
QUOTE_WPNGRENADE,
QUOTE_WPNRAILGUN,
QUOTE_WPNRIOT,
QUOTE_WPNHEAD,
QUOTE_WPNRIPPER,
// Here a gap of two needs to be inserted because the weapon array contains two bogus entries the parser can access.
// Not all ammo types here are used, but the entries must be reserved for the parser.
QUOTE_AMMOFIST = QUOTE_WPNRIPPER + 2,
QUOTE_AMMOSWORD,
QUOTE_AMMOSHURIKEN,
QUOTE_AMMOSTICKY,
QUOTE_AMMOUZI,
QUOTE_AMMOLAUNCH,
QUOTE_AMMONUKE,
QUOTE_AMMOGRENADE,
QUOTE_AMMORAILGUN,
QUOTE_AMMORIOT,
QUOTE_AMMOHEAD,
QUOTE_AMMORIPPER,
// Again, here a gap of two needs to be inserted because the weapon array contains two bogus entries the parser can access.
};
#define PACK 1
extern bool CameraTestMode;
enum PlayerDeathTypes
{
PLAYER_DEATH_FLIP, PLAYER_DEATH_CRUMBLE, PLAYER_DEATH_EXPLODE, PLAYER_DEATH_RIPPER, PLAYER_DEATH_SQUISH, PLAYER_DEATH_DROWN, MAX_PLAYER_DEATHS
};
typedef void (*PLAYER_ACTION_FUNCp)(PLAYERp);
#include "inv.h"
typedef struct
{
short cursectnum,lastcursectnum,pang,filler;
int xvect,yvect,oxvect,oyvect,slide_xvect,slide_yvect;
int posx,posy,posz;
SECTOR_OBJECTp sop_control;
} REMOTE_CONTROL, *REMOTE_CONTROLp;
struct PLAYERstruct
{
// variable that fit in the sprite or user structure
union
{
struct { int32_t posx, posy, posz; };
vec3_t pos;
};
// interpolation
int oposx, oposy, oposz;
// holds last valid move position
short lv_sectnum;
int lv_x,lv_y,lv_z;
SPRITEp remote_sprite;
REMOTE_CONTROL remote;
SECTOR_OBJECTp sop_remote;
SECTOR_OBJECTp sop; // will either be sop_remote or sop_control
int jump_count, jump_speed; // jumping
short down_speed, up_speed; // diving
int z_speed,oz_speed; // used for diving and flying instead of down_speed, up_speed
int climb_ndx;
int hiz,loz;
int ceiling_dist,floor_dist;
SECTORp hi_sectp, lo_sectp;
SPRITEp hi_sp, lo_sp;
SPRITEp last_camera_sp;
int circle_camera_dist;
int six,siy,siz; // save player interp position for PlayerSprite
short siang;
int xvect, yvect;
int oxvect, oyvect;
int friction;
int slide_xvect, slide_yvect;
short slide_ang;
int slide_dec;
float drive_avel;
short view_outside_dang; // outside view delta ang
short circle_camera_ang;
short camera_check_time_delay;
short cursectnum,lastcursectnum;
fixed_t turn180_target; // 180 degree turn
// variables that do not fit into sprite structure
int hvel,tilt,tilt_dest;
PlayerHorizon horizon;
PlayerAngle angle;
short recoil_amt;
short recoil_speed;
short recoil_ndx;
fixed_t recoil_horizoff;
int oldposx,oldposy,oldposz;
int RevolveX, RevolveY;
short RevolveDeltaAng;
binangle RevolveAng;
// under vars are for wading and swimming
short PlayerSprite, PlayerUnderSprite;
SPRITEp SpriteP, UnderSpriteP;
short pnum; // carry along the player number
short LadderSector;
int lx,ly; // ladder x and y
short JumpDuration;
short WadeDepth;
short bob_amt;
short bob_ndx;
short bcnt; // bob count
int bob_z, obob_z;
//Multiplayer variables
InputPacket input;
InputPacket lastinput;
// must start out as 0
int playerreadyflag;
PLAYER_ACTION_FUNCp DoPlayerAction;
int Flags, Flags2;
ESyncBits KeyPressBits;
SECTOR_OBJECTp sop_control; // sector object pointer
SECTOR_OBJECTp sop_riding; // sector object pointer
struct
{
PANEL_SPRITEp Next, Prev;
} PanelSpriteList;
// Key stuff
unsigned char HasKey[8];
// Weapon stuff
short SwordAng;
int WpnGotOnceFlags; // for no respawn mode where weapons are allowed grabbed only once
int WpnFlags;
short WpnAmmo[MAX_WEAPONS];
short WpnNum;
PANEL_SPRITEp CurWpn;
PANEL_SPRITEp Wpn[MAX_WEAPONS];
PANEL_SPRITEp Chops;
unsigned char WpnRocketType; // rocket type
unsigned char WpnRocketHeat; // 5 to 0 range
unsigned char WpnRocketNuke; // 1, you have it, or you don't
unsigned char WpnFlameType; // Guardian weapons fire
unsigned char WpnFirstType; // First weapon type - Sword/Shuriken
unsigned char WeaponType; // for weapons with secondary functions
short FirePause; // for sector objects - limits rapid firing
//
// Inventory Vars
//
short InventoryNum;
short InventoryBarTics;
short InventoryTics[MAX_INVENTORY];
short InventoryPercent[MAX_INVENTORY];
int8_t InventoryAmount[MAX_INVENTORY];
bool InventoryActive[MAX_INVENTORY];
short DiveTics;
short DiveDamageTics;
// Death stuff
uint16_t DeathType;
short Kills;
short Killer; //who killed me
short KilledPlayer[MAX_SW_PLAYERS_REG];
short SecretsFound;
// Health
short Armor;
short MaxHealth;
//char RocketBarrel;
char PlayerName[32];
unsigned char UziShellLeftAlt;
unsigned char UziShellRightAlt;
unsigned char TeamColor; // used in team play and also used in regular mulit-play for show
// palette fading up and down for player hit and get items
short FadeTics; // Tics between each fade cycle
short FadeAmt; // Current intensity of fade
bool NightVision; // Is player's night vision active?
unsigned char StartColor; // Darkest color in color range being used
//short electro[64];
bool IsAI; // Is this and AI character?
short fta,ftq; // First time active and first time quote, for talking in multiplayer games
short NumFootPrints; // Number of foot prints left to lay down
unsigned char WpnUziType; // Toggle between single or double uzi's if you own 2.
unsigned char WpnShotgunType; // Shotgun has normal or fully automatic fire
unsigned char WpnShotgunAuto; // 50-0 automatic shotgun rounds
unsigned char WpnShotgunLastShell; // Number of last shell fired
unsigned char WpnRailType; // Normal Rail Gun or EMP Burst Mode
bool Bloody; // Is player gooey from the slaughter?
bool InitingNuke;
bool TestNukeInit;
bool NukeInitialized; // Nuke already has counted down
short FistAng; // KungFu attack angle
unsigned char WpnKungFuMove; // KungFu special moves
short HitBy; // SpriteNum of whatever player was last hit by
short Reverb; // Player's current reverb setting
short Heads; // Number of Accursed Heads orbiting player
int PlayerVersion;
char cookieQuote[256]; // Should be an FString but must be POD for now so that PLAYER remains POD.
int cookieTime;
char WpnReloadState;
};
extern PLAYER Player[MAX_SW_PLAYERS_REG+1];
//
// Player Flags
//
enum
{
PF_DEAD = (BIT(1)),