Files
Bubberstation/code/datums/mutations/speech.dm
MrMelbert 8c1e35e1c0 Refactors mind language holders into non-existent, fixes new languages being deleted on species swap + tests (#76612)
## About The Pull Request

This PR refactors mind language holders into non-existence

As a result, `update_atom_languages` is no longer necessary

Mind-bound languages are transferred via `/mind/proc/transfer_to`

Species changing no longer deletes and re-creates the mob's language
holder, allowing them to keep any languages they have.

Species languages are sourced from `LANGUAGE_SPECIES` now, meaning they
are removed when they change species. If the mob is not a human with a
species datum, these are effectively just atom level languages.

Makes a bunch of unit tests to ensure language transfer over certain
events works as intended

## Why It's Good For The Game

Mobs with minds having two independent language holders results in a
good few bugs, and simply doesn't make sense when we have sources
(`LANGUAGE_MIND`).

Instead of tracking two language holders, we can simply use sources
better and only track one.

This means that the language holder you start with is your language
holder, period. It doesn't get deleted or re-instantiated or whatever.

## Changelog

🆑 Melbert
refactor: Refactored language holders, making species changes not delete
all of your known languages
/🆑
2023-07-10 18:34:57 +00:00

266 lines
10 KiB
Plaintext

//These are all minor mutations that affect your speech somehow.
//Individual ones aren't commented since their functions should be evident at a glance
/datum/mutation/human/nervousness
name = "Nervousness"
desc = "Causes the holder to stutter."
quality = MINOR_NEGATIVE
text_gain_indication = "<span class='danger'>You feel nervous.</span>"
/datum/mutation/human/nervousness/on_life(seconds_per_tick, times_fired)
if(SPT_PROB(5, seconds_per_tick))
owner.set_stutter_if_lower(20 SECONDS)
/datum/mutation/human/wacky
name = "Wacky"
desc = "You are not a clown. You are the entire circus."
quality = MINOR_NEGATIVE
text_gain_indication = "<span class='sans'><span class='infoplain'>You feel an off sensation in your voicebox.</span></span>"
text_lose_indication = "<span class='notice'>The off sensation passes.</span>"
/datum/mutation/human/wacky/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
RegisterSignal(owner, COMSIG_MOB_SAY, PROC_REF(handle_speech))
/datum/mutation/human/wacky/on_losing(mob/living/carbon/human/owner)
if(..())
return
UnregisterSignal(owner, COMSIG_MOB_SAY)
/datum/mutation/human/wacky/proc/handle_speech(datum/source, list/speech_args)
SIGNAL_HANDLER
speech_args[SPEECH_SPANS] |= SPAN_SANS
/datum/mutation/human/mute
name = "Mute"
desc = "Completely inhibits the vocal section of the brain."
quality = NEGATIVE
text_gain_indication = "<span class='danger'>You feel unable to express yourself at all.</span>"
text_lose_indication = "<span class='danger'>You feel able to speak freely again.</span>"
/datum/mutation/human/mute/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
ADD_TRAIT(owner, TRAIT_MUTE, GENETIC_MUTATION)
/datum/mutation/human/mute/on_losing(mob/living/carbon/human/owner)
if(..())
return
REMOVE_TRAIT(owner, TRAIT_MUTE, GENETIC_MUTATION)
/datum/mutation/human/unintelligible
name = "Unintelligible"
desc = "Partially inhibits the vocal center of the brain, severely distorting speech."
quality = NEGATIVE
text_gain_indication = "<span class='danger'>You can't seem to form any coherent thoughts!</span>"
text_lose_indication = "<span class='danger'>Your mind feels more clear.</span>"
/datum/mutation/human/unintelligible/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
ADD_TRAIT(owner, TRAIT_UNINTELLIGIBLE_SPEECH, GENETIC_MUTATION)
/datum/mutation/human/unintelligible/on_losing(mob/living/carbon/human/owner)
if(..())
return
REMOVE_TRAIT(owner, TRAIT_UNINTELLIGIBLE_SPEECH, GENETIC_MUTATION)
/datum/mutation/human/swedish
name = "Swedish"
desc = "A horrible mutation originating from the distant past. Thought to be eradicated after the incident in 2037."
quality = MINOR_NEGATIVE
text_gain_indication = "<span class='notice'>You feel Swedish, however that works.</span>"
text_lose_indication = "<span class='notice'>The feeling of Swedishness passes.</span>"
/datum/mutation/human/swedish/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
RegisterSignal(owner, COMSIG_MOB_SAY, PROC_REF(handle_speech))
/datum/mutation/human/swedish/on_losing(mob/living/carbon/human/owner)
if(..())
return
UnregisterSignal(owner, COMSIG_MOB_SAY)
/datum/mutation/human/swedish/proc/handle_speech(datum/source, list/speech_args)
SIGNAL_HANDLER
var/message = speech_args[SPEECH_MESSAGE]
if(message)
message = replacetext(message,"w","v")
message = replacetext(message,"j","y")
message = replacetext(message,"a",pick("å","ä","æ","a"))
message = replacetext(message,"bo","bjo")
message = replacetext(message,"o",pick("ö","ø","o"))
if(prob(30))
message += " Bork[pick("",", bork",", bork, bork")]!"
speech_args[SPEECH_MESSAGE] = trim(message)
/datum/mutation/human/chav
name = "Chav"
desc = "Unknown"
quality = MINOR_NEGATIVE
text_gain_indication = "<span class='notice'>Ye feel like a reet prat like, innit?</span>"
text_lose_indication = "<span class='notice'>You no longer feel like being rude and sassy.</span>"
/datum/mutation/human/chav/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
RegisterSignal(owner, COMSIG_MOB_SAY, PROC_REF(handle_speech))
/datum/mutation/human/chav/on_losing(mob/living/carbon/human/owner)
if(..())
return
UnregisterSignal(owner, COMSIG_MOB_SAY)
/datum/mutation/human/chav/proc/handle_speech(datum/source, list/speech_args)
SIGNAL_HANDLER
var/message = speech_args[SPEECH_MESSAGE]
if(message[1] != "*")
message = " [message]"
var/list/chav_words = strings("chav_replacement.json", "chav")
for(var/key in chav_words)
var/value = chav_words[key]
if(islist(value))
value = pick(value)
message = replacetextEx(message, " [uppertext(key)]", " [uppertext(value)]")
message = replacetextEx(message, " [capitalize(key)]", " [capitalize(value)]")
message = replacetextEx(message, " [key]", " [value]")
if(prob(30))
message += ", mate"
speech_args[SPEECH_MESSAGE] = trim(message)
/datum/mutation/human/elvis
name = "Elvis"
desc = "A terrifying mutation named after its 'patient-zero'."
quality = MINOR_NEGATIVE
locked = TRUE
text_gain_indication = "<span class='notice'>You feel pretty good, honeydoll.</span>"
text_lose_indication = "<span class='notice'>You feel a little less conversation would be great.</span>"
/datum/mutation/human/elvis/on_life(seconds_per_tick, times_fired)
switch(pick(1,2))
if(1)
if(SPT_PROB(7.5, seconds_per_tick))
var/list/dancetypes = list("swinging", "fancy", "stylish", "20'th century", "jivin'", "rock and roller", "cool", "salacious", "bashing", "smashing")
var/dancemoves = pick(dancetypes)
owner.visible_message("<b>[owner]</b> busts out some [dancemoves] moves!")
if(2)
if(SPT_PROB(7.5, seconds_per_tick))
owner.visible_message("<b>[owner]</b> [pick("jiggles their hips", "rotates their hips", "gyrates their hips", "taps their foot", "dances to an imaginary song", "jiggles their legs", "snaps their fingers")]!")
/datum/mutation/human/elvis/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
RegisterSignal(owner, COMSIG_MOB_SAY, PROC_REF(handle_speech))
/datum/mutation/human/elvis/on_losing(mob/living/carbon/human/owner)
if(..())
return
UnregisterSignal(owner, COMSIG_MOB_SAY)
/datum/mutation/human/elvis/proc/handle_speech(datum/source, list/speech_args)
SIGNAL_HANDLER
var/message = speech_args[SPEECH_MESSAGE]
if(message)
message = " [message] "
message = replacetext(message," i'm not "," I ain't ")
message = replacetext(message," girl ",pick(" honey "," baby "," baby doll "))
message = replacetext(message," man ",pick(" son "," buddy "," brother"," pal "," friendo "))
message = replacetext(message," out of "," outta ")
message = replacetext(message," thank you "," thank you, thank you very much ")
message = replacetext(message," thanks "," thank you, thank you very much ")
message = replacetext(message," what are you "," whatcha ")
message = replacetext(message," yes ",pick(" sure", "yea "))
message = replacetext(message," muh valids "," my kicks ")
speech_args[SPEECH_MESSAGE] = trim(message)
/datum/mutation/human/stoner
name = "Stoner"
desc = "A common mutation that severely decreases intelligence."
quality = NEGATIVE
locked = TRUE
text_gain_indication = "<span class='notice'>You feel...totally chill, man!</span>"
text_lose_indication = "<span class='notice'>You feel like you have a better sense of time.</span>"
/datum/mutation/human/stoner/on_acquiring(mob/living/carbon/human/owner)
..()
owner.grant_language(/datum/language/beachbum, source = LANGUAGE_STONER)
owner.add_blocked_language(subtypesof(/datum/language) - /datum/language/beachbum, LANGUAGE_STONER)
/datum/mutation/human/stoner/on_losing(mob/living/carbon/human/owner)
..()
owner.remove_language(/datum/language/beachbum, source = LANGUAGE_STONER)
owner.remove_blocked_language(subtypesof(/datum/language) - /datum/language/beachbum, LANGUAGE_STONER)
/datum/mutation/human/medieval
name = "Medieval"
desc = "A horrible mutation originating from the distant past, thought to have once been a common gene in all of old world Europe."
quality = MINOR_NEGATIVE
text_gain_indication = "<span class='notice'>You feel like seeking the holy grail!</span>"
text_lose_indication = "<span class='notice'>You no longer feel like seeking anything.</span>"
/datum/mutation/human/medieval/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
RegisterSignal(owner, COMSIG_MOB_SAY, PROC_REF(handle_speech))
/datum/mutation/human/medieval/on_losing(mob/living/carbon/human/owner)
if(..())
return
UnregisterSignal(owner, COMSIG_MOB_SAY)
/datum/mutation/human/medieval/proc/handle_speech(datum/source, list/speech_args)
SIGNAL_HANDLER
var/message = speech_args[SPEECH_MESSAGE]
if(message)
message = " [message] "
var/list/medieval_words = strings("medieval_replacement.json", "medieval")
var/list/startings = strings("medieval_replacement.json", "startings")
for(var/key in medieval_words)
var/value = medieval_words[key]
if(islist(value))
value = pick(value)
if(uppertext(key) == key)
value = uppertext(value)
if(capitalize(key) == key)
value = capitalize(value)
message = replacetextEx(message,regex("\b[REGEX_QUOTE(key)]\b","ig"), value)
message = trim(message)
var/chosen_starting = pick(startings)
message = "[chosen_starting] [message]"
speech_args[SPEECH_MESSAGE] = message
/datum/mutation/human/piglatin
name = "Pig Latin"
desc = "Historians say back in the 2020's humanity spoke entirely in this mystical language."
quality = MINOR_NEGATIVE
text_gain_indication = span_notice("Omethingsay eelsfay offyay.")
text_lose_indication = span_notice("The off sensation passes.")
/datum/mutation/human/piglatin/on_acquiring(mob/living/carbon/human/owner)
if(..())
return
RegisterSignal(owner, COMSIG_MOB_SAY, PROC_REF(handle_speech))
/datum/mutation/human/piglatin/on_losing(mob/living/carbon/human/owner)
if(..())
return
UnregisterSignal(owner, COMSIG_MOB_SAY)
/datum/mutation/human/piglatin/proc/handle_speech(datum/source, list/speech_args)
SIGNAL_HANDLER
var/spoken_message = speech_args[SPEECH_MESSAGE]
spoken_message = piglatin_sentence(spoken_message)
speech_args[SPEECH_MESSAGE] = spoken_message