P_SPEC.H 13 KB

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