diff --git a/Barotrauma/BarotraumaClient/ClientSource/Characters/Character.cs b/Barotrauma/BarotraumaClient/ClientSource/Characters/Character.cs index 23cd60f7f4..381863066c 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Characters/Character.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Characters/Character.cs @@ -1376,7 +1376,7 @@ public void PlaySound(CharacterSound.SoundType soundType, float soundIntervalFac } var selectedSound = matchingSounds.GetRandomUnsynced(); if (selectedSound?.Sound == null) { return; } - soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, AnimController.WorldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: CurrentHull, ignoreMuffling: selectedSound.IgnoreMuffling); + soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, AnimController.WorldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: CurrentHull, ignoreMuffling: selectedSound.IgnoreMuffling, freqMult: selectedSound.GetRandomFrequencyMultiplier()); soundTimer = Params.SoundInterval; } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterSound.cs b/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterSound.cs index 5f35749717..d89781f2b9 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterSound.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterSound.cs @@ -1,4 +1,5 @@ using Barotrauma.Sounds; +using Microsoft.Xna.Framework; using System.Collections.Immutable; namespace Barotrauma @@ -16,6 +17,8 @@ public enum SoundType public SoundType Type => Params.State; public ImmutableHashSet TagSet => Params.TagSet; public float Volume => roundSound == null ? 0.0f : roundSound.Volume; + + public Vector2 FrequencyMultiplierRange => roundSound == null ? new Vector2(1.0f) : roundSound.FrequencyMultiplierRange; public float Range => roundSound == null ? 0.0f : roundSound.Range; public Sound Sound => roundSound?.Sound; @@ -26,5 +29,10 @@ public CharacterSound(CharacterParams.SoundParams soundParams) Params = soundParams; roundSound = RoundSound.Load(soundParams.Element); } + + public float GetRandomFrequencyMultiplier() + { + return Rand.Range(FrequencyMultiplierRange.X, FrequencyMultiplierRange.Y); + } } } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Sounds/SoundChannel.cs b/Barotrauma/BarotraumaClient/ClientSource/Sounds/SoundChannel.cs index a67ad6feeb..ac0cfb24d4 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Sounds/SoundChannel.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Sounds/SoundChannel.cs @@ -276,7 +276,7 @@ public float FrequencyMultiplier { if (value is < MinFrequencyMultiplier or > MaxFrequencyMultiplier) { - DebugConsole.ThrowError($"Frequency multiplier out of range: {value}" + Environment.StackTrace.CleanupStackTrace()); + DebugConsole.ThrowError($"Frequency multiplier out of range: {value} . Minimum acceptable frequency value is {MinFrequencyMultiplier} , maximum acceptable frequency value is {MaxFrequencyMultiplier} ." + Environment.StackTrace.CleanupStackTrace()); } frequencyMultiplier = Math.Clamp(value, MinFrequencyMultiplier, MaxFrequencyMultiplier);