diff --git a/src/g_level.cpp b/src/g_level.cpp index 4909303a5..266820fab 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1854,6 +1854,7 @@ void FLevelLocals::Init() flags2 |= info->flags2; flags3 |= info->flags3; levelnum = info->levelnum; + LightningSound = info->LightningSound; Music = info->Music; musicorder = info->musicorder; MusicVolume = 1.f; diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 15ae2442e..9fac6276e 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -194,7 +194,7 @@ public: AActor *SpawnMapThing(int index, FMapThing *mt, int position); AActor *SpawnPlayer(FPlayerStart *mthing, int playernum, int flags = 0); void StartLightning(); - void ForceLightning(int mode); + void ForceLightning(int mode, const FString& tempSound = ""); void ClearDynamic3DFloorData(); void WorldDone(void); void AirControlChanged(); @@ -631,6 +631,7 @@ public: uint32_t hazardcolor; // what color strife hazard blends the screen color as uint32_t hazardflash; // what color strife hazard flashes the screen color as + FString LightningSound = "world/thunder"; FString Music; int musicorder; int cdtrack; diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 1b5b28784..dfe90b2c9 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -250,6 +250,7 @@ void level_info_t::Reset() else flags2 = LEVEL2_LAXMONSTERACTIVATION; flags3 = 0; + LightningSound = "world/thunder"; Music = ""; LevelName = ""; AuthorName = ""; @@ -997,6 +998,13 @@ DEFINE_MAP_OPTION(next, true) parse.ParseNextMap(info->NextMap); } +DEFINE_MAP_OPTION(lightningsound, true) +{ + parse.ParseAssign(); + parse.sc.MustGetString(); + info->LightningSound = parse.sc.String; +} + DEFINE_MAP_OPTION(author, true) { parse.ParseAssign(); diff --git a/src/gamedata/g_mapinfo.h b/src/gamedata/g_mapinfo.h index 427a32830..b56d3b632 100644 --- a/src/gamedata/g_mapinfo.h +++ b/src/gamedata/g_mapinfo.h @@ -344,6 +344,7 @@ struct level_info_t uint32_t flags2; uint32_t flags3; + FString LightningSound = "world/thunder"; FString Music; FString LevelName; FString AuthorName; diff --git a/src/playsim/mapthinkers/a_lightning.cpp b/src/playsim/mapthinkers/a_lightning.cpp index bcca1a520..0316d643f 100644 --- a/src/playsim/mapthinkers/a_lightning.cpp +++ b/src/playsim/mapthinkers/a_lightning.cpp @@ -48,11 +48,12 @@ IMPLEMENT_CLASS(DLightningThinker, false, false) // //---------------------------------------------------------------------------- -void DLightningThinker::Construct() +void DLightningThinker::Construct(const FString& tempSound) { Stopped = false; LightningFlashCount = 0; NextLightningFlash = ((pr_lightning()&15)+5)*TICRATE; // don't flash at level start + TempLightningSound = tempSound; LightningLightLevels.Resize(Level->sectors.Size()); fillshort(&LightningLightLevels[0], LightningLightLevels.Size(), SHRT_MAX); @@ -74,7 +75,8 @@ void DLightningThinker::Serialize(FSerializer &arc) arc("stopped", Stopped) ("next", NextLightningFlash) ("count", LightningFlashCount) - ("levels", LightningLightLevels); + ("levels", LightningLightLevels) + ("tempsound", TempLightningSound); } //---------------------------------------------------------------------------- @@ -177,7 +179,15 @@ void DLightningThinker::LightningFlash () } Level->flags |= LEVEL_SWAPSKIES; // set alternate sky - S_Sound (CHAN_AUTO, 0, "world/thunder", 1.0, ATTN_NONE); + if (TempLightningSound.IsEmpty()) + { + S_Sound(CHAN_AUTO, 0, Level->LightningSound, 1.0, ATTN_NONE); + } + else + { + S_Sound(CHAN_AUTO, 0, TempLightningSound, 1.0, ATTN_NONE); + TempLightningSound = ""; + } // [ZZ] just in case Level->localEventManager->WorldLightning(); // start LIGHTNING scripts @@ -210,16 +220,18 @@ void DLightningThinker::LightningFlash () // //---------------------------------------------------------------------------- -void DLightningThinker::ForceLightning (int mode) +void DLightningThinker::ForceLightning (int mode, const FString& tempSound) { switch (mode) { default: NextLightningFlash = 0; + TempLightningSound = tempSound; break; case 1: NextLightningFlash = 0; + TempLightningSound = tempSound; // Fall through case 2: Stopped = true; @@ -286,16 +298,16 @@ void FLevelLocals::StartLightning () // //---------------------------------------------------------------------------- -void FLevelLocals::ForceLightning (int mode) +void FLevelLocals::ForceLightning (int mode, const FString& tempSound) { DLightningThinker *lightning = LocateLightning (this); if (lightning == nullptr) { - lightning = CreateThinker(); + lightning = CreateThinker(tempSound); } if (lightning != nullptr) { - lightning->ForceLightning (mode); + lightning->ForceLightning (mode, tempSound); } } @@ -303,6 +315,7 @@ DEFINE_ACTION_FUNCTION(FLevelLocals, ForceLightning) { PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); PARAM_INT(mode); - self->ForceLightning(mode); + PARAM_STRING(tempSound); + self->ForceLightning(mode,tempSound); return 0; } \ No newline at end of file diff --git a/src/playsim/mapthinkers/a_lightning.h b/src/playsim/mapthinkers/a_lightning.h index 89992f620..502c76c64 100644 --- a/src/playsim/mapthinkers/a_lightning.h +++ b/src/playsim/mapthinkers/a_lightning.h @@ -12,11 +12,11 @@ class DLightningThinker : public DThinker DECLARE_CLASS (DLightningThinker, DThinker); public: static const int DEFAULT_STAT = STAT_LIGHTNING; - void Construct(); + void Construct(const FString& tempSound = ""); ~DLightningThinker (); void Serialize(FSerializer &arc); void Tick (); - void ForceLightning (int mode); + void ForceLightning (int mode, const FString& tempSound = ""); void TerminateLightning(); protected: @@ -25,6 +25,7 @@ protected: int NextLightningFlash; int LightningFlashCount; bool Stopped; + FString TempLightningSound; TArray LightningLightLevels; }; diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index ae191ecec..450d4552a 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -2764,6 +2764,7 @@ DEFINE_FIELD_X(LevelInfo, level_info_t, flags) DEFINE_FIELD_X(LevelInfo, level_info_t, flags2) DEFINE_FIELD_X(LevelInfo, level_info_t, flags3) DEFINE_FIELD_X(LevelInfo, level_info_t, Music) +DEFINE_FIELD_X(LevelInfo, level_info_t, LightningSound) DEFINE_FIELD_X(LevelInfo, level_info_t, LevelName) DEFINE_FIELD_X(LevelInfo, level_info_t, AuthorName) DEFINE_FIELD_X(LevelInfo, level_info_t, musicorder) @@ -2807,6 +2808,7 @@ DEFINE_FIELD(FLevelLocals, NextSecretMap) DEFINE_FIELD(FLevelLocals, F1Pic) DEFINE_FIELD(FLevelLocals, AuthorName) DEFINE_FIELD(FLevelLocals, maptype) +DEFINE_FIELD(FLevelLocals, LightningSound) DEFINE_FIELD(FLevelLocals, Music) DEFINE_FIELD(FLevelLocals, musicorder) DEFINE_FIELD(FLevelLocals, skytexture1) diff --git a/wadsrc/static/zscript/doombase.zs b/wadsrc/static/zscript/doombase.zs index cded9e3a8..058b3a245 100644 --- a/wadsrc/static/zscript/doombase.zs +++ b/wadsrc/static/zscript/doombase.zs @@ -337,6 +337,7 @@ struct LevelInfo native native readonly int flags; native readonly int flags2; native readonly int flags3; + native readonly String LightningSound; native readonly String Music; native readonly String LevelName; native readonly String AuthorName; @@ -428,6 +429,7 @@ struct LevelLocals native native readonly String F1Pic; native readonly int maptype; native readonly String AuthorName; + native String LightningSound; native readonly String Music; native readonly int musicorder; native readonly TextureID skytexture1; @@ -524,7 +526,7 @@ struct LevelLocals native native String GetChecksum() const; native void ChangeSky(TextureID sky1, TextureID sky2 ); - native void ForceLightning(int mode = 0); + native void ForceLightning(int mode = 0, string tempSound = ""); native SectorTagIterator CreateSectorTagIterator(int tag, line defline = null); native LineIdIterator CreateLineIdIterator(int tag);