Files
lew 11a9a2d644 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.
2026-06-11 10:47:26 +00:00

103 lines
8.3 KiB
Plaintext

// Noise "language", for audible emotes.
/datum/language/noise
name = LANGUAGE_NOISE
desc = "Noises."
key = "e"
flags = RESTRICTED | INNATE | NO_TALK_MSG | NO_STUTTER | TCOMSSIM
allow_accents = TRUE
/datum/language/noise/format_message(message, verb)
return span("message", colourize(message))
/datum/language/noise/format_message_plain(message, verb)
return message
/datum/language/noise/get_talkinto_msg_range(message)
// if you make a loud noise (screams etc), you'll be heard from 4 tiles over instead of two
return (copytext(message, length(message)) == "!") ? 4 : 2
// 'basic' language; spoken by default.
/datum/language/common
name = LANGUAGE_TCB
desc = "A spiritual successor of Esperanto, established in 2404 in Tau Ceti by Ceti intellectuals. Its unique, fully customized alphabet and structure allow it to be spoken even by most alien species. It's the official language of Tau Ceti and has growing traction in diplomatic circles and Universalists across human space."
speech_verb = list("says")
key = "0"
flags = RESTRICTED|TCOMSSIM
allow_accents = TRUE
syllables = list("a", "ado", "ago", "aj", "ajn", "al", "alt", "am", "amas", "an", "ang", "ante", "ap", "ard", "arma", "aro", "as", "aur", "aut", "aw", "ba", "bal", "bao", "be", "beau", "bel", "bi", "bit", "blu", "bo", "bod", "boj", "bojn", "bu", "but", "ca", "caj", "ce", "cer", "chun",
"ci", "cion", "coj", "cor", "da", "daj", "dan", "de", "den", "dis", "do", "dor", "dorm", "eco", "ego", "ek", "eks", "en", "ero", "es", "est", "et", "eve", "fa", "fe", "fel", "fla", "foj", "fra", "fraz", "fros", "ful", "fut", "ga", "gan", "gar", "gi", "gis", "go", "gran", "ha", "han", "hav",
"hom", "hong", "hu", "hum", "hushi", "ia", "iaj", "ica", "id", "idon", "il", "in", "ing", "io", "is", "iton", "iza", "ja", "ji", "jirou", "joj", "ka", "kaj", "kajo", "kan", "ke", "ket", "ki", "kna", "krio", "ku", "kui", "kuk", "kun", "kur", "la", "laca", "leng", "les", "li", "liao", "lib",
"ling", "lis", "lo", "lon", "long", "lu", "lud", "ma", "mal", "man", "me", "mego", "mero", "mi", "mia", "min", "mo", "moj", "mola", "mon", "mul", "ne", "ner", "ni", "nio", "no", "nu", "of", "oj", "om", "on", "ou", "pe", "pi", "plan", "pli", "po", "por", "post", "pre", "prin", "pru", "pu",
"pur", "qiu", "que", "ra", "ras", "re", "ri", "rig", "ril", "ro", "roj", "ron", "roso", "rou", "ru", "sa", "san", "sci", "sek", "shi", "shiia", "shiue", "shiwu", "shu", "shui", "si", "siaj", "sku", "so", "som", "sti", "str", "stre", "su", "suno", "ta", "tan", "tas", "te", "tel", "tem",
"the", "ti", "tian", "tita", "tiu", "to", "toj", "ton", "tran", "tre", "tri", "trin", "tro", "trus", "un", "undo", "uno ", "uz", "va", "var", "varm", "vas", "ve", "vek", "ven", "ves", "vi", "via", "vin", "vino", "vint", "vir", "von", "vu", "whe", "wu", "yong", "zem", "zo", "zoj", "zon")
// Galactic common languages (systemwide accepted standards).
/datum/language/trader
name = LANGUAGE_TRADEBAND
short = "TRADE"
desc = "Descended from latin and romance languages of old Earth, Tradeband remains the main tongue of the upper class of humanity. The language sounds elegant and well structured to most ears. It remains in popular use with traders, diplomats, and those seeking to hold onto a piece of a romantic past."
speech_verb = list("enunciates")
sing_verb = list("performs")
colour = "tradeband"
written_style = "tradeband"
key = "2"
flags = TCOMSSIM
allow_accents = TRUE
syllables = list("a", "acc", "ai", "al", "ali", "am", "ama", "ami", "amo", "an", "ang", "arme", "ave", "ba", "bai", "bar", "bat", "bi", "blie", "bris", "ca", "can", "cant", "car", "care", "ce", "ci", "cis", "cit", "cla", "co", "cul", "cur", "curt", "da", "dam", "dans", "de",
"di", "dier", "dim", "dins", "dorm", "du", "duro", "e", "eaux", "ec", "ecto", "ees", "ego", "el", "en", "ent", "er", "ere", "eres", "eri", "ero", "es", "et", "ex", "far", "fi", "fic", "fine", "fol", "foll", "fri", "fro", "gen", "gil", "go", "gran", "hab", "ho", "huc", "ia",
"iam", "ibus", "idor", "ie", "iens", "ier", "ieur", "iis", "il", "in", "ine", "int", "ir", "is", "ise", "it", "itt", "jar", "je", "jo", "jor", "la", "lar", "lav", "le", "lees", "ler", "les", "li", "lib", "lie", "lo", "lu", "ma", "man", "manu", "mar", "mari", "mas", "me", "mea",
"mee", "mejo", "men", "mes", "meum", "meus", "mi", "mier", "min", "mine", "mit", "mo", "moi", "mon", "mons", "mors", "mou", "mul", "na", "nam", "ne", "nee", "nent", "nes", "ni", "nit", "no", "nom", "nu", "num", "o", "oc", "occ", "oja", "om", "omni", "or", "ori", "oro", "os", "ou",
"oub", "pa", "par", "pars", "pas", "plu", "pluv", "po", "pol", "pos", "pou", "pous", "pre", "pu", "pug", "pus", "que", "qui", "re", "ri", "ric", "riga", "rito", "ro", "rom", "sa", "sal", "se", "ser", "sers", "ses", "sim", "sion", "so", "sol", "som", "sou", "sper", "sse", "ste", "su",
"suis", "sul", "sur", "ta", "tar", "te", "teau", "tem", "temp", "ten", "tene", "tes", "ti", "tibus", "tien", "tion", "to", "tol", "ton", "tons", "tout", "tra", "trai", "tre", "trou", "tuo", "tus", "tut", "ues", "ui", "ul", "um", "un", "upa", "us", "ut", "ux", "va", "vail", "ve", "ven",
"veni", "vi", "viam", "vie", "vo", "xus", "za", "zio")
// Criminal language.
/datum/language/gutter
name = LANGUAGE_GUTTER
short = "FREE"
desc = "A language of renegades and frontiersmen descending from various languages from Earth like Hindi combined into a multi-rooted jumble that sounds incoherent or even barbarian to non-native speakers. This language is the only common cultural identity for humans in the frontier. Speaking this language in itself boldly declares the speaker a free spirit. Often called 'Gutter' by Alliance citizens."
speech_verb = list("says")
sing_verb = list("croons")
colour = "freespeak"
written_style = "freespeak"
key = "3"
flags = TCOMSSIM
allow_accents = TRUE
syllables = list("a", "aan", "aas", "ab", "aba", "ad", "aee", "aft", "ag", "ai", "aise", "ak", "akee", "aq", "ar", "ata", "aur", "aus", "ba", "baat", "bach", "bad", "bahe", "band", "be", "ben", "ber", "bhaa", "bhu", "bra", "burt", "cap", "cer", "ch", "cha", "chaar", "chale", "chalo", "chil",
"com", "da", "daa", "daaj", "dat", "de", "dee", "dhaa", "di", "die", "dik", "din", "diz", "do", "dos", "dosh", "durch", "eer", "ek", "er", "es", "fal", "fang", "fra", "fun", "ga", "gan", "gao", "gee", "geet", "gern", "gir", "gon", "gren", "gri", "gu", "guda", "ha", "haa", "hai", "hain", "har",
"hat", "he", "hee", "heer", "hekt", "heu", "hit", "hn", "ho", "hua", "huk", "hul", "ich", "ig", "in", "isch", "ja", "jaa", "jad", "jan", "jao", "jar", "jas", "jee", "jiao", "jin", "jing ", "un", "ka", "kaha", "kana", "kar", "kara", "karo", "ke ", "kee", "keln", "kha", "khada", "khe", "khi", "ko",
"koo", "ky", "la", "laa", "laat", "lad", "lada", "lana", "lane", "le", "lee", "leiden", "leis", "len", "lie", "lo", "maa", "maan", "mod ", "most", "muj", "mujhe", "mukt", "na", "naya", "ne", "nee", "net", "neta", "nir", "nka", "oon", "oop", "pa", "paa", "pet", "phen", "phot", "pi", "plo", "pra",
"que", "ra", "raa", "rahe", "raho", "ran", "rana", "rar", "re", "ri", "rie", "rin", "ro", "rona", "rosh", "rtiv", "saa", "saal", "saath", "san", "santu", "sch", "se", "sen", "sh", "sha", "shee", "shi", "shn", "sht", "shuo", "soch", "sol", "soo", "ssa", "ster", "suk", "sur", "ta", "taan", "tak",
"taka", "tal", "tan", "tar", "ten", "tend", "th", "tho", "tili", "to", "ton", "tr", "tu", "tum", "tung", "udaa", "ugr", "unge", "ut", "va", "vaa", "vaad", "vaib", "ve", "ven", "ver", "vi", "vis", "vol", "wic", "wu", "wut", "xi", "xiao", "ya", "yah", "yon", "you", "zas", "ze", "zhu", "zi", "zo", "zorn", "zt")
// Sign language
/datum/language/sign
name = LANGUAGE_SIGN
desc = "A signed version of Tau Ceti Basic. It is primarily used by those who are deaf, hearing impaired, or mute."
speech_verb = list("signs")
signlang_verb = list("signs", "gestures")
sing_verb = null
colour = "i"
key = "s"
flags = NO_STUTTER | SIGNLANG
// Helper
/proc/get_lang_name(var/datum/language/language)
if (!language || !istype(language))
return "Unknown"
return language.name
/datum/language/aphasia
name = LANGUAGE_GIBBERING
desc = "It is theorized that any sufficiently brain-damaged person can speak this language."
speech_verb = list("garbles")
ask_verb = list("mumbles")
whisper_verb = list("mutters")
exclaim_verb = list("screams incoherently")
sing_verb = list("gibbers")
key = "gi"
syllables = list("m","n","gh","h","l","s","r","a","e","i","o","u")
space_chance = 20
flags = RESTRICTED