]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Pathological Liar (#27618)
authorEd <96445749+TheShuEd@users.noreply.github.com>
Sat, 4 May 2024 11:11:46 +0000 (14:11 +0300)
committerGitHub <noreply@github.com>
Sat, 4 May 2024 11:11:46 +0000 (04:11 -0700)
* content

* upgrade

* n't

* ye ya

* Update speech-liar.ftl

* Mith replacement ideas

* fix

* more!

* Revert "more!"

This reverts commit 6d10bdf694985c525a2b451ed39380f975059b44.

* Update Content.Server/Speech/Components/ReplacementAccentComponent.cs

---------

Co-authored-by: Kara <lunarautomaton6@gmail.com>
Content.Server/Speech/Components/ReplacementAccentComponent.cs
Content.Server/Speech/EntitySystems/ReplacementAccentSystem.cs
Resources/Locale/en-US/speech/speech-liar.ftl [new file with mode: 0644]
Resources/Locale/en-US/traits/traits.ftl
Resources/Prototypes/Accents/word_replacements.yml
Resources/Prototypes/Traits/neutral.yml

index ac4e9fbafef7806c814467562c1c482682e99272..e7f57b80d04919f52b1d5ba84d5e3bf0ecfcbeef 100644 (file)
@@ -32,5 +32,11 @@ namespace Content.Server.Speech.Components
     {
         [DataField("accent", customTypeSerializer: typeof(PrototypeIdSerializer<ReplacementAccentPrototype>), required: true)]
         public string Accent = default!;
+
+        /// <summary>
+        /// Allows you to substitute words, not always, but with some chance
+        /// </summary>
+        [DataField]
+        public float ReplacementChance = 1f;
     }
 }
index 36fa7e07ad5eb075d368b1dabb210ad618116688..c332c6cda8f6937dde59dd7be596874533050591 100644 (file)
@@ -24,6 +24,9 @@ namespace Content.Server.Speech.EntitySystems
 
         private void OnAccent(EntityUid uid, ReplacementAccentComponent component, AccentGetEvent args)
         {
+            if (!_random.Prob(component.ReplacementChance))
+                return;
+
             args.Message = ApplyReplacements(args.Message, component.Accent);
         }
 
@@ -46,6 +49,12 @@ namespace Content.Server.Speech.EntitySystems
             if (prototype.WordReplacements == null)
                 return message;
 
+            // Prohibition of repeated word replacements.
+            // All replaced words placed in the final message are placed here as dashes (___) with the same length.
+            // The regex search goes through this buffer message, from which the already replaced words are crossed out,
+            // ensuring that the replaced words cannot be replaced again.
+            var maskMessage = message;
+
             foreach (var (first, replace) in prototype.WordReplacements)
             {
                 var f = _loc.GetString(first);
@@ -53,10 +62,10 @@ namespace Content.Server.Speech.EntitySystems
                 // this is kind of slow but its not that bad
                 // essentially: go over all matches, try to match capitalization where possible, then replace
                 // rather than using regex.replace
-                for (int i = Regex.Count(message, $@"(?<!\w){f}(?!\w)", RegexOptions.IgnoreCase); i > 0; i--)
+                for (int i = Regex.Count(maskMessage, $@"(?<!\w){f}(?!\w)", RegexOptions.IgnoreCase); i > 0; i--)
                 {
                     // fetch the match again as the character indices may have changed
-                    Match match = Regex.Match(message, $@"(?<!\w){f}(?!\w)", RegexOptions.IgnoreCase);
+                    Match match = Regex.Match(maskMessage, $@"(?<!\w){f}(?!\w)", RegexOptions.IgnoreCase);
                     var replacement = r;
 
                     // Intelligently replace capitalization
@@ -80,6 +89,8 @@ namespace Content.Server.Speech.EntitySystems
 
                     // In-place replace the match with the transformed capitalization replacement
                     message = message.Remove(match.Index, match.Length).Insert(match.Index, replacement);
+                    string mask = new string('_', match.Length);
+                    maskMessage = message.Remove(match.Index, match.Length).Insert(match.Index, mask);
                 }
             }
 
