Files
Paradise/code/modules/mob/living/autohiss.dm
GDN 9e6dcf9c46 removes the remaining datum redeclares (#25220)
* removes the remaining datum redeclares

* the two fixes

* finneee contra

* OK CONTRA

* readd

* CURSED TO BE BROWN!

* facking automerge
2024-04-21 18:26:35 +00:00

64 lines
2.1 KiB
Plaintext

/mob/proc/handle_autohiss(message, datum/language/L)
return message // no autohiss at this level
/mob/living/carbon/human/handle_autohiss(message, datum/language/L)
if(!client || client.prefs.active_character.autohiss_mode == AUTOHISS_OFF) // no need to process if there's no client or they have autohiss off
return message
return dna.species.handle_autohiss(message, L, client.prefs.active_character.autohiss_mode)
/client/verb/toggle_autohiss()
set name = "Toggle Auto-Accent"
set desc = "Toggle automatic accents for your species"
set category = "OOC"
prefs.active_character.autohiss_mode = (prefs.active_character.autohiss_mode + 1) % AUTOHISS_NUM
switch(prefs.active_character.autohiss_mode)
if(AUTOHISS_OFF)
to_chat(src, "Auto-hiss is now OFF.")
if(AUTOHISS_BASIC)
to_chat(src, "Auto-hiss is now BASIC.")
if(AUTOHISS_FULL)
to_chat(src, "Auto-hiss is now FULL.")
else
prefs.active_character.autohiss_mode = AUTOHISS_OFF
to_chat(src, "Auto-hiss is now OFF.")
/datum/species/proc/handle_autohiss(message, datum/language/lang, mode)
if(!autohiss_basic_map)
return message
if(autohiss_exempt && (lang && (lang.name in autohiss_exempt)))
return message
var/map = autohiss_basic_map.Copy()
if(mode == AUTOHISS_FULL && autohiss_extra_map)
map |= autohiss_extra_map
. = list()
while(length_char(message))
var/min_index = 10000 // if the message is longer than this, the autohiss is the least of your problems
var/min_char = null
for(var/char in map)
var/i = findtext_char(message, char)
if(!i) // no more of this character anywhere in the string, don't even bother searching next time
map -= char
else if(i < min_index)
min_index = i
min_char = char
if(!min_char) // we didn't find any of the mapping characters
. += message
break
. += copytext_char(message, 1, min_index)
if(copytext_char(message, min_index, min_index + 1) == uppertext(min_char))
. += uppertext(pick(map[min_char]))
else
. += pick(map[min_char])
message = copytext_char(message, min_index + 1)
return jointext(., "")
#undef AUTOHISS_OFF
#undef AUTOHISS_BASIC
#undef AUTOHISS_FULL
#undef AUTOHISS_NUM