10 #define MAX_AMBIENT_SFX 8 // Per level
16 afxcmd_play, // (sound)
17 afxcmd_playabsvol, // (sound, volume)
18 afxcmd_playrelvol, // (sound, volume)
19 afxcmd_delay, // (ticks)
20 afxcmd_delayrand, // (andbits)
26 int *LevelAmbientSfx[MAX_AMBIENT_SFX];
38 afxcmd_play, sfx_amb1,
43 afxcmd_play, sfx_amb2,
48 afxcmd_play, sfx_amb3,
51 afxcmd_play, sfx_amb7,
54 afxcmd_play, sfx_amb3,
57 afxcmd_play, sfx_amb7,
60 afxcmd_play, sfx_amb3,
63 afxcmd_play, sfx_amb7,
70 afxcmd_play, sfx_amb4,
72 afxcmd_playrelvol, sfx_amb11, -3,
74 afxcmd_playrelvol, sfx_amb4, -3,
76 afxcmd_playrelvol, sfx_amb11, -3,
78 afxcmd_playrelvol, sfx_amb4, -3,
80 afxcmd_playrelvol, sfx_amb11, -3,
82 afxcmd_playrelvol, sfx_amb4, -3,
84 afxcmd_playrelvol, sfx_amb11, -3,
89 afxcmd_play, sfx_amb5,
91 afxcmd_play, sfx_amb5,
93 afxcmd_play, sfx_amb5,
95 afxcmd_play, sfx_amb5,
100 afxcmd_play, sfx_amb6,
102 afxcmd_playrelvol, sfx_amb6, -8,
104 afxcmd_playrelvol, sfx_amb6, -8,
106 afxcmd_playrelvol, sfx_amb6, -8,
111 afxcmd_play, sfx_bstsit,
116 afxcmd_play, sfx_amb8,
121 afxcmd_play, sfx_amb9,
123 afxcmd_playrelvol, sfx_amb9, -4,
125 afxcmd_playrelvol, sfx_amb9, -4,
127 afxcmd_playrelvol, sfx_amb10, -4,
129 afxcmd_playrelvol, sfx_amb10, -4,
131 afxcmd_playrelvol, sfx_amb10, -4,
136 afxcmd_play, sfx_amb4,
138 afxcmd_playrelvol, sfx_amb11, -3,
140 afxcmd_playrelvol, sfx_amb4, -3,
142 afxcmd_playrelvol, sfx_amb11, -3,
144 afxcmd_playrelvol, sfx_amb4, -3,
146 afxcmd_playrelvol, sfx_amb11, -3,
148 afxcmd_playrelvol, sfx_amb4, -3,
150 afxcmd_playrelvol, sfx_amb11, -3,
156 AmbSndSeq1, // Scream
157 AmbSndSeq2, // Squish
159 AmbSndSeq4, // SlowFootsteps
160 AmbSndSeq5, // Heartbeat
164 AmbSndSeq9, // Laughter
165 AmbSndSeq10 // FastFootsteps
168 animdef_t animdefs[] =
172 {false, "FLTWAWA3", "FLTWAWA1", 8}, // Water
173 {false, "FLTSLUD3", "FLTSLUD1", 8}, // Sludge
174 {false, "FLTTELE4", "FLTTELE1", 6}, // Teleport
175 {false, "FLTFLWW3", "FLTFLWW1", 9}, // River - West
176 {false, "FLTLAVA4", "FLTLAVA1", 8}, // Lava
177 {false, "FLATHUH4", "FLATHUH1", 8}, // Super Lava
178 {true, "LAVAFL3", "LAVAFL1", 6}, // Texture: Lavaflow
179 {true, "WATRWAL3", "WATRWAL1", 4}, // Texture: Waterfall
183 anim_t anims[MAXANIMS];
191 } TerrainTypeDefs[] =
193 { "FLTWAWA1", FLOOR_WATER },
194 { "FLTFLWW1", FLOOR_WATER },
195 { "FLTLAVA1", FLOOR_LAVA },
196 { "FLATHUH1", FLOOR_LAVA },
197 { "FLTSLUD1", FLOOR_SLUDGE },
201 mobj_t LavaInflictor;
203 //----------------------------------------------------------------------------
207 //----------------------------------------------------------------------------
209 void P_InitLava(void)
211 memset(&LavaInflictor, 0, sizeof(mobj_t));
212 LavaInflictor.type = MT_PHOENIXFX2;
213 LavaInflictor.flags2 = MF2_FIREDAMAGE|MF2_NODMGTHRUST;
216 //----------------------------------------------------------------------------
218 // PROC P_InitTerrainTypes
220 //----------------------------------------------------------------------------
222 void P_InitTerrainTypes(void)
228 size = (numflats+1)*sizeof(int);
229 TerrainTypes = Z_Malloc(size, PU_STATIC, 0);
230 memset(TerrainTypes, 0, size);
231 for(i = 0; TerrainTypeDefs[i].type != -1; i++)
233 lump = W_CheckNumForName(TerrainTypeDefs[i].name);
236 TerrainTypes[lump-firstflat] = TerrainTypeDefs[i].type;
241 //----------------------------------------------------------------------------
243 // PROC P_InitPicAnims
245 //----------------------------------------------------------------------------
247 void P_InitPicAnims(void)
252 for(i = 0; animdefs[i].istexture != -1; i++)
254 if(animdefs[i].istexture)
255 { // Texture animation
256 if(R_CheckTextureNumForName(animdefs[i].startname) == -1)
257 { // Texture doesn't exist
260 lastanim->picnum = R_TextureNumForName(animdefs[i].endname);
261 lastanim->basepic = R_TextureNumForName(animdefs[i].startname);
265 if(W_CheckNumForName(animdefs[i].startname) == -1)
266 { // Flat doesn't exist
269 lastanim->picnum = R_FlatNumForName(animdefs[i].endname);
270 lastanim->basepic = R_FlatNumForName(animdefs[i].startname);
272 lastanim->istexture = animdefs[i].istexture;
273 lastanim->numpics = lastanim->picnum-lastanim->basepic+1;
274 if(lastanim->numpics < 2)
276 I_Error("P_InitPicAnims: bad cycle from %s to %s",
277 animdefs[i].startname, animdefs[i].endname);
279 lastanim->speed = animdefs[i].speed;
285 ==============================================================================
289 ==============================================================================
293 // Will return a side_t* given the number of the current sector,
294 // the line number, and the side (0/1) that you want.
296 side_t *getSide(int currentSector,int line, int side)
298 return &sides[ (sectors[currentSector].lines[line])->sidenum[side] ];
302 // Will return a sector_t* given the number of the current sector,
303 // the line number and the side (0/1) that you want.
305 sector_t *getSector(int currentSector,int line,int side)
307 return sides[ (sectors[currentSector].lines[line])->sidenum[side] ].sector;
311 // Given the sector number and the line number, will tell you whether
312 // the line is two-sided or not.
314 int twoSided(int sector,int line)
316 return (sectors[sector].lines[line])->flags & ML_TWOSIDED;
319 //==================================================================
321 // Return sector_t * of sector next to current. NULL if not two-sided line
323 //==================================================================
324 sector_t *getNextSector(line_t *line,sector_t *sec)
326 if (!(line->flags & ML_TWOSIDED))
329 if (line->frontsector == sec)
330 return line->backsector;
332 return line->frontsector;
335 //==================================================================
337 // FIND LOWEST FLOOR HEIGHT IN SURROUNDING SECTORS
339 //==================================================================
340 fixed_t P_FindLowestFloorSurrounding(sector_t *sec)
345 fixed_t floor = sec->floorheight;
347 for (i=0 ;i < sec->linecount ; i++)
349 check = sec->lines[i];
350 other = getNextSector(check,sec);
353 if (other->floorheight < floor)
354 floor = other->floorheight;
359 //==================================================================
361 // FIND HIGHEST FLOOR HEIGHT IN SURROUNDING SECTORS
363 //==================================================================
364 fixed_t P_FindHighestFloorSurrounding(sector_t *sec)
369 fixed_t floor = -500*FRACUNIT;
371 for (i=0 ;i < sec->linecount ; i++)
373 check = sec->lines[i];
374 other = getNextSector(check,sec);
377 if (other->floorheight > floor)
378 floor = other->floorheight;
383 //==================================================================
385 // FIND NEXT HIGHEST FLOOR IN SURROUNDING SECTORS
387 //==================================================================
388 fixed_t P_FindNextHighestFloor(sector_t *sec,int currentheight)
395 fixed_t height = currentheight;
396 fixed_t heightlist[20]; // 20 adjoining sectors max!
398 for (i =0,h = 0 ;i < sec->linecount ; i++)
400 check = sec->lines[i];
401 other = getNextSector(check,sec);
404 if (other->floorheight > height)
405 heightlist[h++] = other->floorheight;
409 // Find lowest height in list
412 for (i = 1;i < h;i++)
413 if (heightlist[i] < min)
419 //==================================================================
421 // FIND LOWEST CEILING IN THE SURROUNDING SECTORS
423 //==================================================================
424 fixed_t P_FindLowestCeilingSurrounding(sector_t *sec)
429 fixed_t height = MAXINT;
431 for (i=0 ;i < sec->linecount ; i++)
433 check = sec->lines[i];
434 other = getNextSector(check,sec);
437 if (other->ceilingheight < height)
438 height = other->ceilingheight;
443 //==================================================================
445 // FIND HIGHEST CEILING IN THE SURROUNDING SECTORS
447 //==================================================================
448 fixed_t P_FindHighestCeilingSurrounding(sector_t *sec)
455 for (i=0 ;i < sec->linecount ; i++)
457 check = sec->lines[i];
458 other = getNextSector(check,sec);
461 if (other->ceilingheight > height)
462 height = other->ceilingheight;
467 //==================================================================
469 // RETURN NEXT SECTOR # THAT LINE TAG REFERS TO
471 //==================================================================
472 int P_FindSectorFromLineTag(line_t *line,int start)
476 for (i=start+1;i<numsectors;i++)
477 if (sectors[i].tag == line->tag)
482 //==================================================================
484 // Find minimum light from an adjacent sector
486 //==================================================================
487 int P_FindMinSurroundingLight(sector_t *sector,int max)
495 for (i=0 ; i < sector->linecount ; i++)
497 line = sector->lines[i];
498 check = getNextSector(line,sector);
501 if (check->lightlevel < min)
502 min = check->lightlevel;
508 ==============================================================================
512 Events are operations triggered by using, crossing, or shooting special lines, or by timed thinkers
514 ==============================================================================
520 ===============================================================================
522 = P_CrossSpecialLine - TRIGGER
524 = Called every time a thing origin is about to cross
525 = a line with a non 0 special
527 ===============================================================================
530 void P_CrossSpecialLine(int linenum, int side, mobj_t *thing)
534 line = &lines[linenum];
536 { // Check if trigger allowed by non-player mobj
537 switch(line->special)
539 case 39: // Trigger_TELEPORT
540 case 97: // Retrigger_TELEPORT
541 case 4: // Trigger_Raise_Door
542 //case 10: // PLAT DOWN-WAIT-UP-STAY TRIGGER
543 //case 88: // PLAT DOWN-WAIT-UP-STAY RETRIGGER
550 switch(line->special)
552 //====================================================
554 //====================================================
556 EV_DoDoor(line,open,VDOORSPEED);
559 case 3: // Close Door
560 EV_DoDoor(line,close,VDOORSPEED);
563 case 4: // Raise Door
564 EV_DoDoor(line,normal,VDOORSPEED);
567 case 5: // Raise Floor
568 EV_DoFloor(line,raiseFloor);
571 case 6: // Fast Ceiling Crush & Raise
572 EV_DoCeiling(line,fastCrushAndRaise);
575 case 8: // Trigger_Build_Stairs (8 pixel steps)
576 EV_BuildStairs(line, 8*FRACUNIT);
579 case 106: // Trigger_Build_Stairs_16 (16 pixel steps)
580 EV_BuildStairs(line, 16*FRACUNIT);
583 case 10: // PlatDownWaitUp
584 EV_DoPlat(line,downWaitUpStay,0);
587 case 12: // Light Turn On - brightest near
588 EV_LightTurnOn(line,0);
591 case 13: // Light Turn On 255
592 EV_LightTurnOn(line,255);
595 case 16: // Close Door 30
596 EV_DoDoor(line,close30ThenOpen,VDOORSPEED);
599 case 17: // Start Light Strobing
600 EV_StartLightStrobing(line);
603 case 19: // Lower Floor
604 EV_DoFloor(line,lowerFloor);
607 case 22: // Raise floor to nearest height and change texture
608 EV_DoPlat(line,raiseToNearestAndChange,0);
611 case 25: // Ceiling Crush and Raise
612 EV_DoCeiling(line,crushAndRaise);
615 case 30: // Raise floor to shortest texture height
616 // on either side of lines
617 EV_DoFloor(line,raiseToTexture);
620 case 35: // Lights Very Dark
621 EV_LightTurnOn(line,35);
624 case 36: // Lower Floor (TURBO)
625 EV_DoFloor(line,turboLower);
628 case 37: // LowerAndChange
629 EV_DoFloor(line,lowerAndChange);
632 case 38: // Lower Floor To Lowest
633 EV_DoFloor( line, lowerFloorToLowest );
636 case 39: // TELEPORT!
637 EV_Teleport( line, side, thing );
640 case 40: // RaiseCeilingLowerFloor
641 EV_DoCeiling( line, raiseToHighest );
642 EV_DoFloor( line, lowerFloorToLowest );
645 case 44: // Ceiling Crush
646 EV_DoCeiling( line, lowerAndCrush );
653 case 53: // Perpetual Platform Raise
654 EV_DoPlat(line,perpetualRaise,0);
657 case 54: // Platform Stop
661 case 56: // Raise Floor Crush
662 EV_DoFloor(line,raiseFloorCrush);
665 case 57: // Ceiling Crush Stop
666 EV_CeilingCrushStop(line);
669 case 58: // Raise Floor 24
670 EV_DoFloor(line,raiseFloor24);
673 case 59: // Raise Floor 24 And Change
674 EV_DoFloor(line,raiseFloor24AndChange);
677 case 104: // Turn lights off in sector(tag)
678 EV_TurnTagLightsOff(line);
681 case 105: // Trigger_SecretExit
686 //====================================================
687 // RE-DOABLE TRIGGERS
688 //====================================================
690 case 72: // Ceiling Crush
691 EV_DoCeiling( line, lowerAndCrush );
693 case 73: // Ceiling Crush and Raise
694 EV_DoCeiling(line,crushAndRaise);
696 case 74: // Ceiling Crush Stop
697 EV_CeilingCrushStop(line);
699 case 75: // Close Door
700 EV_DoDoor(line,close,VDOORSPEED);
702 case 76: // Close Door 30
703 EV_DoDoor(line,close30ThenOpen,VDOORSPEED);
705 case 77: // Fast Ceiling Crush & Raise
706 EV_DoCeiling(line,fastCrushAndRaise);
708 case 79: // Lights Very Dark
709 EV_LightTurnOn(line,35);
711 case 80: // Light Turn On - brightest near
712 EV_LightTurnOn(line,0);
714 case 81: // Light Turn On 255
715 EV_LightTurnOn(line,255);
717 case 82: // Lower Floor To Lowest
718 EV_DoFloor( line, lowerFloorToLowest );
720 case 83: // Lower Floor
721 EV_DoFloor(line,lowerFloor);
723 case 84: // LowerAndChange
724 EV_DoFloor(line,lowerAndChange);
726 case 86: // Open Door
727 EV_DoDoor(line,open,VDOORSPEED);
729 case 87: // Perpetual Platform Raise
730 EV_DoPlat(line,perpetualRaise,0);
732 case 88: // PlatDownWaitUp
733 EV_DoPlat(line,downWaitUpStay,0);
735 case 89: // Platform Stop
738 case 90: // Raise Door
739 EV_DoDoor(line,normal,VDOORSPEED);
741 case 100: // Retrigger_Raise_Door_Turbo
742 EV_DoDoor(line, normal, VDOORSPEED*3);
744 case 91: // Raise Floor
745 EV_DoFloor(line,raiseFloor);
747 case 92: // Raise Floor 24
748 EV_DoFloor(line,raiseFloor24);
750 case 93: // Raise Floor 24 And Change
751 EV_DoFloor(line,raiseFloor24AndChange);
753 case 94: // Raise Floor Crush
754 EV_DoFloor(line,raiseFloorCrush);
756 case 95: // Raise floor to nearest height and change texture
757 EV_DoPlat(line,raiseToNearestAndChange,0);
759 case 96: // Raise floor to shortest texture height
760 // on either side of lines
761 EV_DoFloor(line,raiseToTexture);
763 case 97: // TELEPORT!
764 EV_Teleport( line, side, thing );
766 case 98: // Lower Floor (TURBO)
767 EV_DoFloor(line,turboLower);
772 //----------------------------------------------------------------------------
774 // PROC P_ShootSpecialLine
776 // Called when a thing shoots a special line.
778 //----------------------------------------------------------------------------
780 void P_ShootSpecialLine(mobj_t *thing, line_t *line)
783 { // Check if trigger allowed by non-player mobj
784 switch(line->special)
786 case 46: // Impact_OpenDoor
793 switch(line->special)
795 case 24: // Impact_RaiseFloor
796 EV_DoFloor(line, raiseFloor);
797 P_ChangeSwitchTexture(line, 0);
799 case 46: // Impact_OpenDoor
800 EV_DoDoor(line, open, VDOORSPEED);
801 P_ChangeSwitchTexture(line, 1);
803 case 47: // Impact_RaiseFloorNear&Change
804 EV_DoPlat(line, raiseToNearestAndChange, 0);
805 P_ChangeSwitchTexture(line, 0);
810 //----------------------------------------------------------------------------
812 // PROC P_PlayerInSpecialSector
814 // Called every tic frame that the player origin is in a special sector.
816 //----------------------------------------------------------------------------
818 void P_PlayerInSpecialSector(player_t *player)
821 static int pushTab[5] = {
829 sector = player->mo->subsector->sector;
830 if(player->mo->z != sector->floorheight)
831 { // Player is not touching the floor
834 switch(sector->special)
836 case 7: // Damage_Sludge
839 P_DamageMobj(player->mo, NULL, NULL, 4);
842 case 5: // Damage_LavaWimpy
845 P_DamageMobj(player->mo, &LavaInflictor, NULL, 5);
846 P_HitFloor(player->mo);
849 case 16: // Damage_LavaHefty
852 P_DamageMobj(player->mo, &LavaInflictor, NULL, 8);
853 P_HitFloor(player->mo);
856 case 4: // Scroll_EastLavaDamage
857 P_Thrust(player, 0, 2048*28);
860 P_DamageMobj(player->mo, &LavaInflictor, NULL, 5);
861 P_HitFloor(player->mo);
864 case 9: // SecretArea
865 player->secretcount++;
868 case 11: // Exit_SuperDamage (DOOM E1M8 finale)
870 player->cheats &= ~CF_GODMODE;
871 if(!(leveltime&0x1f))
873 P_DamageMobj(player->mo, NULL, NULL, 20);
875 if(player->health <= 10)
882 case 25: case 26: case 27: case 28: case 29: // Scroll_North
883 P_Thrust(player, ANG90, pushTab[sector->special-25]);
885 case 20: case 21: case 22: case 23: case 24: // Scroll_East
886 P_Thrust(player, 0, pushTab[sector->special-20]);
888 case 30: case 31: case 32: case 33: case 34: // Scroll_South
889 P_Thrust(player, ANG270, pushTab[sector->special-30]);
891 case 35: case 36: case 37: case 38: case 39: // Scroll_West
892 P_Thrust(player, ANG180, pushTab[sector->special-35]);
895 case 40: case 41: case 42: case 43: case 44: case 45:
896 case 46: case 47: case 48: case 49: case 50: case 51:
897 // Wind specials are handled in (P_mobj):P_XYMovement
900 case 15: // Friction_Low
901 // Only used in (P_mobj):P_XYMovement and (P_user):P_Thrust
905 I_Error("P_PlayerInSpecialSector: "
906 "unknown special %i", sector->special);
910 //----------------------------------------------------------------------------
912 // PROC P_UpdateSpecials
914 // Animate planes, scroll walls, etc.
916 //----------------------------------------------------------------------------
918 void P_UpdateSpecials(void)
925 // Animate flats and textures
926 for(anim = anims; anim < lastanim; anim++)
928 for(i = anim->basepic; i < anim->basepic+anim->numpics; i++)
930 pic = anim->basepic+((leveltime/anim->speed+i)%anim->numpics);
933 texturetranslation[i] = pic;
937 flattranslation[i] = pic;
941 // Update scrolling texture offsets
942 for(i = 0; i < numlinespecials; i++)
944 line = linespeciallist[i];
945 switch(line->special)
947 case 48: // Effect_Scroll_Left
948 sides[line->sidenum[0]].textureoffset += FRACUNIT;
950 case 99: // Effect_Scroll_Right
951 sides[line->sidenum[0]].textureoffset -= FRACUNIT;
956 for(i = 0; i < MAXBUTTONS; i++)
958 if(buttonlist[i].btimer)
960 buttonlist[i].btimer--;
961 if(!buttonlist[i].btimer)
963 switch(buttonlist[i].where)
966 sides[buttonlist[i].line->sidenum[0]].toptexture =
967 buttonlist[i].btexture;
970 sides[buttonlist[i].line->sidenum[0]].midtexture =
971 buttonlist[i].btexture;
974 sides[buttonlist[i].line->sidenum[0]].bottomtexture =
975 buttonlist[i].btexture;
978 S_StartSound((mobj_t *)&buttonlist[i].soundorg, sfx_switch);
979 memset(&buttonlist[i], 0, sizeof(button_t));
985 //============================================================
987 // Special Stuff that can't be categorized
989 //============================================================
990 int EV_DoDonut(line_t *line)
1002 while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
1004 s1 = §ors[secnum];
1006 // ALREADY MOVING? IF SO, KEEP GOING...
1007 if (s1->specialdata)
1011 s2 = getNextSector(s1->lines[0],s1);
1012 for (i = 0;i < s2->linecount;i++)
1014 if ((!s2->lines[i]->flags & ML_TWOSIDED) ||
1015 (s2->lines[i]->backsector == s1))
1017 s3 = s2->lines[i]->backsector;
1020 // Spawn rising slime
1022 floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
1023 P_AddThinker (&floor->thinker);
1024 s2->specialdata = floor;
1025 floor->thinker.function = T_MoveFloor;
1026 floor->type = donutRaise;
1027 floor->crush = false;
1028 floor->direction = 1;
1030 floor->speed = FLOORSPEED / 2;
1031 floor->texture = s3->floorpic;
1032 floor->newspecial = 0;
1033 floor->floordestheight = s3->floorheight;
1036 // Spawn lowering donut-hole
1038 floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
1039 P_AddThinker (&floor->thinker);
1040 s1->specialdata = floor;
1041 floor->thinker.function = T_MoveFloor;
1042 floor->type = lowerFloor;
1043 floor->crush = false;
1044 floor->direction = -1;
1046 floor->speed = FLOORSPEED / 2;
1047 floor->floordestheight = s3->floorheight;
1055 ==============================================================================
1059 ==============================================================================
1062 ================================================================================
1065 = After the map has been loaded, scan for specials that
1068 ===============================================================================
1071 short numlinespecials;
1072 line_t *linespeciallist[MAXLINEANIMS];
1074 void P_SpawnSpecials (void)
1081 if (W_CheckNumForName("texture2") >= 0)
1085 // Init special SECTORs
1088 for (i=0 ; i<numsectors ; i++, sector++)
1090 if (!sector->special)
1092 switch (sector->special)
1094 case 1: // FLICKERING LIGHTS
1095 P_SpawnLightFlash (sector);
1097 case 2: // STROBE FAST
1098 P_SpawnStrobeFlash(sector,FASTDARK,0);
1100 case 3: // STROBE SLOW
1101 P_SpawnStrobeFlash(sector,SLOWDARK,0);
1103 case 4: // STROBE FAST/DEATH SLIME
1104 P_SpawnStrobeFlash(sector,FASTDARK,0);
1105 sector->special = 4;
1107 case 8: // GLOWING LIGHT
1108 P_SpawnGlowingLight(sector);
1110 case 9: // SECRET SECTOR
1113 case 10: // DOOR CLOSE IN 30 SECONDS
1114 P_SpawnDoorCloseIn30 (sector);
1116 case 12: // SYNC STROBE SLOW
1117 P_SpawnStrobeFlash (sector, SLOWDARK, 1);
1119 case 13: // SYNC STROBE FAST
1120 P_SpawnStrobeFlash (sector, FASTDARK, 1);
1122 case 14: // DOOR RAISE IN 5 MINUTES
1123 P_SpawnDoorRaiseIn5Mins (sector, i);
1130 // Init line EFFECTs
1132 numlinespecials = 0;
1133 for (i = 0;i < numlines; i++)
1134 switch(lines[i].special)
1136 case 48: // Effect_Scroll_Left
1137 case 99: // Effect_Scroll_Right
1138 linespeciallist[numlinespecials] = &lines[i];
1144 // Init other misc stuff
1146 for (i = 0;i < MAXCEILINGS;i++)
1147 activeceilings[i] = NULL;
1148 for (i = 0;i < MAXPLATS;i++)
1149 activeplats[i] = NULL;
1150 for (i = 0;i < MAXBUTTONS;i++)
1151 memset(&buttonlist[i],0,sizeof(button_t));
1154 //----------------------------------------------------------------------------
1156 // PROC P_InitAmbientSound
1158 //----------------------------------------------------------------------------
1160 void P_InitAmbientSound(void)
1164 AmbSfxTics = 10*TICSPERSEC;
1165 AmbSfxPtr = AmbSndSeqInit;
1168 //----------------------------------------------------------------------------
1170 // PROC P_AddAmbientSfx
1172 // Called by (P_mobj):P_SpawnMapThing during (P_setup):P_SetupLevel.
1174 //----------------------------------------------------------------------------
1176 void P_AddAmbientSfx(int sequence)
1178 if(AmbSfxCount == MAX_AMBIENT_SFX)
1180 I_Error("Too many ambient sound sequences");
1182 LevelAmbientSfx[AmbSfxCount++] = AmbientSfx[sequence];
1185 //----------------------------------------------------------------------------
1187 // PROC P_AmbientSound
1189 // Called every tic by (P_tick):P_Ticker.
1191 //----------------------------------------------------------------------------
1193 void P_AmbientSound(void)
1200 { // No ambient sound sequences on current level
1214 AmbSfxVolume = P_Random()>>2;
1215 S_StartSoundAtVolume(NULL, *AmbSfxPtr++, AmbSfxVolume);
1217 case afxcmd_playabsvol:
1218 sound = *AmbSfxPtr++;
1219 AmbSfxVolume = *AmbSfxPtr++;
1220 S_StartSoundAtVolume(NULL, sound, AmbSfxVolume);
1222 case afxcmd_playrelvol:
1223 sound = *AmbSfxPtr++;
1224 AmbSfxVolume += *AmbSfxPtr++;
1225 if(AmbSfxVolume < 0)
1229 else if(AmbSfxVolume > 127)
1233 S_StartSoundAtVolume(NULL, sound, AmbSfxVolume);
1236 AmbSfxTics = *AmbSfxPtr++;
1239 case afxcmd_delayrand:
1240 AmbSfxTics = P_Random()&(*AmbSfxPtr++);
1244 AmbSfxTics = 6*TICSPERSEC+P_Random();
1245 AmbSfxPtr = LevelAmbientSfx[P_Random()%AmbSfxCount];
1249 I_Error("P_AmbientSound: Unknown afxcmd %d", cmd);
1252 } while(done == false);