]> icculus.org git repositories - theoddone33/hhexen.git/blob - include/p_local.h
osezer patch 010
[theoddone33/hhexen.git] / include / p_local.h
1
2 //**************************************************************************
3 //**
4 //** p_local.h : Heretic 2 : Raven Software, Corp.
5 //**
6 //** $RCSfile$
7 //** $Revision$
8 //** $Date$
9 //** $Author$
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 #ifdef RENDER3D
189 typedef struct
190 {
191     float x,y,dx,dy;
192 } fdivline_t;
193 #endif
194
195 typedef struct
196 {
197         fixed_t         frac;           // along trace line
198         boolean         isaline;
199         union {
200                 mobj_t  *thing;
201                 line_t  *line;
202         }                       d;
203 } intercept_t;
204
205 #define MAXINTERCEPTS   128
206 extern  intercept_t             intercepts[MAXINTERCEPTS], *intercept_p;
207 typedef boolean (*traverser_t) (intercept_t *in);
208
209
210 fixed_t P_AproxDistance (fixed_t dx, fixed_t dy);
211 int     P_PointOnLineSide (fixed_t x, fixed_t y, line_t *line);
212 int     P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t *line);
213 void    P_MakeDivline (line_t *li, divline_t *dl);
214 fixed_t P_InterceptVector (divline_t *v2, divline_t *v1);
215 int     P_BoxOnLineSide (fixed_t *tmbox, line_t *ld);
216
217 extern  fixed_t opentop, openbottom, openrange;
218 extern  fixed_t lowfloor;
219 void    P_LineOpening (line_t *ld);
220
221 boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) );
222 boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) );
223
224 #define PT_ADDLINES             1
225 #define PT_ADDTHINGS    2
226 #define PT_EARLYOUT             4
227
228 extern  divline_t       trace;
229 boolean P_PathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2,
230         int flags, boolean (*trav) (intercept_t *));
231
232 void    P_UnsetThingPosition (mobj_t *thing);
233 void    P_SetThingPosition (mobj_t *thing);
234 mobj_t *P_RoughMonsterSearch(mobj_t *mo, int distance);
235
236 // ***** P_MAP *****
237
238 extern boolean floatok;                         // if true, move would be ok if
239 extern fixed_t tmfloorz, tmceilingz;    // within tmfloorz - tmceilingz
240 extern int tmfloorpic;
241 extern mobj_t *BlockingMobj;
242
243 extern line_t *ceilingline;
244 boolean P_TestMobjLocation(mobj_t *mobj);
245 boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y);
246 mobj_t *P_CheckOnmobj(mobj_t *thing);
247 void P_FakeZMovement(mobj_t *mo);
248 boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y);
249 boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y);
250 void P_SlideMove(mobj_t *mo);
251 void P_BounceWall(mobj_t *mo);
252 boolean P_CheckSight(mobj_t *t1, mobj_t *t2);
253 void P_UseLines(player_t *player);
254 boolean P_UsePuzzleItem(player_t *player, int itemType);
255 void PIT_ThrustSpike(mobj_t *actor);
256
257 boolean P_ChangeSector (sector_t *sector, int crunch);
258
259 extern mobj_t *PuffSpawned; // true if a puff was spawned
260 extern  mobj_t          *linetarget;              // who got hit (or NULL)
261 fixed_t P_AimLineAttack (mobj_t *t1, angle_t angle, fixed_t distance);
262
263 void P_LineAttack (mobj_t *t1, angle_t angle, fixed_t distance, fixed_t slope, 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