diff --git a/Content.Server/Chat/Systems/ChatSystem.Emote.cs b/Content.Server/Chat/Systems/ChatSystem.Emote.cs
index 707a0e0dc5..75acd2493b 100644
--- a/Content.Server/Chat/Systems/ChatSystem.Emote.cs
+++ b/Content.Server/Chat/Systems/ChatSystem.Emote.cs
@@ -1,6 +1,7 @@
using System.Collections.Frozen;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Speech;
+using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -126,16 +127,16 @@ public partial class ChatSystem
/// Tries to find and play relevant emote sound in emote sounds collection.
///
/// True if emote sound was played.
- public bool TryPlayEmoteSound(EntityUid uid, EmoteSoundsPrototype? proto, EmotePrototype emote)
+ public bool TryPlayEmoteSound(EntityUid uid, EmoteSoundsPrototype? proto, EmotePrototype emote, AudioParams? audioParams = null)
{
- return TryPlayEmoteSound(uid, proto, emote.ID);
+ return TryPlayEmoteSound(uid, proto, emote.ID, audioParams);
}
///
/// Tries to find and play relevant emote sound in emote sounds collection.
///
/// True if emote sound was played.
- public bool TryPlayEmoteSound(EntityUid uid, EmoteSoundsPrototype? proto, string emoteId)
+ public bool TryPlayEmoteSound(EntityUid uid, EmoteSoundsPrototype? proto, string emoteId, AudioParams? audioParams = null)
{
if (proto == null)
return false;
@@ -149,8 +150,8 @@ public partial class ChatSystem
return false;
}
- // if general params for all sounds set - use them
- var param = proto.GeneralParams ?? sound.Params;
+ // optional override params > general params for all sounds in set > individual sound params
+ var param = audioParams ?? proto.GeneralParams ?? sound.Params;
_audio.PlayPvs(sound, uid, param);
return true;
}
diff --git a/Content.Server/Speech/Components/MumbleAccentComponent.cs b/Content.Server/Speech/Components/MumbleAccentComponent.cs
index 0681ebab2f..2577859b15 100644
--- a/Content.Server/Speech/Components/MumbleAccentComponent.cs
+++ b/Content.Server/Speech/Components/MumbleAccentComponent.cs
@@ -1,7 +1,14 @@
+using Robust.Shared.Audio;
+
namespace Content.Server.Speech.Components;
[RegisterComponent]
public sealed partial class MumbleAccentComponent : Component
{
-
+ ///
+ /// This modifies the audio parameters of emote sounds, screaming, laughing, etc.
+ /// By default, it reduces the volume and distance of emote sounds.
+ ///
+ [DataField]
+ public AudioParams EmoteAudioParams = AudioParams.Default.WithVolume(-8f).WithMaxDistance(5);
}
diff --git a/Content.Server/Speech/EntitySystems/MumbleAccentSystem.cs b/Content.Server/Speech/EntitySystems/MumbleAccentSystem.cs
index 757f31ad9e..6b1af5c227 100644
--- a/Content.Server/Speech/EntitySystems/MumbleAccentSystem.cs
+++ b/Content.Server/Speech/EntitySystems/MumbleAccentSystem.cs
@@ -1,9 +1,13 @@
+using Content.Server.Chat.Systems;
using Content.Server.Speech.Components;
+using Content.Shared.Chat.Prototypes;
+using Content.Shared.Speech.Components;
namespace Content.Server.Speech.EntitySystems;
public sealed class MumbleAccentSystem : EntitySystem
{
+ [Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
public override void Initialize()
@@ -11,6 +15,19 @@ public sealed class MumbleAccentSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent(OnAccentGet);
+ SubscribeLocalEvent(OnEmote, before: [typeof(VocalSystem)]);
+ }
+
+ private void OnEmote(Entity ent, ref EmoteEvent args)
+ {
+ if (args.Handled || !args.Emote.Category.HasFlag(EmoteCategory.Vocal))
+ return;
+
+ if (TryComp(ent.Owner, out var vocalComp))
+ {
+ // play a muffled version of the vocal emote
+ args.Handled = _chat.TryPlayEmoteSound(ent.Owner, vocalComp.EmoteSounds, args.Emote, ent.Comp.EmoteAudioParams);
+ }
}
public string Accentuate(string message, MumbleAccentComponent component)
@@ -18,8 +35,8 @@ public sealed class MumbleAccentSystem : EntitySystem
return _replacement.ApplyReplacements(message, "mumble");
}
- private void OnAccentGet(EntityUid uid, MumbleAccentComponent component, AccentGetEvent args)
+ private void OnAccentGet(Entity ent, ref AccentGetEvent args)
{
- args.Message = Accentuate(args.Message, component);
+ args.Message = Accentuate(args.Message, ent.Comp);
}
}
diff --git a/Content.Server/Speech/Muting/MutingSystem.cs b/Content.Server/Speech/Muting/MutingSystem.cs
index 238d501e24..edf82bbfb2 100644
--- a/Content.Server/Speech/Muting/MutingSystem.cs
+++ b/Content.Server/Speech/Muting/MutingSystem.cs
@@ -17,7 +17,7 @@ namespace Content.Server.Speech.Muting
{
base.Initialize();
SubscribeLocalEvent(OnSpeakAttempt);
- SubscribeLocalEvent(OnEmote, before: new[] { typeof(VocalSystem) });
+ SubscribeLocalEvent(OnEmote, before: new[] { typeof(VocalSystem), typeof(MumbleAccentSystem) });
SubscribeLocalEvent(OnScreamAction, before: new[] { typeof(VocalSystem) });
}