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