From 1a1e72063a62ca9bdc6a2da925eb3275c3206f84 Mon Sep 17 00:00:00 2001
From: Willhelm53 <97707302+Willhelm53@users.noreply.github.com>
Date: Sat, 22 Oct 2022 17:40:28 -0500
Subject: [PATCH] Skeleton Accents (#11805)
---
.../Components/SkeletonAccentComponent.cs | 14 ++++
.../EntitySystems/SkeletonAccentSystem.cs | 68 +++++++++++++++++++
.../Locale/en-US/speech/accent-systems.ftl | 1 +
Resources/Prototypes/Body/Parts/skeleton.yml | 1 +
.../Entities/Mobs/Species/skeleton.yml | 1 +
5 files changed, 85 insertions(+)
create mode 100644 Content.Server/Speech/Components/SkeletonAccentComponent.cs
create mode 100644 Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs
create mode 100644 Resources/Locale/en-US/speech/accent-systems.ftl
diff --git a/Content.Server/Speech/Components/SkeletonAccentComponent.cs b/Content.Server/Speech/Components/SkeletonAccentComponent.cs
new file mode 100644
index 0000000000..f533982680
--- /dev/null
+++ b/Content.Server/Speech/Components/SkeletonAccentComponent.cs
@@ -0,0 +1,14 @@
+namespace Content.Server.Speech.Components;
+
+///
+/// Rattle me bones!
+///
+[RegisterComponent]
+public sealed class SkeletonAccentComponent : Component
+{
+ ///
+ /// Chance that the message will be appended with "ACK ACK!"
+ ///
+ [DataField("ackChance")]
+ public float ackChance = 0.3f; // Funnier if it doesn't happen every single time
+}
diff --git a/Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs b/Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs
new file mode 100644
index 0000000000..ead9b4382e
--- /dev/null
+++ b/Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs
@@ -0,0 +1,68 @@
+using System.Text.RegularExpressions;
+using Content.Server.Speech.Components;
+using Robust.Shared.Random;
+
+namespace Content.Server.Speech.EntitySystems;
+
+public sealed class SkeletonAccentSystem : EntitySystem
+{
+ [Dependency] private readonly IRobustRandom _random = default!;
+
+ private static readonly Dictionary DirectReplacements = new()
+ {
+ { "fuck you", "I've got a BONE to pick with you" },
+ { "fucked", "boned"},
+ { "fuck", "RATTLE RATTLE" },
+ { "fck", "RATTLE RATTLE" },
+ { "shit", "RATTLE RATTLE" }, // Capitalize RATTLE RATTLE regardless of original message case.
+ { "definitely", "make no bones about it" },
+ { "absolutely", "make no bones about it" },
+ { "afraid", "rattled"},
+ { "scared", "rattled"},
+ { "spooked", "rattled"},
+ { "shocked", "rattled"},
+ { "killed", "skeletonized"},
+ { "humorous", "humerus"},
+ { "to be a", "tibia"},
+ { "under", "ulna"}
+ };
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnAccentGet);
+ }
+
+ public string Accentuate(string message, SkeletonAccentComponent component)
+ {
+ // Order:
+ // Do character manipulations first
+ // Then direct word/phrase replacements
+ // Then prefix/suffix
+
+ var msg = message;
+
+ // Character manipulations:
+ // At the start of words, any non-vowel + "one" becomes "bone", e.g. tone -> bone ; lonely -> bonely; clone -> clone (remains unchanged).
+ msg = Regex.Replace(msg, @"(?