1 // Emacs style mode select -*- C++ -*- 2 //----------------------------------------------------------------------------- 3 // 4 // $Id: p_local.h 1565 2020-12-19 06:21:39Z wesleyjohnson $ 5 // 6 // Copyright (C) 1993-1996 by id Software, Inc. 7 // Portions Copyright (C) 1998-2000 by DooM Legacy Team. 8 // 9 // This program is free software; you can redistribute it and/or 10 // modify it under the terms of the GNU General Public License 11 // as published by the Free Software Foundation; either version 2 12 // of the License, or (at your option) any later version. 13 // 14 // This program is distributed in the hope that it will be useful, 15 // but WITHOUT ANY WARRANTY; without even the implied warranty of 16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 // GNU General Public License for more details. 18 // 19 // 20 // $Log: p_local.h,v $ 21 // Revision 1.24 2004/07/27 08:19:36 exl 22 // New fmod, fs functions, bugfix or 2, patrol nodes 23 // 24 // Revision 1.23 2003/06/11 00:28:50 ssntails 25 // Big Blockmap Support (128kb+ ?) 26 // 27 // Revision 1.22 2003/03/22 22:35:59 hurdler 28 // Revision 1.21 2002/09/27 16:40:09 tonyd 29 // First commit of acbot 30 // 31 // Revision 1.20 2001/08/06 23:57:09 stroggonmeth 32 // Removed portal code, improved 3D floors in hardware mode. 33 // 34 // Revision 1.19 2001/07/28 16:18:37 bpereira 35 // 36 // Revision 1.18 2001/07/16 22:35:41 bpereira 37 // - fixed crash of e3m8 in heretic 38 // - fixed crosshair not drawed bug 39 // 40 // Revision 1.17 2001/04/17 22:26:07 calumr 41 // Initial Mac add 42 // 43 // Revision 1.16 2001/03/21 18:24:38 stroggonmeth 44 // Misc changes and fixes. Code cleanup 45 // 46 // Revision 1.15 2001/02/10 12:27:14 bpereira 47 // 48 // Revision 1.14 2001/01/25 22:15:43 bpereira 49 // added heretic support 50 // 51 // Revision 1.13 2000/11/03 02:37:36 stroggonmeth 52 // Fix a few warnings when compiling. 53 // 54 // Revision 1.12 2000/11/02 19:49:35 bpereira 55 // 56 // Revision 1.11 2000/11/02 17:50:08 stroggonmeth 57 // Big 3Dfloors & FraggleScript commit!! 58 // 59 // Revision 1.10 2000/10/21 08:43:30 bpereira 60 // Revision 1.9 2000/08/31 14:30:55 bpereira 61 // Revision 1.8 2000/04/16 18:38:07 bpereira 62 // 63 // Revision 1.7 2000/04/13 23:47:47 stroggonmeth 64 // See logs 65 // 66 // Revision 1.6 2000/04/11 19:07:24 stroggonmeth 67 // Finished my logs, fixed a crashing bug. 68 // 69 // Revision 1.5 2000/04/08 17:29:24 stroggonmeth 70 // 71 // Revision 1.4 2000/04/06 20:40:22 hurdler 72 // Mostly remove warnings under windows 73 // 74 // Revision 1.3 2000/04/04 00:32:46 stroggonmeth 75 // Initial Boom compatability plus few misc changes all around. 76 // 77 // Revision 1.2 2000/02/27 00:42:10 hurdler 78 // Revision 1.1.1.1 2000/02/22 20:32:32 hurdler 79 // Initial import into CVS (v1.29 pr3) 80 // 81 // 82 // DESCRIPTION: 83 // Play functions, animation, global header. 84 // 85 //----------------------------------------------------------------------------- 86 87 88 #ifndef P_LOCAL_H 89 #define P_LOCAL_H 90 91 #include "doomdef.h" 92 // DOORDELAY_CONTROL 93 #include "doomtype.h" 94 // tic_t 95 #include "command.h" 96 // consvar_t 97 #include "d_player.h" 98 #include "m_fixed.h" 99 #include "m_bbox.h" 100 #include "p_mobj.h" 101 #include "r_defs.h" 102 #include "p_maputl.h" 103 104 105 #define FLOATSPEED (FRACUNIT*4) 106 107 // added by Boris : for dehacked patches, replaced #define by int 108 extern int MAXHEALTH; // 100 109 110 #define VIEWHEIGHT 41 111 #define VIEWHEIGHTS "41" 112 113 // default viewheight is changeable at console 114 extern consvar_t cv_viewheight; // p_mobj.c 115 116 // mapblocks are used to check movement 117 // against lines and things 118 #define MAPBLOCKUNITS 128 119 #define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT) 120 #define MAPBLOCKSHIFT (FRACBITS+7) 121 #define MAPBMASK (MAPBLOCKSIZE-1) 122 #define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS) 123 124 125 // player radius used only in am_map.c 126 #define PLAYERRADIUS (16*FRACUNIT) 127 128 // MAXRADIUS is for precalculated sector block boxes 129 // the spider demon is larger, 130 // but we do not have any moving sectors nearby 131 #define MAXRADIUS (32*FRACUNIT) 132 133 #define MAXMOVE (30*FRACUNIT/NEWTICRATERATIO) 134 135 //added:26-02-98: max Z move up or down without jumping 136 // above this, a heigth difference is considered as a 'dropoff' 137 #define MAXSTEPMOVE (24*FRACUNIT) 138 139 #define USERANGE (64*FRACUNIT) 140 #define MELEERANGE (64*FRACUNIT) 141 #define MISSILERANGE (32*64*FRACUNIT) 142 143 // follow a player exlusively for 3 seconds 144 #define BASETHRESHOLD 100 145 146 //#define AIMINGTOSLOPE(aiming) finetangent[(2048+(aiming>>ANGLETOFINESHIFT)) & FINEMASK] 147 #define AIMINGTOSLOPE(aiming) finesine[(aiming>>ANGLETOFINESHIFT) & FINEMASK] 148 149 //26-07-98: p_mobj.c 150 extern consvar_t cv_gravity; 151 152 #ifdef DOORDELAY_CONTROL 153 // [WDJ] 1/15/2009 support control of door and event delay. see p_doors.c 154 // init in r_main.c 155 extern int adj_ticks_per_sec; 156 extern consvar_t cv_doordelay; 157 #else 158 // standard ticks per second 159 #define adj_ticks_per_sec 35 160 #endif 161 162 // [WDJ] 2/7/2011 Voodoo doll controls and support 163 extern consvar_t cv_instadeath; 164 extern consvar_t cv_voodoo_mode; 165 typedef enum { 166 VM_vanilla, VM_multispawn, VM_target, VM_auto 167 } voodoo_mode_e; 168 extern voodoo_mode_e voodoo_mode; 169 extern player_t * spechit_player; // last player to trigger switch or linedef 170 171 172 // 173 // P_PSPR 174 // 175 void P_SetupPsprites (player_t* curplayer); 176 void P_MovePsprites (player_t* curplayer); 177 void P_DropWeapon (player_t* player); 178 179 180 // 181 // P_USER 182 // 183 typedef struct camera_s 184 { 185 player_t * chase; // player the camera chases, NULL when off 186 mobj_t* mo; // the camera object 187 angle_t aiming; 188 int fixedcolormap; 189 190 //SoM: Things used by FS cameras. 191 fixed_t viewheight; 192 angle_t startangle; 193 } camera_t; 194 195 extern camera_t camera; 196 197 extern consvar_t cv_cam_dist; 198 extern consvar_t cv_cam_height; 199 extern consvar_t cv_cam_speed; 200 201 extern fixed_t jumpgravity; // variable by fragglescipt 202 203 204 void P_ResetCamera (player_t* player); 205 void P_PlayerThink (player_t* player); 206 void P_SetPlayer_color( player_t * player, byte color ); 207 208 // client prediction 209 void CL_ResetSpiritPosition (mobj_t *mobj); 210 void P_MoveSpirit (player_t* p,ticcmd_t *cmd, int realtics); 211 212 // 213 // P_MOBJ 214 // 215 #define ONFLOORZ FIXED_MIN 216 #define ONCEILINGZ FIXED_MAX 217 218 // Time interval for item respawning. 219 // WARING MUST be a power of 2 220 #define ITEMQUESIZE 128 221 222 extern mapthing_t *itemrespawnque[ITEMQUESIZE]; 223 extern tic_t itemrespawntime[ITEMQUESIZE]; 224 extern int iquehead; 225 extern int iquetail; 226 227 228 void P_RespawnSpecials (void); 229 void P_RespawnWeapons(void); 230 231 mobj_t* P_SpawnMobj ( fixed_t x, fixed_t y, fixed_t z, mobjtype_t type ); 232 233 // Morph control flags 234 typedef enum { 235 MM_testsize = 0x01, 236 MM_telefog = 0x02 237 } morphmobj_e; 238 // Change the type and info, but keep the location and player. 239 boolean P_MorphMobj( mobj_t * mo, mobjtype_t type, int mmflags, int keepflags ); 240 241 void P_RemoveMobj (mobj_t* th); 242 boolean P_SetMobjState (mobj_t* mobj, statenum_t state); 243 void P_MobjThinker (mobj_t* mobj); 244 245 //spawn splash at surface of water in sector where the mobj resides 246 void P_SpawnSplash (mobj_t* mo, fixed_t z); 247 //Fab: when fried in in lava/slime, spawn some smoke 248 void P_SpawnSmoke (fixed_t x, fixed_t y, fixed_t z); 249 250 void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z); 251 void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage); 252 void P_SpawnBloodSplats (fixed_t x, fixed_t y, fixed_t z, int damage, fixed_t momx, fixed_t momy); 253 mobj_t *P_SpawnMissile (mobj_t* source, mobj_t* dest, mobjtype_t type); 254 255 mobj_t *P_SPMAngle ( mobj_t* source, mobjtype_t type, angle_t angle ); 256 #define P_SpawnPlayerMissile(s,t) P_SPMAngle(s,t,s->angle) 257 258 // Bots 259 extern consvar_t cv_bots; 260 extern consvar_t cv_bot_skill; 261 extern consvar_t cv_bot_speed; 262 extern consvar_t cv_bot_skin; 263 extern consvar_t cv_bot_respawn_time; 264 extern consvar_t cv_bot_random; 265 extern consvar_t cv_bot_randseed; 266 extern consvar_t cv_bot_gen; 267 268 // 269 // P_ENEMY 270 // 271 extern consvar_t cv_monbehavior; 272 extern consvar_t cv_monsterfriction; 273 extern consvar_t cv_doorstuck; 274 extern consvar_t cv_solidcorpse; 275 extern consvar_t cv_monstergravity; 276 extern consvar_t cv_monster_remember; 277 278 extern consvar_t cv_mbf_dropoff; 279 extern consvar_t cv_mbf_falloff; 280 extern consvar_t cv_mbf_pursuit; 281 extern consvar_t cv_mbf_staylift; 282 extern consvar_t cv_mbf_monster_avoid_hazard; 283 extern consvar_t cv_mbf_monster_backing; 284 extern consvar_t cv_mbf_help_friend; 285 extern consvar_t cv_mbf_distfriend; 286 extern consvar_t cv_mbf_monkeys; 287 #ifdef DOGS 288 extern consvar_t cv_mbf_dogs; 289 extern consvar_t cv_mbf_dog_jumping; 290 #endif 291 extern uint16_t helper_MT; // Substitute helper thing (like DOG). 292 293 // when pushing a line 294 //#define MAXSPECIALCROSS 16 295 296 extern int *spechit; //SoM: 3/15/2000: Limit removal 297 extern int numspechit; 298 299 void P_NoiseAlert (mobj_t* target, mobj_t* emmiter); 300 boolean P_IsOnLift( const mobj_t *actor ); 301 int P_IsUnderDamage(mobj_t *actor); 302 303 void P_UnsetThingPosition (mobj_t* thing); 304 void P_SetThingPosition (mobj_t* thing); 305 306 // init braintagets position 307 void P_Init_BrainTarget(); 308 309 // 310 // P_MAP 311 // 312 313 // TryMove, thing map global vars 314 extern fixed_t tm_bbox[4]; // box around the thing 315 extern mobj_t* tm_thing; // the thing itself 316 extern uint32_t tm_flags; // thing flags of tm_thing 317 extern fixed_t tm_x, tm_y; // thing map position 318 319 // TryMove, thing map response global vars 320 // If "floatok" true, move would be ok 321 // if within "tmfloorz - tmceilingz". 322 extern byte tmr_floatok; // floating thing ok to move 323 extern byte tmr_felldown; // MBF, went off deep dropoff 324 extern fixed_t tmr_floorz; // floor and ceiling of new position 325 extern fixed_t tmr_ceilingz; 326 extern fixed_t tmr_sectorceilingz; //added:28-02-98: p_spawnmobj 327 extern mobj_t* tmr_floorthing; // standing on another thing 328 extern line_t* tmr_ceilingline; // line that lowers ceiling, for missile sky test 329 extern line_t* tmr_blockingline; // stopping line that is solid 330 extern line_t* tmr_dropoffline; // line that is dropoff edge 331 extern fixed_t tmr_dropoffz; // the lowest point contacted (monster check) 332 333 extern msecnode_t* sector_list; 334 335 // P_CheckPosition, P_TryMove, P_CheckCrossLine 336 // use tm_ global vars, and return tmr_ global vars 337 boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y); 338 boolean P_TryMove (mobj_t* thing, fixed_t x, fixed_t y, byte allowdropoff); 339 boolean P_CheckCrossLine (mobj_t* thing, fixed_t x, fixed_t y); 340 341 boolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y, byte stomp); 342 void P_SlideMove (mobj_t* mo); 343 344 boolean P_CheckSight (mobj_t* t1, mobj_t* t2); 345 boolean P_CheckSight2 (mobj_t* t1, mobj_t* t2, fixed_t x, fixed_t y, fixed_t z); //added by AC for predicting 346 void P_UseLines (player_t* player); 347 348 boolean P_CheckSector(sector_t *sector, boolean crunch); 349 boolean P_ChangeSector (sector_t* sector, boolean crunch); 350 351 void P_DelSeclist(msecnode_t *); 352 void P_Create_SecNodeList(mobj_t*,fixed_t,fixed_t); 353 void P_Init_Secnode( void ); 354 355 extern fixed_t got_friction; 356 extern int got_movefactor; // return values of P_GetFriction and P_GetMoveFactor 357 fixed_t P_GetFriction( const mobj_t * mo ); 358 int P_GetMoveFactor(mobj_t* mo); 359 360 // Line Attack return global vars lar_* 361 extern mobj_t* lar_linetarget; // who got hit (or NULL) 362 extern fixed_t la_attackrange; // max range of weapon 363 364 fixed_t P_AimLineAttack ( mobj_t* t1, angle_t angle, fixed_t distance, 365 byte mbf_friend_protection ); 366 367 void P_LineAttack ( mobj_t* t1, angle_t angle, fixed_t distance, 368 fixed_t slope, int damage ); 369 370 void P_RadiusAttack ( mobj_t* spot, mobj_t* source, int damage ); 371 372 // MBF 373 void P_ApplyTorque(mobj_t *mo); 374 375 376 // 377 // P_SETUP 378 // 379 extern byte* rejectmatrix; // for fast sight rejection 380 // Read wad blockmap using int16_t wadblockmaplump[]. 381 // Expand from 16bit wad to internal 32bit blockmap. 382 extern uint32_t* blockmaphead; // offsets in blockmap are from here 383 extern uint32_t* blockmapindex; // Big blockmap, SSNTails 384 extern unsigned int bmapwidth; 385 extern unsigned int bmapheight; // in mapblocks 386 extern fixed_t bmaporgx; 387 extern fixed_t bmaporgy; // origin of block map 388 extern mobj_t** blocklinks; // for thing chains 389 390 391 // 392 // P_INTER 393 // 394 extern int maxammo[NUMAMMO]; 395 extern int clipammo[NUMAMMO]; 396 397 void P_TouchSpecialThing ( mobj_t* special, mobj_t* toucher ); 398 399 boolean P_DamageMobj ( mobj_t* target, mobj_t* inflictor, 400 mobj_t* source, int damage ); 401 402 // 403 // P_SIGHT 404 // 405 406 // slopes to top and bottom of target 407 extern fixed_t see_topslope; 408 extern fixed_t see_bottomslope; 409 410 411 // 412 // P_SPEC 413 // 414 #include "p_spec.h" 415 416 417 // Secondary features. 418 extern byte EN_monster_friction; 419 extern byte EN_variable_friction; 420 #ifdef FRICTIONTHINKER 421 extern byte EN_boom_friction_thinker; 422 #endif 423 extern byte EN_skull_bounce_fix; // PrBoom 2001 !comp[comp_soul] 424 extern byte EN_skull_bounce_floor; 425 extern byte EN_catch_respawn_0; 426 427 // Boom 428 extern byte EN_pushers; 429 extern byte EN_boom_physics; 430 extern byte EN_blazing_double_sound; 431 extern byte EN_vile_revive_bug; 432 extern byte EN_sleeping_sarg_bug; 433 extern byte EN_doorlight; 434 extern byte EN_skull_limit; 435 extern byte EN_old_pain_spawn; 436 extern byte EN_invul_god; 437 extern byte EN_boom_floor; 438 extern byte EN_doom_movestep_bug; 439 440 // MBF 441 extern fixed_t EV_mbf_distfriend; 442 extern byte EN_mbf_speed; 443 extern byte EN_mbf_telefrag; 444 445 // Heretic, Hexen 446 extern byte EN_inventory; // Heretic, Hexen 447 448 // Use Legacy N_Random, instead of some P_Random. 449 extern byte EN_nrandom; 450 451 452 // Infight values are arranged for quick testing. 453 // Any infighting 454 #define MONSTER_INFIGHTING ((byte)(monster_infight - INFT_infight) < (byte)(INFT_coop - INFT_infight)) 455 // Missile infighting 456 // if( monster_infight == (INFT_infight|INFT_full) ) 457 // Other 458 // if( monster_infight == INFT_coop ) 459 // Cannot change due to being saved in demos. 460 typedef enum { 461 // Boom values 462 INFT_none, // Boom demo value, Doom default of no infight. 463 INFT_infight, // Boom demo value, Monster to monster fighting. 464 // Enhanced values 465 INFT_full_infight = INFT_infight+4, // infight with missiles 466 INFT_coop = 16, // Legacy enhancement, and ZDoom option 467 INFT_force = 0x80, // transient flag 468 INFT_infight_off = INFT_none & INFT_force, // DEH non-null off (not important in demos) 469 } infight_e; 470 // Values from infight_e and from Boom demo. 471 extern byte monster_infight; //DarkWolf95:November 21, 2003: Monsters Infight! 472 extern byte monster_infight_deh; // DEH input. 473 474 typedef enum { 475 FR_orig, FR_boom, FR_mbf, FR_prboom, FR_legacy, FR_heretic, FR_hexen 476 } friction_model_e; 477 extern byte friction_model; // friction_model_e 478 479 extern byte boom_detect; 480 extern byte legacy_detect; 481 482 void DemoAdapt_p_user( void ); 483 void DemoAdapt_p_mobj( void ); 484 void DemoAdapt_p_enemy( void ); 485 void DemoAdapt_p_floor( void ); 486 void DemoAdapt_p_map( void ); 487 void DemoAdapt_bots( void ); 488 489 // Alter for Doom or Heretic. 490 extern int ceilmovesound; 491 extern int doorclosesound; 492 493 // Heretic specific 494 extern int H_ArtifactFlash; 495 496 #define TELEFOGHEIGHT (32*FRACUNIT) 497 extern mobjtype_t PuffType; 498 #define FOOTCLIPSIZE (10*FRACUNIT) 499 #define HITDICE(a) ((1+(P_Random()&7))*a) 500 501 #define MAXCHICKENHEALTH 30 502 503 // Now used by Heretic and Doom powers (ironfeet). 504 // A power counts down to 0. Below BLINKTHRESHOLD, there is a warning blink. 505 #define BLINKTHRESHOLD (4*32) 506 #define WPNLEV2TICS (40*TICRATE) 507 #define FLIGHTTICS (60*TICRATE) 508 509 #define CHICKENTICS (40*TICRATE) 510 #define FLOATRANDZ (INT_MAX - 1) 511 512 void P_RepositionMace(mobj_t *mo); 513 void P_ActivateBeak(player_t *player); 514 void P_PlayerUseArtifact(player_t *player, artitype_t arti); 515 void P_DSparilTeleport(mobj_t *actor); 516 void P_Init_Monsters(void); 517 boolean PH_LookForMonsters(mobj_t *actor); // Heretic 518 int P_GetThingFloorType(mobj_t *thing); 519 mobj_t *P_CheckOnmobj(mobj_t *thing); 520 void P_AddMaceSpot(mapthing_t *mthing); 521 boolean P_SightPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); 522 void P_HerePlayerInSpecialSector(player_t *player); 523 void P_UpdateBeak(player_t *player, pspdef_t *psp); 524 boolean P_TestMobjLocation(mobj_t *mobj); 525 void P_PostChickenWeapon(player_t *player, weapontype_t weapon); 526 void P_SetPsprite ( player_t* player, 527 int position, 528 statenum_t stnum ); 529 boolean P_UseArtifact(player_t *player, artitype_t arti); 530 boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, angle_t angle); 531 boolean P_SeekerMissile(mobj_t *actor, angle_t thresh, angle_t turnMax); 532 mobj_t *P_SpawnMissileAngle(mobj_t *source, mobjtype_t type, 533 angle_t angle, fixed_t momz); 534 boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state); 535 boolean P_CheckMissileSpawn (mobj_t* th); 536 void P_ThrustMobj(mobj_t *mo, angle_t angle, fixed_t move); 537 void P_Thrust(player_t *player, angle_t angle, fixed_t move); 538 void P_ExplodeMissile (mobj_t* mo); 539 boolean P_GiveArtifact(player_t *player, artitype_t arti, mobj_t *mo); 540 boolean P_ChickenMorphPlayer(player_t *player); 541 void P_Massacre(void); 542 void P_AddBossSpot(fixed_t x, fixed_t y, angle_t angle); 543 544 statenum_t deh_frame_to_state( int deh_frame ); 545 546 extern spr_light_t sprite_light[NUMLIGHTS]; 547 extern byte sprite_light_ind[NUMSPRITES]; 548 void Setup_sprite_light( byte mons_ball_light ); 549 550 //extern consvar_t cv_dynamiclight; 551 //extern consvar_t cv_staticlight; 552 extern consvar_t cv_corona; 553 extern consvar_t cv_coronasize; 554 extern consvar_t cv_corona_draw_mode; 555 extern consvar_t cv_monball_light; 556 557 void Deathmatch_OnChange( void ); 558 559 // Sky 560 extern consvar_t cv_sky_gen; 561 562 #endif // P_LOCAL_H 563