1 //------------------------------------------------------------------------- 2 /* 3 Copyright (C) 1997, 2005 - 3D Realms Entertainment 4 5 This file is part of Shadow Warrior version 1.2 6 7 Shadow Warrior is free software; you can redistribute it and/or 8 modify it under the terms of the GNU General Public License 9 as published by the Free Software Foundation; either version 2 10 of the License, or (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 16 See the GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 22 Original Source: 1997 - Frank Maddin and Jim Norwood 23 Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms 24 */ 25 //------------------------------------------------------------------------- 26 27 #ifndef GAME_H 28 29 #define GAME_H 30 31 #ifndef DEBUG 32 #define DEBUG 0 33 #endif 34 35 #include "compat.h" 36 #include "baselayer.h" 37 #include "mmulti.h" 38 39 #include "mytypes.h" 40 #include "keyboard.h" 41 #include "sounds.h" 42 #include "settings.h" 43 44 //#define SW_SHAREWARE 1 // This determines whether game is shareware compile or not! 45 extern char isShareware, useDarts; 46 extern const char *gameeditionname; 47 #define SW_SHAREWARE (isShareware) 48 #define SW_REGISTERED (!isShareware) 49 50 // Turn warning off for unreferenced variables. 51 // I really should fix them at some point 52 //#pragma off(unreferenced) 53 54 55 #define ERR_STD_ARG __FILE__, __LINE__ 56 57 #if DEBUG 58 void HeapCheck(char *, int); 59 #define HEAP_CHECK() HeapCheck(__FILE__, __LINE__) 60 61 void _Assert(char *, char *, unsigned); 62 #define ASSERT(f) \ 63 if (f) \ 64 do { } while(0); \ 65 else \ 66 _Assert(#f,ERR_STD_ARG); 67 68 #define PRODUCTION_ASSERT(f) ASSERT(f) 69 70 void dsprintf(char *, char *, ...); 71 #define DSPRINTF dsprintf 72 73 74 #if 1 // !JIM! Frank, I redirect this for me you'll want to set this back for you 75 extern int DispMono; 76 #define MONO_PRINT(str) if (DispMono) debugprintf("MONO: %s\n", str); 77 #else 78 void adduserquote(char *daquote); 79 extern int DispMono; 80 #define MONO_PRINT(str) if (DispMono) CON_ConMessage(str); // Put it in my userquote stuff! 81 //#define MONO_PRINT(str) if (DispMono) printf(str); 82 #endif 83 84 #define RANDOM_DEBUG 1 // Set this to 1 for network testing. 85 #else 86 #define ASSERT(f) do { } while(0) 87 #define MONO_PRINT(str) 88 89 void _Assert(char *, char *, unsigned); 90 #define PRODUCTION_ASSERT(f) \ 91 if (f) \ 92 do { } while(0); \ 93 else \ 94 _Assert(#f,ERR_STD_ARG); 95 96 void dsprintf_null(char *, char *, ...); 97 #define DSPRINTF dsprintf_null 98 //#define DSPRINTF() 99 100 #define HEAP_CHECK() 101 #define RANDOM_DEBUG 0 102 #endif 103 104 105 #if RANDOM_DEBUG 106 int RandomRange(int, char*, unsigned); 107 int krand1(char*, unsigned); 108 #define RANDOM_P2(pwr_of_2) (MOD_P2(krand1(__FILE__,__LINE__),(pwr_of_2))) 109 #define RANDOM_RANGE(range) (RandomRange(range,__FILE__,__LINE__)) 110 #define RANDOM() (krand1(__FILE__,__LINE__)) 111 #else 112 int RandomRange(int); 113 int krand1(void); 114 #define RANDOM_P2(pwr_of_2) (MOD_P2(krand1(),(pwr_of_2))) 115 #define RANDOM_RANGE(range) (RandomRange(range)) 116 #define RANDOM() (krand1()) 117 #endif 118 119 120 #define PRINT(line,str) DebugPrint(line,str) 121 122 #include "pragmas.h" 123 124 125 // 126 // Map directions/degrees 127 // 128 129 /* 130 y-- 131 ^ 1536 132 | 133 | 134 | 135 | 136 | 137 | 2047 138 <----------------------------> 139 1024 | 0 140 x-- | x++ 141 | 142 | 143 | 144 | 145 V 512 146 y++ 147 148 */ 149 150 ////////////////////////////////////////////////////// 151 // 152 // KEYBOARD 153 // 154 ////////////////////////////////////////////////////// 155 156 extern BOOL MenuInputMode; 157 extern BOOL MessageInputMode; 158 extern BOOL ConInputMode; 159 extern BOOL ConPanel; 160 extern BOOL InputMode; 161 extern char MessageInputString[256]; 162 extern char MessageOutputString[256]; 163 164 // 165 // Defines 166 // 167 168 #define CIRCLE_CAMERA_DIST_MIN 12000 169 170 // dist at which actors will not move (unless shot?? to do) 171 #define MAX_ACTIVE_RANGE 42000 172 // dist at which actors roam about on their own 173 #define MIN_ACTIVE_RANGE 20000 174 175 #undef KEYSC_UP 176 #define KEYSC_UP sc_UpArrow 177 #undef KEYSC_DOWN 178 #define KEYSC_DOWN sc_DownArrow 179 #undef KEYSC_LEFT 180 #define KEYSC_LEFT sc_LeftArrow 181 #undef KEYSC_RIGHT 182 #define KEYSC_RIGHT sc_RightArrow 183 #undef KEYSC_INS 184 #define KEYSC_INS sc_Insert 185 #undef KEYSC_DEL 186 #define KEYSC_DEL sc_Delete 187 #undef KEYSC_HOME 188 #define KEYSC_HOME sc_Home 189 #undef KEYSC_END 190 #define KEYSC_END sc_End 191 #undef KEYSC_PGUP 192 #define KEYSC_PGUP sc_PgUp 193 #undef KEYSC_PGDN 194 #define KEYSC_PGDN sc_PgDn 195 196 #define KEYSC_RALT sc_RightAlt 197 #define KEYSC_RCTRL sc_RightControl 198 #define KEYSC_KPSLASH sc_kpad_Slash 199 #define KEYSC_KPENTER sc_kpad_Enter 200 #define KEYSC_PRINTSCREEN sc_PrintScreen 201 #define KEYSC_LASTSC sc_LastScanCode 202 203 #define KEYSC_KP_1 sc_kpad_1 204 #define KEYSC_KP_2 sc_kpad_2 205 #define KEYSC_KP_3 sc_kpad_3 206 #define KEYSC_KP_4 sc_kpad_4 207 #define KEYSC_KP_6 sc_kpad_6 208 #define KEYSC_KP_5 sc_kpad_5 209 #define KEYSC_KP_7 sc_kpad_7 210 #define KEYSC_KP_8 sc_kpad_8 211 #define KEYSC_KP_9 sc_kpad_9 212 #define KEYSC_KP_0 sc_kpad_0 213 #define KEYSC_KPMINUS sc_kpad_Minus 214 #define KEYSC_KPPLUS sc_kpad_Plus 215 #define KEYSC_KPPERIOD sc_kpad_Period 216 217 #define KEYSC_EUP sc_UpArrow 218 #define KEYSC_EDOWN sc_DownArrow 219 #define KEYSC_ELEFT sc_LeftArrow 220 #define KEYSC_ERIGHT sc_RightArrow 221 #define KEYSC_EINS sc_Insert 222 #define KEYSC_EDEL sc_Delete 223 #define KEYSC_EHOME sc_Home 224 #define KEYSC_EEND sc_End 225 #define KEYSC_EPGUP sc_PgUp 226 #define KEYSC_EPGDN sc_PgDn 227 228 #undef KB_KeyPressed 229 #define KB_KeyPressed( scan ) \ 230 ( KB_KeyDown[ ( scan ) ]) 231 #define KEY_PRESSED(sc) KB_KeyPressed((sc)) 232 #define PKEY_PRESSED(sc) KB_KeyPressed((sc)) 233 234 // 235 // NETWORK - REDEFINABLE SHARED (SYNC) KEYS BIT POSITIONS 236 // 237 238 // weapons takes up 4 bits 239 #define SK_WEAPON_BIT0 0 240 #define SK_WEAPON_BIT1 1 241 #define SK_WEAPON_BIT2 2 242 #define SK_WEAPON_BIT3 3 243 #define SK_WEAPON_MASK (BIT(SK_WEAPON_BIT0)| \ 244 BIT(SK_WEAPON_BIT1)| \ 245 BIT(SK_WEAPON_BIT2)| \ 246 BIT(SK_WEAPON_BIT3)) // 16 possible numbers 0-15 247 248 #define SK_INV_HOTKEY_BIT0 4 249 #define SK_INV_HOTKEY_BIT1 5 250 #define SK_INV_HOTKEY_BIT2 6 251 #define SK_INV_HOTKEY_MASK (BIT(SK_INV_HOTKEY_BIT0)|BIT(SK_INV_HOTKEY_BIT1)|BIT(SK_INV_HOTKEY_BIT2)) 252 253 #define SK_AUTO_AIM 7 254 #define SK_CENTER_VIEW 8 255 #define SK_PAUSE 9 256 #define SK_RUN_LOCK 10 257 258 #define SK_MESSAGE 11 259 #define SK_LOOK_UP 12 260 #define SK_LOOK_DOWN 13 261 #define SK_CRAWL_LOCK 14 262 #define SK_FLY 15 263 264 #define SK_RUN 16 265 #define SK_SHOOT 17 266 #define SK_OPERATE 18 267 #define SK_JUMP 19 268 #define SK_CRAWL 20 269 #define SK_SNAP_UP 21 270 #define SK_SNAP_DOWN 22 271 #define SK_QUIT_GAME 23 272 273 #define SK_MULTI_VIEW 24 274 275 #define SK_TURN_180 25 276 277 #define SK_INV_LEFT 26 278 #define SK_INV_RIGHT 27 279 280 #define SK_INV_USE 29 281 #define SK_HIDE_WEAPON 30 282 #define SK_SPACE_BAR 31 283 284 285 // REDEFINABLE PLAYER KEYS NUMBERS 286 287 #define PK_FORWARD 0 288 #define PK_BACKWARD 1 289 #define PK_LEFT 2 290 #define PK_RIGHT 3 291 #define PK_RUN 4 292 #define PK_STRAFE 5 293 #define PK_SHOOT 6 294 #define PK_OPERATE 7 295 #define PK_JUMP 8 296 #define PK_CRAWL 9 297 #define PK_LOOK_UP 10 298 #define PK_LOOK_DOWN 11 299 #define PK_STRAFE_LEFT 12 300 #define PK_STRAFE_RIGHT 13 301 #define PK_MAP 14 302 #define PK_MULTI_VIEW 15 303 #define PK_ZOOM_IN 16 304 #define PK_ZOOM_OUT 17 305 #define PK_MESSAGE 18 306 307 // #define PKEY(num) KEY_PRESSED(keys[num]) 308 309 #define MK_FIXED(msw,lsw) (((LONG)(msw)<<16)|(lsw)) 310 #define FIXED(msw,lsw) MK_FIXED(msw,lsw) 311 312 #if B_LITTLE_ENDIAN != 0 313 # define MSW_VAR(fixed) (*(((USHORTp)&(fixed)) + 1)) 314 # define LSW_VAR(fixed) (*((USHORTp)&(fixed))) 315 316 # define MSB_VAR(fixed) (*(((BYTEp)&(fixed)) + 1)) 317 # define LSB_VAR(fixed) (*((BYTEp)&(fixed))) 318 #else 319 # define LSW_VAR(fixed) (*(((USHORTp)&(fixed)) + 1)) 320 # define MSW_VAR(fixed) (*((USHORTp)&(fixed))) 321 322 # define LSB_VAR(fixed) (*(((BYTEp)&(fixed)) + 1)) 323 # define MSB_VAR(fixed) (*((BYTEp)&(fixed))) 324 #endif 325 326 #define MSW(fixed) ((fixed)>>16) 327 #define LSW(fixed) (((USHORT)(fixed))) 328 #define MSW_ROUND(fixed) (((fixed)>>16)+(((fixed)&0x8000)>>15)) 329 330 // Defines for reading in ST1 sprite tagging 331 #define SP_TAG1(sp) ((sp)->hitag) 332 #define SP_TAG2(sp) ((sp)->lotag) 333 #define SP_TAG3(sp) ((sp)->clipdist) 334 #define SP_TAG4(sp) ((sp)->ang) 335 #define SP_TAG5(sp) ((sp)->xvel) 336 #define SP_TAG6(sp) ((sp)->yvel) 337 #define SP_TAG7(sp) (MSB_VAR((sp)->zvel)) 338 #define SP_TAG8(sp) (LSB_VAR((sp)->zvel)) 339 #define SP_TAG9(sp) (MSB_VAR((sp)->owner)) 340 #define SP_TAG10(sp) (LSB_VAR((sp)->owner)) 341 #define SP_TAG11(sp) ((sp)->shade) 342 #define SP_TAG12(sp) ((sp)->pal) 343 #define SP_TAG13(sp) B_LITTLE16(*((short*)&(sp)->xoffset)) 344 #define SP_TAG14(sp) B_LITTLE16(*((short*)&(sp)->xrepeat)) 345 #define SP_TAG15(sp) ((sp)->z) 346 #define SET_SP_TAG13(sp,val) (*((short*)&(sp)->xoffset)) = B_LITTLE16(val) 347 #define SET_SP_TAG14(sp,val) (*((short*)&(sp)->xrepeat)) = B_LITTLE16(val) 348 349 #define SPRITE_TAG1(sp) (sprite[sp].hitag) 350 #define SPRITE_TAG2(sp) (sprite[sp].lotag) 351 #define SPRITE_TAG3(sp) (sprite[sp].clipdist) 352 #define SPRITE_TAG4(sp) (sprite[sp].ang) 353 #define SPRITE_TAG5(sp) (sprite[sp].xvel) 354 #define SPRITE_TAG6(sp) (sprite[sp].yvel) 355 #define SPRITE_TAG7(sp) (MSB_VAR(sprite[sp].zvel)) 356 #define SPRITE_TAG8(sp) (LSB_VAR(sprite[sp].zvel)) 357 #define SPRITE_TAG9(sp) (MSB_VAR(sprite[sp].owner)) 358 #define SPRITE_TAG10(sp) (LSB_VAR(sprite[sp].owner)) 359 #define SPRITE_TAG11(sp) (sprite[sp].shade) 360 #define SPRITE_TAG12(sp) (sprite[sp].pal) 361 #define SPRITE_TAG13(sp) B_LITTLE16(*((short*)&sprite[sp].xoffset)) 362 #define SPRITE_TAG14(sp) B_LITTLE16(*((short*)&sprite[sp].xrepeat)) 363 #define SPRITE_TAG15(sp) (sprite[sp].z) 364 #define SET_SPRITE_TAG13(sp,val) (*((short*)&sprite[sp].xoffset)) = B_LITTLE16(val) 365 #define SET_SPRITE_TAG14(sp,val) (*((short*)&sprite[sp].xrepeat)) = B_LITTLE16(val) 366 367 // this will get you the other wall moved by dragpoint 368 #define DRAG_WALL(w) (wall[wall[(w)].nextwall].point2) 369 370 // OVER and UNDER water macros 371 #define SpriteInDiveArea(sp) (TEST(sector[(sp)->sectnum].extra, SECTFX_DIVE_AREA) ? TRUE : FALSE) 372 #define SpriteInUnderwaterArea(sp) (TEST(sector[(sp)->sectnum].extra, SECTFX_UNDERWATER|SECTFX_UNDERWATER2) ? TRUE : FALSE) 373 374 #define SectorIsDiveArea(sect) (TEST(sector[sect].extra, SECTFX_DIVE_AREA) ? TRUE : FALSE) 375 #define SectorIsUnderwaterArea(sect) (TEST(sector[sect].extra, SECTFX_UNDERWATER|SECTFX_UNDERWATER2) ? TRUE : FALSE) 376 377 // Key Press Flags macros 378 #define FLAG_KEY_PRESSED(pp,sync_key) TEST(pp->KeyPressFlags,1<<sync_key) 379 #define FLAG_KEY_RELEASE(pp,sync_key) RESET(pp->KeyPressFlags,1<<sync_key) 380 #define FLAG_KEY_RESET(pp,sync_key) SET(pp->KeyPressFlags,1<<sync_key) 381 382 // syncbit manipulation macros 383 // key_test MUST be a boolean - force it to be 384 #define SET_SYNC_KEY(player, sync_num, key_test) SET((player)->input.bits, ((!!(key_test)) << (sync_num))) 385 #define TEST_SYNC_KEY(player, sync_num) TEST((player)->input.bits, (1 << (sync_num))) 386 #define RESET_SYNC_KEY(player, sync_num) RESET((player)->input.bits, (1 << (sync_num))) 387 388 #define TRAVERSE_SPRITE_SECT(l, o, n) for ((o) = (l); (n) = nextspritesect[o], (o) != -1; (o) = (n)) 389 #define TRAVERSE_SPRITE_STAT(l, o, n) for ((o) = (l); (n) = nextspritestat[o], (o) != -1; (o) = (n)) 390 #define TRAVERSE_CONNECT(i) for (i = connecthead; i != -1; i = connectpoint2[i]) if (!Player[i].IsDisconnected) 391 392 393 #define NORM_ANGLE(ang) ((ang) & 2047) 394 #define ANGLE_2_PLAYER(pp,x,y) (NORM_ANGLE(getangle(pp->posx-(x), pp->posy-(y)))) 395 396 397 int StdRandomRange(int range); 398 #define STD_RANDOM_P2(pwr_of_2) (MOD_P2(rand(),(pwr_of_2))) 399 #define STD_RANDOM_RANGE(range) (StdRandomRange(range)) 400 #define STD_RANDOM() (rand()) 401 402 #define MOVEx(vel,ang) (((int)(vel) * (int)sintable[NORM_ANGLE((ang) + 512)]) >> 14) 403 #define MOVEy(vel,ang) (((int)(vel) * (int)sintable[NORM_ANGLE((ang))]) >> 14) 404 405 #define DIST(x1, y1, x2, y2) ksqrt( SQ((x1) - (x2)) + SQ((y1) - (y2)) ) 406 407 #define PIC_SIZX(sn) (tilesizx[sprite[sn].picnum]) 408 #define PIC_SIZY(sn) (tilesizy[sprite[sn].picnum]) 409 410 // Distance macro - tx, ty, tmin are holding vars that must be declared in the routine 411 // that uses this macro 412 #define DISTANCE(x1, y1, x2, y2, dist, tx, ty, tmin) \ 413 { \ 414 tx = labs(x2-x1); \ 415 ty = labs(y2-y1); \ 416 tmin = min(tx,ty); \ 417 dist = tx + ty - DIV2(tmin); \ 418 } 419 420 #define SPRITE_SIZE_X(sp_num) ((sprite[sp_num].xrepeat == 64) ? \ 421 tilesizx[sprite[sp_num].picnum] : \ 422 ((sprite[sp_num].xrepeat * tilesizx[sprite[sp_num].picnum]) >> 6) \ 423 ) 424 425 #define SPRITE_SIZE_Y(sp_num) ((sprite[sp_num].yrepeat == 64) ? \ 426 tilesizy[sprite[sp_num].picnum] : \ 427 ((sprite[sp_num].yrepeat * tilesizy[sprite[sp_num].picnum]) >> 6) \ 428 ) 429 430 #define SPRITE_SIZE_Z(sp_num) ((sprite[sp_num].yrepeat == 64) ? \ 431 Z(tilesizy[sprite[sp_num].picnum]) : \ 432 ((sprite[sp_num].yrepeat * tilesizy[sprite[sp_num].picnum]) << 2) \ 433 ) 434 435 #define SPRITEp_SIZE_X(sp) (((sp)->xrepeat == 64) ? \ 436 tilesizx[(sp)->picnum] : \ 437 (((sp)->xrepeat * tilesizx[(sp)->picnum]) >> 6) \ 438 ) 439 440 #define SPRITEp_SIZE_Y(sp) (((sp)->yrepeat == 64) ? \ 441 tilesizy[(sp)->picnum] : \ 442 (((sp)->yrepeat * tilesizy[(sp)->picnum]) >> 6) \ 443 ) 444 445 #define SPRITEp_SIZE_Z(sp) (((sp)->yrepeat == 64) ? \ 446 Z(tilesizy[(sp)->picnum]) : \ 447 (((sp)->yrepeat * tilesizy[(sp)->picnum]) << 2) \ 448 ) 449 450 // Given a z height and sprite return the correct x repeat value 451 #define SPRITEp_SIZE_X_2_XREPEAT(sp, x) (((x)*64)/tilesizx[(sp)->picnum]) 452 // Given a z height and sprite return the correct y repeat value 453 #define SPRITEp_SIZE_Z_2_YREPEAT(sp, zh) ((zh)/(4*tilesizy[(sp)->picnum])) 454 #define SPRITEp_SIZE_Y_2_YREPEAT(sp, y) (((y)*64)/tilesizy[(sp)->picnum]) 455 456 457 // x & y offset of tile 458 #define TILE_XOFF(picnum) ((CHAR)TEST(picanm[(picnum)] >> 8, 0xFF)) 459 #define TILE_YOFF(picnum) ((CHAR)TEST(picanm[(picnum)] >> 16, 0xFF)) 460 461 // x & y offset of current sprite tile 462 #define SPRITEp_XOFF(sp) ((CHAR)TEST(picanm[(sp)->picnum] >> 8, 0xFF)) 463 #define SPRITEp_YOFF(sp) ((CHAR)TEST(picanm[(sp)->picnum] >> 16, 0xFF)) 464 465 // Z size of top (TOS) and bottom (BOS) part of sprite 466 #define SPRITEp_SIZE_TOS(sp) (DIV2(SPRITEp_SIZE_Z(sp)) + Z(SPRITEp_YOFF(sp))) 467 #define SPRITEp_SIZE_BOS(sp) (DIV2(SPRITEp_SIZE_Z(sp)) - Z(SPRITEp_YOFF(sp))) 468 469 // acual Z for TOS and BOS - handles both WYSIWYG and old style 470 #define SPRITEp_TOS(sp) (TEST((sp)->cstat, CSTAT_SPRITE_YCENTER) ? \ 471 ((sp)->z - SPRITEp_SIZE_TOS(sp)) : \ 472 ((sp)->z - SPRITEp_SIZE_Z(sp))) 473 474 #define SPRITEp_BOS(sp) (TEST((sp)->cstat, CSTAT_SPRITE_YCENTER) ? \ 475 ((sp)->z + SPRITEp_SIZE_BOS(sp)) : \ 476 (sp)->z) 477 478 // mid and upper/lower sprite caluculations 479 #define SPRITEp_MID(sp) (DIV2(SPRITEp_TOS(sp) + SPRITEp_BOS(sp))) 480 #define SPRITEp_UPPER(sp) (SPRITEp_TOS(sp) + DIV4(SPRITEp_SIZE_Z(sp))) 481 #define SPRITEp_LOWER(sp) (SPRITEp_BOS(sp) - DIV4(SPRITEp_SIZE_Z(sp))) 482 483 #define Z(value) ((int)(value) << 8) 484 #define PIXZ(value) ((int)(value) >> 8) 485 486 #define SQ(val) ((val) * (val)) 487 488 #define KENFACING_PLAYER(pp,sp) (sintable[NORM_ANGLE(sp->ang+512)]*(pp->posy-sp->y) >= sintable[NORM_ANGLE(sp-ang)]*(pp->posx-sp->x)) 489 #define FACING_PLAYER(pp,sp) (labs(GetDeltaAngle((sp)->ang, NORM_ANGLE(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y)))) < 512) 490 #define PLAYER_FACING(pp,sp) (labs(GetDeltaAngle((pp)->pang, NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < 320) 491 #define FACING(sp1,sp2) (labs(GetDeltaAngle((sp2)->ang, NORM_ANGLE(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y)))) < 512) 492 493 #define FACING_PLAYER_RANGE(pp,sp,range) (labs(GetDeltaAngle((sp)->ang, NORM_ANGLE(getangle((pp)->posx - (sp)->x, (pp)->posy - (sp)->y)))) < (range)) 494 #define PLAYER_FACING_RANGE(pp,sp,range) (labs(GetDeltaAngle((pp)->pang, NORM_ANGLE(getangle((sp)->x - (pp)->posx, (sp)->y - (pp)->posy)))) < (range)) 495 #define FACING_RANGE(sp1,sp2,range) (labs(GetDeltaAngle((sp2)->ang, NORM_ANGLE(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y)))) < (range)) 496 497 // two vectors 498 // can determin direction 499 #define DOT_PRODUCT_2D(x1,y1,x2,y2) (mulscale((x1),(x2),16) + mulscale((y1),(y2),16)) 500 #define DOT_PRODUCT_3D(x1,y1,z1,x2,y2,z2) (mulscale((x1),(x2),16) + mulscale((y1),(y2),16) + mulscale((z1),(z2),16)) 501 502 // just determine if the player is moving 503 #define PLAYER_MOVING(pp) ((pp)->xvect|(pp)->yvect) 504 505 #define KEY_EXT(scan) (KEY_PRESSED(scan) | KEY_PRESSED(scan+128)) 506 507 #define TEST_GOTSECTOR(sect_num) (TEST(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7))) 508 #define RESET_GOTSECTOR(sect_num) (RESET(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7))) 509 #define SET_GOTSECTOR(sect_num) (SET(gotsector[(sect_num) >> 3], 1 << ((sect_num) & 7))) 510 511 #define TEST_GOTPIC(tile_num) (TEST(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7))) 512 #define RESET_GOTPIC(tile_num) (RESET(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7))) 513 #define SET_GOTPIC(tile_num) (SET(gotpic[(tile_num) >> 3], 1 << ((tile_num) & 7))) 514 515 #define LOW_TAG(sectnum) ( sector[sectnum].lotag ) 516 #define HIGH_TAG(sectnum) ( sector[sectnum].hitag ) 517 518 #define LOW_TAG_SPRITE(spnum) ( sprite[(spnum)].lotag ) 519 #define HIGH_TAG_SPRITE(spnum) ( sprite[(spnum)].hitag ) 520 521 #define LOW_TAG_WALL(wallnum) ( wall[(wallnum)].lotag ) 522 #define HIGH_TAG_WALL(wallnum) ( wall[(wallnum)].hitag ) 523 524 #define SEC(value) ((value)*120) 525 526 #define CEILING_DIST (Z(4)) 527 #define FLOOR_DIST (Z(4)) 528 529 // Attributes for monochrome text 530 #define MDA_BLANK 0x00 531 #define MDA_NORMAL 0x07 532 #define MDA_BLINK 0x87 533 #define MDA_HIGH 0x0F 534 #define MDA_HIGHBLINK 0x8F 535 #define MDA_UNDER 0x01 536 #define MDA_UNDERBLINK 0x81 537 #define MDA_UNDERHIGH 0x09 538 #define MDA_UNDERHIGHBLINK 0x89 539 #define MDA_REVERSE 0x70 540 #define MDA_REVERSEBLINK 0xF0 541 542 // defines for move_sprite return value 543 #define HIT_MASK (BIT(13)|BIT(14)|BIT(15)) 544 #define HIT_SPRITE (BIT(14)|BIT(15)) 545 #define HIT_WALL BIT(15) 546 #define HIT_SECTOR BIT(14) 547 #define HIT_PLAX_WALL BIT(13) 548 549 #define NORM_SPRITE(val) ((val) & (SIZ(sprite) - 1)) 550 #define NORM_WALL(val) ((val) & (SIZ(wall) - 1)) 551 #define NORM_SECTOR(val) ((val) & (SIZ(sector) - 1)) 552 553 // overwritesprite flags 554 #define OVER_SPRITE_MIDDLE (BIT(0)) 555 #define OVER_SPRITE_VIEW_CLIP (BIT(1)) 556 #define OVER_SPRITE_TRANSLUCENT (BIT(2)) 557 #define OVER_SPRITE_XFLIP (BIT(3)) 558 #define OVER_SPRITE_YFLIP (BIT(4)) 559 560 // rotatesprite flags 561 #define ROTATE_SPRITE_TRANSLUCENT (BIT(0)) 562 #define ROTATE_SPRITE_VIEW_CLIP (BIT(1)) // clip to view 563 #define ROTATE_SPRITE_YFLIP (BIT(2)) 564 #define ROTATE_SPRITE_IGNORE_START_MOST (BIT(3)) // don't clip to startumost 565 #define ROTATE_SPRITE_SCREEN_CLIP (BIT(1)|BIT(3)) // use window 566 #define ROTATE_SPRITE_CORNER (BIT(4)) // place sprite from upper left corner 567 #define ROTATE_SPRITE_TRANS_FLIP (BIT(5)) 568 #define ROTATE_SPRITE_NON_MASK (BIT(6)) // non masked sprites 569 #define ROTATE_SPRITE_ALL_PAGES (BIT(7)) // copies to all pages 570 571 #define RS_SCALE BIT(16) 572 573 // system defines for status bits 574 #define CEILING_STAT_PLAX BIT(0) 575 #define CEILING_STAT_SLOPE BIT(1) 576 #define CEILING_STAT_SWAPXY BIT(2) 577 #define CEILING_STAT_SMOOSH BIT(3) 578 #define CEILING_STAT_XFLIP BIT(4) 579 #define CEILING_STAT_YFLIP BIT(5) 580 #define CEILING_STAT_RELATIVE BIT(6) 581 #define CEILING_STAT_TYPE_MASK (BIT(7)|BIT(8)) 582 #define CEILING_STAT_MASKED BIT(7) 583 #define CEILING_STAT_TRANS BIT(8) 584 #define CEILING_STAT_TRANS_FLIP (BIT(7)|BIT(8)) 585 #define CEILING_STAT_FAF_BLOCK_HITSCAN BIT(15) 586 587 #define FLOOR_STAT_PLAX BIT(0) 588 #define FLOOR_STAT_SLOPE BIT(1) 589 #define FLOOR_STAT_SWAPXY BIT(2) 590 #define FLOOR_STAT_SMOOSH BIT(3) 591 #define FLOOR_STAT_XFLIP BIT(4) 592 #define FLOOR_STAT_YFLIP BIT(5) 593 #define FLOOR_STAT_RELATIVE BIT(6) 594 #define FLOOR_STAT_TYPE_MASK (BIT(7)|BIT(8)) 595 #define FLOOR_STAT_MASKED BIT(7) 596 #define FLOOR_STAT_TRANS BIT(8) 597 #define FLOOR_STAT_TRANS_FLIP (BIT(7)|BIT(8)) 598 #define FLOOR_STAT_FAF_BLOCK_HITSCAN BIT(15) 599 600 #define CSTAT_WALL_BLOCK BIT(0) 601 #define CSTAT_WALL_BOTTOM_SWAP BIT(1) 602 #define CSTAT_WALL_ALIGN_BOTTOM BIT(2) 603 #define CSTAT_WALL_XFLIP BIT(3) 604 #define CSTAT_WALL_MASKED BIT(4) 605 #define CSTAT_WALL_1WAY BIT(5) 606 #define CSTAT_WALL_BLOCK_HITSCAN BIT(6) 607 #define CSTAT_WALL_TRANSLUCENT BIT(7) 608 #define CSTAT_WALL_YFLIP BIT(8) 609 #define CSTAT_WALL_TRANS_FLIP BIT(9) 610 #define CSTAT_WALL_BLOCK_ACTOR (BIT(14)) // my def 611 #define CSTAT_WALL_WARP_HITSCAN (BIT(15)) // my def 612 613 //cstat, bit 0: 1 = Blocking sprite (use with clipmove, getzrange) "B" 614 // bit 1: 1 = 50/50 transluscence, 0 = normal "T" 615 // bit 2: 1 = x-flipped, 0 = normal "F" 616 // bit 3: 1 = y-flipped, 0 = normal "F" 617 // bits 5-4: 00 = FACE sprite (default) "R" 618 // 01 = WALL sprite (like masked walls) 619 // 10 = FLOOR sprite (parallel to ceilings&floors) 620 // 11 = SPIN sprite (face sprite that can spin 2draw style - not done yet) 621 // bit 6: 1 = 1-sided sprite, 0 = normal "1" 622 // bit 7: 1 = Real centered centering, 0 = foot center "C" 623 // bit 8: 1 = Blocking sprite (use with hitscan) "H" 624 // bit 9: reserved 625 // bit 10: reserved 626 // bit 11: reserved 627 // bit 12: reserved 628 // bit 13: reserved 629 // bit 14: reserved 630 // bit 15: 1 = Invisible sprite, 0 = not invisible 631 632 #define CSTAT_SPRITE_BLOCK BIT(0) 633 #define CSTAT_SPRITE_TRANSLUCENT BIT(1) 634 #define CSTAT_SPRITE_XFLIP BIT(2) 635 #define CSTAT_SPRITE_YFLIP BIT(3) 636 #define CSTAT_SPRITE_WALL BIT(4) 637 #define CSTAT_SPRITE_FLOOR BIT(5) 638 #define CSTAT_SPRITE_SLAB (BIT(4)|BIT(5)) 639 #define CSTAT_SPRITE_ONE_SIDE BIT(6) 640 #define CSTAT_SPRITE_YCENTER BIT(7) 641 #define CSTAT_SPRITE_BLOCK_HITSCAN BIT(8) 642 #define CSTAT_SPRITE_TRANS_FLIP BIT(9) 643 644 #define CSTAT_SPRITE_RESTORE BIT(12) // my def 645 #define CSTAT_SPRITE_CLOSE_FLOOR BIT(13) // my def - tells whether a sprite 646 // started out close to a ceiling or floor 647 #define CSTAT_SPRITE_BLOCK_MISSILE BIT(14) // my def 648 #define CSTAT_SPRITE_INVISIBLE BIT(15) 649 650 #define CSTAT_SPRITE_BREAKABLE (CSTAT_SPRITE_BLOCK_HITSCAN|CSTAT_SPRITE_BLOCK_MISSILE) 651 652 #undef CLIPMASK0 // defined in build.h 653 #undef CLIPMASK1 654 655 // new define more readable defines 656 657 // Clip Sprite adjustment 658 #define CS(sprite_bit) ((sprite_bit)<<16) 659 660 // for players to clip against walls 661 #define CLIPMASK_PLAYER (CS(CSTAT_SPRITE_BLOCK) | CSTAT_WALL_BLOCK) 662 663 // for actors to clip against walls 664 #define CLIPMASK_ACTOR \ 665 ( \ 666 CS(CSTAT_SPRITE_BLOCK) | \ 667 CSTAT_WALL_BLOCK | \ 668 CSTAT_WALL_BLOCK_ACTOR \ 669 ) 670 671 // for missiles to clip against actors 672 #define CLIPMASK_MISSILE \ 673 ( \ 674 CS(CSTAT_SPRITE_BLOCK_HITSCAN|CSTAT_SPRITE_BLOCK_MISSILE) | \ 675 CSTAT_WALL_BLOCK_HITSCAN \ 676 ) 677 678 #define CLIPMASK_WARP_HITSCAN \ 679 ( \ 680 CS(CSTAT_SPRITE_BLOCK_HITSCAN) | \ 681 CSTAT_WALL_BLOCK_HITSCAN | \ 682 CSTAT_WALL_WARP_HITSCAN \ 683 ) 684 685 686 687 // break up of picanm[] 688 #define TILE_ANIM_NUM (0xF|BIT(4)|BIT(5)) 689 #define TILE_ANIM_TYPE (BIT(6)|BIT(7)) 690 #define TILE_SPEED (0xF << 20) 691 692 #define SIZ(array) (sizeof(array)/sizeof(array[0])) 693 694 695 // 696 // Directions 697 // 698 699 #define DEGREE_45 256 700 #define DEGREE_90 512 701 702 // 703 // nextsectorneighborz defines - what a god-awful name! 704 // 705 706 #define SEARCH_DOWN 1 707 #define SEARCH_UP -1 708 #define SEARCH_FLOOR 1 709 #define SEARCH_CEILING -1 710 711 #define UP_DIR -1 712 #define DOWN_DIR 1 713 714 #define OPEN 0 715 #define CLOSE 1 716 717 //// 718 // 719 // Directional enumerations 720 // 721 //// 722 723 enum DirOrd 724 { 725 ORD_NORTH, ORD_NE, ORD_EAST, ORD_SE, ORD_SOUTH, ORD_SW, ORD_WEST, ORD_NW 726 }; 727 728 enum Dir8 729 { 730 NORTH = ORD_NORTH * DEGREE_45, 731 NE = ORD_NE * DEGREE_45, 732 EAST = ORD_EAST * DEGREE_45, 733 SE = ORD_SE * DEGREE_45, 734 SOUTH = ORD_SOUTH * DEGREE_45, 735 SW = ORD_SW * DEGREE_45, 736 WEST = ORD_WEST * DEGREE_45, 737 NW = ORD_NW * DEGREE_45, 738 }; 739 740 typedef enum Dir8 DIR8; 741 742 // Auto building enumerations 743 744 #define DIGI_ENUM 745 enum digi 746 { 747 #include "digi.h" 748 DIGI_MAX 749 }; 750 #undef DIGI_ENUM 751 752 #define DAMAGE_ENUM 753 enum dam 754 { 755 #include "damage.h" 756 }; 757 #undef DAMAGE_ENUM 758 759 //// 760 // 761 // State declarations 762 // 763 //// 764 765 766 // Forward declarations 767 struct STATEstruct; 768 typedef struct STATEstruct STATE, *STATEp, **STATEpp; 769 770 //struct PIC_STATEstruct; 771 //typedef struct PIC_STATEstruct PIC_STATE, *PIC_STATEp; 772 773 struct PANEL_STATEstruct; 774 typedef struct PANEL_STATEstruct PANEL_STATE, *PANEL_STATEp; 775 776 struct PLAYERstruct; 777 typedef struct PLAYERstruct PLAYER, *PLAYERp; 778 779 struct PERSONALITYstruct; 780 typedef struct PERSONALITYstruct PERSONALITY, *PERSONALITYp; 781 782 struct ATTRIBUTEstruct; 783 typedef struct ATTRIBUTEstruct ATTRIBUTE, *ATTRIBUTEp; 784 785 struct SECTOR_OBJECTstruct; 786 typedef struct SECTOR_OBJECTstruct SECTOR_OBJECT, *SECTOR_OBJECTp; 787 788 struct PANEL_SPRITEstruct; 789 typedef struct PANEL_SPRITEstruct PANEL_SPRITE, *PANEL_SPRITEp; 790 791 struct ANIMstruct; 792 typedef struct ANIMstruct ANIM, *ANIMp; 793 794 typedef int ANIMATOR(SHORT SpriteNum); 795 typedef ANIMATOR *ANIMATORp; 796 797 typedef void pANIMATOR(PANEL_SPRITEp); 798 typedef pANIMATOR *pANIMATORp; 799 800 typedef void soANIMATOR(SECTOR_OBJECTp); 801 typedef soANIMATOR *soANIMATORp; 802 803 typedef spritetype SPRITE, *SPRITEp; 804 typedef sectortype SECTOR, *SECTORp; 805 typedef walltype WALL, *WALLp; 806 807 struct STATEstruct 808 { 809 short Pic; 810 int Tics; 811 ANIMATORp Animator; 812 813 STATEp NextState; 814 }; 815 816 // 817 // State Flags 818 // 819 820 #define SF_TICS_MASK 0xFFFF 821 #define SF_QUICK_CALL BIT(16) 822 #define SF_PLAYER_FUNC BIT(17) // only for players to execute 823 #define SF_TIC_ADJUST BIT(18) // use tic adjustment for these frames 824 #define SF_WALL_STATE BIT(19) // use for walls instead of sprite 825 826 /////////////////////////////////////////////////////////////////////////////// 827 // Jim's MISC declarations from other files 828 /////////////////////////////////////////////////////////////////////////////// 829 830 typedef enum {WATER_FOOT, BLOOD_FOOT} FOOT_TYPE; 831 832 extern FOOT_TYPE FootMode; 833 extern BOOL InGame; // Declared in game.c 834 extern BOOL Global_PLock; // Game.c 835 int QueueFloorBlood(short hitsprite); // Weapon.c 836 int QueueFootPrint(short hitsprite); // Weapon.c 837 int QueueGeneric(short SpriteNum, short pic); // Weapon.c 838 int QueueLoWangs(short SpriteNum); // Weapon.c 839 int SpawnShell(short SpriteNum, short ShellNum); // Weapon.c 840 void UnlockKeyLock(short key_num, short hitsprite); // JSector.c 841 842 #define MAX_PAIN 5 843 extern int PlayerPainVocs[MAX_PAIN]; 844 extern int PlayerLowHealthPainVocs[MAX_PAIN]; 845 846 #define MAX_TAUNTAI 33 847 extern int TauntAIVocs[MAX_TAUNTAI]; 848 849 #define MAX_GETSOUNDS 5 850 extern int PlayerGetItemVocs[MAX_GETSOUNDS]; 851 852 #define MAX_YELLSOUNDS 3 853 extern int PlayerYellVocs[MAX_YELLSOUNDS]; 854 855 VOID BossHealthMeter(void); 856 857 // Global variables used for modifying variouse things from the Console 858 859 /////////////////////////////////////////////////////////////////////////////////////////// 860 // 861 // CALLER - DLL handler 862 // 863 /////////////////////////////////////////////////////////////////////////////////////////// 864 extern unsigned char DLL_Loaded; 865 extern int DLL_Handle; // Global DLL handle 866 extern char *DLL_path; // DLL path name 867 868 int DLL_Load(char *DLLpathname); 869 BOOL DLL_Unload(int procHandle); 870 BOOL DLL_ExecFunc(int procHandle, char *fName); 871 872 /////////////////////////////////////////////////////////////////////////////////////////// 873 // 874 // JPlayer 875 // 876 /////////////////////////////////////////////////////////////////////////////////////////// 877 #define MESSAGE_LINE 142 // Used to be 164 878 #define MAXUSERQUOTES 6 879 #define MAXCONQUOTES 13 880 881 extern int quotebot, quotebotgoal; 882 extern short user_quote_time[MAXUSERQUOTES]; 883 extern char user_quote[MAXUSERQUOTES][256]; 884 885 extern int conbot, conbotgoal; 886 extern char con_quote[MAXCONQUOTES][256]; 887 888 int minitext(int x,int y,char *t,char p,char sb); 889 int minitextshade(int x,int y,char *t,char s,char p,char sb); 890 void operatefta(void); 891 void adduserquote(char *daquote); 892 void operateconfta(void); 893 void addconquote(char *daquote); 894 895 /////////////////////////////////////////////////////////////////////////////////////////// 896 // 897 // Console 898 // 899 /////////////////////////////////////////////////////////////////////////////////////////// 900 void CON_Message(const char *message, ...) PRINTF_FORMAT(1, 2); 901 void CON_ConMessage(const char *message, ...) PRINTF_FORMAT(1, 2); 902 void CON_StoreArg(const char *userarg); 903 BOOL CON_CheckParm(const char *userarg); 904 void CON_CommandHistory(signed char dir); 905 BOOL CON_AddCommand(const char *command, void (*function)(void)); 906 void CON_ProcessUserCommand( void ); 907 void CON_InitConsole( void ); 908 909 /////////////////////////////////////////////////////////////////////////////////////////// 910 // 911 // CD - RedBook Audio 912 // 913 /////////////////////////////////////////////////////////////////////////////////////////// 914 915 void CDAudio_Eject(void); 916 BYTE CDAudio_GetVolume(void); 917 void CDAudio_SetVolume(BYTE volume); 918 void CDAudio_Play(BYTE track, BOOL looping); 919 void CDAudio_Stop(void); 920 void CDAudio_Resume(void); 921 void CDAudio_Update(void); 922 BOOL CDAudio_Playing(void); 923 int CDAudio_Init(void); 924 void CDAudio_Shutdown(void); 925 926 /////////////////////////////////////////////////////////////////////////////////////////// 927 // 928 // Weapon 929 // 930 /////////////////////////////////////////////////////////////////////////////////////////// 931 932 #define MAX_WEAPONS_KEYS 10 933 #define MAX_WEAPONS_EXTRA 4 // extra weapons like the two extra head attacks 934 #define MAX_WEAPONS (MAX_WEAPONS_KEYS + MAX_WEAPONS_EXTRA) 935 936 // weapons that not missile type sprites 937 #define WPN_NM_LAVA (-8) 938 #define WPN_NM_SECTOR_SQUISH (-9) 939 940 //#define WEAP_ENTRY(id, init_func, damage_lo, damage_hi, radius) 941 942 typedef struct 943 { 944 VOID (*Init)(PLAYERp); 945 SHORT damage_lo; 946 SHORT damage_hi; 947 unsigned int radius; 948 SHORT max_ammo; 949 SHORT min_ammo; 950 SHORT with_weapon; 951 char *weapon_name; 952 char *ammo_name; 953 SHORT weapon_pickup; 954 SHORT ammo_pickup; 955 } DAMAGE_DATA, *DAMAGE_DATAp; 956 957 extern DAMAGE_DATA DamageData[]; 958 959 // bit arrays that determine if a) Weapon has no ammo b) Weapon is the ammo (no weapon exists) 960 extern int WeaponHasNoAmmo, WeaponIsAmmo; 961 962 963 VOID InitWeaponFist(PLAYERp); 964 VOID InitWeaponStar(PLAYERp); 965 VOID InitWeaponShotgun(PLAYERp); 966 VOID InitWeaponRocket(PLAYERp); 967 VOID InitWeaponRail(PLAYERp); 968 VOID InitWeaponMicro(PLAYERp); 969 VOID InitWeaponUzi(PLAYERp); 970 VOID InitWeaponSword(PLAYERp); 971 VOID InitWeaponHothead(PLAYERp); 972 VOID InitWeaponElectro(PLAYERp); 973 VOID InitWeaponHeart(PLAYERp); 974 VOID InitWeaponGrenade(PLAYERp); 975 VOID InitWeaponMine(PLAYERp); 976 977 VOID InitWeaponNapalm(PLAYERp); 978 VOID InitWeaponRing(PLAYERp); 979 980 extern VOID (*InitWeapon[MAX_WEAPONS])(PLAYERp); 981 982 /////////////////////////////////////////////////////////////////////////////////////////// 983 // 984 // Player 985 // 986 /////////////////////////////////////////////////////////////////////////////////////////// 987 988 #define MAX_SW_PLAYERS_SW (4) 989 #define MAX_SW_PLAYERS_REG (8) 990 #define MAX_SW_PLAYERS (isShareware ? MAX_SW_PLAYERS_SW : MAX_SW_PLAYERS_REG) 991 992 typedef struct 993 { 994 char map_name[16]; 995 char numplayers; 996 char Episode,Level; 997 char LevelSong[16]; 998 }DEMO_HEADER, *DEMO_HEADERp; 999 1000 typedef struct 1001 { 1002 int x,y,z; 1003 }DEMO_START_POS, *DEMO_START_POSp; 1004 1005 #define MAX_LEVELS_REG 29 1006 #define MAX_LEVELS_SW 4 1007 #define MAX_LEVELS (isShareware ? MAX_LEVELS_SW : MAX_LEVELS_REG) 1008 1009 typedef struct 1010 { 1011 char *LevelName; 1012 char *SongName; 1013 char *Description; 1014 char *BestTime; 1015 char *ParTime; 1016 }LEVEL_INFO, *LEVEL_INFOp, **LEVEL_INFOpp; 1017 1018 extern LEVEL_INFO LevelInfo[MAX_LEVELS_REG+2]; 1019 1020 #define MAX_EPISODE_NAME_LEN 24 1021 extern char EpisodeNames[2][MAX_EPISODE_NAME_LEN+2]; // +2 = leading '^' and trailing NULL 1022 1023 #define MAX_EPISODE_SUBTITLE_LEN 40 1024 extern char EpisodeSubtitles[2][MAX_EPISODE_SUBTITLE_LEN+1]; 1025 1026 #define MAX_SKILL_NAME_LEN 24 1027 extern char SkillNames[4][MAX_SKILL_NAME_LEN+2]; 1028 1029 #define MAX_FORTUNES 16 1030 extern char *ReadFortune[MAX_FORTUNES]; 1031 1032 #define MAX_KEYS 8 1033 extern char *KeyMsg[MAX_KEYS]; 1034 extern char *KeyDoorMessage[MAX_KEYS]; 1035 1036 typedef struct 1037 { 1038 SHORT vel; 1039 SHORT svel; 1040 CHAR angvel; 1041 CHAR aimvel; 1042 LONG bits; 1043 }SW_PACKET; 1044 1045 extern SW_PACKET loc; 1046 1047 #define PACK 1 1048 1049 extern BOOL CameraTestMode; 1050 1051 enum PlayerDeathTypes 1052 { 1053 PLAYER_DEATH_FLIP, PLAYER_DEATH_CRUMBLE, PLAYER_DEATH_EXPLODE, PLAYER_DEATH_RIPPER, PLAYER_DEATH_SQUISH, PLAYER_DEATH_DROWN, MAX_PLAYER_DEATHS 1054 }; 1055 1056 typedef void (*PLAYER_ACTION_FUNCp)(PLAYERp); 1057 1058 #include "inv.h" 1059 1060 typedef struct 1061 { 1062 short cursectnum,lastcursectnum,pang,filler; 1063 int xvect,yvect,oxvect,oyvect,slide_xvect,slide_yvect; 1064 int posx,posy,posz; 1065 SECTOR_OBJECTp sop_control; 1066 }REMOTE_CONTROL, *REMOTE_CONTROLp; 1067 1068 struct PLAYERstruct 1069 { 1070 // variable that fit in the sprite or user structure 1071 int posx, posy, posz; 1072 // interpolation 1073 int 1074 oposx, oposy, oposz; 1075 short oang; 1076 short ohoriz; 1077 1078 // holds last valid move position 1079 short lv_sectnum; 1080 int lv_x,lv_y,lv_z; 1081 1082 SPRITEp remote_sprite; 1083 REMOTE_CONTROL remote; 1084 SECTOR_OBJECTp sop_remote; 1085 SECTOR_OBJECTp sop; // will either be sop_remote or sop_control 1086 1087 int jump_count, jump_speed; // jumping 1088 short down_speed, up_speed; // diving 1089 int z_speed,oz_speed; // used for diving and flying instead of down_speed, up_speed 1090 int climb_ndx; 1091 int hiz,loz; 1092 int ceiling_dist,floor_dist; 1093 SECTORp hi_sectp, lo_sectp; 1094 SPRITEp hi_sp, lo_sp; 1095 1096 SPRITEp last_camera_sp; 1097 int camera_dist; // view mode dist 1098 int circle_camera_dist; 1099 int six,siy,siz; // save player interp position for PlayerSprite 1100 short siang; 1101 1102 int xvect, yvect; 1103 int oxvect, oyvect; 1104 int friction; 1105 int slide_xvect, slide_yvect; 1106 short slide_ang; 1107 int slide_dec; 1108 int drive_angvel; 1109 int drive_oangvel; 1110 1111 1112 1113 // scroll 2D mode stuff 1114 int scr_x, scr_y, oscr_x, oscr_y; 1115 int scr_xvect, scr_yvect; 1116 short scr_ang, oscr_ang, scr_sectnum; 1117 1118 short view_outside_dang; // outside view delta ang 1119 short circle_camera_ang; 1120 short camera_check_time_delay; 1121 1122 short pang,cursectnum,lastcursectnum; 1123 short turn180_target; // 180 degree turn 1124 1125 // variables that do not fit into sprite structure 1126 int horizbase,horiz,horizoff,hvel,tilt,tilt_dest; 1127 short recoil_amt; 1128 short recoil_speed; 1129 short recoil_ndx; 1130 short recoil_horizoff; 1131 1132 int oldposx,oldposy,oldposz; 1133 int RevolveX, RevolveY; 1134 short RevolveDeltaAng, RevolveAng; 1135 1136 // under vars are for wading and swimming 1137 short PlayerSprite, PlayerUnderSprite; 1138 SPRITEp SpriteP, UnderSpriteP; 1139 1140 1141 short pnum; // carry along the player number 1142 1143 short LadderSector,LadderAngle; 1144 int lx,ly; // ladder x and y 1145 short JumpDuration; 1146 short WadeDepth; 1147 short bob_amt; 1148 short bob_ndx; 1149 short bcnt; // bob count 1150 int bob_z; 1151 1152 //Multiplayer variables 1153 SW_PACKET input; 1154 1155 //FIFO queue to hold values while faketimerhandler is called from within the drawing routing 1156 #define MOVEFIFOSIZ 256 1157 SW_PACKET inputfifo[MOVEFIFOSIZ]; 1158 1159 1160 int movefifoend; 1161 int myminlag; 1162 int syncvalhead; 1163 #define MAXSYNCBYTES 16 1164 // TENSW: on really bad network connections, the sync FIFO queue can overflow if it is the 1165 // same size as the move fifo. 1166 #define SYNCFIFOSIZ 1024 1167 BYTE syncval[SYNCFIFOSIZ][MAXSYNCBYTES]; 1168 1169 // must start out as 0 1170 int playerreadyflag; 1171 1172 PLAYER_ACTION_FUNCp DoPlayerAction; 1173 int Flags, Flags2; 1174 int KeyPressFlags; 1175 1176 SECTOR_OBJECTp sop_control; // sector object pointer 1177 SECTOR_OBJECTp sop_riding; // sector object pointer 1178 1179 struct 1180 { 1181 PANEL_SPRITEp Next, Prev; 1182 }PanelSpriteList; 1183 1184 // Key stuff 1185 #define NUM_KEYS 8 1186 unsigned char HasKey[NUM_KEYS]; 1187 1188 // Weapon stuff 1189 short SwordAng; 1190 int WpnGotOnceFlags; // for no respawn mode where weapons are allowed grabbed only once 1191 int WpnFlags; 1192 short WpnAmmo[MAX_WEAPONS]; 1193 short WpnNum; 1194 PANEL_SPRITEp CurWpn; 1195 PANEL_SPRITEp Wpn[MAX_WEAPONS]; 1196 PANEL_SPRITEp Chops; 1197 unsigned char WpnRocketType; // rocket type 1198 unsigned char WpnRocketHeat; // 5 to 0 range 1199 unsigned char WpnRocketNuke; // 1, you have it, or you don't 1200 unsigned char WpnFlameType; // Guardian weapons fire 1201 unsigned char WpnFirstType; // First weapon type - Sword/Shuriken 1202 unsigned char WeaponType; // for weapons with secondary functions 1203 short FirePause; // for sector objects - limits rapid firing 1204 // 1205 // Inventory Vars 1206 // 1207 short InventoryNum; 1208 short InventoryBarTics; 1209 PANEL_SPRITEp InventorySprite[MAX_INVENTORY]; 1210 PANEL_SPRITEp InventorySelectionBox; 1211 PANEL_SPRITEp MiniBarHealthBox, MiniBarAmmo; 1212 PANEL_SPRITEp MiniBarHealthBoxDigit[3], MiniBarAmmoDigit[3]; 1213 short InventoryTics[MAX_INVENTORY]; 1214 short InventoryPercent[MAX_INVENTORY]; 1215 CHAR InventoryAmount[MAX_INVENTORY]; 1216 BOOL InventoryActive[MAX_INVENTORY]; 1217 1218 short DiveTics; 1219 short DiveDamageTics; 1220 1221 // Death stuff 1222 short DeathType; 1223 short Kills; 1224 short Killer; //who killed me 1225 short KilledPlayer[MAX_SW_PLAYERS_REG]; 1226 short SecretsFound; 1227 1228 // Health 1229 short Armor; 1230 short MaxHealth; 1231 1232 //char RocketBarrel; 1233 char PlayerName[32]; 1234 1235 unsigned char UziShellLeftAlt; 1236 unsigned char UziShellRightAlt; 1237 unsigned char TeamColor; // used in team play and also used in regular mulit-play for show 1238 1239 // palette fading up and down for player hit and get items 1240 short FadeTics; // Tics between each fade cycle 1241 short FadeAmt; // Current intensity of fade 1242 BOOL NightVision; // Is player's night vision active? 1243 unsigned char StartColor; // Darkest color in color range being used 1244 //short electro[64]; 1245 unsigned char temp_pal[768]; // temporary working palette 1246 BOOL IsAI; // Is this and AI character? 1247 short fta,ftq; // First time active and first time quote, for talking in multiplayer games 1248 short NumFootPrints; // Number of foot prints left to lay down 1249 BOOL PlayerTalking; // Is player currently talking 1250 int TalkVocnum; // Number of sound that player is using 1251 int TalkVocHandle; // Handle of sound in sound queue, to access in Dose's code 1252 unsigned char WpnUziType; // Toggle between single or double uzi's if you own 2. 1253 unsigned char WpnShotgunType; // Shotgun has normal or fully automatic fire 1254 unsigned char WpnShotgunAuto; // 50-0 automatic shotgun rounds 1255 unsigned char WpnShotgunLastShell; // Number of last shell fired 1256 unsigned char WpnRailType; // Normal Rail Gun or EMP Burst Mode 1257 BOOL Bloody; // Is player gooey from the slaughter? 1258 int nukevochandle; // Stuff for the Nuke 1259 BOOL InitingNuke; 1260 BOOL TestNukeInit; 1261 BOOL NukeInitialized; // Nuke already has counted down 1262 short FistAng; // KungFu attack angle 1263 unsigned char WpnKungFuMove; // KungFu special moves 1264 BOOL BunnyMode; // Can shoot Bunnies out of rocket launcher 1265 short HitBy; // SpriteNum of whatever player was last hit by 1266 short Reverb; // Player's current reverb setting 1267 short Heads; // Number of Accursed Heads orbiting player 1268 int PlayerVersion; 1269 BOOL IsDisconnected; // Is this player dropped from the game? 1270 }; 1271 1272 extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; 1273 1274 1275 // 1276 // Player Flags 1277 // 1278 1279 #define PF_DEAD (BIT(1)) 1280 #define PF_JUMPING (BIT(2)) 1281 #define PF_FALLING (BIT(3)) 1282 #define PF_LOCK_CRAWL (BIT(4)) 1283 #define PF_LOCK_HORIZ (BIT(5)) 1284 #define PF_LOOKING (BIT(6)) 1285 #define PF_PLAYER_MOVED (BIT(7)) 1286 #define PF_PLAYER_RIDING (BIT(8)) 1287 #define PF_AUTO_AIM (BIT(9)) 1288 #define PF_RECOIL (BIT(10)) 1289 1290 #define PF_FLYING (BIT(11)) 1291 #define PF_WEAPON_RETRACT (BIT(12)) 1292 #define PF_PICKED_UP_AN_UZI (BIT(13)) 1293 #define PF_CRAWLING (BIT(14)) 1294 #define PF_CLIMBING (BIT(15)) 1295 #define PF_SWIMMING (BIT(16)) 1296 #define PF_DIVING (BIT(17)) 1297 #define PF_DIVING_IN_LAVA (BIT(18)) 1298 #define PF_TWO_UZI (BIT(19)) 1299 #define PF_LOCK_RUN (BIT(20)) 1300 #define PF_TURN_180 (BIT(21)) 1301 #define PF_DEAD_HEAD (BIT(22)) // are your a dead head 1302 #define PF_HEAD_CONTROL (BIT(23)) // have control of turning when a head? 1303 #define PF_CLIP_CHEAT (BIT(24)) // cheat for wall clipping 1304 #define PF_SLIDING (BIT(25)) // cheat for wall clipping 1305 #define PF_VIEW_FROM_OUTSIDE (BIT(26)) 1306 #define PF_VIEW_OUTSIDE_WEAPON (BIT(27)) 1307 #define PF_VIEW_FROM_CAMERA (BIT(28)) 1308 #define PF_TANK (BIT(29)) // Doin the tank thang 1309 #define PF_MOUSE_AIMING_ON (BIT(30)) 1310 #define PF_WEAPON_DOWN (BIT(31)) 1311 1312 #define PF2_TELEPORTED (BIT(0)) 1313 1314 /////////////////////////////////////////////////////////////////////////////////////////// 1315 // 1316 // Actor 1317 // 1318 /////////////////////////////////////////////////////////////////////////////////////////// 1319 1320 // 1321 // Hit Points 1322 // 1323 1324 #define HEALTH_RIPPER 70 1325 #define HEALTH_RIPPER2 200 1326 #define HEALTH_MOMMA_RIPPER 500 1327 #define HEALTH_NINJA 40 1328 #define HEALTH_RED_NINJA 160 1329 #define HEALTH_COOLIE 120 1330 #define HEALTH_COOLIE_GHOST 65 1331 #define HEALTH_SKEL_PRIEST 90 1332 #define HEALTH_GORO 200 1333 #define HEALTH_HORNET 4 1334 #define HEALTH_SKULL 4 1335 #define HEALTH_EEL 100 1336 1337 #define HEALTH_SERP_GOD 3800 1338 1339 // 1340 // Action Set Structure 1341 // 1342 1343 typedef struct 1344 { 1345 #define MAX_ACTOR_CLOSE_ATTACK 2 1346 #define MAX_ACTOR_ATTACK 6 1347 STATEp *Stand; 1348 STATEp *Run; 1349 STATEp *Jump; 1350 STATEp *Fall; 1351 STATEp *Crawl; 1352 STATEp *Swim; 1353 STATEp *Fly; 1354 STATEp *Rise; 1355 STATEp *Sit; 1356 STATEp *Look; 1357 STATEp *Climb; 1358 STATEp *Pain; 1359 STATEp *Death1; 1360 STATEp *Death2; 1361 STATEp *Dead; 1362 STATEp *DeathJump; 1363 STATEp *DeathFall; 1364 1365 STATEp *CloseAttack[MAX_ACTOR_CLOSE_ATTACK]; 1366 short CloseAttackPercent[MAX_ACTOR_CLOSE_ATTACK]; 1367 1368 STATEp *Attack[MAX_ACTOR_ATTACK]; 1369 short AttackPercent[MAX_ACTOR_ATTACK]; 1370 1371 STATEp *Special[2]; 1372 STATEp *Duck; 1373 STATEp *Dive; 1374 }ACTOR_ACTION_SET,*ACTOR_ACTION_SETp; 1375 1376 typedef struct 1377 { 1378 int pos; // current position - always moves toward tgt 1379 int open_dest; // destination of open position 1380 int tgt; // current target 1381 int speed; // speed of movement 1382 int orig_speed; // original speed - vel jacks with speed 1383 int vel; // velocity adjuments 1384 int num_walls; // save off positions of walls for rotator 1385 int *origx; 1386 int *origy; 1387 }ROTATOR, *ROTATORp; 1388 1389 // 1390 // User Extension record 1391 // 1392 1393 typedef struct 1394 { 1395 // 1396 // Variables that can be used by actors and Player 1397 // 1398 ROTATORp rotator; 1399 1400 // wall vars for lighting 1401 int WallCount; 1402 CHARp WallShade; // malloced - save off wall shades for lighting 1403 1404 WALLp WallP; // operate on wall instead of sprite 1405 STATEp State; 1406 STATEp *Rot; 1407 STATEp StateStart; 1408 STATEp StateEnd; 1409 STATEp *StateFallOverride; // a bit kludgy - override std fall state 1410 1411 ANIMATORp ActorActionFunc; 1412 ACTOR_ACTION_SETp ActorActionSet; 1413 PERSONALITYp Personality; 1414 ATTRIBUTEp Attrib; 1415 SECTOR_OBJECTp sop_parent; // denotes that this sprite is a part of the 1416 // sector object - contains info for the SO 1417 1418 int ox, oy, oz; 1419 1420 int Flags; 1421 int Flags2; 1422 int Tics; 1423 1424 short RotNum; 1425 short ID; 1426 1427 // Health/Pain related 1428 short Health; 1429 short MaxHealth; 1430 1431 short LastDamage; // last damage amount taken 1432 short PainThreshold; // amount of damage that can be taken before 1433 // going into pain frames. 1434 1435 // jump & fall 1436 short jump_speed; 1437 short jump_grav; 1438 1439 // clipmove 1440 short ceiling_dist; 1441 short floor_dist; 1442 short lo_step; 1443 int hiz,loz; 1444 int zclip; // z height to move up for clipmove 1445 SECTORp hi_sectp, lo_sectp; 1446 SPRITEp hi_sp, lo_sp; 1447 1448 int active_range; 1449 1450 short SpriteNum; 1451 short Attach; // attach to sprite if needed - electro snake 1452 SPRITEp SpriteP; 1453 1454 // if a player's sprite points to player structure 1455 PLAYERp PlayerP; 1456 short Sibling; 1457 1458 1459 // 1460 // Possibly used by both. 1461 // 1462 1463 // precalculated vectors 1464 int xchange,ychange,zchange; 1465 1466 int z_tgt; 1467 1468 // velocity 1469 int vel_tgt; 1470 short vel_rate; 1471 BYTE speed; // Ordinal Speed Range 0-3 from slow to fast 1472 1473 short Counter; 1474 short Counter2; 1475 short Counter3; 1476 short DamageTics; 1477 short BladeDamageTics; 1478 1479 short WpnGoal; 1480 unsigned int Radius; // for distance checking 1481 int OverlapZ; // for z overlap variable 1482 1483 // 1484 // Only have a place for actors 1485 // 1486 1487 // For actors on fire 1488 short flame; 1489 1490 // target player for the enemy - can only handle one player at at time 1491 //PLAYERp tgt_player; 1492 SPRITEp tgt_sp; 1493 1494 // scaling 1495 short scale_speed; 1496 unsigned short scale_value; 1497 short scale_tgt; 1498 1499 // zig zagging 1500 short DistCheck; 1501 //short ZigZagDist; 1502 //short ZigZagAng; 1503 //short ZigZagDir; 1504 1505 short Dist; 1506 short TargetDist; 1507 short WaitTics; 1508 1509 // track 1510 short track; 1511 short point; 1512 short track_dir; 1513 int track_vel; 1514 1515 // sliding variables - slide backwards etc 1516 short slide_ang; 1517 int slide_vel; 1518 short slide_dec; 1519 1520 short motion_blur_dist; 1521 short motion_blur_num; 1522 1523 short wait_active_check; // for enemy checking of player 1524 short inactive_time; // length of time actor has been unaware of his tgt 1525 int sx,sy,sz; 1526 short sang; 1527 char spal; // save off default palette number 1528 1529 int ret; //holder for move_sprite return value 1530 1531 // Need to get rid of these flags 1532 int Flag1; 1533 1534 CHAR LastWeaponNum; 1535 CHAR WeaponNum; 1536 1537 short bounce; // count bounces off wall for killing shrap stuff 1538 // !JIM! my extensions 1539 int ShellNum; // This is shell no. 0 to whatever 1540 // Shell gets deleted when ShellNum < (ShellCount - MAXSHELLS) 1541 short FlagOwner; // The spritenum of the original flag 1542 short Vis; // Shading upgrade, for shooting, etc... 1543 BOOL DidAlert; // Has actor done his alert noise before? 1544 }USER,*USERp; 1545 1546 // sprite->extra flags 1547 // BUILD AND GAME - DO NOT MOVE THESE 1548 #define SPRX_SKILL (BIT(0) | BIT(1) | BIT(2)) 1549 1550 // BIT(4) ST1 BUILD AND GAME 1551 #define SPRX_STAY_PUT_VATOR (BIT(5)) // BUILD AND GAME - will not move with vators etc 1552 // DO NOT MOVE THIS 1553 1554 #define SPRX_STAG (BIT(6)) // BUILD AND GAME - NON-ST1 sprite with ST1 type tagging 1555 // DO NOT MOVE 1556 1557 #define SPRX_QUEUE_SPRITE (BIT(7)) // Queue sprite -check queue when deleting 1558 #define SPRX_MULTI_ITEM (BIT(9)) // BUILD AND GAME - multi player item 1559 1560 // have users - could be moved 1561 #define SPRX_PLAYER_OR_ENEMY (BIT(11)) // for checking quickly if sprite is a 1562 // player or actor 1563 // do not need Users 1564 #define SPRX_FOUND (BIT(12)) // BUILD ONLY INTERNAL - used for finding sprites 1565 #define SPRX_BLADE (BIT(12)) // blade sprite 1566 #define SPRX_BREAKABLE (BIT(13)) // breakable items 1567 #define SPRX_BURNABLE (BIT(14)) // used for burnable sprites in the game 1568 1569 // temp use 1570 #define SPRX_BLOCK (BIT(15)) // BUILD AND GAME 1571 // BUILD - tell which actors should not spawn 1572 // GAME - used for internal game code 1573 // ALT-M debug mode 1574 1575 // !LIGHT 1576 // all three bits set - should never happen with skill 1577 // #define SPRX_USER_NON_STANDARD (BIT(0)|BIT(1)|BIT(2)) // used for lighting 1578 1579 // boolean flags carried over from build 1580 #define SPRX_BOOL11 (BIT(5)) 1581 #define SPRX_BOOL1 (BIT(6)) 1582 #define SPRX_BOOL2 (BIT(7)) 1583 #define SPRX_BOOL3 (BIT(8)) 1584 #define SPRX_BOOL4 (BIT(9)) 1585 #define SPRX_BOOL5 (BIT(10)) 1586 #define SPRX_BOOL6 (BIT(11)) 1587 #define SPRX_BOOL7 (BIT(4)) // bit 12 was used build 1588 #define SPRX_BOOL8 (BIT(13)) 1589 #define SPRX_BOOL9 (BIT(14)) 1590 #define SPRX_BOOL10 (BIT(15)) 1591 1592 #define SET_BOOL1(sp) SET((sp)->extra, SPRX_BOOL1) 1593 #define SET_BOOL2(sp) SET((sp)->extra, SPRX_BOOL2) 1594 #define SET_BOOL3(sp) SET((sp)->extra, SPRX_BOOL3) 1595 #define SET_BOOL4(sp) SET((sp)->extra, SPRX_BOOL4) 1596 #define SET_BOOL5(sp) SET((sp)->extra, SPRX_BOOL5) 1597 #define SET_BOOL6(sp) SET((sp)->extra, SPRX_BOOL6) 1598 #define SET_BOOL7(sp) SET((sp)->extra, SPRX_BOOL7) 1599 #define SET_BOOL8(sp) SET((sp)->extra, SPRX_BOOL8) 1600 #define SET_BOOL9(sp) SET((sp)->extra, SPRX_BOOL9) 1601 #define SET_BOOL10(sp) SET((sp)->extra, SPRX_BOOL10) 1602 #define SET_BOOL11(sp) SET((sp)->extra, SPRX_BOOL11) 1603 1604 #define RESET_BOOL1(sp) RESET((sp)->extra, SPRX_BOOL1) 1605 #define RESET_BOOL2(sp) RESET((sp)->extra, SPRX_BOOL2) 1606 #define RESET_BOOL3(sp) RESET((sp)->extra, SPRX_BOOL3) 1607 #define RESET_BOOL4(sp) RESET((sp)->extra, SPRX_BOOL4) 1608 #define RESET_BOOL5(sp) RESET((sp)->extra, SPRX_BOOL5) 1609 #define RESET_BOOL6(sp) RESET((sp)->extra, SPRX_BOOL6) 1610 #define RESET_BOOL7(sp) RESET((sp)->extra, SPRX_BOOL7) 1611 #define RESET_BOOL8(sp) RESET((sp)->extra, SPRX_BOOL8) 1612 #define RESET_BOOL9(sp) RESET((sp)->extra, SPRX_BOOL9) 1613 #define RESET_BOOL10(sp) RESET((sp)->extra, SPRX_BOOL10) 1614 #define RESET_BOOL11(sp) RESET((sp)->extra, SPRX_BOOL11) 1615 1616 #define TEST_BOOL1(sp) TEST((sp)->extra, SPRX_BOOL1) 1617 #define TEST_BOOL2(sp) TEST((sp)->extra, SPRX_BOOL2) 1618 #define TEST_BOOL3(sp) TEST((sp)->extra, SPRX_BOOL3) 1619 #define TEST_BOOL4(sp) TEST((sp)->extra, SPRX_BOOL4) 1620 #define TEST_BOOL5(sp) TEST((sp)->extra, SPRX_BOOL5) 1621 #define TEST_BOOL6(sp) TEST((sp)->extra, SPRX_BOOL6) 1622 #define TEST_BOOL7(sp) TEST((sp)->extra, SPRX_BOOL7) 1623 #define TEST_BOOL8(sp) TEST((sp)->extra, SPRX_BOOL8) 1624 #define TEST_BOOL9(sp) TEST((sp)->extra, SPRX_BOOL9) 1625 #define TEST_BOOL10(sp) TEST((sp)->extra, SPRX_BOOL10) 1626 #define TEST_BOOL11(sp) TEST((sp)->extra, SPRX_BOOL11) 1627 1628 // User->Flags flags 1629 #define SPR_MOVED BIT(0) // Did actor move 1630 #define SPR_ATTACKED BIT(1) // Is sprite being attacked? 1631 #define SPR_TARGETED BIT(2) // Is sprite a target of a weapon? 1632 #define SPR_ACTIVE BIT(3) // Is sprite aware of the player? 1633 #define SPR_ELECTRO_TOLERANT BIT(4) // Electro spell does not slow actor 1634 #define SPR_JUMPING BIT(5) // Actor is jumping 1635 #define SPR_FALLING BIT(6) // Actor is falling 1636 #define SPR_CLIMBING BIT(7) // Actor is falling 1637 #define SPR_DEAD BIT(8) // Actor is dying 1638 1639 #define SPR_ZDIFF_MODE BIT(10) // For following tracks at different z heights 1640 #define SPR_SPEED_UP BIT(11) // For following tracks at different speeds 1641 #define SPR_SLOW_DOWN BIT(12) // For following tracks at different speeds 1642 #define SPR_DONT_UPDATE_ANG BIT(13) // For tracks - don't update the angle for a while 1643 1644 #define SPR_SO_ATTACHED BIT(14) // sprite is part of a sector object 1645 #define SPR_SUICIDE BIT(15) // sprite is set to kill itself 1646 1647 #define SPR_RUN_AWAY BIT(16) // sprite is in "Run Away" track mode. 1648 #define SPR_FIND_PLAYER BIT(17) // sprite is in "Find Player" track mode. 1649 1650 #define SPR_SWIMMING BIT(18) // Actor is swimming 1651 #define SPR_WAIT_FOR_PLAYER BIT(19) // Track Mode - Actor is waiting for player to come close 1652 #define SPR_WAIT_FOR_TRIGGER BIT(20) // Track Mode - Actor is waiting for player to trigger 1653 #define SPR_SLIDING BIT(21) // Actor is sliding 1654 #define SPR_ON_SO_SECTOR BIT(22) // sprite is on a sector object sector 1655 1656 #define SPR_SHADE_DIR BIT(23) // sprite is on a sector object sector 1657 #define SPR_XFLIP_TOGGLE BIT(24) // sprite rotation xflip bit 1658 #define SPR_NO_SCAREDZ BIT(25) // not afraid of falling 1659 1660 #define SPR_SET_POS_DONT_KILL BIT(26) // Don't kill sprites in MissileSetPos 1661 #define SPR_SKIP2 BIT(27) // 20 moves ps 1662 #define SPR_SKIP4 BIT(28) // 10 moves ps 1663 1664 #define SPR_BOUNCE BIT(29) // For shrapnel types that can bounce once 1665 #define SPR_UNDERWATER BIT(30) // For missiles etc 1666 1667 #define SPR_SHADOW BIT(31) // Sprites that have shadows 1668 1669 // User->Flags2 flags 1670 #define SPR2_BLUR_TAPER (BIT(13)|BIT(14)) // taper type 1671 #define SPR2_BLUR_TAPER_FAST (BIT(13)) // taper fast 1672 #define SPR2_BLUR_TAPER_SLOW (BIT(14)) // taper slow 1673 #define SPR2_SPRITE_FAKE_BLOCK (BIT(15)) // fake blocking bit for damage 1674 #define SPR2_NEVER_RESPAWN (BIT(16)) // for item respawning 1675 #define SPR2_ATTACH_WALL (BIT(17)) 1676 #define SPR2_ATTACH_FLOOR (BIT(18)) 1677 #define SPR2_ATTACH_CEILING (BIT(19)) 1678 #define SPR2_CHILDREN (BIT(20)) // sprite OWNS children 1679 #define SPR2_SO_MISSILE (BIT(21)) // this is a missile from a SO 1680 #define SPR2_DYING (BIT(22)) // Sprite is currently dying 1681 #define SPR2_VIS_SHADING (BIT(23)) // Sprite shading to go along with vis adjustments 1682 #define SPR2_DONT_TARGET_OWNER (BIT(24)) 1683 1684 1685 extern USERp User[MAXSPRITES]; 1686 1687 typedef struct 1688 { 1689 short Xdim, Ydim, ScreenSize; 1690 }BORDER_INFO,*BORDER_INFOp; 1691 1692 1693 typedef struct 1694 { 1695 short high; 1696 }RANGE,*RANGEp; 1697 1698 1699 /////////////////////////////////////////////////////////////////////////////////////////// 1700 // 1701 // Sector Stuff - Sector Objects and Tracks 1702 // 1703 /////////////////////////////////////////////////////////////////////////////////////////// 1704 1705 // flags in EXTRA variable 1706 #define SECTFX_SINK BIT(0) 1707 #define SECTFX_OPERATIONAL BIT(1) 1708 #define SECTFX_WARP_SECTOR BIT(2) 1709 #define SECTFX_CURRENT BIT(3) 1710 #define SECTFX_Z_ADJUST BIT(4) // adjust ceiling/floor 1711 #define SECTFX_NO_RIDE BIT(5) // moving sector - don't ride it 1712 #define SECTFX_DYNAMIC_AREA BIT(6) 1713 #define SECTFX_DIVE_AREA BIT(7) // Diving area 1714 #define SECTFX_UNDERWATER BIT(8) // Underwater area 1715 #define SECTFX_UNDERWATER2 BIT(9) // Underwater area 1716 1717 #define SECTFX_LIQUID_MASK (BIT(10)|BIT(11)) // only valid for sectors with depth 1718 #define SECTFX_LIQUID_NONE (0) 1719 #define SECTFX_LIQUID_LAVA BIT(10) 1720 #define SECTFX_LIQUID_WATER BIT(11) 1721 #define SECTFX_SECTOR_OBJECT BIT(12) // for collision detection 1722 #define SECTFX_VATOR BIT(13) // denotes that this is a vertical moving sector 1723 // vator type 1724 #define SECTFX_TRIGGER BIT(14) // trigger type to replace tags.h trigger types 1725 1726 // flags in sector USER structure 1727 #define SECTFU_SO_DONT_BOB BIT(0) 1728 #define SECTFU_SO_SINK_DEST BIT(1) 1729 #define SECTFU_SO_DONT_SINK BIT(2) 1730 #define SECTFU_DONT_COPY_PALETTE BIT(3) 1731 #define SECTFU_SO_SLOPE_FLOOR_TO_POINT BIT(4) 1732 #define SECTFU_SO_SLOPE_CEILING_TO_POINT BIT(5) 1733 #define SECTFU_DAMAGE_ABOVE_SECTOR BIT(6) 1734 #define SECTFU_VATOR_BOTH BIT(7) // vators set up for both ceiling and floor 1735 #define SECTFU_CANT_SURFACE BIT(8) // for diving 1736 #define SECTFU_SLIDE_SECTOR BIT(9) // for diving 1737 1738 #define MAKE_STAG_ENUM 1739 enum stag_id 1740 { 1741 #include "stag.h" 1742 }; 1743 typedef enum stag_id STAG_ID; 1744 #undef MAKE_STAG_ENUM 1745 1746 1747 #define WALLFX_LOOP_DONT_SPIN BIT(0) 1748 #define WALLFX_LOOP_REVERSE_SPIN BIT(1) 1749 #define WALLFX_LOOP_SPIN_2X BIT(2) 1750 #define WALLFX_LOOP_SPIN_4X BIT(3) 1751 #define WALLFX_LOOP_OUTER BIT(4) // for sector object 1752 #define WALLFX_DONT_MOVE BIT(5) // for sector object 1753 #define WALLFX_SECTOR_OBJECT BIT(6) // for collision detection 1754 #define WALLFX_DONT_STICK BIT(7) // for bullet holes and stars 1755 #define WALLFX_DONT_SCALE BIT(8) // for sector object 1756 #define WALLFX_LOOP_OUTER_SECONDARY BIT(9) // for sector object 1757 1758 enum ShrapType 1759 { 1760 SHRAP_NONE = 0, 1761 SHRAP_GLASS = 1, // 1762 SHRAP_TREE_BARK = 2, // (NEED) outside tree bark 1763 SHRAP_SO_SMOKE = 3, // only used for damaged SO's 1764 SHRAP_PAPER = 4, // 1765 SHRAP_BLOOD = 5, // std blood from gibs 1766 SHRAP_EXPLOSION = 6, // small explosion 1767 SHRAP_LARGE_EXPLOSION = 7, // large explosion 1768 SHRAP_METAL = 8, // 1769 SHRAP_STONE = 9, // what we have might be ok 1770 SHRAP_PLANT = 10, // (NEED) 1771 SHRAP_GIBS = 11, // std blood and guts 1772 SHRAP_WOOD = 12, // 1773 SHRAP_GENERIC = 13, // what we have might be ok - sort of gray brown rock look 1774 SHRAP_TREE_PULP = 14, // (NEED) inside tree wood 1775 SHRAP_COIN = 15, 1776 SHRAP_METALMIX = 16, 1777 SHRAP_WOODMIX = 17, 1778 SHRAP_MARBELS = 18, 1779 SHRAP_PAPERMIX = 19, 1780 SHRAP_USER_DEFINED = 99 1781 }; 1782 1783 typedef struct 1784 { 1785 int dist, flags; 1786 short depth_fract, depth; // do NOT change this, doubles as a long FIXED point number 1787 short stag, // ST? tag number - for certain things it helps to know it 1788 ang, 1789 height, 1790 speed, 1791 damage, 1792 number; // usually used for matching number 1793 BYTE flags2; 1794 }SECT_USER, *SECT_USERp; 1795 1796 extern SECT_USERp SectUser[MAXSECTORS]; 1797 SECT_USERp SpawnSectUser(short sectnum); 1798 1799 1800 typedef struct 1801 { 1802 unsigned int size, checksum; 1803 }MEM_HDR,*MEM_HDRp; 1804 1805 BOOL ValidPtr(VOID *ptr); 1806 VOID * AllocMem(int size); 1807 VOID * CallocMem(int size, int num); 1808 VOID * ReAllocMem(VOID *ptr, int size); 1809 VOID FreeMem(VOID *ptr); 1810 1811 typedef struct 1812 { 1813 short sprite_num; 1814 short dang; 1815 int dist; 1816 int weight; 1817 }TARGET_SORT, *TARGET_SORTp; 1818 1819 #define MAX_TARGET_SORT 16 1820 extern TARGET_SORT TargetSort[MAX_TARGET_SORT]; 1821 extern unsigned TargetSortCount; 1822 1823 enum DoorType 1824 { 1825 OPERATE_TYPE, 1826 DOOR_HORIZ_TYPE, 1827 DOOR_SLIDE_TYPE, 1828 DOOR_SWING_TYPE, 1829 DOOR_ROTATE_TYPE 1830 }; 1831 1832 typedef enum DoorType DOOR_TYPE; 1833 1834 typedef struct 1835 { 1836 DOOR_TYPE Type; 1837 short Sector; 1838 short Speed; 1839 short TimeOut; 1840 } DOOR_AUTO_CLOSE, *DOOR_AUTO_CLOSEp; 1841 1842 #define MAX_DOOR_AUTO_CLOSE 16 1843 1844 typedef struct 1845 { 1846 int origx[17], origy[17]; 1847 short sector, angopen, angclosed, angopendir, sang, anginc, wall[17]; 1848 } SWING; 1849 1850 typedef struct 1851 { 1852 int floor_origz, ceiling_origz, range; 1853 short sector, sintable_ndx, speed_shift; 1854 char flags; 1855 } SINE_WAVE_FLOOR, *SINE_WAVE_FLOORp; 1856 1857 #define MAX_SINE_WAVE 6 1858 extern SINE_WAVE_FLOOR SineWaveFloor[MAX_SINE_WAVE][21]; 1859 1860 typedef struct 1861 { 1862 int orig_xy, range; 1863 short wall, sintable_ndx, speed_shift, type; 1864 } SINE_WALL, *SINE_WALLp; 1865 1866 #define MAX_SINE_WALL 10 1867 #define MAX_SINE_WALL_POINTS 64 1868 extern SINE_WALL SineWall[MAX_SINE_WALL][MAX_SINE_WALL_POINTS]; 1869 1870 typedef struct 1871 { 1872 short Sector, TimeOut; 1873 } SPRING_BOARD; 1874 1875 extern SPRING_BOARD SpringBoard[20]; 1876 extern SWING Rotate[17]; 1877 1878 typedef struct 1879 { 1880 short sector, speed; 1881 int xmid, ymid; 1882 } SPIN; 1883 1884 extern SPIN Spin[17]; 1885 extern DOOR_AUTO_CLOSE DoorAutoClose[MAX_DOOR_AUTO_CLOSE]; 1886 extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound; 1887 1888 #define MAXANIM 256 1889 typedef void ANIM_CALLBACK(ANIMp, void *); 1890 typedef ANIM_CALLBACK *ANIM_CALLBACKp; 1891 typedef void *ANIM_DATAp; 1892 1893 struct ANIMstruct 1894 { 1895 int *ptr, goal; 1896 int vel; 1897 short vel_adj; 1898 ANIM_CALLBACKp callback; 1899 ANIM_DATAp callbackdata; 1900 }; 1901 1902 extern ANIM Anim[MAXANIM]; 1903 extern short AnimCnt; 1904 1905 1906 typedef struct 1907 { 1908 int x,y,z; 1909 short ang, tag_low, tag_high, filler; 1910 }TRACK_POINT, *TRACK_POINTp; 1911 1912 typedef struct 1913 { 1914 TRACK_POINTp TrackPoint; 1915 int ttflags; 1916 short flags; 1917 short NumPoints; 1918 }TRACK, *TRACKp; 1919 1920 // Most track type flags are in tags.h 1921 1922 // Regular track flags 1923 #define TF_TRACK_OCCUPIED BIT(0) 1924 1925 typedef struct 1926 { 1927 BYTE FromRange,ToRange,FromColor,ToColor; 1928 }COLOR_MAP, *COLOR_MAPp; 1929 1930 #define MAX_TRACKS 100 1931 1932 extern TRACK Track[MAX_TRACKS]; 1933 1934 struct SECTOR_OBJECTstruct 1935 { 1936 #define MAX_SO_SECTOR 40 1937 #define MAX_SO_POINTS (MAX_SO_SECTOR*15) 1938 #define MAX_SO_SPRITE 60 1939 #define MAX_CLIPBOX 32 1940 1941 SECTORp sectp[MAX_SO_SECTOR]; 1942 soANIMATORp PreMoveAnimator; 1943 soANIMATORp PostMoveAnimator; 1944 soANIMATORp Animator; 1945 SPRITEp controller; 1946 1947 SPRITEp sp_child; // child sprite that holds info for the sector object 1948 1949 int xmid,ymid,zmid, // midpoints of the sector object 1950 vel, // velocity 1951 vel_tgt, // target velocity 1952 player_xoff, // player x offset from the xmid 1953 player_yoff, // player y offset from the ymid 1954 zorig_floor[MAX_SO_SECTOR], // original z values for all sectors 1955 zorig_ceiling[MAX_SO_SECTOR], // original z values for all sectors 1956 zdelta, // z delta from original 1957 z_tgt, // target z delta 1958 z_rate, // rate at which z aproaches target 1959 update, // Distance from player at which you continue updating 1960 // only works for single player. 1961 bob_diff, // bobbing difference for the frame 1962 target_dist, // distance to next point 1963 floor_loz, // floor low z 1964 floor_hiz, // floor hi z 1965 morph_z, // morphing point z 1966 morph_z_min, // morphing point z min 1967 morph_z_max, 1968 bob_amt, // bob amount max in z coord 1969 // variables set by mappers for drivables 1970 drive_angspeed, 1971 drive_angslide, 1972 drive_speed, 1973 drive_slide, 1974 crush_z, 1975 flags; 1976 1977 short sector[MAX_SO_SECTOR], // hold the sector numbers of the sector object 1978 sp_num[MAX_SO_SPRITE], // hold the sprite numbers of the object 1979 xorig[MAX_SO_POINTS], // save the original x & y location of each wall so it can be 1980 yorig[MAX_SO_POINTS], // refreshed 1981 sectnum, // current secnum of midpoint 1982 mid_sector, // middle sector 1983 max_damage, // max damage 1984 ram_damage, // damage taken by ramming 1985 wait_tics, // 1986 num_sectors, // number of sectors 1987 num_walls, // number of sectors 1988 track, // the track # 0 to 20 1989 point, // the point on the track that the sector object is headed toward 1990 vel_rate, // rate at which velocity aproaches target 1991 dir, // direction traveling on the track 1992 ang, // angle facing 1993 ang_moving, // angle the SO is facing 1994 clipdist, // cliping distance for operational sector objects 1995 clipbox_dist[MAX_CLIPBOX], // mult-clip box variables 1996 clipbox_xoff[MAX_CLIPBOX], // mult-clip box variables 1997 clipbox_yoff[MAX_CLIPBOX], // mult-clip box variables 1998 clipbox_ang[MAX_CLIPBOX], // mult-clip box variables 1999 clipbox_vdist[MAX_CLIPBOX], // mult-clip box variables 2000 clipbox_num, 2001 ang_tgt, // target angle 2002 ang_orig, // original angle 2003 last_ang, // last angle before started spinning 2004 old_ang, // holding variable for the old angle 2005 spin_speed, // spin_speed 2006 spin_ang, // spin angle 2007 turn_speed, // shift value determines how fast SO turns to match new angle 2008 bob_sine_ndx, // index into sine table 2009 bob_speed, // shift value for speed 2010 op_main_sector, // main sector operational SO moves in - for speed purposes 2011 save_vel, // save velocity 2012 save_spin_speed,// save spin speed 2013 match_event, // match number 2014 match_event_sprite, // spritenum of the match event sprite 2015 // SO Scaling Vector Info 2016 scale_type, // type of scaling - enum controled 2017 scale_active_type, // activated by a switch or trigger 2018 2019 // values for whole SO 2020 scale_dist, // distance from center 2021 scale_speed, // speed of scaling 2022 scale_dist_min, // absolute min 2023 scale_dist_max, // absolute max 2024 scale_rand_freq, // freqency of direction change - based on rand(1024) 2025 2026 // values for single point scaling 2027 scale_point_dist[MAX_SO_POINTS], // distance from center 2028 scale_point_speed[MAX_SO_POINTS], // speed of scaling 2029 scale_point_base_speed, // base speed of scaling 2030 scale_point_dist_min, // absolute min 2031 scale_point_dist_max, // absolute max 2032 scale_point_rand_freq, // freqency of direction change - based on rand(1024) 2033 2034 scale_x_mult, // x multiplyer for scaling 2035 scale_y_mult, // y multiplyer for scaling 2036 2037 // Used for center point movement 2038 morph_wall_point, // actual wall point to drag 2039 morph_ang, // angle moving from CENTER 2040 morph_speed, // speed of movement 2041 morph_dist_max, // radius boundry 2042 morph_rand_freq, // freq of dir change 2043 morph_dist, // dist from CENTER 2044 morph_z_speed, // z speed for morph point 2045 morph_xoff, // save xoff from center 2046 morph_yoff, // save yoff from center 2047 2048 //scale_rand_reverse, // random at random interval 2049 // limit rotation angle 2050 limit_ang_center,// for limiting the angle of turning - turrets etc 2051 limit_ang_delta; // 2052 }; 2053 2054 #define MAX_SECTOR_OBJECTS 20 2055 2056 #define SOBJ_SPEED_UP BIT(0) 2057 #define SOBJ_SLOW_DOWN BIT(1) 2058 #define SOBJ_ZUP BIT(2) 2059 #define SOBJ_ZDOWN BIT(3) 2060 #define SOBJ_ZDIFF_MODE BIT(4) 2061 #define SOBJ_MOVE_VERTICAL BIT(5) // for sprite objects - move straight up/down 2062 #define SOBJ_ABSOLUTE_ANGLE BIT(7) 2063 #define SOBJ_SPRITE_OBJ BIT(8) 2064 #define SOBJ_DONT_ROTATE BIT(9) 2065 #define SOBJ_WAIT_FOR_EVENT BIT(10) 2066 #define SOBJ_HAS_WEAPON BIT(11) 2067 #define SOBJ_SYNC1 BIT(12) // for syncing up several SO's perfectly 2068 #define SOBJ_SYNC2 BIT(13) // for syncing up several SO's perfectly 2069 #define SOBJ_DYNAMIC BIT(14) // denotes scaling or morphing object 2070 #define SOBJ_ZMID_FLOOR BIT(15) // can't remember which sector objects need this 2071 // think its the bobbing and sinking ones 2072 #define SOBJ_SLIDE BIT(16) 2073 2074 #define SOBJ_OPERATIONAL BIT(17) 2075 #define SOBJ_KILLABLE BIT(18) 2076 #define SOBJ_DIE_HARD BIT(19) 2077 #define SOBJ_UPDATE_ONCE BIT(20) 2078 #define SOBJ_UPDATE BIT(21) 2079 #define SOBJ_NO_QUAKE BIT(22) 2080 #define SOBJ_REMOTE_ONLY BIT(23) 2081 #define SOBJ_RECT_CLIP BIT(24) 2082 #define SOBJ_BROKEN BIT(25) 2083 2084 // track set to these to tell them apart 2085 #define SO_OPERATE_TRACK_START 90 2086 #define SO_TURRET_MGUN 96 // machine gun 2087 #define SO_TURRET 97 2088 #define SO_TANK 98 2089 #define SO_SPEED_BOAT 99 2090 2091 extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS]; 2092 2093 /////////////////////////////////////////////////////////////////////////////////////////// 2094 // 2095 // Prototypes 2096 // 2097 /////////////////////////////////////////////////////////////////////////////////////////// 2098 2099 ANIMATOR NullAnimator; 2100 2101 VOID SetBorder(PLAYERp pp, int); 2102 VOID SetFragBar(PLAYERp pp); 2103 int Distance(int x1, int y1, int x2, int y2); 2104 short GetDeltaAngle(short, short); 2105 2106 int SetActorRotation(short SpriteNum,int,int); 2107 int NewStateGroup(short SpriteNum, STATEp SpriteGroup[]); 2108 VOID SectorMidPoint(short sectnum, int *xmid, int *ymid, int *zmid); 2109 USERp SpawnUser(short SpriteNum, short id, STATEp state); 2110 2111 short ActorFindTrack(short SpriteNum, CHAR player_dir, int track_type, short *track_point_num, short *track_dir); 2112 2113 SECT_USERp GetSectUser(short sectnum); 2114 2115 short SoundDist(int x, int y, int z, int basedist); 2116 short SoundAngle(int x, int y); 2117 //void PlaySound(int num, short angle, short vol); 2118 int PlaySound(int num, int *x, int *y, int *z, Voc3D_Flags flags); 2119 void PlayerSound(int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp); 2120 2121 ANIMATOR DoActorBeginJump,DoActorJump,DoActorBeginFall,DoActorFall,DoActorDeathMove; 2122 2123 int SpawnShrap(short,short); 2124 2125 VOID PlayerUpdateHealth(PLAYERp pp, short value); 2126 VOID PlayerUpdateAmmo(PLAYERp pp, short WeaponNum, short value); 2127 VOID PlayerUpdateWeapon(PLAYERp pp, short WeaponNum); 2128 VOID PlayerUpdateKills(PLAYERp pp, short value); 2129 VOID PlayerUpdatePanelInfo(PLAYERp pp); 2130 VOID RefreshInfoLine(PLAYERp pp); 2131 2132 VOID DoAnim(int numtics); 2133 void AnimDelete(int *animptr); 2134 short AnimGetGoal(int *animptr); 2135 short AnimSet(int *animptr, int thegoal, int thevel); 2136 //short AnimSetCallback(int *animptr, int thegoal, int thevel, ANIM_CALLBACKp call, ANIM_DATAp data); 2137 short AnimSetCallback(short anim_ndx, ANIM_CALLBACKp call, ANIM_DATAp data); 2138 short AnimSetVelAdj(short anim_ndx, short vel_adj); 2139 2140 VOID EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp person); 2141 2142 VOID getzrangepoint(int x, int y, int z, short sectnum, LONGp ceilz, LONGp ceilhit, LONGp florz, LONGp florhit); 2143 int move_sprite(short spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, ULONG cliptype, int numtics); 2144 int move_missile(short spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, ULONG cliptype, int numtics); 2145 int DoPickTarget(SPRITEp sp, WORD max_delta_ang, BOOL skip_targets); 2146 2147 VOID change_sprite_stat(short, short); 2148 VOID SetOwner(short, short); 2149 VOID SetAttach(short, short); 2150 VOID analyzesprites(int,int,int,BOOL); 2151 VOID ChangeState(short SpriteNum, STATEp statep); 2152 2153 VOID UpdateSectorFAF_Connect(short SpriteNum, int newz); 2154 #if 0 2155 BOOL FAF_ConnectCeiling(short sectnum); 2156 BOOL FAF_ConnectFloor(short sectnum); 2157 #else 2158 #define FAF_PLACE_MIRROR_PIC 341 2159 #define FAF_MIRROR_PIC 2356 2160 #define FAF_ConnectCeiling(sectnum) (sector[(sectnum)].ceilingpicnum == FAF_MIRROR_PIC) 2161 #define FAF_ConnectFloor(sectnum) (sector[(sectnum)].floorpicnum == FAF_MIRROR_PIC) 2162 #define FAF_ConnectArea(sectnum) (FAF_ConnectCeiling(sectnum) || FAF_ConnectFloor(sectnum)) 2163 #endif 2164 void updatesectorz(int, int, int, short *); 2165 VOID FAF_ConnectPlayerCeiling(PLAYERp pp); 2166 VOID FAF_ConnectPlayerFloor(PLAYERp pp); 2167 BOOL PlayerCeilingHit(PLAYERp pp, int zlimit); 2168 BOOL PlayerFloorHit(PLAYERp pp, int zlimit); 2169 2170 VOID FAFhitscan(LONG x, LONG y, LONG z, SHORT sectnum, 2171 LONG xvect, LONG yvect, LONG zvect, 2172 SHORTp hitsect, SHORTp hitwall, SHORTp hitsprite, 2173 LONGp hitx, LONGp hity, LONGp hitz, LONG clipmask); 2174 2175 BOOL FAFcansee(LONG xs, LONG ys, LONG zs, SHORT sects, LONG xe, LONG ye, LONG ze, SHORT secte); 2176 2177 VOID FAFgetzrange(LONG x, LONG y, LONG z, SHORT sectnum, 2178 LONGp hiz, LONGp ceilhit, 2179 LONGp loz, LONGp florhit, 2180 LONG clipdist, LONG clipmask); 2181 2182 VOID FAFgetzrangepoint(LONG x, LONG y, LONG z, SHORT sectnum, 2183 LONGp hiz, LONGp ceilhit, 2184 LONGp loz, LONGp florhit); 2185 2186 VOID COVERupdatesector(LONG x, LONG y, SHORTp newsector); 2187 2188 void updatesectorz(int,int,int,SHORTp); 2189 2190 extern int clipmoveboxtracenum; 2191 2192 2193 void short_setinterpolation(short *posptr); 2194 void short_stopinterpolation(short *posptr); 2195 void short_updateinterpolations(void); 2196 void short_dointerpolations(int smoothratio); 2197 void short_restoreinterpolations(void); 2198 2199 enum SoundType 2200 { 2201 SOUND_OBJECT_TYPE, 2202 SOUND_EVERYTHING_TYPE 2203 }; 2204 2205 VOID DoSoundSpotMatch(short match, short sound_num, short sound_type); 2206 2207 #define ACTOR_GRAVITY 8 2208 2209 /////////////////////////////////////////////////////////////////////////////////////////// 2210 // 2211 // Externs 2212 // 2213 /////////////////////////////////////////////////////////////////////////////////////////// 2214 2215 extern BOOL ExitLevel; 2216 extern BOOL Warping; 2217 extern BYTE CommPlayers; 2218 extern BOOL CommEnabled; 2219 extern char CommPlayerName[]; 2220 extern short Level; 2221 extern short Episode; 2222 2223 extern int LastFrameTics; 2224 extern char ds[]; 2225 extern short Skill; 2226 extern int GodMode; 2227 2228 extern int x_min_bound, y_min_bound, x_max_bound, y_max_bound; 2229 2230 //extern unsigned char synctics, lastsynctics; 2231 extern BORDER_INFO BorderInfo; 2232 extern short snum; 2233 2234 extern int lockspeed,totalsynctics; 2235 2236 #define synctics 3 2237 #define ACTORMOVETICS (synctics<<1) 2238 #define TICSPERMOVEMENT synctics 2239 #define FAKETIMERHANDLER() if (totalclock >= ototalclock + synctics) faketimerhandler() 2240 2241 // subtract value from clipdist on getzrange calls 2242 #define GETZRANGE_CLIP_ADJ 8 2243 //#define GETZRANGE_CLIP_ADJ 0 2244 2245 // MULTIPLAYER 2246 // VARIABLES: (You should extern these in your game.c) 2247 /* 2248 extern short numplayers, myconnectindex; 2249 extern short connecthead, connectpoint2[MAXPLAYERS]; 2250 */ 2251 extern int *lastpacket2clock; 2252 extern char username[MAXPLAYERS][50]; 2253 2254 // save player info when moving to a new level 2255 extern USER puser[MAX_SW_PLAYERS_REG]; 2256 2257 /////////////////////////// 2258 // 2259 // TEXT PRINTING 2260 // 2261 /////////////////////////// 2262 2263 #define TEXT_TEST_LINE (200/2) 2264 #define TEXT_XCENTER(width) ((320 - width)/2) 2265 #define TEXT_YCENTER(h) ((200 - height)/2) 2266 #define TEXT_TEST_COL(width) TEXT_XCENTER(width) 2267 #define TEXT_TEST_TIME 2 2268 2269 void PutStringTimer(PLAYERp pp, short x, short y, const char *string, short seconds); 2270 2271 /////////////////////////// 2272 // 2273 // OLDER network additions 2274 // 2275 /////////////////////////// 2276 2277 /* 2278 int initmultiplayers(int, int, int); 2279 void uninitmultiplayers(void); 2280 2281 void sendlogon(void); 2282 void sendlogoff(void); 2283 */ 2284 2285 2286 /////////////////////////// 2287 // 2288 // RECENT network additions 2289 // 2290 /////////////////////////// 2291 2292 extern int ototalclock, save_totalclock, gotlastpacketclock,smoothratio; 2293 extern BOOL ready2send; 2294 2295 // local copy of variables updated by faketimerhandler 2296 extern int locselectedgun; 2297 2298 //FIFO queue to hold values while faketimerhandler is called from within the drawing routing 2299 extern int movefifoplc, movefifoend[]; 2300 2301 2302 extern BOOL MoveSkip4, MoveSkip2, MoveSkip8; 2303 2304 #define MASTER_SWITCHING 1 2305 2306 extern char option[]; 2307 extern int keys[]; 2308 2309 extern short screenpeek; 2310 2311 extern int dimensionmode, zoom; 2312 extern int vel,svel,angvel; 2313 2314 #define STAT_DAMAGE_LIST_SIZE 20 2315 extern SHORT StatDamageList[STAT_DAMAGE_LIST_SIZE]; 2316 2317 /////////////////////////////////////////////////////////////// 2318 // 2319 // Stuff for player palette flashes when hurt or getting items 2320 // 2321 /////////////////////////////////////////////////////////////// 2322 2323 #define COLOR_PAIN 128 // Light red range 2324 extern void SetFadeAmt( PLAYERp pp, short damage, unsigned char startcolor ); 2325 extern void DoPaletteFlash( PLAYERp pp ); 2326 extern unsigned char palette_data[256][3]; 2327 extern BOOL NightVision; 2328 #endif 2329 2330 int _PlayerSound(char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp); 2331 #define PlayerSound(num, x, y, z, flags, pp) _PlayerSound(__FILE__, __LINE__, (num), (x), (y), (z), (flags), (pp)) 2332 2333 #define MAXSO (MAXLONG) 2334 2335 /////////////////////////////////////////////////////////////// 2336 // 2337 // Stuff added by JonoF. These should get put into their own 2338 // headers and included by that which needs them. 2339 // 2340 /////////////////////////////////////////////////////////////// 2341 2342 int PickJumpMaxSpeed(short SpriteNum, short max_speed); // ripper.c 2343 int DoRipperRipHeart(short SpriteNum); // ripper.c 2344 int DoRipper2RipHeart(short SpriteNum); // ripper2.c 2345 int BunnyHatch2(short Weapon); // bunny.c 2346 int DoSkullBeginDeath(SHORT SpriteNum); // skull.c 2347 2348 void AnimateCacheCursor(void); // game.c 2349 void MapSetAll2D(BYTE fill); // game.c 2350 void TerminateGame(void ); // game.c 2351 void TerminateLevel(void ); // game.c 2352 void ResetKeys(void ); // game.c 2353 BOOL KeyPressed(void ); // game.c 2354 void drawoverheadmap(int cposx,int cposy,int czoom,short cang); // game.c 2355 void COVERsetbrightness(int bright, unsigned char *pal); // game.c 2356 void DrawMenuLevelScreen(void ); // game.c 2357 VOID DebugWriteString(char *string); // game.c 2358 VOID ManualPlayerInsert(PLAYERp pp); // game.c 2359 2360 VOID SetRedrawScreen(PLAYERp pp); // border.c 2361 void SetupAspectRatio(void ); // border.c 2362 VOID ClearStartMost(VOID); // border.c 2363 VOID SetCrosshair(VOID); // border.c 2364 2365 void initsynccrc(void); // sync.c 2366 void demosync_record(void ); // sync.c 2367 void demosync_test(int cnt); // sync.c 2368 void getsyncstat(void ); // sync.c 2369 void SyncStatMessage(void ); // sync.c 2370 2371 void drawscreen(PLAYERp pp); // draw.c 2372 void post_analyzesprites(void ); // draw.c 2373 int COVERsetgamemode(int mode, int xdim, int ydim, int bpp); // draw.c 2374 VOID ScreenCaptureKeys(VOID); // draw.c 2375 2376 int minigametext(int x,int y,char *t,char s,short dabits); // jplayer.c 2377 void computergetinput(int snum,SW_PACKET *syn); // jplayer.c 2378 2379 void DrawOverlapRoom(int tx,int ty,int tz,short tang,int thoriz,short tsectnum); // rooms.c 2380 void SetupMirrorTiles(void ); // rooms.c 2381 BOOL FAF_Sector(short sectnum); // rooms.c 2382 int GetZadjustment(short sectnum,short hitag); // rooms.c 2383 2384 void TermSetup(void); // swconfig.c 2385 2386 void InitSetup(void); // setup.c 2387 2388 void LoadKVXFromScript(char *filename); // scrip2.c 2389 void LoadPLockFromScript(char *filename); // scrip2.c 2390 void LoadCustomInfoFromScript(char *filename); // scrip2.c 2391 2392 void EveryCheatToggle(PLAYERp pp,char *cheat_string); // cheats.c 2393 2394 int PlayerInitChemBomb(PLAYERp pp); // jweapon.c 2395 int PlayerInitFlashBomb(PLAYERp pp); // jweapon.c 2396 int PlayerInitCaltrops(PLAYERp pp); // jweapon.c 2397 int InitPhosphorus(SHORT SpriteNum); // jweapon.c 2398 void SpawnFloorSplash(short SpriteNum); // jweapon.c 2399 2400 int SaveGame(short save_num); // save.c 2401 int LoadGame(short save_num); // save.c 2402 int LoadGameFullHeader(short save_num, char *descr, short *level, short *skill); // save,c 2403 void LoadGameDescr(short save_num, char *descr); // save.c 2404 2405 void SetRotatorActive(short SpriteNum); // rotator.c 2406 2407 BOOL VatorSwitch(short match, short setting); // vator.c 2408 void MoveSpritesWithSector(short sectnum,int z_amt,BOOL type); // vator.c 2409 void SetVatorActive(short SpriteNum); // vator.c 2410 2411 short DoSpikeMatch(PLAYERp pp,short match); // spike.c 2412 void SpikeAlign(short SpriteNum); // spike.c 2413 2414 short DoSectorObjectSetScale(short match); // morph.c 2415 short DoSOevent(short match,short state); // morph.c 2416 void SOBJ_AlignCeilingToPoint(SECTOR_OBJECTp sop,int x,int y,int z); // morph.c 2417 void SOBJ_AlignFloorToPoint(SECTOR_OBJECTp sop,int x,int y,int z); // morph.c 2418 void ScaleSectorObject(SECTOR_OBJECTp sop); // morph.c 2419 void MorphTornado(SECTOR_OBJECTp sop); // morph.c 2420 void MorphFloor(SECTOR_OBJECTp sop); // morph.c 2421 void ScaleRandomPoint(SECTOR_OBJECTp sop,short k,short ang,int x,int y,int *dx,int *dy); // morph.c 2422 2423 void CopySectorMatch(short match); // copysect.c 2424 2425 int DoWallMoveMatch(short match); // wallmove.c 2426 int DoWallMove(SPRITEp sp); // wallmove.c 2427 BOOL CanSeeWallMove(SPRITEp wp,short match); // wallmove.c 2428 2429 short DoSpikeOperate(PLAYERp pp,short sectnum); // spike.c 2430 void SetSpikeActive(short SpriteNum); // spike.c 2431 2432 #define NTAG_SEARCH_LO 1 2433 #define NTAG_SEARCH_HI 2 2434 #define NTAG_SEARCH_LO_HI 3 2435 2436 int COVERinsertsprite(short sectnum, short statnum); //returns (short)spritenum; 2437 2438 void NextScreenPeek(void); // game.c 2439