Skip to content

Commit

Permalink
Remove Ending Punctuation From Emote Detection (#561)
Browse files Browse the repository at this point in the history
# Description

Replaces the tons of super inconsistent emote defs with consistent and
more dynamic ones.

---

<details><summary><h1>Media</h1></summary>
<p>


https://github.com/user-attachments/assets/eed4a1c9-7fe7-45a9-acb9-cbd64dd319e0

</p>
</details>

---

# Changelog

:cl:
- fix: Emotes now consistently work with any or no punctuation

---------

Signed-off-by: DEATHB4DEFEAT <[email protected]>
  • Loading branch information
DEATHB4DEFEAT committed Jul 21, 2024
1 parent c211c66 commit f25fc1e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 461 deletions.
6 changes: 6 additions & 0 deletions Content.Server/Chat/Systems/ChatSystem.Emote.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Frozen;
using System.Linq;
using Content.Shared.Chat.Prototypes;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand All @@ -9,6 +10,7 @@ namespace Content.Server.Chat.Systems;
public partial class ChatSystem
{
private FrozenDictionary<string, EmotePrototype> _wordEmoteDict = FrozenDictionary<string, EmotePrototype>.Empty;
private IReadOnlyList<string> Punctuation { get; } = new List<string> { ",", ".", "!", "?", "-", "~", "'", "\"", };

protected override void OnPrototypeReload(PrototypesReloadedEventArgs obj)
{
Expand Down Expand Up @@ -150,6 +152,10 @@ public bool TryPlayEmoteSound(EntityUid uid, EmoteSoundsPrototype? proto, string
private void TryEmoteChatInput(EntityUid uid, string textInput)
{
var actionLower = textInput.ToLower();
// Replace ending punctuation with nothing
if (Punctuation.Any(punctuation => actionLower.EndsWith(punctuation)))
actionLower = actionLower.Remove(actionLower.Length - 1);

if (!_wordEmoteDict.TryGetValue(actionLower, out var emote))
return;

Expand Down
154 changes: 10 additions & 144 deletions Resources/Prototypes/DeltaV/Voice/speech_emotes.yml
Original file line number Diff line number Diff line change
@@ -1,198 +1,64 @@
- type: emote
id: HarpyRing
category: Vocal
chatMessages: [rings.]
chatMessages: [ rings ]
chatTriggers:
- ring
- ring.
- ring!
- ring?
- rings
- rings.
- rings!
- rings?
- ringing
- ringing.
- ringing!
- ringing?
- ringed
- ringed.
- ringed!
- ringed?
- rang
- rang.
- rang!
- rang?

- type: emote
id: HarpyPew
category: Vocal
chatMessages: [pews.]
chatMessages: [ pews ]
chatTriggers:
- pew
- pew.
- pew!
- pew?
- pews
- pews.
- pews!
- pews?
- pewpew
- pewpew.
- pewpew!
- pewpew?
- pewpews

- type: emote
id: HarpyBang
category: Vocal
chatMessages: [bangs.]
chatMessages: [ bangs ]
chatTriggers:
- bang
- bang.
- bang!
- bang?
- bangs
- bangs.
- bangs!
- bangs?
- banging
- banging.
- banging!
- banging?
- banged
- banged.
- banged!
- banged?

- type: emote
id: HarpyRev
category: Vocal
chatMessages: [revs.]
chatMessages: [ revs ]
chatTriggers:
- rev
- rev.
- rev!
- rev?
- revs
- revs.
- revs!
- revs?
- revving
- revving.
- revving!
- revving?
- revved
- revved.
- revved!
- revved?

- type: emote
id: HarpyCaw
category: Vocal
chatMessages: [caws.]
chatMessages: [ caws ]
chatTriggers:
- caw
- caw.
- caw!
- caw?
- caws
- caws.
- caws!
- caws?
- cawing
- cawing.
- cawing!
- cawing?
- cawed
- cawed.
- cawed!
- cawed?

#Vulpkanin
- type: emote
id: Bark
category: Vocal
chatMessages: [barks.]
chatMessages: [ barks ]
chatTriggers:
- bark
- bark.
- bark!
- bark?
- barks
- barks.
- barks!
- barks?
- barked
- barked.
- barked!
- barked?
- barking
- barking.
- barking!
- barking?

- type: emote
id: Snarl
category: Vocal
chatMessages: [snarls.]
chatMessages: [ snarls ]
chatTriggers:
- snarl
- snarl.
- snarl!
- snarl?
- snarls
- snarls.
- snarls!
- snarls?
- snarled
- snarled.
- snarled!
- snarled?
- snarling
- snarling.
- snarling!
- snarling?

- type: emote
id: Whine
category: Vocal
chatMessages: [whines.]
chatMessages: [ whines ]
chatTriggers:
- whine
- whine.
- whine!
- whine?
- whines
- whines.
- whines!
- whines?
- whined
- whined.
- whined!
- whined?
- whining
- whining.
- whining!
- whining?

- type: emote
id: Howl
category: Vocal
chatMessages: [howls.]
chatMessages: [ howls ]
chatTriggers:
- howl
- howl.
- howl!
- howl?
- howls
- howls.
- howls!
- howls?
- howling
- howling.
- howling!
- howling?
- howled
- howled.
- howling!
- howling?
61 changes: 13 additions & 48 deletions Resources/Prototypes/Nyanotrasen/Voice/speech_emotes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,37 @@
- type: emote
id: Hiss
category: Vocal
chatMessages: [hisses.]
chatMessages: [ hisses ]
chatTriggers:
- hiss.
- hisses.
- hisses!
- hissing.
- hissed.
- hisses

- type: emote
id: Meow
category: Vocal
chatMessages: [meows.]
chatMessages: [ meows ]
chatTriggers:
- meow.
- meow!
- meows.
- meows~
- meows!
- meowing.
- meowed.
- miau.
- miaus.
- miaus!
- nya.
- nyas.
- nyas!
- mraow.
- mraow!
- mraow~
- mraows.
- mraows!
- mraows~
- meows
- miaus
- nyas
- mraows

- type: emote
id: Mew
category: Vocal
chatMessages: [mews.]
chatMessages: [ mews ]
chatTriggers:
- mew.
- mew!
- mew~
- mews.
- mews!
- mews~
- mewing.
- mewed.
- mews

- type: emote
id: Growl
category: Vocal
chatMessages: [growls.]
chatMessages: [ growls ]
chatTriggers:
- growl.
- growls.
- growls!
- growling.
- growled.
- growls

- type: emote
id: Purr
category: Vocal
chatMessages: [purrs.]
chatMessages: [ purrs ]
chatTriggers:
- purr.
- purrs.
- purrs~
- purrs!
- purring.
- purred.
- purrs
20 changes: 9 additions & 11 deletions Resources/Prototypes/Voice/disease_emotes.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
- type: emote
id: Sneeze
category: Vocal
chatMessages: [sneezes]
chatMessages: [ sneezes ]

- type: emote
id: Cough
category: Vocal
chatMessages: [coughs]
chatMessages: [ coughs ]
chatTriggers:
- cough
- coughs

- type: emote
id: CatMeow
category: Vocal
chatMessages: [meows]
chatMessages: [ meows ]

- type: emote
id: CatHisses
category: Vocal
chatMessages: [hisses]
chatMessages: [ hisses ]

- type: emote
id: MonkeyScreeches
category: Vocal
chatMessages: [screeches]
chatMessages: [ screeches ]

- type: emote
id: RobotBeep
category: Vocal
chatMessages: [beeps]
chatMessages: [ beeps ]

- type: emote
id: Yawn
category: Vocal
chatMessages: [yawns]
chatMessages: [ yawns ]
chatTriggers:
- yawn
- yawns

- type: emote
id: Snore
category: Vocal
chatMessages: [snores]
chatMessages: [ snores ]
Loading

0 comments on commit f25fc1e

Please sign in to comment.