1 // 2 // Copyright(C) 1993-1996 Id Software, Inc. 3 // Copyright(C) 1993-2008 Raven Software 4 // Copyright(C) 2005-2014 Simon Howard 5 // 6 // This program is free software; you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License 8 // as published by the Free Software Foundation; either version 2 9 // of the License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 17 18 #ifndef __P_LOCAL__ 19 #define __P_LOCAL__ 20 21 #ifndef __R_LOCAL__ 22 #include "r_local.h" 23 #endif 24 25 #define STARTREDPALS 1 26 #define STARTBONUSPALS 9 27 #define STARTPOISONPALS 13 28 #define STARTICEPAL 21 29 #define STARTHOLYPAL 22 30 #define STARTSCOURGEPAL 25 31 #define NUMREDPALS 8 32 #define NUMBONUSPALS 4 33 #define NUMPOISONPALS 8 34 35 #define TOCENTER -8 36 #define FLOATSPEED (FRACUNIT*4) 37 38 #define MAXHEALTH 100 39 #define MAXMORPHHEALTH 30 40 #define VIEWHEIGHT (48*FRACUNIT) 41 42 // mapblocks are used to check movement against lines and things 43 #define MAPBLOCKUNITS 128 44 #define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT) 45 #define MAPBLOCKSHIFT (FRACBITS+7) 46 #define MAPBMASK (MAPBLOCKSIZE-1) 47 #define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS) 48 49 // player radius for movement checking 50 #define PLAYERRADIUS 16*FRACUNIT 51 52 // MAXRADIUS is for precalculated sector block boxes 53 // the spider demon is larger, but we don't have any moving sectors 54 // nearby 55 #define MAXRADIUS 32*FRACUNIT 56 57 #define GRAVITY FRACUNIT 58 #define MAXMOVE (30*FRACUNIT) 59 60 #define USERANGE (64*FRACUNIT) 61 #define MELEERANGE (64*FRACUNIT) 62 #define MISSILERANGE (32*64*FRACUNIT) 63 64 typedef enum 65 { 66 DI_EAST, 67 DI_NORTHEAST, 68 DI_NORTH, 69 DI_NORTHWEST, 70 DI_WEST, 71 DI_SOUTHWEST, 72 DI_SOUTH, 73 DI_SOUTHEAST, 74 DI_NODIR, 75 NUMDIRS 76 } dirtype_t; 77 78 #define BASETHRESHOLD 100 // follow a player exlusively for 3 seconds 79 80 // ***** P_TICK ***** 81 82 extern thinker_t thinkercap; // both the head and tail of the thinker list 83 extern int TimerGame; // tic countdown for deathmatch 84 85 void P_InitThinkers(void); 86 void P_AddThinker(thinker_t * thinker); 87 void P_RemoveThinker(thinker_t * thinker); 88 89 // ***** P_PSPR ***** 90 91 #define USE_MANA1 1 92 #define USE_MANA2 1 93 94 void P_SetPsprite(player_t * player, int position, statenum_t stnum); 95 void P_SetPspriteNF(player_t * player, int position, statenum_t stnum); 96 void P_SetupPsprites(player_t * curplayer); 97 void P_MovePsprites(player_t * curplayer); 98 void P_DropWeapon(player_t * player); 99 void P_ActivateMorphWeapon(player_t * player); 100 void P_PostMorphWeapon(player_t * player, weapontype_t weapon); 101 102 // ***** P_USER ***** 103 104 extern int PStateNormal[NUMCLASSES]; 105 extern int PStateRun[NUMCLASSES]; 106 extern int PStateAttack[NUMCLASSES]; 107 extern int PStateAttackEnd[NUMCLASSES]; 108 109 void P_PlayerThink(player_t * player); 110 void P_Thrust(player_t * player, angle_t angle, fixed_t move); 111 void P_PlayerRemoveArtifact(player_t * player, int slot); 112 void P_PlayerUseArtifact(player_t * player, artitype_t arti); 113 boolean P_UseArtifact(player_t * player, artitype_t arti); 114 int P_GetPlayerNum(player_t * player); 115 void P_TeleportOther(mobj_t * victim); 116 void ResetBlasted(mobj_t * mo); 117 118 // ***** P_MOBJ ***** 119 120 // Any floor type >= FLOOR_LIQUID will floorclip sprites 121 enum 122 { 123 FLOOR_SOLID, 124 FLOOR_ICE, 125 FLOOR_LIQUID, 126 FLOOR_WATER, 127 FLOOR_LAVA, 128 FLOOR_SLUDGE 129 }; 130 131 #define ONFLOORZ INT_MIN 132 #define ONCEILINGZ INT_MAX 133 #define FLOATRANDZ (INT_MAX-1) 134 #define FROMCEILINGZ128 (INT_MAX-2) 135 136 extern mobjtype_t PuffType; 137 extern mobj_t *MissileMobj; 138 139 mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); 140 void P_RemoveMobj(mobj_t * th); 141 boolean P_SetMobjState(mobj_t * mobj, statenum_t state); 142 boolean P_SetMobjStateNF(mobj_t * mobj, statenum_t state); 143 void P_ThrustMobj(mobj_t * mo, angle_t angle, fixed_t move); 144 int P_FaceMobj(mobj_t * source, mobj_t * target, angle_t * delta); 145 boolean P_SeekerMissile(mobj_t * actor, angle_t thresh, angle_t turnMax); 146 void P_MobjThinker(mobj_t * mobj); 147 void P_BlasterMobjThinker(mobj_t * mobj); 148 void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z); 149 void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, int damage); 150 void P_BloodSplatter(fixed_t x, fixed_t y, fixed_t z, mobj_t * originator); 151 void P_BloodSplatter2(fixed_t x, fixed_t y, fixed_t z, mobj_t * originator); 152 void P_RipperBlood(mobj_t * mo); 153 int P_GetThingFloorType(mobj_t * thing); 154 int P_HitFloor(mobj_t * thing); 155 boolean P_CheckMissileSpawn(mobj_t * missile); 156 mobj_t *P_SpawnMissile(mobj_t * source, mobj_t * dest, mobjtype_t type); 157 mobj_t *P_SpawnMissileXYZ(fixed_t x, fixed_t y, fixed_t z, 158 mobj_t * source, mobj_t * dest, mobjtype_t type); 159 mobj_t *P_SpawnMissileAngle(mobj_t * source, mobjtype_t type, 160 angle_t angle, fixed_t momz); 161 mobj_t *P_SpawnMissileAngleSpeed(mobj_t * source, mobjtype_t type, 162 angle_t angle, fixed_t momz, fixed_t speed); 163 mobj_t *P_SpawnPlayerMissile(mobj_t * source, mobjtype_t type); 164 mobj_t *P_SPMAngle(mobj_t * source, mobjtype_t type, angle_t angle); 165 mobj_t *P_SPMAngleXYZ(mobj_t * source, fixed_t x, fixed_t y, 166 fixed_t z, mobjtype_t type, angle_t angle); 167 void P_CreateTIDList(void); 168 void P_RemoveMobjFromTIDList(mobj_t * mobj); 169 void P_InsertMobjIntoTIDList(mobj_t * mobj, int tid); 170 mobj_t *P_FindMobjFromTID(int tid, int *searchPosition); 171 mobj_t *P_SpawnKoraxMissile(fixed_t x, fixed_t y, fixed_t z, 172 mobj_t * source, mobj_t * dest, mobjtype_t type); 173 174 // ***** P_ENEMY ***** 175 176 void P_NoiseAlert(mobj_t * target, mobj_t * emmiter); 177 int P_Massacre(void); 178 boolean A_RaiseMobj(mobj_t * actor); 179 boolean A_SinkMobj(mobj_t * actor); 180 void A_NoBlocking(mobj_t * actor); 181 boolean P_LookForMonsters(mobj_t * actor); 182 void P_InitCreatureCorpseQueue(boolean corpseScan); 183 void A_DeQueueCorpse(mobj_t * actor); 184 185 186 // ***** P_MAPUTL ***** 187 188 typedef struct 189 { 190 fixed_t x, y, dx, dy; 191 } divline_t; 192 193 typedef struct 194 { 195 fixed_t frac; // along trace line 196 boolean isaline; 197 union 198 { 199 mobj_t *thing; 200 line_t *line; 201 } d; 202 } intercept_t; 203 204 #define MAXINTERCEPTS 128 205 extern intercept_t intercepts[MAXINTERCEPTS], *intercept_p; 206 typedef boolean(*traverser_t) (intercept_t * in); 207 208 209 fixed_t P_AproxDistance(fixed_t dx, fixed_t dy); 210 int P_PointOnLineSide(fixed_t x, fixed_t y, line_t * line); 211 int P_PointOnDivlineSide(fixed_t x, fixed_t y, divline_t * line); 212 void P_MakeDivline(line_t * li, divline_t * dl); 213 fixed_t P_InterceptVector(divline_t * v2, divline_t * v1); 214 int P_BoxOnLineSide(fixed_t * tmbox, line_t * ld); 215 216 extern fixed_t opentop, openbottom, openrange; 217 extern fixed_t lowfloor; 218 void P_LineOpening(line_t * linedef); 219 220 boolean P_BlockLinesIterator(int x, int y, boolean(*func) (line_t *)); 221 boolean P_BlockThingsIterator(int x, int y, boolean(*func) (mobj_t *)); 222 223 #define PT_ADDLINES 1 224 #define PT_ADDTHINGS 2 225 #define PT_EARLYOUT 4 226 227 extern divline_t trace; 228 boolean P_PathTraverse(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, 229 int flags, boolean(*trav) (intercept_t *)); 230 231 void P_UnsetThingPosition(mobj_t * thing); 232 void P_SetThingPosition(mobj_t * thing); 233 mobj_t *P_RoughMonsterSearch(mobj_t * mo, int distance); 234 235 // ***** P_MAP ***** 236 237 extern boolean floatok; // if true, move would be ok if 238 extern fixed_t tmfloorz, tmceilingz; // within tmfloorz - tmceilingz 239 extern int tmfloorpic; 240 extern mobj_t *BlockingMobj; 241 242 extern line_t *ceilingline; 243 boolean P_TestMobjLocation(mobj_t * mobj); 244 boolean P_CheckPosition(mobj_t * thing, fixed_t x, fixed_t y); 245 mobj_t *P_CheckOnmobj(mobj_t * thing); 246 void P_FakeZMovement(mobj_t * mo); 247 boolean P_TryMove(mobj_t * thing, fixed_t x, fixed_t y); 248 boolean P_TeleportMove(mobj_t * thing, fixed_t x, fixed_t y); 249 void P_SlideMove(mobj_t * mo); 250 void P_BounceWall(mobj_t * mo); 251 boolean P_CheckSight(mobj_t * t1, mobj_t * t2); 252 void P_UseLines(player_t * player); 253 boolean P_UsePuzzleItem(player_t * player, int itemType); 254 void PIT_ThrustSpike(mobj_t * actor); 255 256 boolean P_ChangeSector(sector_t * sector, int crunch); 257 258 extern mobj_t *PuffSpawned; // true if a puff was spawned 259 extern mobj_t *linetarget; // who got hit (or NULL) 260 fixed_t P_AimLineAttack(mobj_t * t1, angle_t angle, fixed_t distance); 261 262 void P_LineAttack(mobj_t * t1, angle_t angle, fixed_t distance, fixed_t slope, 263 int damage); 264 265 void P_RadiusAttack(mobj_t * spot, mobj_t * source, int damage, int distance, 266 boolean damageSource); 267 268 // ***** P_SETUP ***** 269 270 extern byte *rejectmatrix; // for fast sight rejection 271 extern short *blockmaplump; // offsets in blockmap are from here 272 extern short *blockmap; 273 extern int bmapwidth, bmapheight; // in mapblocks 274 extern fixed_t bmaporgx, bmaporgy; // origin of block map 275 extern mobj_t **blocklinks; // for thing chains 276 277 // ***** P_INTER ***** 278 279 extern int clipmana[NUMMANA]; 280 281 void P_SetMessage(player_t * player, char *message, boolean ultmsg); 282 void P_SetYellowMessage(player_t * player, char *message, boolean ultmsg); 283 void P_ClearMessage(player_t * player); 284 void P_TouchSpecialThing(mobj_t * special, mobj_t * toucher); 285 void P_DamageMobj(mobj_t * target, mobj_t * inflictor, mobj_t * source, 286 int damage); 287 void P_FallingDamage(player_t * player); 288 void P_PoisonPlayer(player_t * player, mobj_t * poisoner, int poison); 289 void P_PoisonDamage(player_t * player, mobj_t * source, int damage, 290 boolean playPainSound); 291 boolean P_GiveMana(player_t * player, manatype_t mana, int count); 292 boolean P_GiveArtifact(player_t * player, artitype_t arti, mobj_t * mo); 293 boolean P_GiveArmor(player_t * player, armortype_t armortype, int amount); 294 boolean P_GiveBody(player_t * player, int num); 295 boolean P_GivePower(player_t * player, powertype_t power); 296 boolean P_MorphPlayer(player_t * player); 297 298 // ***** AM_MAP ***** 299 300 boolean AM_Responder(event_t * ev); 301 void AM_Ticker(void); 302 void AM_Drawer(void); 303 304 // ***** A_ACTION ***** 305 boolean A_LocalQuake(byte * args, mobj_t * victim); 306 void P_SpawnDirt(mobj_t * actor, fixed_t radius); 307 void A_BridgeRemove(mobj_t * actor); 308 309 // ***** SB_BAR ***** 310 311 extern int SB_state; 312 extern int ArtifactFlash; 313 void SB_PaletteFlash(boolean forceChange); 314 315 // ===== PO_MAN ===== 316 317 typedef enum 318 { 319 PODOOR_NONE, 320 PODOOR_SLIDE, 321 PODOOR_SWING, 322 } podoortype_t; 323 324 typedef struct 325 { 326 thinker_t thinker; 327 int polyobj; 328 int speed; 329 unsigned int dist; 330 int angle; 331 fixed_t xSpeed; // for sliding walls 332 fixed_t ySpeed; 333 } polyevent_t; 334 335 typedef struct 336 { 337 thinker_t thinker; 338 int polyobj; 339 int speed; 340 int dist; 341 int totalDist; 342 int direction; 343 fixed_t xSpeed, ySpeed; 344 int tics; 345 int waitTics; 346 podoortype_t type; 347 boolean close; 348 } polydoor_t; 349 350 enum 351 { 352 PO_ANCHOR_TYPE = 3000, 353 PO_SPAWN_TYPE, 354 PO_SPAWNCRUSH_TYPE 355 }; 356 357 #define PO_LINE_START 1 // polyobj line start special 358 #define PO_LINE_EXPLICIT 5 359 360 extern polyobj_t *polyobjs; // list of all poly-objects on the level 361 extern int po_NumPolyobjs; 362 363 void T_PolyDoor(polydoor_t * pd); 364 void T_RotatePoly(polyevent_t * pe); 365 boolean EV_RotatePoly(line_t * line, byte * args, int direction, boolean 366 overRide); 367 void T_MovePoly(polyevent_t * pe); 368 boolean EV_MovePoly(line_t * line, byte * args, boolean timesEight, boolean 369 overRide); 370 boolean EV_OpenPolyDoor(line_t * line, byte * args, podoortype_t type); 371 372 boolean PO_MovePolyobj(int num, int x, int y); 373 boolean PO_RotatePolyobj(int num, angle_t angle); 374 void PO_Init(int lump); 375 boolean PO_Busy(int polyobj); 376 377 #include "p_spec.h" 378 379 #endif // __P_LOCAL__ 380