diff --git a/source/core/vmexports.cpp b/source/core/vmexports.cpp index 67383b5dc..765acad2b 100644 --- a/source/core/vmexports.cpp +++ b/source/core/vmexports.cpp @@ -75,6 +75,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, SetReverbDelay, FX_SetReverbDelay) return 0; } +int Raze_FindSoundByResID(int id) +{ + return soundEngine->FindSoundByResID(id).index(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Raze, FindSoundByResID, Raze_FindSoundByResID) +{ + PARAM_PROLOGUE; + PARAM_INT(i); + ACTION_RETURN_INT(Raze_FindSoundByResID(i)); +} + //============================================================================= // // internal sector struct - no longer identical with on-disk format diff --git a/wadsrc/static/zscript/games/duke/actors/soundcontroller.zs b/wadsrc/static/zscript/games/duke/actors/soundcontroller.zs index ca62f5ba8..01c37ae87 100644 --- a/wadsrc/static/zscript/games/duke/actors/soundcontroller.zs +++ b/wadsrc/static/zscript/games/duke/actors/soundcontroller.zs @@ -57,7 +57,7 @@ class DukeSoundController : DukeActor if (distance < maxdist && self.temp_data[0] == 0) { // Start playing an ambience sound. - self.PlayActorSound(self.lotag, CHAN_AUTO, CHANF_LOOP); + self.PlayActorSound(Raze.FindSoundByResID(self.lotag), CHAN_AUTO, CHANF_LOOP); self.temp_data[0] = 1; // AMBIENT_SFX_PLAYING } else if (distance >= maxdist && self.temp_data[0] == 1) @@ -72,7 +72,7 @@ class DukeSoundController : DukeActor if (self.temp_data[4] > 0) self.temp_data[4]--; else if (sec == p.actor.sector) { - Duke.PlaySound(self.lotag + uint(Duke.global_random()) % uint(self.hitag + 1)); + Duke.PlaySound(Raze.FindSoundByResID(self.lotag + uint(Duke.global_random()) % uint(self.hitag + 1))); self.temp_data[4] = 26 * 40 + (Duke.global_random() % (26 * 40)); } } diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index c5fd4cb22..bff836bbf 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -153,6 +153,7 @@ struct Raze native static int SoundEnabled(); native static void SetReverb(int r); native static void SetReverbDelay(int d); + native static Sound FindSoundByResID(int id); native static sectortype updatesector(Vector2 pos, sectortype lastsect, double maxdist = 96);