Skeleton Accents (#11805)
This commit is contained in:
14
Content.Server/Speech/Components/SkeletonAccentComponent.cs
Normal file
14
Content.Server/Speech/Components/SkeletonAccentComponent.cs
Normal 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
|
||||||
|
}
|
||||||
68
Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs
Normal file
68
Content.Server/Speech/EntitySystems/SkeletonAccentSystem.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Resources/Locale/en-US/speech/accent-systems.ftl
Normal file
1
Resources/Locale/en-US/speech/accent-systems.ftl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
skeleton-suffix = ACK ACK!
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user