localize skeleton accent (#32166)

* localize skeleton accent

* commit number 2

* remove that from this

* this

* babushka
This commit is contained in:
lzk
2024-09-15 21:49:05 +02:00
committed by GitHub
parent 12e2371c8d
commit 7fed39d511
3 changed files with 54 additions and 24 deletions

View File

@@ -7,29 +7,11 @@ namespace Content.Server.Speech.EntitySystems;
public sealed partial class SkeletonAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
[GeneratedRegex(@"(?<!\w)[^aeiou]one", RegexOptions.IgnoreCase, "en-US")]
private static partial Regex BoneRegex();
private static readonly Dictionary<string, string> 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();
@@ -50,11 +32,8 @@ public sealed partial class SkeletonAccentSystem : EntitySystem
// At the start of words, any non-vowel + "one" becomes "bone", e.g. tone -> bone ; lonely -> bonely; clone -> clone (remains unchanged).
msg = BoneRegex().Replace(msg, "bone");
// Direct word/phrase replacements:
foreach (var (first, replace) in DirectReplacements)
{
msg = Regex.Replace(msg, $@"(?<!\w){first}(?!\w)", replace, RegexOptions.IgnoreCase);
}
// apply word replacements
msg = _replacement.ApplyReplacements(msg, "skeleton");
// Suffix:
if (_random.Prob(component.ackChance))