Skeleton Accents (#11805)

This commit is contained in:
Willhelm53
2022-10-22 17:40:28 -05:00
committed by GitHub
parent c173294048
commit 1a1e72063a
5 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
namespace Content.Server.Speech.Components;
/// <summary>
/// Rattle me bones!
/// </summary>
[RegisterComponent]
public sealed class SkeletonAccentComponent : Component
{
/// <summary>
/// Chance that the message will be appended with "ACK ACK!"
/// </summary>
[DataField("ackChance")]
public float ackChance = 0.3f; // Funnier if it doesn't happen every single time
}

View File

@@ -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<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();
SubscribeLocalEvent<SkeletonAccentComponent, AccentGetEvent>(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, @"(?<!\w)[^aeiou]one", "bone", RegexOptions.IgnoreCase);
// Direct word/phrase replacements:
foreach (var (first, replace) in DirectReplacements)
{
msg = Regex.Replace(msg, $@"(?<!\w){first}(?!\w)", replace, RegexOptions.IgnoreCase);
}
// Suffix:
if (_random.Prob(component.ackChance))
{
msg += (" " + Loc.GetString("skeleton-suffix")); // e.g. "We only want to socialize. ACK ACK!"
}
return msg;
}
private void OnAccentGet(EntityUid uid, SkeletonAccentComponent component, AccentGetEvent args)
{
args.Message = Accentuate(args.Message, component);
}
}

View File

@@ -0,0 +1 @@
skeleton-suffix = ACK ACK!

View File

@@ -55,6 +55,7 @@
baseWalkSpeed: 0 baseWalkSpeed: 0
baseSprintSpeed: 0 baseSprintSpeed: 0
- type: Speech - type: Speech
- type: SkeletonAccent
- type: Vocal - type: Vocal
maleScream: /Audio/Voice/Skeleton/skeleton_scream.ogg maleScream: /Audio/Voice/Skeleton/skeleton_scream.ogg
femaleScream: /Audio/Voice/Skeleton/skeleton_scream.ogg femaleScream: /Audio/Voice/Skeleton/skeleton_scream.ogg

View File

@@ -48,6 +48,7 @@
60: 0.9 60: 0.9
80: 0.7 80: 0.7
- type: Speech - type: Speech
- type: SkeletonAccent
- type: Fixtures - type: Fixtures
fixtures: fixtures:
- shape: - shape: