From 23f0b304f284d2600cb2c6b4c9d36fdca7f99ec4 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Tue, 7 Jan 2025 20:00:20 -0500 Subject: [PATCH] Add bleating accent to goats (#34273) --- .../Components/BleatingAccentComponent.cs | 7 +++++ .../EntitySystems/BleatingAccentSystem.cs | 28 +++++++++++++++++++ .../en-US/chat/managers/chat-manager.ftl | 5 ++++ .../Prototypes/Entities/Mobs/NPCs/animals.yml | 9 ++++++ .../Prototypes/Voice/speech_emote_sounds.yml | 7 +++++ Resources/Prototypes/Voice/speech_sounds.yml | 9 ++++++ Resources/Prototypes/Voice/speech_verbs.yml | 8 ++++++ 7 files changed, 73 insertions(+) create mode 100644 Content.Server/Speech/Components/BleatingAccentComponent.cs create mode 100644 Content.Server/Speech/EntitySystems/BleatingAccentSystem.cs diff --git a/Content.Server/Speech/Components/BleatingAccentComponent.cs b/Content.Server/Speech/Components/BleatingAccentComponent.cs new file mode 100644 index 0000000000..484235ab90 --- /dev/null +++ b/Content.Server/Speech/Components/BleatingAccentComponent.cs @@ -0,0 +1,7 @@ +namespace Content.Server.Speech.Components; + +/// +/// Makes this entity speak like a sheep or a goat in all chat messages it sends. +/// +[RegisterComponent] +public sealed partial class BleatingAccentComponent : Component { } diff --git a/Content.Server/Speech/EntitySystems/BleatingAccentSystem.cs b/Content.Server/Speech/EntitySystems/BleatingAccentSystem.cs new file mode 100644 index 0000000000..903377477e --- /dev/null +++ b/Content.Server/Speech/EntitySystems/BleatingAccentSystem.cs @@ -0,0 +1,28 @@ +using System.Text.RegularExpressions; +using Content.Server.Speech.Components; + +namespace Content.Server.Speech.EntitySystems; + +public sealed partial class BleatingAccentSystem : EntitySystem +{ + private static readonly Regex BleatRegex = new("([mbdlpwhrkcnytfo])([aiu])", RegexOptions.IgnoreCase); + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnAccentGet); + } + + private void OnAccentGet(Entity entity, ref AccentGetEvent args) + { + args.Message = Accentuate(args.Message); + } + + public static string Accentuate(string message) + { + // Repeats the vowel in certain consonant-vowel pairs + // So you taaaalk liiiike thiiiis + return BleatRegex.Replace(message, "$1$2$2$2$2"); + } +} diff --git a/Resources/Locale/en-US/chat/managers/chat-manager.ftl b/Resources/Locale/en-US/chat/managers/chat-manager.ftl index 59b927742b..c3d35c9739 100644 --- a/Resources/Locale/en-US/chat/managers/chat-manager.ftl +++ b/Resources/Locale/en-US/chat/managers/chat-manager.ftl @@ -118,6 +118,11 @@ chat-speech-verb-canine-1 = barks chat-speech-verb-canine-2 = woofs chat-speech-verb-canine-3 = howls +chat-speech-verb-name-goat = Goat +chat-speech-verb-goat-1 = bleats +chat-speech-verb-goat-2 = grunts +chat-speech-verb-goat-3 = cries + chat-speech-verb-name-small-mob = Mouse chat-speech-verb-small-mob-1 = squeaks chat-speech-verb-small-mob-2 = pieps diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index 2413d5531b..e88100d22c 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -998,6 +998,15 @@ - type: Grammar attributes: gender: female # Here because of UdderComponent + - type: Speech + speechSounds: Goat + speechVerb: Goat + - type: Vocal + sounds: + Female: Goat + Male: Goat + Unsexed: Goat + - type: BleatingAccent - type: InteractionPopup successChance: 0.2 interactSuccessString: petting-success-goat diff --git a/Resources/Prototypes/Voice/speech_emote_sounds.yml b/Resources/Prototypes/Voice/speech_emote_sounds.yml index a45260093f..8f4d4fc88e 100644 --- a/Resources/Prototypes/Voice/speech_emote_sounds.yml +++ b/Resources/Prototypes/Voice/speech_emote_sounds.yml @@ -527,3 +527,10 @@ path: /Audio/Animals/parrot_raught.ogg params: variation: 0.125 + +- type: emoteSounds + id: Goat + sound: + path: /Audio/Animals/goat_bah.ogg + params: + variation: 0.125 diff --git a/Resources/Prototypes/Voice/speech_sounds.yml b/Resources/Prototypes/Voice/speech_sounds.yml index bc3cffb359..c1ad6b9e40 100644 --- a/Resources/Prototypes/Voice/speech_sounds.yml +++ b/Resources/Prototypes/Voice/speech_sounds.yml @@ -159,3 +159,12 @@ path: /Audio/Animals/chicken_cluck_happy.ogg exclaimSound: path: /Audio/Animals/chicken_cluck_happy.ogg + +- type: speechSounds + id: Goat + saySound: + path: /Audio/Animals/goat_bah.ogg + askSound: + path: /Audio/Animals/goat_bah.ogg + exclaimSound: + path: /Audio/Animals/goat_bah.ogg diff --git a/Resources/Prototypes/Voice/speech_verbs.yml b/Resources/Prototypes/Voice/speech_verbs.yml index 9879cefb75..f8202847fd 100644 --- a/Resources/Prototypes/Voice/speech_verbs.yml +++ b/Resources/Prototypes/Voice/speech_verbs.yml @@ -110,6 +110,14 @@ - chat-speech-verb-canine-2 - chat-speech-verb-canine-3 +- type: speechVerb + id: Goat + name: chat-speech-verb-name-goat + speechVerbStrings: + - chat-speech-verb-goat-1 + - chat-speech-verb-goat-2 + - chat-speech-verb-goat-3 + - type: speechVerb id: LargeMob name: chat-speech-verb-name-large-mob