]> icculus.org git repositories - theoddone33/hhexen.git/blob - include/p_spec.h
osezer patch 006
[theoddone33/hhexen.git] / include / p_spec.h
1
2 //**************************************************************************
3 //**
4 //** p_spec.h : Heretic 2 : Raven Software, Corp.
5 //**
6 //** $RCSfile$
7 //** $Revision$
8 //** $Date$
9 //** $Author$
10 //**
11 //**************************************************************************
12
13 extern int *TerrainTypes;
14
15 //
16 //      scrolling line specials
17 //
18
19 #define MAXLINEANIMS 64
20 extern short numlinespecials;
21 extern line_t *linespeciallist[MAXLINEANIMS];
22
23 //      Define values for map objects
24 #define MO_TELEPORTMAN 14
25
26 // at game start
27 void P_InitTerrainTypes(void);
28 void P_InitLava(void);
29
30 // at map load
31 void P_SpawnSpecials(void);
32
33 // every tic
34 void P_UpdateSpecials(void);
35
36 // when needed
37 boolean P_ExecuteLineSpecial(int special, byte *args, line_t *line, int side,
38         mobj_t *mo);
39 boolean P_ActivateLine(line_t *ld, mobj_t *mo, int side, int activationType);
40 //boolean P_UseSpecialLine ( mobj_t *thing, line_t *line);
41 //void    P_ShootSpecialLine ( mobj_t *thing, line_t *line);
42 //void    P_CrossSpecialLine (int linenum, int side, mobj_t *thing);
43
44 void P_PlayerInSpecialSector(player_t *player);
45 void P_PlayerOnSpecialFlat(player_t *player, int floorType);
46
47 //int twoSided(int sector,int line);
48 //sector_t *getSector(int currentSector,int line,int side);
49 //side_t  *getSide(int currentSector,int line, int side);
50 fixed_t P_FindLowestFloorSurrounding(sector_t *sec);
51 fixed_t P_FindHighestFloorSurrounding(sector_t *sec);
52 fixed_t P_FindNextHighestFloor(sector_t *sec,int currentheight);
53 fixed_t P_FindLowestCeilingSurrounding(sector_t *sec);
54 fixed_t P_FindHighestCeilingSurrounding(sector_t *sec);
55 //int P_FindSectorFromLineTag(line_t  *line,int start);
56 int P_FindSectorFromTag(int tag, int start);
57 //int P_FindMinSurroundingLight(sector_t *sector,int max);
58 sector_t *getNextSector(line_t *line,sector_t *sec);
59 line_t *P_FindLine(int lineTag, int *searchPosition);
60
61 //
62 //      SPECIAL
63 //
64 //int EV_DoDonut(line_t *line);
65
66 //-------------------------------
67 // P_anim.c
68 //-------------------------------
69
70 void P_AnimateSurfaces(void);
71 void P_InitFTAnims(void);
72 void P_InitLightning(void);
73 void P_ForceLightning(void);
74
75 /*
76 ===============================================================================
77
78                                                         P_LIGHTS
79
80 ===============================================================================
81 */
82
83 typedef enum
84 {
85         LITE_RAISEBYVALUE,
86         LITE_LOWERBYVALUE,
87         LITE_CHANGETOVALUE,
88         LITE_FADE,
89         LITE_GLOW,
90         LITE_FLICKER,
91         LITE_STROBE
92 } lighttype_t;
93
94 typedef struct
95 {
96         thinker_t       thinker;
97         sector_t        *sector;
98         lighttype_t     type;
99         int             value1;
100         int                     value2;
101         int                     tics1;
102         int                     tics2;
103         int             count;
104 } light_t;
105         
106 typedef struct
107 {
108         thinker_t       thinker;
109         sector_t        *sector;
110         int index;
111         int base;
112 } phase_t;
113
114 #define LIGHT_SEQUENCE_START    2
115 #define LIGHT_SEQUENCE          3
116 #define LIGHT_SEQUENCE_ALT      4
117
118 void T_Phase(phase_t *phase);
119 void T_Light(light_t *light);
120 void P_SpawnPhasedLight(sector_t *sector, int base, int index);
121 void P_SpawnLightSequence(sector_t *sector, int indexStep);
122 boolean EV_SpawnLight(line_t *line, byte *arg, lighttype_t type);
123
124 #if 0
125 typedef struct
126 {
127         thinker_t thinker;
128         sector_t *sector;
129         int count;
130         int maxlight;
131         int minlight;
132         int maxtime;
133         int mintime;
134 } lightflash_t;
135
136 typedef struct
137 {
138         thinker_t thinker;
139         sector_t *sector;
140         int count;
141         int minlight;
142         int maxlight;
143         int darktime;
144         int brighttime;
145 } strobe_t;
146
147 typedef struct
148 {
149         thinker_t thinker;
150         sector_t *sector;
151         int minlight;
152         int maxlight;
153         int direction;
154 } glow_t;
155
156 typedef struct
157 {
158         thinker_t       thinker;
159         sector_t        *sector;
160         int index;
161         int base;
162 } phase_t;
163
164 #define GLOWSPEED 8
165 #define STROBEBRIGHT 5
166 #define FASTDARK 15
167 #define SLOWDARK 35
168
169 #define LIGHT_SEQUENCE_START    2
170 #define LIGHT_SEQUENCE                  3
171 #define LIGHT_SEQUENCE_ALT      4
172
173 void T_LightFlash (lightflash_t *flash);
174 void P_SpawnLightFlash (sector_t *sector);
175 void T_StrobeFlash (strobe_t *flash);
176 void P_SpawnStrobeFlash (sector_t *sector, int fastOrSlow, int inSync);
177 void EV_StartLightStrobing(line_t *line);
178 void EV_TurnTagLightsOff(line_t      *line);
179 void EV_LightTurnOn(line_t *line, int bright);
180 void T_Glow(glow_t *g);
181 void P_SpawnGlowingLight(sector_t *sector);
182 void T_Phase(phase_t *phase);
183 void P_SpawnPhasedLight(sector_t *sector, int base, int index);
184 void P_SpawnLightSequence(sector_t *sector, int indexStep);
185 #endif
186
187 /*
188 ===============================================================================
189
190                                                         P_SWITCH
191
192 ===============================================================================
193 */
194 typedef struct
195 {
196         char name1[9];
197         char name2[9];
198         int soundID;
199 } switchlist_t;
200
201 typedef enum
202 {
203         SWTCH_TOP,
204         SWTCH_MIDDLE,
205         SWTCH_BOTTOM
206 } bwhere_e;
207
208 typedef struct
209 {
210         line_t *line;
211         bwhere_e where;
212         int btexture;
213         int btimer;
214         mobj_t *soundorg;
215 } button_t;
216
217 #define MAXSWITCHES 50              // max # of wall switches in a level
218 #define MAXBUTTONS 16              // 4 players, 4 buttons each at once, max.
219 #define BUTTONTIME 35              // 1 second
220
221 extern button_t buttonlist[MAXBUTTONS];
222
223 void P_ChangeSwitchTexture(line_t *line, int useAgain);
224 void P_InitSwitchList(void);
225
226 /*
227 ===============================================================================
228
229                                                         P_PLATS
230
231 ===============================================================================
232 */
233
234 typedef enum
235 {
236         PLAT_UP,
237         PLAT_DOWN,
238         PLAT_WAITING
239 } plat_e;
240
241 typedef enum
242 {
243         PLAT_PERPETUALRAISE,
244         PLAT_DOWNWAITUPSTAY,
245         PLAT_DOWNBYVALUEWAITUPSTAY,
246         PLAT_UPWAITDOWNSTAY,
247         PLAT_UPBYVALUEWAITDOWNSTAY
248 } plattype_e;
249
250 typedef struct
251 {
252         thinker_t thinker;
253         sector_t *sector;
254         fixed_t speed;
255         fixed_t low;
256         fixed_t high;
257         int wait;
258         int count;
259         plat_e status;
260         plat_e oldstatus;
261         int crush;
262         int tag;
263         plattype_e type;
264 } plat_t;
265
266 #define PLATWAIT 3
267 #define PLATSPEED FRACUNIT
268 #define MAXPLATS 30
269
270 extern plat_t *activeplats[MAXPLATS];
271
272 void T_PlatRaise(plat_t *plat);
273 int EV_DoPlat(line_t *line, byte *args, plattype_e type, int amount);
274 void P_AddActivePlat(plat_t *plat);
275 void P_RemoveActivePlat(plat_t *plat);
276 void EV_StopPlat(line_t *line, byte *args);
277
278 /*
279 ===============================================================================
280
281                                                         P_DOORS
282
283 ===============================================================================
284 */
285 typedef enum
286 {
287         DREV_NORMAL,
288         DREV_CLOSE30THENOPEN,
289         DREV_CLOSE,
290         DREV_OPEN,
291         DREV_RAISEIN5MINS
292 } vldoor_e;
293
294 typedef struct
295 {
296         thinker_t thinker;
297         sector_t *sector;
298         vldoor_e type;
299         fixed_t topheight;
300         fixed_t speed;
301         int direction; // 1 = up, 0 = waiting at top, -1 = down
302         int topwait; // tics to wait at the top (keep in case a door going down is reset)
303         int topcountdown;   // when it reaches 0, start going down
304 } vldoor_t;
305
306 #define VDOORSPEED FRACUNIT*2
307 #define VDOORWAIT 150
308
309 boolean EV_VerticalDoor(line_t *line, mobj_t *thing);
310 int EV_DoDoor(line_t *line, byte *args, vldoor_e type);
311 void T_VerticalDoor(vldoor_t *door);
312 //void P_SpawnDoorCloseIn30(sector_t *sec);
313 //void P_SpawnDoorRaiseIn5Mins(sector_t *sec, int secnum);
314
315 /*
316 ===============================================================================
317
318                                                         P_CEILNG
319
320 ===============================================================================
321 */
322 typedef enum
323 {
324         CLEV_LOWERTOFLOOR,
325         CLEV_RAISETOHIGHEST,
326         CLEV_LOWERANDCRUSH,
327         CLEV_CRUSHANDRAISE,
328         CLEV_LOWERBYVALUE,
329         CLEV_RAISEBYVALUE,
330         CLEV_CRUSHRAISEANDSTAY,
331         CLEV_MOVETOVALUETIMES8
332 } ceiling_e;
333
334 typedef struct
335 {
336         thinker_t thinker;
337         sector_t *sector;
338         ceiling_e type;
339         fixed_t bottomheight, topheight;
340         fixed_t speed;
341         int crush;
342         int direction; // 1 = up, 0 = waiting, -1 = down
343         int tag; // ID
344         int olddirection;
345 } ceiling_t;
346
347 #define CEILSPEED FRACUNIT
348 #define CEILWAIT 150
349 #define MAXCEILINGS 30
350
351 extern ceiling_t *activeceilings[MAXCEILINGS];
352
353 int EV_DoCeiling(line_t *line, byte *args, ceiling_e type);
354 void T_MoveCeiling(ceiling_t *ceiling);
355 void P_AddActiveCeiling(ceiling_t *c);
356 void P_RemoveActiveCeiling(ceiling_t *c);
357 int EV_CeilingCrushStop(line_t *line, byte *args);
358
359 /*
360 ===============================================================================
361
362                                                         P_FLOOR
363
364 ===============================================================================
365 */
366 typedef enum
367 {
368         FLEV_LOWERFLOOR,             // lower floor to highest surrounding floor
369         FLEV_LOWERFLOORTOLOWEST,     // lower floor to lowest surrounding floor
370         FLEV_LOWERFLOORBYVALUE,
371         FLEV_RAISEFLOOR,             // raise floor to lowest surrounding CEILING
372         FLEV_RAISEFLOORTONEAREST,  // raise floor to next highest surrounding floor
373         FLEV_RAISEFLOORBYVALUE,
374         FLEV_RAISEFLOORCRUSH,
375         FLEV_RAISEBUILDSTEP,        // One step of a staircase
376         FLEV_RAISEBYVALUETIMES8,
377         FLEV_LOWERBYVALUETIMES8,
378         FLEV_LOWERTIMES8INSTANT,
379         FLEV_RAISETIMES8INSTANT,
380         FLEV_MOVETOVALUETIMES8
381 } floor_e;
382
383 typedef struct
384 {
385         thinker_t thinker;
386         sector_t *sector;
387         floor_e type;
388         int crush;
389         int direction;
390         int newspecial;
391         short texture;
392         fixed_t floordestheight;
393         fixed_t speed;
394         int     delayCount;
395         int delayTotal;
396         fixed_t stairsDelayHeight;
397         fixed_t stairsDelayHeightDelta;
398         fixed_t resetHeight;
399         short resetDelay;
400         short resetDelayCount;
401         byte textureChange;
402 } floormove_t;
403
404 typedef struct
405 {
406         thinker_t thinker;
407         sector_t *sector;
408         int ceilingSpeed;
409         int floorSpeed;
410         int floordest;
411         int ceilingdest;
412         int direction;
413         int crush;
414 } pillar_t;
415
416 typedef struct
417 {
418         thinker_t thinker;
419         sector_t *sector;
420         fixed_t originalHeight;
421         fixed_t accumulator;
422         fixed_t accDelta;
423         fixed_t targetScale;
424         fixed_t scale;
425         fixed_t scaleDelta;
426         int ticker;
427         int state;
428 } floorWaggle_t;
429
430 #define FLOORSPEED FRACUNIT
431
432 typedef enum
433 {
434         RES_OK,
435         RES_CRUSHED,
436         RES_PASTDEST
437 } result_e;
438
439 typedef enum
440 {
441         STAIRS_NORMAL,
442         STAIRS_SYNC,
443         STAIRS_PHASED
444 } stairs_e;
445
446 result_e T_MovePlane(sector_t *sector, fixed_t speed,
447                         fixed_t dest, int crush, int floorOrCeiling, int direction);
448
449 int EV_BuildStairs(line_t *line, byte *args, int direction, stairs_e type);
450 int EV_DoFloor(line_t *line, byte *args, floor_e floortype);
451 void T_MoveFloor(floormove_t *floor);
452 void T_BuildPillar(pillar_t *pillar);
453 void T_FloorWaggle(floorWaggle_t *waggle);
454 int EV_BuildPillar(line_t *line, byte *args, boolean crush);
455 int EV_OpenPillar(line_t *line, byte *args);
456 int EV_DoFloorAndCeiling(line_t *line, byte *args, boolean raise);
457 int EV_FloorCrushStop(line_t *line, byte *args);
458 boolean EV_StartFloorWaggle(int tag, int height, int speed, int offset,
459         int timer);
460
461 //--------------------------------------------------------------------------
462 //
463 // p_telept
464 //
465 //--------------------------------------------------------------------------
466
467 boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, angle_t angle,
468         boolean useFog);
469 boolean EV_Teleport(int tid, mobj_t *thing, boolean fog);
470
471 //--------------------------------------------------------------------------
472 //
473 // p_acs
474 //
475 //--------------------------------------------------------------------------
476
477 #define MAX_ACS_SCRIPT_VARS 10
478 #define MAX_ACS_MAP_VARS 32
479 #define MAX_ACS_WORLD_VARS 64
480 #define ACS_STACK_DEPTH 32
481 #define MAX_ACS_STORE 20
482
483 typedef enum
484 {
485         ASTE_INACTIVE,
486         ASTE_RUNNING,
487         ASTE_SUSPENDED,
488         ASTE_WAITINGFORTAG,
489         ASTE_WAITINGFORPOLY,
490         ASTE_WAITINGFORSCRIPT,
491         ASTE_TERMINATING
492 } aste_t;
493
494 typedef struct acs_s acs_t;
495 typedef struct acsInfo_s acsInfo_t;
496
497 struct acsInfo_s
498 {
499         int number;
500         int *address;
501         int argCount;
502         aste_t state;
503         int waitValue;
504 };
505
506 struct acs_s
507 {
508         thinker_t thinker;
509         mobj_t *activator;
510         line_t *line;
511         int side;
512         int number;
513         int infoIndex;
514         int delayCount;
515         int stack[ACS_STACK_DEPTH];
516         int     stackPtr;
517         int vars[MAX_ACS_SCRIPT_VARS];
518         int *ip;
519 };
520
521 typedef struct
522 {
523         int map;                // Target map
524         int script;             // Script number on target map
525         byte args[4];   // Padded to 4 for alignment
526 } acsstore_t;
527
528 void P_LoadACScripts(int lump);
529 boolean P_StartACS(int number, int map, byte *args, mobj_t *activator,
530         line_t *line, int side);
531 boolean P_StartLockedACS(line_t *line, byte *args, mobj_t *mo, int side); 
532 boolean P_TerminateACS(int number, int map);
533 boolean P_SuspendACS(int number, int map);
534 void T_InterpretACS(acs_t *script);
535 void P_TagFinished(int tag);
536 void P_PolyobjFinished(int po);
537 void P_ACSInitNewGame(void);
538 void P_CheckACSStore(void);
539
540 extern int ACScriptCount;
541 extern byte *ActionCodeBase;
542 extern acsInfo_t *ACSInfo;
543 extern int MapVars[MAX_ACS_MAP_VARS];
544 extern int WorldVars[MAX_ACS_WORLD_VARS];
545 extern acsstore_t ACSStore[MAX_ACS_STORE+1]; // +1 for termination marker
546
547 //--------------------------------------------------------------------------
548 //
549 // p_things
550 //
551 //--------------------------------------------------------------------------
552
553 extern mobjtype_t TranslateThingType[];
554
555 boolean EV_ThingProjectile(byte *args, boolean gravity);
556 boolean EV_ThingSpawn(byte *args, boolean fog);
557 boolean EV_ThingActivate(int tid);
558 boolean EV_ThingDeactivate(int tid);
559 boolean EV_ThingRemove(int tid);
560 boolean EV_ThingDestroy(int tid);
561