Odamex
Setting the Standard in Multiplayer Doom
common/p_local.h
Go to the documentation of this file.
00001 // Emacs style mode select   -*- C++ -*-
00002 //-----------------------------------------------------------------------------
00003 //
00004 // $Id: p_local.h 2117 2011-02-22 20:33:04Z mike $
00005 //
00006 // Copyright (C) 1993-1996 by id Software, Inc.
00007 // Copyright (C) 2006-2010 by The Odamex Team.
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // DESCRIPTION:
00020 //      Play functions, animation, global header.
00021 //
00022 //-----------------------------------------------------------------------------
00023 
00024 
00025 #ifndef __P_LOCAL__
00026 #define __P_LOCAL__
00027 
00028 #ifndef __R_LOCAL__
00029 #include "r_local.h"
00030 #endif
00031 
00032 #define FLOATSPEED              (FRACUNIT*4)
00033 
00034 #define MAXHEALTH               100
00035 #define VIEWHEIGHT              (41*FRACUNIT)
00036 
00037 // mapblocks are used to check movement
00038 // against lines and things
00039 #define MAPBLOCKUNITS   128
00040 #define MAPBLOCKSIZE    (MAPBLOCKUNITS*FRACUNIT)
00041 #define MAPBLOCKSHIFT   (FRACBITS+7)
00042 #define MAPBMASK                (MAPBLOCKSIZE-1)
00043 #define MAPBTOFRAC              (MAPBLOCKSHIFT-FRACBITS)
00044 
00045 
00046 // player radius for movement checking
00047 #define PLAYERRADIUS    16*FRACUNIT
00048 
00049 // MAXRADIUS is for precalculated sector block boxes
00050 // the spider demon is larger,
00051 // but we do not have any moving sectors nearby
00052 #define MAXRADIUS               32*FRACUNIT
00053 
00054 //#define GRAVITY               FRACUNIT
00055 #define MAXMOVE                 (30*FRACUNIT)
00056 
00057 #define STOPSPEED                                               0x1000
00058 #define FRICTION                                                0xe800
00059 
00060 #define USERANGE                (64*FRACUNIT)
00061 #define MELEERANGE              (64*FRACUNIT)
00062 #define MISSILERANGE    (32*64*FRACUNIT)
00063 
00064 #define WATER_SINK_FACTOR               3
00065 #define WATER_SINK_SMALL_FACTOR 4
00066 #define WATER_SINK_SPEED                (FRACUNIT/2)
00067 #define WATER_JUMP_SPEED                (FRACUNIT*7/2)
00068 
00069 // follow a player exlusively for 3 seconds
00070 #define BASETHRESHOLD   100
00071 
00072 
00073 
00074 //
00075 // P_PSPR
00076 //
00077 void P_SetupPsprites (player_t* curplayer);
00078 void P_MovePsprites (player_t* curplayer);
00079 void P_DropWeapon (player_t* player);
00080 
00081 
00082 //
00083 // P_USER
00084 //
00085 void    P_FallingDamage (AActor *ent);
00086 void    P_PlayerThink (player_t *player);
00087 
00088 //
00089 // P_MOBJ
00090 //
00091 #define ONFLOORZ                MININT
00092 #define ONCEILINGZ              MAXINT
00093 
00094 // Time interval for item respawning.
00095 #define ITEMQUESIZE     128
00096 
00097 extern mapthing2_t              itemrespawnque[ITEMQUESIZE];
00098 extern int                              itemrespawntime[ITEMQUESIZE];
00099 extern int                              iquehead;
00100 extern int                              iquetail;
00101 
00102 void    P_ThrustMobj (AActor *mo, angle_t angle, fixed_t move);
00103 void    P_RespawnSpecials (void);
00104 
00105 bool    P_SetMobjState (AActor* mobj, statenum_t state);
00106 
00107 void    P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int updown);
00108 void    P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage);
00109 AActor* P_SpawnMissile (AActor* source, AActor* dest, mobjtype_t type);
00110 void    P_SpawnPlayerMissile (AActor* source, mobjtype_t type);
00111 
00112 //
00113 // [RH] P_THINGS
00114 //
00115 extern int SpawnableThings[];
00116 extern const int NumSpawnableThings;
00117 
00118 BOOL    P_Thing_Spawn (int tid, int type, angle_t angle, BOOL fog);
00119 BOOL    P_Thing_Projectile (int tid, int type, angle_t angle,
00120                                                         fixed_t speed, fixed_t vspeed, BOOL gravity);
00121 BOOL    P_ActivateMobj (AActor *mobj, AActor *activator);
00122 BOOL    P_DeactivateMobj (AActor *mobj);
00123 
00124 //
00125 // P_ENEMY
00126 //
00127 void    P_NoiseAlert (AActor* target, AActor* emmiter);
00128 void    P_SpawnBrainTargets(void);      // killough 3/26/98: spawn icon landings
00129 
00130 extern struct brain_s {                         // killough 3/26/98: global state of boss brain
00131         int easy, targeton;
00132 } brain;
00133 
00134 
00135 //
00136 // P_MAPUTL
00137 //
00138 typedef struct
00139 {
00140         fixed_t         x;
00141         fixed_t         y;
00142         fixed_t         dx;
00143         fixed_t         dy;
00144 
00145 } divline_t;
00146 
00147 typedef struct
00148 {
00149         fixed_t         frac;                   // along trace line
00150         BOOL    isaline;
00151         union {
00152                 AActor* thing;
00153                 line_t* line;
00154         }                                       d;
00155 } intercept_t;
00156 
00157 #define MAXINTERCEPTS   128
00158 
00159 extern TArray<intercept_t> intercepts;
00160 
00161 typedef BOOL (*traverser_t) (intercept_t *in);
00162 
00163 fixed_t P_AproxDistance (fixed_t dx, fixed_t dy);
00164 int     P_PointOnLineSide (fixed_t x, fixed_t y, const line_t *line);
00165 int     P_PointOnDivlineSide (fixed_t x, fixed_t y, const divline_t *line);
00166 void    P_MakeDivline (const line_t *li, divline_t *dl);
00167 fixed_t P_InterceptVector (const divline_t *v2, const divline_t *v1);
00168 int     P_BoxOnLineSide (const fixed_t *tmbox, const line_t *ld);
00169 
00170 extern fixed_t                  opentop;
00171 extern fixed_t                  openbottom;
00172 extern fixed_t                  openrange;
00173 extern fixed_t                  lowfloor;
00174 
00175 void    P_LineOpening (const line_t *linedef);
00176 
00177 BOOL P_BlockLinesIterator (int x, int y, BOOL(*func)(line_t*) );
00178 BOOL P_BlockThingsIterator (int x, int y, BOOL(*func)(AActor*) );
00179 
00180 #define PT_ADDLINES     1
00181 #define PT_ADDTHINGS    2
00182 #define PT_EARLYOUT     4
00183 
00184 extern divline_t                trace;
00185 
00186 BOOL
00187 P_PathTraverse
00188 ( fixed_t               x1,
00189   fixed_t               y1,
00190   fixed_t               x2,
00191   fixed_t               y2,
00192   int                   flags,
00193   BOOL          (*trav) (intercept_t *));
00194 
00195 // [ML] 2/1/10: Break out P_PointToAngle from R_PointToAngle2 (from EE)
00196 angle_t P_PointToAngle(fixed_t xo, fixed_t yo, fixed_t x, fixed_t y);
00197 
00198 //
00199 // P_MAP
00200 //
00201 
00202 // If "floatok" true, move would be ok
00203 // if within "tmfloorz - tmceilingz".
00204 extern BOOL                             floatok;
00205 extern fixed_t                  tmfloorz;
00206 extern fixed_t                  tmceilingz;
00207 extern msecnode_t               *sector_list;           // phares 3/16/98
00208 extern AActor                   *BlockingMobj;
00209 extern line_t                   *BlockingLine;          // Used only by P_Move
00210                                                                                         // This is not necessarily a *blocking* line
00211 
00212 //Added by MC: tmsectortype
00213 extern fixed_t                  tmdropoffz; //Needed in b_move.c
00214 extern sector_t                 *tmsector;
00215 
00216 extern  line_t*                 ceilingline;
00217 
00218 bool    P_TestMobjZ (AActor *mobj);
00219 BOOL    P_TestMobjLocation (AActor *mobj);
00220 bool    P_CheckPosition (AActor *thing, fixed_t x, fixed_t y);
00221 AActor  *P_CheckOnmobj (AActor *thing);
00222 void    P_FakeZMovement (AActor *mo);
00223 BOOL    P_TryMove (AActor* thing, fixed_t x, fixed_t y, bool dropoff);
00224 BOOL    P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, BOOL telefrag); // [RH] Added z and telefrag parameters
00225 void    P_SlideMove (AActor* mo);
00226 bool    P_CheckSight (const AActor* t1, const AActor* t2, bool ignoreInvisibility = false);
00227 bool    P_CheckSight2 (const AActor* t1, const AActor* t2, bool ignoreInvisibility = false);
00228 void    P_UseLines (player_t* player);
00229 
00230 // GhostlyDeath -- I put this here
00231 bool P_CheckSightEdges(const AActor* t1, const AActor* t2, float radius_boost);
00232 bool P_CheckSightEdges2(const AActor* t1, const AActor* t2, float radius_boost);
00233 
00234 bool    P_ChangeSector (sector_t* sector, bool crunch);
00235 
00236 extern  AActor* linetarget;     // who got hit (or NULL)
00237 
00238 fixed_t P_AimLineAttack (AActor *t1, angle_t angle, fixed_t distance);
00239 void    P_LineAttack (AActor *t1, angle_t angle, fixed_t distance, fixed_t slope, int damage);
00240 
00241 // [RH] Position the chasecam
00242 void    P_AimCamera (AActor *t1);
00243 extern  fixed_t CameraX, CameraY, CameraZ;
00244 
00245 // [RH] Means of death
00246 void    P_RadiusAttack (AActor *spot, AActor *source, int damage, int mod);
00247 
00248 void    P_DelSeclist(msecnode_t *);                                                     // phares 3/16/98
00249 void    P_CreateSecNodeList(AActor*,fixed_t,fixed_t);           // phares 3/14/98
00250 int             P_GetMoveFactor(const AActor *mo, int *frictionp);      // phares  3/6/98
00251 int             P_GetFriction(const AActor *mo, int *frictionfactor);
00252 BOOL    Check_Sides(AActor *, int, int);                                        // phares
00253 
00254 
00255 //
00256 // P_SETUP
00257 //
00258 extern byte*                    rejectmatrix;   // for fast sight rejection
00259 extern BOOL                             rejectempty;
00260 extern int*                             blockmaplump;   // offsets in blockmap are from here
00261 extern int*                             blockmap;
00262 extern int                              bmapwidth;
00263 extern int                              bmapheight;     // in mapblocks
00264 extern fixed_t                  bmaporgx;
00265 extern fixed_t                  bmaporgy;               // origin of block map
00266 extern AActor**                 blocklinks;     // for thing chains
00267 
00268 
00269 
00270 //
00271 // P_INTER
00272 //
00273 extern int                              maxammo[NUMAMMO];
00274 extern int                              clipammo[NUMAMMO];
00275 
00276 void P_TouchSpecialThing (AActor *special, AActor *toucher, bool FromServer = false);
00277 
00278 void P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, int mod=0, int flags=0);
00279 
00280 #define DMG_NO_ARMOR            1
00281 
00282 // [RH] Means of death flags (based on Quake2's)
00283 #define MOD_UNKNOWN                     0
00284 #define MOD_FIST                        1
00285 #define MOD_PISTOL                      2
00286 #define MOD_SHOTGUN                     3
00287 #define MOD_CHAINGUN            4
00288 #define MOD_ROCKET                      5
00289 #define MOD_R_SPLASH            6
00290 #define MOD_PLASMARIFLE         7
00291 #define MOD_BFG_BOOM            8
00292 #define MOD_BFG_SPLASH          9
00293 #define MOD_CHAINSAW            10
00294 #define MOD_SSHOTGUN            11
00295 #define MOD_WATER                       12
00296 #define MOD_SLIME                       13
00297 #define MOD_LAVA                        14
00298 #define MOD_CRUSH                       15
00299 #define MOD_TELEFRAG            16
00300 #define MOD_FALLING                     17
00301 #define MOD_SUICIDE                     18
00302 #define MOD_BARREL                      19
00303 #define MOD_EXIT                        20
00304 #define MOD_SPLASH                      21
00305 #define MOD_HIT                         22
00306 
00307 extern  int MeansOfDeath;
00308 
00309 //
00310 // PO_MAN
00311 //
00312 typedef enum
00313 {
00314         PODOOR_NONE,
00315         PODOOR_SLIDE,
00316         PODOOR_SWING,
00317         
00318         NUMTYPES        
00319 } podoortype_t;
00320 
00321 inline FArchive &operator<< (FArchive &arc, podoortype_t type)
00322 {
00323         return arc << (BYTE)type;
00324 }
00325 inline FArchive &operator>> (FArchive &arc, podoortype_t &out)
00326 {
00327         BYTE in; arc >> in; out = (podoortype_t)in; return arc;
00328 }
00329 
00330 class DPolyAction : public DThinker
00331 {
00332         DECLARE_SERIAL (DPolyAction, DThinker)
00333 public:
00334         DPolyAction (int polyNum);
00335 protected:
00336         DPolyAction ();
00337         int m_PolyObj;
00338         int m_Speed;
00339         int m_Dist;
00340 
00341         friend void ThrustMobj (AActor *actor, seg_t *seg, polyobj_t *po);
00342 };
00343 
00344 class DRotatePoly : public DPolyAction
00345 {
00346         DECLARE_SERIAL (DRotatePoly, DPolyAction)
00347 public:
00348         DRotatePoly (int polyNum);
00349         void RunThink ();
00350 protected:
00351         friend BOOL EV_RotatePoly (line_t *line, int polyNum, int speed, int byteAngle, int direction, BOOL overRide);
00352 private:
00353         DRotatePoly ();
00354 };
00355 
00356 class DMovePoly : public DPolyAction
00357 {
00358         DECLARE_SERIAL (DMovePoly, DPolyAction)
00359 public:
00360         DMovePoly (int polyNum);
00361         void RunThink ();
00362 protected:
00363         DMovePoly ();
00364         int m_Angle;
00365         fixed_t m_xSpeed; // for sliding walls
00366         fixed_t m_ySpeed;
00367 
00368         friend BOOL EV_MovePoly (line_t *line, int polyNum, int speed, angle_t angle, fixed_t dist, BOOL overRide);
00369 };
00370 
00371 class DPolyDoor : public DMovePoly
00372 {
00373         DECLARE_SERIAL (DPolyDoor, DMovePoly)
00374 public:
00375         DPolyDoor (int polyNum, podoortype_t type);
00376         void RunThink ();
00377 protected:
00378         int m_Direction;
00379         int m_TotalDist;
00380         int m_Tics;
00381         int m_WaitTics;
00382         podoortype_t m_Type;
00383         bool m_Close;
00384 
00385         friend BOOL EV_OpenPolyDoor (line_t *line, int polyNum, int speed, angle_t angle, int delay, int distance, podoortype_t type);
00386 private:
00387         DPolyDoor ();
00388 };
00389 
00390 // [RH] Data structure for P_SpawnMapThing() to keep track
00391 //              of polyobject-related things.
00392 typedef struct polyspawns_s
00393 {
00394         struct polyspawns_s *next;
00395         fixed_t x;
00396         fixed_t y;
00397         short angle;
00398         short type;
00399 } polyspawns_t;
00400 
00401 enum
00402 {
00403         PO_HEX_ANCHOR_TYPE = 3000,
00404         PO_HEX_SPAWN_TYPE,
00405         PO_HEX_SPAWNCRUSH_TYPE,
00406 
00407         // [RH] Thing numbers that don't conflict with Doom things
00408         PO_ANCHOR_TYPE = 9300,
00409         PO_SPAWN_TYPE,
00410         PO_SPAWNCRUSH_TYPE
00411 };
00412 
00413 #define PO_LINE_START 1 // polyobj line start special
00414 #define PO_LINE_EXPLICIT 5
00415 
00416 extern polyobj_t *polyobjs; // list of all poly-objects on the level
00417 extern int po_NumPolyobjs;
00418 extern polyspawns_t *polyspawns;        // [RH] list of polyobject things to spawn
00419 
00420 
00421 BOOL PO_MovePolyobj (int num, int x, int y);
00422 BOOL PO_RotatePolyobj (int num, angle_t angle);
00423 void PO_Init (void);
00424 BOOL PO_Busy (int polyobj);
00425 
00426 //
00427 // P_SPEC
00428 //
00429 #include "p_spec.h"
00430 
00431 
00432 #endif  // __P_LOCAL__
00433 
00434 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends