diff --git a/Content.Server/Speech/Components/StutteringAccentComponent.cs b/Content.Server/Speech/Components/StutteringAccentComponent.cs index b283a8354b..e82cd9b12b 100644 --- a/Content.Server/Speech/Components/StutteringAccentComponent.cs +++ b/Content.Server/Speech/Components/StutteringAccentComponent.cs @@ -3,5 +3,32 @@ namespace Content.Server.Speech.Components [RegisterComponent] public sealed partial class StutteringAccentComponent : Component { + /// + /// Percentage chance that a stutter will occur if it matches. + /// + [DataField("matchRandomProb")] + [ViewVariables(VVAccess.ReadWrite)] + public float MatchRandomProb = 0.8f; + + /// + /// Percentage chance that a stutter occurs f-f-f-f-four times. + /// + [DataField("fourRandomProb")] + [ViewVariables(VVAccess.ReadWrite)] + public float FourRandomProb = 0.1f; + + /// + /// Percentage chance that a stutter occurs t-t-t-three times. + /// + [DataField("threeRandomProb")] + [ViewVariables(VVAccess.ReadWrite)] + public float ThreeRandomProb = 0.2f; + + /// + /// Percentage chance that a stutter cut off. + /// + [DataField("cutRandomProb")] + [ViewVariables(VVAccess.ReadWrite)] + public float CutRandomProb = 0.05f; } } diff --git a/Content.Server/Speech/EntitySystems/StutteringSystem.cs b/Content.Server/Speech/EntitySystems/StutteringSystem.cs index 8717d57ad0..d6e3c0b749 100644 --- a/Content.Server/Speech/EntitySystems/StutteringSystem.cs +++ b/Content.Server/Speech/EntitySystems/StutteringSystem.cs @@ -31,10 +31,10 @@ namespace Content.Server.Speech.EntitySystems private void OnAccent(EntityUid uid, StutteringAccentComponent component, AccentGetEvent args) { - args.Message = Accentuate(args.Message); + args.Message = Accentuate(args.Message, component); } - public string Accentuate(string message) + public string Accentuate(string message, StutteringAccentComponent component) { var length = message.Length; @@ -45,17 +45,17 @@ namespace Content.Server.Speech.EntitySystems for (var i = 0; i < length; i++) { newLetter = message[i].ToString(); - if (Stutter.IsMatch(newLetter) && _random.Prob(0.8f)) + if (Stutter.IsMatch(newLetter) && _random.Prob(component.MatchRandomProb)) { - if (_random.Prob(0.1f)) + if (_random.Prob(component.FourRandomProb)) { newLetter = $"{newLetter}-{newLetter}-{newLetter}-{newLetter}"; } - else if (_random.Prob(0.2f)) + else if (_random.Prob(component.ThreeRandomProb)) { newLetter = $"{newLetter}-{newLetter}-{newLetter}"; } - else if (_random.Prob(0.05f)) + else if (_random.Prob(component.CutRandomProb)) { newLetter = ""; } diff --git a/Resources/Locale/en-US/traits/traits.ftl b/Resources/Locale/en-US/traits/traits.ftl index 28c0ecf794..524d249e92 100644 --- a/Resources/Locale/en-US/traits/traits.ftl +++ b/Resources/Locale/en-US/traits/traits.ftl @@ -34,3 +34,6 @@ trait-wheelchair-bound-desc = You cannot move without your wheelchair. Wheelchai trait-frontal-lisp-name = Frontal Lisp trait-frontal-lisp-desc = You thpeak with a lithp + +trait-socialanxiety-name = Social Anxiety +trait-socialanxiety-desc = You are anxious when you speak and stutter. diff --git a/Resources/Prototypes/Traits/inconveniences.yml b/Resources/Prototypes/Traits/inconveniences.yml index ad61b14971..f8e932c9b9 100644 --- a/Resources/Prototypes/Traits/inconveniences.yml +++ b/Resources/Prototypes/Traits/inconveniences.yml @@ -5,3 +5,14 @@ components: - type: LightweightDrunk boozeStrengthMultiplier: 2 + +- type: trait + id: SocialAnxiety + name: trait-socialanxiety-name + description: trait-socialanxiety-desc + components: + - type: StutteringAccent + matchRandomProb: 0.2 + fourRandomProb: 0 + threeRandomProb: 0.3 + cutRandomProb: 0