diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 69ca13f16..40629bfcb 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -1021,7 +1021,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_PlaySound) if (!looping) { - S_PlaySound(self, channel, soundid, (float)volume, (float)attenuation, local); + if (!(channel & CHAN_NOSTOP) || !S_IsActorPlayingSomething(self, channel & 7, soundid)) + { + S_PlaySound(self, channel, soundid, (float)volume, (float)attenuation, local); + } } else { diff --git a/src/s_sound.h b/src/s_sound.h index d6d2a5403..00c7d0587 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -284,6 +284,7 @@ void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool #define CHAN_JUSTSTARTED 512 // internal: Sound has not been updated yet. #define CHAN_ABSTIME 1024// internal: Start time is absolute and does not depend on current time. #define CHAN_VIRTUAL 2048// internal: Channel is currently virtual +#define CHAN_NOSTOP 4096// only for A_PlaySound. Does not start if channel is playing something. // sound attenuation values #define ATTN_NONE 0.f // full volume the entire level diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt index ef2c4521f..6996da6cc 100644 --- a/wadsrc/static/zscript/constants.txt +++ b/wadsrc/static/zscript/constants.txt @@ -413,7 +413,8 @@ enum ESoundFlags CHAN_MAYBE_LOCAL = 16, CHAN_UI = 32, CHAN_NOPAUSE = 64, - CHAN_PICKUP = (CHAN_ITEM|CHAN_MAYBE_LOCAL) + CHAN_PICKUP = (CHAN_ITEM|CHAN_MAYBE_LOCAL), + CHAN_NOSTOP = 4096 }; diff --git a/wadsrc/static/zscript/hexen/magelightning.txt b/wadsrc/static/zscript/hexen/magelightning.txt index 343c96012..d45162d49 100644 --- a/wadsrc/static/zscript/hexen/magelightning.txt +++ b/wadsrc/static/zscript/hexen/magelightning.txt @@ -124,7 +124,7 @@ class Lightning : Actor if ((!thing.player && !thing.bBoss) || !(level.time&1)) { thing.DamageMobj(self, target, 3, 'Electric'); - A_PlaySound(AttackSound, CHAN_WEAPON, 1, true); + A_PlaySound(AttackSound, CHAN_WEAPON|CHAN_NOSTOP, 1, false); if (thing.bIsMonster && random[LightningHit]() < 64) { thing.Howl ();