Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Content.Server/Content.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<ProjectReference Include="..\Content.Shared.Database\Content.Shared.Database.csproj" />
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="_Funkystation\Speech\EntitySystems\" />
</ItemGroup>
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />

<Import Project="..\RobustToolbox\Imports\Lidgren.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Server.Speech.Components
{
[RegisterComponent]
public sealed partial class BostonAccentComponent : Component
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Server.Speech.Components
{
[RegisterComponent]
public sealed partial class CakAccentComponent : Component
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Content.Server.Speech.Components
{
[RegisterComponent]
public sealed partial class ScandinavianAccentComponent : Component
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Content.Server.Speech.Components;
using System.Text.RegularExpressions;
using Content.Shared.Speech;

namespace Content.Server.Speech.EntitySystems;

public sealed class BostonAccentSystem : EntitySystem
{
private static readonly Regex RegexLowercaseAr = new(@"\Bar(?!e\b)");
private static readonly Regex RegexUppercaseAr = new(@"\BAR(?!E\b)");
private static readonly Regex RegexLowercaseEr = new(@"er\B");
private static readonly Regex RegexUppercaseEr = new(@"ER\B");
private static readonly Regex RegexSentenceCaseEr = new(@"Er\B");
private static readonly Regex RegexLowercaseEndingEr = new(@"\Ber(?=(s\b|\b))");
private static readonly Regex RegexUppercaseEndingEr = new(@"\BER(?=(s\b|\b))");
private static readonly Regex RegexLowercaseEndingOr = new(@"\Bor(?=(s\b|\b))");
private static readonly Regex RegexUppercaseEndingOr = new(@"\BOR(?=(s\b|\b))");
private static readonly Regex RegexLowercaseNty = new(@"\Bnt(?=(y|ie))");
private static readonly Regex RegexUppercaseNty = new(@"\BNT(?=(Y|IE))");
private static readonly Regex RegexApostropheT = new(@"'t", RegexOptions.IgnoreCase);

public override void Initialize()
{
SubscribeLocalEvent<BostonAccentComponent, AccentGetEvent>(OnAccent);
}

public string Accentuate(string message)
{
var msg = message;

// start -> staht
// this doesn't change "are" because that feels wrong to me
msg = RegexLowercaseAr.Replace(msg, "ah");
msg = RegexUppercaseAr.Replace(msg, "AH");

// error -> ehror
msg = RegexLowercaseEr.Replace(msg, "eh");
msg = RegexUppercaseEr.Replace(msg, "EH");
msg = RegexSentenceCaseEr.Replace(msg, "Eh");

// meter -> metah
msg = RegexLowercaseEndingEr.Replace(msg, "ah");
msg = RegexUppercaseEndingEr.Replace(msg, "AH");

// reactor -> reactah
msg = RegexLowercaseEndingOr.Replace(msg, "ah");
msg = RegexUppercaseEndingOr.Replace(msg, "AH");

// bounty -> bounny
msg = RegexLowercaseNty.Replace(msg, "nn");
msg = RegexUppercaseNty.Replace(msg, "NN");

// don't -> don'
msg = RegexApostropheT.Replace(msg, "'");

return msg;
}
private void OnAccent(Entity<BostonAccentComponent> ent, ref AccentGetEvent args)
{
args.Message = Accentuate(args.Message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Content.Server.Speech.Components;
using System.Text.RegularExpressions;
using Content.Shared.Speech;

namespace Content.Server.Speech.EntitySystems;

public sealed class CakAccentSystem : EntitySystem
{
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;

private static readonly Regex RegexWhitespace = new(@"\s");

public override void Initialize()
{
SubscribeLocalEvent<CakAccentComponent, AccentGetEvent>(OnAccent, before: new[] {typeof(OwOAccentSystem)});
}

public string Accentuate(string message)
{
// This is atrocious but makes sure that the word is not part of a longer sentence.
if (RegexWhitespace.Count(message) == 2)
{
message = _replacement.ApplyReplacements(message, "cak2spaces");
}
else if (RegexWhitespace.Count(message) == 1)
{
message = _replacement.ApplyReplacements(message, "cak1space");
}
else if (RegexWhitespace.Count(message) == 0)
{
message = _replacement.ApplyReplacements(message, "cak0spaces");
}
return message;
}

private void OnAccent(Entity<CakAccentComponent> ent, ref AccentGetEvent args)
{
args.Message = Accentuate(args.Message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System.Text;
using Content.Server.Speech.Components;
using Robust.Shared.Random;
using System.Text.RegularExpressions;
using Content.Shared.Speech;

namespace Content.Server.Speech.EntitySystems;

public sealed class ScandinavianAccentSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;

private static readonly Regex RegexLowercaseAe = new(@"ae");
private static readonly Regex RegexUppercaseAe = new(@"A(?i)e");
private static readonly Regex RegexLowercaseTh = new(@"th");
private static readonly Regex RegexUppercaseTh = new(@"T(?i)h");

public override void Initialize()
{
SubscribeLocalEvent<ScandinavianAccentComponent, AccentGetEvent>(OnAccent);
}

public string Accentuate(string message)
{
message = RegexLowercaseAe.Replace(message, "æ");
message = RegexUppercaseAe.Replace(message, "Æ");
message = RegexLowercaseTh.Replace(message, "ð");
message = RegexUppercaseTh.Replace(message, "Ð");


var messageBuilder = new StringBuilder(message);

// SHITCODE INCOMING. "A" and "O" have a 50% chance to be replaced with an accented equivalent. "E" has a 25% chance to be replaced with "Æ".
for (var i = 0; i < messageBuilder.Length; i++)
{
var random_int = _random.Next(0,4);
switch (messageBuilder[i])
{
case 'A':
messageBuilder[i] = random_int switch
{
0 => 'Å',
1 => 'Ä',
_ => 'A'
};
break;
case 'a':
messageBuilder[i] = random_int switch
{
0 => 'å',
1 => 'ä',
_ => 'a'
};
break;
case 'E':
messageBuilder[i] = random_int switch
{
0 => 'Æ',
_ => 'E'
};
break;
case 'e':
messageBuilder[i] = random_int switch
{
0 => 'æ',
_ => 'e'
};
break;
case 'O':
messageBuilder[i] = random_int switch
{
0 => 'Ø',
1 => 'Ö',
_ => 'O'
};
break;
case 'o':
messageBuilder[i] = random_int switch
{
0 => 'ø',
1 => 'ö',
_ => 'o'
};
break;
default:
break;
}
}

return messageBuilder.ToString();
}
private void OnAccent(Entity<ScandinavianAccentComponent> ent, ref AccentGetEvent args)
{
args.Message = Accentuate(args.Message);
}
}
14 changes: 14 additions & 0 deletions Resources/Locale/en-US/_Funkystation/accent/cak.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
accent-cak-words-1 = goodbye
accent-cak-words-1-2 = bye-bye
accent-cak-words-1-3 = bye
accent-cak-words-1-4 = farewell

accent-cak-words-2 = bye bye
accent-cak-words-2-2 = see you
accent-cak-words-2-3 = see ya
accent-cak-words-2-4 = so long

accent-cak-words-3 = see you later
accent-cak-words-3-2 = see ya later

accent-cak-words-replace = I'm out this bitch
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/_Funkystation/traits/traits.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trait-boston-name = Boston accent
trait-boston-desc = You sound like you need to pahk your cah in the yahd.

trait-scandinavian-name = Scandinavian accent
trait-scandinavian-desc = Yøu sound like yøu cöme frøm søme nondescript norðern Euröpæän nation. Ör you'ræ a Viking!
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,7 @@
settings: short
- type: GhostTakeoverAvailable
- type: OwOAccent
- type: CakAccent # Funky
- type: Speech
speechSounds: Cat
speechVerb: SmallMob
Expand Down
21 changes: 21 additions & 0 deletions Resources/Prototypes/_Funkystation/Accents/word_replacements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
- type: accent
id: cak0spaces
wordReplacements:
accent-cak-words-1: accent-cak-words-replace
accent-cak-words-1-2: accent-cak-words-replace
accent-cak-words-1-3: accent-cak-words-replace
accent-cak-words-1-4: accent-cak-words-replace

- type: accent
id: cak1space
wordReplacements:
accent-cak-words-2: accent-cak-words-replace
accent-cak-words-2-2: accent-cak-words-replace
accent-cak-words-2-3: accent-cak-words-replace
accent-cak-words-2-4: accent-cak-words-replace

- type: accent
id: cak2spaces
wordReplacements:
accent-cak-words-3: accent-cak-words-replace
accent-cak-words-3-2: accent-cak-words-replace
17 changes: 17 additions & 0 deletions Resources/Prototypes/_Funkystation/Traits/speech.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
- type: trait
id: BostonAccent
name: trait-boston-name
description: trait-boston-desc
category: SpeechTraits
cost: 1
components:
- type: BostonAccent

- type: trait
id: ScandinavianAccent
name: trait-scandinavian-name
description: trait-scandinavian-desc
category: SpeechTraits
cost: 1
components:
- type: ScandinavianAccent
Loading