diff --git a/Resources/Locale/en-US/speech/speech-liar.ftl b/Resources/Locale/en-US/speech/speech-liar.ftl
new file mode 100644 (file)
index 0000000..1cd0a77
--- /dev/null
@@ -0,0 +1,132 @@
+liar-word-1 = yes
+liar-word-replacement-1 = no
+
+liar-word-2 = no
+liar-word-replacement-2 = yes
+
+liar-word-3 = yeah
+liar-word-replacement-3 = nah
+
+liar-word-4 = nah
+liar-word-replacement-4 = yeah
+
+liar-word-5 = yep
+liar-word-replacement-5 = nope
+
+liar-word-6 = nope
+liar-word-replacement-6 = yep
+
+liar-word-7 = sure
+liar-word-replacement-7 = nah
+
+liar-word-8 = was
+liar-word-replacement-8 = wasnt
+
+liar-word-9 = wasnt
+liar-word-replacement-9 = was
+
+liar-word-10 = was
+liar-word-replacement-10 = wasnt
+
+liar-word-11 = is
+liar-word-replacement-11 = isnt
+
+liar-word-12 = will
+liar-word-replacement-12 = wont
+
+liar-word-12 = not
+liar-word-replacement-12 = ""
+
+liar-word-13 = dont
+liar-word-replacement-13 = ""
+
+liar-word-14 = can
+liar-word-replacement-14 = cant
+
+liar-word-15 = cant
+liar-word-replacement-15 = can
+
+liar-word-16 = should
+liar-word-replacement-16 = shouldnt
+
+liar-word-17 = dead
+liar-word-replacement-17 = alive
+
+liar-word-18 = alive
+liar-word-replacement-18 = dead
+
+liar-word-19 = does
+liar-word-replacement-19 = doesnt
+
+liar-word-20 = did
+liar-word-replacement-20 = didnt
+
+liar-word-21 = didnt
+liar-word-replacement-21 = ""
+
+liar-word-22 = nothing
+liar-word-replacement-22 = something
+
+liar-word-23 = something
+liar-word-replacement-23 = nothing
+
+liar-word-24 = somebody
+liar-word-replacement-24 = nobody
+
+liar-word-25 = nobody
+liar-word-replacement-25 = somebody
+
+liar-word-26 = can
+liar-word-replacement-26 = "can't"
+
+liar-word-27 = "can't"
+liar-word-replacement-27 = can
+
+liar-word-28 = should
+liar-word-replacement-28 = "shouldn't"
+
+liar-word-29 = do
+liar-word-replacement-29 = "don't"
+
+liar-word-30 = "don't"
+liar-word-replacement-30 = ""
+
+liar-word-31 = does
+liar-word-replacement-31 = "doesn't"
+
+liar-word-32 = did
+liar-word-replacement-32 = "didn't"
+
+liar-word-33 = "didn't"
+liar-word-replacement-33 = did
+
+liar-word-34 = ye
+liar-word-34-2 = ya
+liar-word-replacement-34 = na
+
+liar-word-35 = na
+liar-word-replacement-35 = ye
+
+liar-word-36 = yuh
+liar-word-replacement-36 = nuh
+
+liar-word-37 = nuh
+liar-word-replacement-37 = yuh
+
+liar-word-38 = love
+liar-word-replacement-38 = hate
+
+liar-word-39 = hate
+liar-word-replacement-39 = love
+
+liar-word-40 = like
+liar-word-replacement-40 = don't like
+
+liar-word-41 = good
+liar-word-replacement-41 = bad
+
+liar-word-42 = bad
+liar-word-replacement-42 = good
+
+liar-word-42 = want
+liar-word-replacement-42 = "don't want"
index fa17dc23ec35b48bda22530780df7c62b95dd8b6..c387f2975316bf5f26c38230c9a5c4b402861882 100644 (file)
@@ -38,3 +38,6 @@ trait-southern-desc = You have a different way of speakin'.
 
 trait-snoring-name = Snoring
 trait-snoring-desc = You will snore while sleeping.
+
+trait-liar-name = Pathological liar
+trait-liar-desc = You can hardly bring yourself to tell the truth. Sometimes you lie anyway.
\ No newline at end of file
index fa9d39add23f5373f5b4df879d20dfb5bd3874ac..30c739b8453bfb5cfb63340c674187dbb110890c 100644 (file)
     chatsan-word-42: chatsan-replacement-42
     chatsan-word-43: chatsan-replacement-43
     chatsan-word-44: chatsan-replacement-44
+
+- type: accent
+  id: liar
+  wordReplacements:
+    liar-word-1: liar-word-replacement-1
+    liar-word-2: liar-word-replacement-2
+    liar-word-3: liar-word-replacement-3
+    liar-word-4: liar-word-replacement-4
+    liar-word-5: liar-word-replacement-5
+    liar-word-6: liar-word-replacement-6
+    liar-word-7: liar-word-replacement-7
+    liar-word-8: liar-word-replacement-8
+    liar-word-9: liar-word-replacement-9
+    liar-word-10: liar-word-replacement-10
+    liar-word-11: liar-word-replacement-11
+    liar-word-12: liar-word-replacement-12
+    liar-word-13: liar-word-replacement-13
+    liar-word-14: liar-word-replacement-14
+    liar-word-15: liar-word-replacement-15
+    liar-word-16: liar-word-replacement-16
+    liar-word-17: liar-word-replacement-17
+    liar-word-18: liar-word-replacement-18
+    liar-word-19: liar-word-replacement-19
+    liar-word-20: liar-word-replacement-20
+    liar-word-21: liar-word-replacement-21
+    liar-word-22: liar-word-replacement-22
+    liar-word-23: liar-word-replacement-23
+    liar-word-24: liar-word-replacement-24
+    liar-word-25: liar-word-replacement-25
+    liar-word-26: liar-word-replacement-26
+    liar-word-27: liar-word-replacement-27
+    liar-word-28: liar-word-replacement-28
+    liar-word-29: liar-word-replacement-29
+    liar-word-30: liar-word-replacement-30
+    liar-word-31: liar-word-replacement-31
+    liar-word-32: liar-word-replacement-32
+    liar-word-33: liar-word-replacement-33
+    liar-word-34: liar-word-replacement-34
+    liar-word-34-2: liar-word-replacement-34
+    liar-word-35: liar-word-replacement-35
+    liar-word-36: liar-word-replacement-36
+    liar-word-37: liar-word-replacement-37
+    liar-word-38: liar-word-replacement-38
+    liar-word-39: liar-word-replacement-39
+    liar-word-40: liar-word-replacement-40
+    liar-word-41: liar-word-replacement-41
+    liar-word-42: liar-word-replacement-42
\ No newline at end of file
index ba9bd8d88682abf7cfb41f8a282c8bbe20f9821c..d1e0afc83c1431dd7920499d73ffc542e7a44779 100644 (file)
   description: trait-southern-desc
   components:
     - type: SouthernAccent
+
+- type: trait
+  id: Liar
+  name: trait-liar-name
+  description: trait-liar-desc
+  components:
+    - type: ReplacementAccent
+      replacementChance: 0.15
+      accent: liar