Skip to content

Commit

Permalink
Vox Accent (SerbiaStrong-220#2095)
Browse files Browse the repository at this point in the history
* Vox Accent

* Update VoxAccentComponent.cs

* Update Content.Server/SS220/Speech/Components/VoxAccentComponent.cs

Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com>

* Update Content.Server/SS220/Speech/Components/VoxAccentComponent.cs

Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com>

* Update Content.Server/SS220/Speech/EntitySystems/VoxAccentSystem.cs

Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com>

* Update Content.Server/SS220/Speech/EntitySystems/VoxAccentSystem.cs

Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com>

---------

Co-authored-by: Kirus59 <145689588+Kirus59@users.noreply.github.com>
  • Loading branch information
EstKemran and Kirus59 authored Oct 16, 2024
1 parent 46032ab commit 2a84e21
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Content.Server/SS220/Speech/Components/VoxAccentComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

namespace Content.Server.SS220.Speech.Components;

/// <summary>
/// The vox accent component. Changes "k" to "kk" or "kek", and "ch" to "ch" or "chech"
/// </summary>
[RegisterComponent]
public sealed partial class VoxAccentComponent : Component
{
}
53 changes: 53 additions & 0 deletions Content.Server/SS220/Speech/EntitySystems/VoxAccentSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt

using System.Text.RegularExpressions;
using Robust.Shared.Random;
using Content.Server.SS220.Speech.Components;
using Content.Server.Speech;

namespace Content.Server.SS220.Speech.EntitySystems;

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

private static readonly Regex RegexLowerK = new("k+");
private static readonly Regex RegexUpperK = new("K+");
private static readonly Regex RegexRuLowerK = new("к+");
private static readonly Regex RegexRuUpperK = new("К+");
private static readonly Regex RegexLowerCH = new("ch+");
private static readonly Regex RegexUpperCH = new("CH+");
private static readonly Regex RegexRuLowerCH = new("ч+");
private static readonly Regex RegexRuUpperCH = new("Ч+");

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<VoxAccentComponent, AccentGetEvent>(OnAccent);
}

private void OnAccent(Entity<VoxAccentComponent> entity, ref AccentGetEvent args)
{
var message = args.Message;

// k into kk or kek
message = RegexLowerK.Replace(message, _random.Pick(new List<string>() { "kk", "kek" }));
// K into KK or KEK
message = RegexUpperK.Replace(message, _random.Pick(new List<string>() { "KK", "KEK" }));
// к в кк или кик
message = RegexRuLowerK.Replace(message, _random.Pick(new List<string>() { "кк", "кик" }));
// К в КК или КИК
message = RegexRuUpperK.Replace(message, _random.Pick(new List<string>() { "КК", "КИК" }));

// ch into chch or chech
message = RegexLowerCH.Replace(message, _random.Pick(new List<string>() { "chch", "chech" }));
// CH into CHCH or CHECH
message = RegexUpperCH.Replace(message, _random.Pick(new List<string>() { "CHCH", "CHECH" }));
// ч в чч или чич
message = RegexRuLowerCH.Replace(message, _random.Pick(new List<string>() { "чч", "чич" }));
// Ч в ЧЧ или ЧИЧ
message = RegexRuUpperCH.Replace(message, _random.Pick(new List<string>() { "ЧЧ", "ЧИЧ" }));

args.Message = message;
}
}
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/vox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
spawned:
- id: FoodMeatChicken
amount: 5
- type: VoxAccent #SS220-Vox Accent
- type: Damageable
damageContainer: Biological
damageModifierSet: Vox
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Traits/speech.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- type: OwOAccent #SS220
- type: ReplacementAccent
accent: dwarf
#SS220-Vox accent Begin
- type: TajaranAccent
- type: VoxAccent
#SS220-Vox accent End

# 1 Cost

Expand Down

0 comments on commit 2a84e21

Please sign in to comment.