4 //==================================================================
5 //==================================================================
7 // BROKEN LIGHT FLASHING
9 //==================================================================
10 //==================================================================
12 //==================================================================
16 // After the map has been loaded, scan each sector for specials
17 // that spawn thinkers
19 //==================================================================
20 void T_LightFlash (lightflash_t *flash)
25 if (flash->sector->lightlevel == flash->maxlight)
27 flash-> sector->lightlevel = flash->minlight;
28 flash->count = (P_Random()&flash->mintime)+1;
32 flash-> sector->lightlevel = flash->maxlight;
33 flash->count = (P_Random()&flash->maxtime)+1;
39 //==================================================================
43 // After the map has been loaded, scan each sector for specials that spawn thinkers
45 //==================================================================
46 void P_SpawnLightFlash (sector_t *sector)
50 sector->special = 0; // nothing special about it during gameplay
52 flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0);
53 P_AddThinker (&flash->thinker);
54 flash->thinker.function = T_LightFlash;
55 flash->sector = sector;
56 flash->maxlight = sector->lightlevel;
58 flash->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel);
61 flash->count = (P_Random()&flash->maxtime)+1;
64 //==================================================================
66 // STROBE LIGHT FLASHING
68 //==================================================================
70 //==================================================================
74 // After the map has been loaded, scan each sector for specials that spawn thinkers
76 //==================================================================
77 void T_StrobeFlash (strobe_t *flash)
82 if (flash->sector->lightlevel == flash->minlight)
84 flash-> sector->lightlevel = flash->maxlight;
85 flash->count = flash->brighttime;
89 flash-> sector->lightlevel = flash->minlight;
90 flash->count =flash->darktime;
95 //==================================================================
99 // After the map has been loaded, scan each sector for specials that spawn thinkers
101 //==================================================================
102 void P_SpawnStrobeFlash (sector_t *sector,int fastOrSlow, int inSync)
106 flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0);
107 P_AddThinker (&flash->thinker);
108 flash->sector = sector;
109 flash->darktime = fastOrSlow;
110 flash->brighttime = STROBEBRIGHT;
111 flash->thinker.function = T_StrobeFlash;
112 flash->maxlight = sector->lightlevel;
113 flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);
115 if (flash->minlight == flash->maxlight)
117 sector->special = 0; // nothing special about it during gameplay
120 flash->count = (P_Random()&7)+1;
125 //==================================================================
127 // Start strobing lights (usually from a trigger)
129 //==================================================================
130 void EV_StartLightStrobing(line_t *line)
136 while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
138 sec = §ors[secnum];
139 if (sec->specialdata)
142 P_SpawnStrobeFlash (sec,SLOWDARK, 0);
146 //==================================================================
148 // TURN LINE'S TAG LIGHTS OFF
150 //==================================================================
151 void EV_TurnTagLightsOff(line_t *line)
161 for (j = 0;j < numsectors; j++, sector++)
162 if (sector->tag == line->tag)
164 min = sector->lightlevel;
165 for (i = 0;i < sector->linecount; i++)
167 templine = sector->lines[i];
168 tsec = getNextSector(templine,sector);
171 if (tsec->lightlevel < min)
172 min = tsec->lightlevel;
174 sector->lightlevel = min;
178 //==================================================================
180 // TURN LINE'S TAG LIGHTS ON
182 //==================================================================
183 void EV_LightTurnOn(line_t *line, int bright)
193 for (i=0;i<numsectors;i++, sector++)
194 if (sector->tag == line->tag)
197 // bright = 0 means to search for highest
198 // light level surrounding sector
202 for (j = 0;j < sector->linecount; j++)
204 templine = sector->lines[j];
205 temp = getNextSector(templine,sector);
208 if (temp->lightlevel > bright)
209 bright = temp->lightlevel;
212 sector-> lightlevel = bright;
216 //==================================================================
218 // Spawn glowing light
220 //==================================================================
221 void T_Glow(glow_t *g)
226 g->sector->lightlevel -= GLOWSPEED;
227 if (g->sector->lightlevel <= g->minlight)
229 g->sector->lightlevel += GLOWSPEED;
234 g->sector->lightlevel += GLOWSPEED;
235 if (g->sector->lightlevel >= g->maxlight)
237 g->sector->lightlevel -= GLOWSPEED;
244 void P_SpawnGlowingLight(sector_t *sector)
248 g = Z_Malloc( sizeof(*g), PU_LEVSPEC, 0);
249 P_AddThinker(&g->thinker);
251 g->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel);
252 g->maxlight = sector->lightlevel;
253 g->thinker.function = T_Glow;