diff --git a/Assets/Gothic-Core/Scripts/Adapters/Animations/AnimationSystem.cs b/Assets/Gothic-Core/Scripts/Adapters/Animations/AnimationSystem.cs index ad2b69016..dcc5c5551 100644 --- a/Assets/Gothic-Core/Scripts/Adapters/Animations/AnimationSystem.cs +++ b/Assets/Gothic-Core/Scripts/Adapters/Animations/AnimationSystem.cs @@ -953,7 +953,7 @@ private void ApplySfxEvents(AnimationTrackInstance trackInstance) var clip = _audioService.GetRandomSoundClip(sfx.Name); PrefabProps.NpcSound.clip = clip; - PrefabProps.NpcSound.maxDistance = sfx.Range.ToMeter(); + PrefabProps.NpcSound.maxDistance = _audioService.GetSfxRangeMeters(sfx.Name, sfx.Range.ToMeter()); PrefabProps.NpcSound.Play(); } } diff --git a/Assets/Gothic-Core/Scripts/Services/Audio/AudioService.cs b/Assets/Gothic-Core/Scripts/Services/Audio/AudioService.cs index c45056171..306e5d4e4 100644 --- a/Assets/Gothic-Core/Scripts/Services/Audio/AudioService.cs +++ b/Assets/Gothic-Core/Scripts/Services/Audio/AudioService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Gothic.Core.Domain.Audio; using Gothic.Core.Logging; @@ -40,6 +41,13 @@ public class AudioService private readonly SoundDomain _soundDomain = new SoundDomain().Inject(); + // Animation sounds that carry further than their *eventSFX range (R:). Finite list, all others keep theirs. + private static readonly Dictionary _sfxRangeOverridesMeters = + new(StringComparer.OrdinalIgnoreCase) + { + { "HAMMER", 24f } + }; + private AudioSource _scriptSoundSource; public SoundEffectInstance InvOpen => _vmCacheService.TryGetSfxData("INV_OPEN").GetFirstSound(); @@ -169,6 +177,20 @@ public void SetScriptSoundSource(AudioSource audioSource) _scriptSoundSource = audioSource; } + /// + /// Range (m) in which an animation sound (*eventSFX) is audible: the override of the few sounds that carry + /// further than Gothic's range, else Gothic's own. + /// Chosen in play: Fellan's hammering (R:1000 = 10 m) must reach Alwin's sheep pen ~18 m away (his quest asks + /// whether you hear it); 60 m was heard across the harbour, 24 m reaches the pen. Unity's linear rolloff is + /// quiet long before Gothic's range is felt; a general rolloff change is a follow-up. + /// + public float GetSfxRangeMeters(string sfxName, float gothicRangeMeters) + { + return _sfxRangeOverridesMeters.TryGetValue(sfxName, out var overrideMeters) + ? overrideMeters + : gothicRangeMeters; + } + /// /// Non-positional sound, e.g. Daedalus Snd_Play("LogEntry"). ///