6 //==================================================================
8 // CHANGE THE TEXTURE OF A WALL SWITCH TO ITS OPPOSITE
10 //==================================================================
11 switchlist_t alphSwitchList[] =
13 {"SW1OFF", "SW1ON", 1},
14 {"SW2OFF", "SW2ON", 1},
17 {"SW1CTY", "SW2CTY", 1},
18 {"SW1ORGRY", "SW2ORGRY", 1},
19 {"SW1GRSTN", "SW2GRSTN", 1},
20 {"SW1SNDP", "SW2SNDP", 1},
21 {"SW1SPINE", "SW2SPINE", 1},
22 {"SW1SQPEB", "SW2SQPEB", 1},
23 {"SW1TRST1", "SW2TRST1", 1},
24 {"SW1CSTL", "SW2CSTL", 1},
25 {"SW1MOSS", "SW2MOSS", 1},
26 {"SW1SNDSQ", "SW2SNDSQ", 1},
27 {"SW1RED", "SW2RED", 1},
28 {"SW1WOOD", "SW2WOOD", 1},
29 {"SW1BROWN", "SW2BROWN", 1},
31 {"SW1TRST2", "SW2TRST2", 2},
32 {"SW1MSC", "SW2MSC", 2},
33 {"SW1MSC2", "SW2MSC2", 2},
34 {"SW1GRDMD", "SW2GRDMD", 2},
38 {"SW1BRCOM", "SW2BRCOM", 1},
39 {"SW1BRN1", "SW2BRN1", 1},
40 {"SW1BRN2", "SW2BRN2", 1},
41 {"SW1BRNGN", "SW2BRNGN", 1},
42 {"SW1BROWN", "SW2BROWN", 1},
43 {"SW1COMM", "SW2COMM", 1},
44 {"SW1COMP", "SW2COMP", 1},
45 {"SW1DIRT", "SW2DIRT", 1},
46 {"SW1EXIT", "SW2EXIT", 1},
47 {"SW1GRAY", "SW2GRAY", 1},
48 {"SW1GRAY1", "SW2GRAY1", 1},
49 {"SW1METAL", "SW2METAL", 1},
50 {"SW1PIPE", "SW2PIPE", 1},
51 {"SW1SLAD", "SW2SLAD", 1},
52 {"SW1STARG", "SW2STARG", 1},
53 {"SW1STON1", "SW2STON1", 1},
54 {"SW1STON2", "SW2STON2", 1},
55 {"SW1STONE", "SW2STONE", 1},
56 {"SW1STRTN", "SW2STRTN", 1},
58 {"SW1BLUE", "SW2BLUE", 2},
59 {"SW1CMT", "SW2CMT", 2},
60 {"SW1GARG", "SW2GARG", 2},
61 {"SW1GSTON", "SW2GSTON", 2},
62 {"SW1HOT", "SW2HOT", 2},
63 {"SW1LION", "SW2LION", 2},
64 {"SW1SATYR", "SW2SATYR", 2},
65 {"SW1SKIN", "SW2SKIN", 2},
66 {"SW1VINE", "SW2VINE", 2},
67 {"SW1WOOD", "SW2WOOD", 2},
72 int switchlist[MAXSWITCHES * 2];
74 button_t buttonlist[MAXBUTTONS];
81 = Only called at game initialization
86 void P_InitSwitchList(void)
96 for (index = 0,i = 0;i < MAXSWITCHES;i++)
98 if (!alphSwitchList[i].episode)
100 numswitches = index/2;
101 switchlist[index] = -1;
105 if (alphSwitchList[i].episode <= episode)
107 switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1);
108 switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name2);
113 //==================================================================
115 // Start a button counting down till it turns off.
117 //==================================================================
118 void P_StartButton(line_t *line,bwhere_e w,int texture,int time)
122 for (i = 0;i < MAXBUTTONS;i++)
123 if (!buttonlist[i].btimer)
125 buttonlist[i].line = line;
126 buttonlist[i].where = w;
127 buttonlist[i].btexture = texture;
128 buttonlist[i].btimer = time;
129 buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg;
133 I_Error("P_StartButton: no button slots left!");
136 //==================================================================
138 // Function that changes wall texture.
139 // Tell it if switch is ok to use again (1=yes, it's a button).
141 //==================================================================
142 void P_ChangeSwitchTexture(line_t *line,int useAgain)
153 texTop = sides[line->sidenum[0]].toptexture;
154 texMid = sides[line->sidenum[0]].midtexture;
155 texBot = sides[line->sidenum[0]].bottomtexture;
158 //if (line->special == 11) // EXIT SWITCH?
159 // sound = sfx_swtchx;
161 for (i = 0;i < numswitches*2;i++)
162 if (switchlist[i] == texTop)
164 S_StartSound(buttonlist->soundorg,sound);
165 sides[line->sidenum[0]].toptexture = switchlist[i^1];
167 P_StartButton(line,top,switchlist[i],BUTTONTIME);
171 if (switchlist[i] == texMid)
173 S_StartSound(buttonlist->soundorg,sound);
174 sides[line->sidenum[0]].midtexture = switchlist[i^1];
176 P_StartButton(line, middle,switchlist[i],BUTTONTIME);
180 if (switchlist[i] == texBot)
182 S_StartSound(buttonlist->soundorg,sound);
183 sides[line->sidenum[0]].bottomtexture = switchlist[i^1];
185 P_StartButton(line, bottom,switchlist[i],BUTTONTIME);
191 ==============================================================================
195 = Called when a thing uses a special line
196 = Only the front sides of lines are usable
197 ===============================================================================
200 boolean P_UseSpecialLine ( mobj_t *thing, line_t *line)
203 // Switches that other things can activate
207 if (line->flags & ML_SECRET)
208 return false; // never open secret doors
209 switch(line->special)
211 case 1: // MANUAL DOOR RAISE
212 case 32: // MANUAL BLUE
213 case 33: // MANUAL RED
214 case 34: // MANUAL YELLOW
224 switch (line->special)
226 //===============================================
228 //===============================================
229 case 1: // Vertical Door
230 case 26: // Blue Door/Locked
231 case 27: // Yellow Door /Locked
232 case 28: // Red Door /Locked
234 case 31: // Manual door open
235 case 32: // Blue locked door open
236 case 33: // Red locked door open
237 case 34: // Yellow locked door open
238 EV_VerticalDoor (line, thing);
240 //===============================================
242 //===============================================
243 case 7: // Switch_Build_Stairs (8 pixel steps)
244 if(EV_BuildStairs(line, 8*FRACUNIT))
246 P_ChangeSwitchTexture(line, 0);
249 case 107: // Switch_Build_Stairs_16 (16 pixel steps)
250 if(EV_BuildStairs(line, 16*FRACUNIT))
252 P_ChangeSwitchTexture(line, 0);
255 case 9: // Change Donut
256 if (EV_DoDonut(line))
257 P_ChangeSwitchTexture(line,0);
259 case 11: // Exit level
261 P_ChangeSwitchTexture(line,0);
263 case 14: // Raise Floor 32 and change texture
264 if (EV_DoPlat(line,raiseAndChange,32))
265 P_ChangeSwitchTexture(line,0);
267 case 15: // Raise Floor 24 and change texture
268 if (EV_DoPlat(line,raiseAndChange,24))
269 P_ChangeSwitchTexture(line,0);
271 case 18: // Raise Floor to next highest floor
272 if (EV_DoFloor(line, raiseFloorToNearest))
273 P_ChangeSwitchTexture(line,0);
275 case 20: // Raise Plat next highest floor and change texture
276 if (EV_DoPlat(line,raiseToNearestAndChange,0))
277 P_ChangeSwitchTexture(line,0);
279 case 21: // PlatDownWaitUpStay
280 if (EV_DoPlat(line,downWaitUpStay,0))
281 P_ChangeSwitchTexture(line,0);
283 case 23: // Lower Floor to Lowest
284 if (EV_DoFloor(line,lowerFloorToLowest))
285 P_ChangeSwitchTexture(line,0);
287 case 29: // Raise Door
288 if (EV_DoDoor(line,normal,VDOORSPEED))
289 P_ChangeSwitchTexture(line,0);
291 case 41: // Lower Ceiling to Floor
292 if (EV_DoCeiling(line,lowerToFloor))
293 P_ChangeSwitchTexture(line,0);
295 case 71: // Turbo Lower Floor
296 if (EV_DoFloor(line,turboLower))
297 P_ChangeSwitchTexture(line,0);
299 case 49: // Lower Ceiling And Crush
300 if (EV_DoCeiling(line,lowerAndCrush))
301 P_ChangeSwitchTexture(line,0);
303 case 50: // Close Door
304 if (EV_DoDoor(line,close,VDOORSPEED))
305 P_ChangeSwitchTexture(line,0);
307 case 51: // Secret EXIT
308 G_SecretExitLevel ();
309 P_ChangeSwitchTexture(line,0);
311 case 55: // Raise Floor Crush
312 if (EV_DoFloor(line,raiseFloorCrush))
313 P_ChangeSwitchTexture(line,0);
315 case 101: // Raise Floor
316 if (EV_DoFloor(line,raiseFloor))
317 P_ChangeSwitchTexture(line,0);
319 case 102: // Lower Floor to Surrounding floor height
320 if (EV_DoFloor(line,lowerFloor))
321 P_ChangeSwitchTexture(line,0);
323 case 103: // Open Door
324 if (EV_DoDoor(line,open,VDOORSPEED))
325 P_ChangeSwitchTexture(line,0);
327 //===============================================
329 //===============================================
330 case 42: // Close Door
331 if (EV_DoDoor(line,close,VDOORSPEED))
332 P_ChangeSwitchTexture(line,1);
334 case 43: // Lower Ceiling to Floor
335 if (EV_DoCeiling(line,lowerToFloor))
336 P_ChangeSwitchTexture(line,1);
338 case 45: // Lower Floor to Surrounding floor height
339 if (EV_DoFloor(line,lowerFloor))
340 P_ChangeSwitchTexture(line,1);
342 case 60: // Lower Floor to Lowest
343 if (EV_DoFloor(line,lowerFloorToLowest))
344 P_ChangeSwitchTexture(line,1);
346 case 61: // Open Door
347 if (EV_DoDoor(line,open,VDOORSPEED))
348 P_ChangeSwitchTexture(line,1);
350 case 62: // PlatDownWaitUpStay
351 if (EV_DoPlat(line,downWaitUpStay,1))
352 P_ChangeSwitchTexture(line,1);
354 case 63: // Raise Door
355 if (EV_DoDoor(line,normal,VDOORSPEED))
356 P_ChangeSwitchTexture(line,1);
358 case 64: // Raise Floor to ceiling
359 if (EV_DoFloor(line,raiseFloor))
360 P_ChangeSwitchTexture(line,1);
362 case 66: // Raise Floor 24 and change texture
363 if (EV_DoPlat(line,raiseAndChange,24))
364 P_ChangeSwitchTexture(line,1);
366 case 67: // Raise Floor 32 and change texture
367 if (EV_DoPlat(line,raiseAndChange,32))
368 P_ChangeSwitchTexture(line,1);
370 case 65: // Raise Floor Crush
371 if (EV_DoFloor(line,raiseFloorCrush))
372 P_ChangeSwitchTexture(line,1);
374 case 68: // Raise Plat to next highest floor and change texture
375 if (EV_DoPlat(line,raiseToNearestAndChange,0))
376 P_ChangeSwitchTexture(line,1);
378 case 69: // Raise Floor to next highest floor
379 if (EV_DoFloor(line, raiseFloorToNearest))
380 P_ChangeSwitchTexture(line,1);
382 case 70: // Turbo Lower Floor
383 if (EV_DoFloor(line,turboLower))
384 P_ChangeSwitchTexture(line,1);