Multi-Languages: a complete Saycode rewrite (#22637)

Rewrites Saycode and Langchat to add support for multiple languages in
one message, including audible emotes.

<img width="1139" height="338" alt="image"
src="https://github.com/user-attachments/assets/25e26932-7a6e-4c54-ab74-56fffb92ecad"
/>

Here's some samples to explain how to mix languages.

<img width="422" height="26" alt="image"
src="https://github.com/user-attachments/assets/e1b176cc-8625-4dc9-83c8-a053d3f310e6"
/>

`Languages ,2 can be mixed ,3 like this.`

<img width="540" height="21" alt="image"
src="https://github.com/user-attachments/assets/19156c67-4670-4d7a-84d7-26e527de2676"
/>

`!explains, ,2Emotes work too. ,0The text will get auto-quoted.`

<img width="592" height="18" alt="image"
src="https://github.com/user-attachments/assets/cfc31c5c-2383-41c8-82be-b36836339321"
/>

`,3Most languages ,0can be ,2mixed ,1arbitrarily, ,3any number of
,0times.`

<img width="636" height="20" alt="image"
src="https://github.com/user-attachments/assets/388b4f9d-192a-4374-ac31-bbd4e4e5dfe4"
/>

`,2Emotes. ,eAnd he nods. ,3They don't have to come first anymore.`

There are some exceptions. The exceptions are currently anything with
any of the flags `SIGNLANG`, `HIVEMIND`, `PRESSUREPROOF`,
`KNOWONLYHEAR`. Exceptions work the same as current languages do: they
must be the first language in the message. If so, they prevent switching
into any other language mid-message; if they're not first, they just
wont trigger.

They're exceptions currently because there's not really a clean way that
I or the people I asked for help on this one to make them look nice.
`SIGNLANG` for example doesn't scramble text, it shows it's own `
gestures a lengthy message.` text for those that don't understand. Could
we just replace every instance of sign language with that if somebody
doesn't understand? Probably. It would look pretty awful though. e.g.
`Alina Eskelinen says, "Hello." Alina Eskelinen gestures a short
message.`

This definitely needs testmerging because it more or less rewrites the
entire pipeline surrounding `say`. The `say` code itself had to be
rewritten to support the multiple languages, as well as all the existing
plumbing for listeners receiving messages. In return though, it's
significantly more straightforward and hopefully by extension easier for
people to add to in the future.

Primarily, instead of having four different `hear_say`, `hear_radio`,
`hear_sleep`, etc., routes for messages to come through, every single
audible message is received by `hear_message`, which is responsible for
figuring out how clear the message is (is the radio damaged? is it a
whisper we're eavesdropping on?), who needs to receive it in their
chatbox, formatting it correctly for each listener, and finally if any
npc or object within range needs to react to it in some way, like a
parrot or a mech.

changelog:
- rscadd: "Adds code-switching: you can now speak in multiple languages
in the same message."
- rscadd: "Adds audible emotes to the language list. They can be
triggered with ,e."
  - rscdel: "Removes SSrunechat."
- refactor: "Rewrote langchat in order to support multiple languages and
partial comprehension."
- refactor: "Rewrote a vast majority of all saycode and the code
responsible for displaying saytext to clients."
- bugfix: "Sleeping mobs are no longer able to understand all
languages."
- bugfix: "Langchat now correctly shows the appropriate comprehension
for all viewers rather than all viewers sharing the comprehension of the
last viewer."
- bugfix: "Languages which are supposed to be invisible when not
understood no longer appear as scrambled overhead text."

Forgive me whoever has to review this. Biggest areas that have room for
error is stuff like a borer inside someone's head, and Dionae stuff. Old
langchat had odd exceptions for those and I was forced to rewrite it
entirely, but I think I got it all back to how it was working before.
This commit is contained in:
lew
2026-06-11 10:47:26 +00:00
committed by GitHub
parent a7b05ec4db
commit 11a9a2d644
46 changed files with 1185 additions and 924 deletions
@@ -5,7 +5,7 @@
/mob/statue_mob/send_emote()
to_chat(src, "You are unable to move while trapped as a statue.")
/mob/statue_mob/say(var/message, var/datum/language/speaking = null, var/verb="says", var/alt_name="", var/ghost_hearing = GHOSTS_ALL_HEAR, var/whisper = FALSE)
/mob/statue_mob/say(var/text, var/datum/language/speaking = null, var/verb="says", var/alt_name="", var/ghost_hearing = GHOSTS_ALL_HEAR, var/whisper = FALSE)
to_chat(src, "You are unable to speak while trapped as a statue.")
/obj/structure/closet/statue
@@ -97,12 +97,15 @@
/datum/signal/subspace/vocal
var/datum/weakref/speaker
var/datum/language/language
/// The speaker's say_message, if any. Null for the announcer, etc.
var/datum/say_message/say_message
/datum/signal/subspace/vocal/New(obj/source, frequency, datum/weakref/speaker, datum/language/language, message, say_verb)
/datum/signal/subspace/vocal/New(obj/source, frequency, datum/weakref/speaker, datum/language/language, message, say_verb, datum/say_message/say_message)
src.source = source
src.frequency = frequency
src.language = language
src.speaker = speaker
src.say_message = say_message
var/turf/T = get_turf(source)
if(isturf(T))
@@ -127,7 +130,7 @@
)
/datum/signal/subspace/vocal/copy()
var/datum/signal/subspace/vocal/copy = new(source, frequency, speaker, language)
var/datum/signal/subspace/vocal/copy = new(source, frequency, speaker, language, say_message = say_message)
copy.original = src
copy.data = data.Copy()
copy.levels = levels
@@ -214,12 +217,25 @@
var/compression = data["compression"]
// Carry the original message if untouched in transit, else build one from the flat text.
var/datum/say_message/radio_msg
if(say_message && say_message.to_string() == data["message"])
radio_msg = say_message.copy()
else
radio_msg = new
radio_msg.speaker = M
radio_msg.verb = data["say_verb"]
radio_msg.collapse_to(language, message)
radio_msg.say_mode = SAYMODE_RADIO
radio_msg.base_clarity = compression ? CLARITY_FAINT : CLARITY_CLEAR
radio_msg.radio_parts = list(part_a, part_b, part_c)
for (var/mob/hearer in receive)
if(!hearer)
crash_with("null found in the hearers list returned by the spatial grid")
continue
hearer.hear_radio(message, data["say_verb"], language, part_a, part_b, part_c, M, !!compression)
hearer.hear_message(radio_msg)
// --- This following recording is intended for research and feedback in the use of department radio channels ---