1 //---------------------------------------------------------------------------- 2 // EDGE Specials Lines, Elevator & Floor Code 3 //---------------------------------------------------------------------------- 4 // 5 // Copyright (c) 1999-2009 The EDGE Team. 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; either version 2 10 // of the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 //---------------------------------------------------------------------------- 18 // 19 // Based on the DOOM source code, released by Id Software under the 20 // following copyright: 21 // 22 // Copyright (C) 1993-1996 by id Software, Inc. 23 // 24 //---------------------------------------------------------------------------- 25 // 26 // -KM- 1998/09/01 Lines.ddf 27 // -ACB- 1998/09/13 Cleaned Up. 28 // -ACB- 2001/01/14 Added Elevator Types 29 // 30 31 #ifndef __P_SPEC__ 32 #define __P_SPEC__ 33 34 #include "ddf/main.h" 35 #include "r_defs.h" 36 #include "r_image.h" 37 38 #define MENU_GRAV_NORMAL 8 39 40 41 typedef struct light_s 42 { 43 // type of light effect 44 const lightdef_c *type; 45 46 sector_t *sector; 47 48 // countdown value to next change, or 0 if disabled 49 int count; 50 51 // dark and bright levels 52 int minlight; 53 int maxlight; 54 55 // current direction for GLOW type, -1 down, +1 up 56 int direction; 57 58 // countdown value for FADE type 59 int fade_count; 60 } 61 light_t; 62 63 typedef enum 64 { 65 BWH_None, 66 BWH_Top, 67 BWH_Middle, 68 BWH_Bottom 69 } 70 bwhere_e; 71 72 typedef struct button_s 73 { 74 line_t *line; 75 bwhere_e where; 76 const image_c *bimage; 77 int btimer; 78 struct sfx_s *off_sound; 79 } 80 button_t; 81 82 83 typedef enum 84 { 85 DIRECTION_UP = +1, 86 DIRECTION_WAIT = 0, 87 DIRECTION_DOWN = -1, 88 DIRECTION_STASIS = -2 89 } 90 plane_dir_e; 91 92 93 typedef struct plane_move_s 94 { 95 const movplanedef_c *type; 96 sector_t *sector; 97 98 bool is_ceiling; 99 bool is_elevator; 100 101 float startheight; 102 float destheight; 103 float elev_height; 104 float speed; 105 int crush; // damage, or 0 for no crushing 106 107 // 1 = up, 0 = waiting at top, -1 = down 108 int direction; 109 int olddirection; 110 111 int tag; 112 113 // tics to wait when fully open 114 int waited; 115 116 bool sfxstarted; 117 118 int newspecial; 119 const image_c *new_image; 120 } 121 plane_move_t; 122 123 typedef struct slider_move_s 124 { 125 const sliding_door_c *info; 126 line_t *line; 127 128 // current distance it has opened 129 float opening; 130 131 // target distance 132 float target; 133 134 // length of line 135 float line_len; 136 137 // 1 = opening, 0 = waiting, -1 = closing 138 int direction; 139 140 // tics to wait at the top 141 int waited; 142 143 bool sfxstarted; 144 bool final_open; 145 } 146 slider_move_t; 147 148 typedef struct force_s 149 { 150 bool is_point; 151 bool is_wind; 152 153 vec3_t point; 154 155 float radius; 156 float magnitude; 157 158 vec2_t mag; // wind/current 159 160 sector_t *sector; // the affected sector 161 } 162 force_t; 163 164 // End-level timer (-TIMER option) 165 extern bool levelTimer; 166 extern int levelTimeCount; 167 168 extern linetype_c donut[2]; 169 170 // at map load 171 void P_SpawnSpecials1(void); 172 void P_SpawnSpecials2(int autotag); 173 174 // at map exit 175 void P_StopAmbientSectorSfx(void); 176 177 // every tic 178 void P_UpdateSpecials(void); 179 180 // when needed 181 bool P_UseSpecialLine(mobj_t * thing, line_t * line, int side, 182 float open_bottom, float open_top); 183 bool P_CrossSpecialLine(line_t *ld, int side, mobj_t * thing); 184 void P_ShootSpecialLine(line_t *ld, int side, mobj_t * thing); 185 void P_RemoteActivation(mobj_t * thing, int typenum, int tag, 186 int side, trigger_e method); 187 void P_PlayerInSpecialSector(struct player_s * pl, sector_t *sec); 188 189 // Utilities... 190 int P_TwoSided(int sector, int line); 191 side_t *P_GetSide(int currentSector, int line, int side); 192 sector_t *P_GetSector(int currentSector, int line, int side); 193 sector_t *P_GetNextSector(const line_t * line, const sector_t * sec, 194 bool ignore_selfref = false); 195 196 // Info Needs.... 197 float P_FindSurroundingHeight(const heightref_e ref, const sector_t *sec); 198 float P_FindRaiseToTexture(sector_t * sec); // -KM- 1998/09/01 New func, old inline 199 sector_t *P_FindSectorFromTag(int tag); 200 int P_FindMinSurroundingLight(sector_t * sector, int max); 201 202 // start an action... 203 bool EV_Lights(sector_t * sec, const lightdef_c * type); 204 205 void P_RunActivePlanes(void); 206 void P_RunActiveSliders(void); 207 208 void P_AddActivePlane(plane_move_t *pmov); 209 void P_AddActiveSlider(slider_move_t *smov); 210 void P_DestroyAllPlanes(void); 211 void P_DestroyAllSliders(void); 212 213 void P_AddSpecialLine(line_t *ld); 214 void P_AddSpecialSector(sector_t *sec); 215 void P_SectorChangeSpecial(sector_t *sec, int new_type); 216 217 void P_RunLights(void); 218 light_t *P_NewLight(void); 219 void P_DestroyAllLights(void); 220 void P_RunSectorSFX(void); 221 void P_DestroyAllSectorSFX(void); 222 223 void EV_LightTurnOn(int tag, int bright); 224 bool EV_DoDonut(sector_t * s1, struct sfx_s * sfx[4]); 225 bool EV_Teleport(line_t * line, int tag, mobj_t *thing, const teleportdef_c *def); 226 bool EV_ManualPlane(line_t * line, mobj_t * thing, const movplanedef_c * type); 227 // bool EV_ManualElevator(line_t * line, mobj_t * thing, const elevatordef_c * type); 228 229 bool EV_DoPlane(sector_t * sec, const movplanedef_c * type, sector_t * model); 230 bool EV_DoSlider(line_t * door, line_t *act_line, mobj_t * thing, 231 const linetype_c * special); 232 bool P_SectorIsLowering(sector_t *sec); 233 234 void P_RunForces(void); 235 void P_DestroyAllForces(void); 236 void P_AddPointForce(sector_t *sec, float length); 237 void P_AddSectorForce(sector_t *sec, bool is_wind, float x_mag, float y_mag); 238 239 void P_RunAmbientSFX(void); 240 void P_AddAmbientSFX(sector_t *sec, struct sfx_s *sfx); 241 void P_DestroyAllAmbientSFX(void); 242 243 // 244 // P_SWITCH 245 // 246 void P_InitSwitchList(void); 247 void P_ChangeSwitchTexture(line_t * line, bool useAgain, line_special_e specials, bool noSound); 248 void P_ClearButtons(void); 249 void P_UpdateButtons(void); 250 bool P_ButtonIsPressed(line_t *ld); 251 252 #endif // __P_SPEC__ 253 254 //--- editor settings --- 255 // vi:ts=4:sw=4:noexpandtab 256