mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 14:07:53 +03:00
# Description
This PR adds a new server configuration that disables the special Scream
Action that all players spawn with. It's stupid, it's NRP. And you can
still scream with the emote or emote wheel. If the config is set to
false at roundstart, the Scream action simply won't spawn.
# Changelog
🆑
- tweak: The "Scream Action" no longer appears by default. It may be set
in your server's configuration to spawn or not.
(cherry picked from commit 48a3233ee0ad7ebce93821ff3cb1162558d01288)
115 lines
4.0 KiB
C#
115 lines
4.0 KiB
C#
using Content.Server.Actions;
|
|
using Content.Server.Chat.Systems;
|
|
using Content.Server.Speech.Components;
|
|
using Content.Shared.ActionBlocker;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Chat.Prototypes;
|
|
using Content.Shared.Humanoid;
|
|
using Content.Shared.Speech;
|
|
using Content.Shared.Speech.Components;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Audio.Systems;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.Speech.EntitySystems;
|
|
|
|
public sealed class VocalSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
[Dependency] private readonly ChatSystem _chat = default!;
|
|
[Dependency] private readonly ActionsSystem _actions = default!;
|
|
[Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
|
|
[Dependency] private readonly IConfigurationManager _config = default!;
|
|
|
|
[ValidatePrototypeId<ReplacementAccentPrototype>]
|
|
private const string MuzzleAccent = "mumble";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<VocalComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<VocalComponent, ComponentShutdown>(OnShutdown);
|
|
SubscribeLocalEvent<VocalComponent, SexChangedEvent>(OnSexChanged);
|
|
SubscribeLocalEvent<VocalComponent, EmoteEvent>(OnEmote);
|
|
SubscribeLocalEvent<VocalComponent, ScreamActionEvent>(OnScreamAction);
|
|
}
|
|
|
|
private void OnMapInit(EntityUid uid, VocalComponent component, MapInitEvent args)
|
|
{
|
|
if (_config.GetCVar(CCVars.AllowScreamAction))
|
|
_actions.AddAction(uid, ref component.ScreamActionEntity, component.ScreamAction);
|
|
|
|
LoadSounds(uid, component);
|
|
}
|
|
|
|
private void OnShutdown(EntityUid uid, VocalComponent component, ComponentShutdown args)
|
|
{
|
|
// remove scream action when component removed
|
|
if (component.ScreamActionEntity != null)
|
|
{
|
|
_actions.RemoveAction(uid, component.ScreamActionEntity);
|
|
}
|
|
}
|
|
|
|
private void OnSexChanged(EntityUid uid, VocalComponent component, SexChangedEvent args)
|
|
{
|
|
LoadSounds(uid, component);
|
|
}
|
|
|
|
private void OnEmote(EntityUid uid, VocalComponent component, ref EmoteEvent args)
|
|
{
|
|
if (args.Handled
|
|
|| !args.Emote.Category.HasFlag(EmoteCategory.Vocal)
|
|
|| !_actionBlocker.CanSpeak(uid)
|
|
|| TryComp<ReplacementAccentComponent>(uid, out var replacement) && replacement.Accent == MuzzleAccent) // This is not ideal, but it works.
|
|
return;
|
|
|
|
// snowflake case for wilhelm scream easter egg
|
|
if (args.Emote.ID == component.ScreamId)
|
|
{
|
|
args.Handled = TryPlayScreamSound(uid, component);
|
|
return;
|
|
}
|
|
|
|
// just play regular sound based on emote proto
|
|
args.Handled = _chat.TryPlayEmoteSound(uid, component.EmoteSounds, args.Emote);
|
|
}
|
|
|
|
private void OnScreamAction(EntityUid uid, VocalComponent component, ScreamActionEvent args)
|
|
{
|
|
if (args.Handled || !_config.GetCVar(CCVars.AllowScreamAction))
|
|
return;
|
|
|
|
_chat.TryEmoteWithChat(uid, component.ScreamId);
|
|
args.Handled = true;
|
|
}
|
|
|
|
private bool TryPlayScreamSound(EntityUid uid, VocalComponent component)
|
|
{
|
|
if (_random.Prob(component.WilhelmProbability))
|
|
{
|
|
_audio.PlayPvs(component.Wilhelm, uid, component.Wilhelm.Params);
|
|
return true;
|
|
}
|
|
|
|
return _chat.TryPlayEmoteSound(uid, component.EmoteSounds, component.ScreamId);
|
|
}
|
|
|
|
private void LoadSounds(EntityUid uid, VocalComponent component, Sex? sex = null)
|
|
{
|
|
if (component.Sounds == null)
|
|
return;
|
|
|
|
sex ??= CompOrNull<HumanoidAppearanceComponent>(uid)?.Sex ?? Sex.Unsexed;
|
|
|
|
if (!component.Sounds.TryGetValue(sex.Value, out var protoId))
|
|
return;
|
|
_proto.TryIndex(protoId, out component.EmoteSounds);
|
|
}
|
|
}
|