From 3cb26eca23f77f76e6ef5c9e15656f8a5b112d78 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Sun, 13 Sep 2015 21:08:46 -0700 Subject: [PATCH] Autohiss This commit adds a system (fully client-toggled) to allow unathi and tajaran to "auto-hiss". This means that, for unathi, "S" will be automatically extended to "Ss", "Sss", or "Ssss". Which one it changes is based on a random pick(). There are three modes, off, basic, full. Off, is obviously, off. It does nothing. This is the default setting. Basic, for unathi, enables the S extensions, and for tajaran, enables the "R" extending. Full, for unathi, enables the S extensions, alongside replacing "X" with "Ks". It does not currently do anything extra for Tajaran. Sinta'Unathi is unaffected for Unathi, Siik'Tajr is unaffected for Tajaran. On baystation, NO_STUTTER languages would also be unaffected (the noise language). However, we do not have NO_STUTTER languages. So it hilariously does affect the noise language. "Zartulnal Hharar dancess." --- code/modules/mob/living/autohiss.dm | 95 +++++++++++++++++++++++++++++ code/modules/mob/living/say.dm | 2 + paradise.dme | 1 + 3 files changed, 98 insertions(+) create mode 100644 code/modules/mob/living/autohiss.dm diff --git a/code/modules/mob/living/autohiss.dm b/code/modules/mob/living/autohiss.dm new file mode 100644 index 00000000000..37e183282eb --- /dev/null +++ b/code/modules/mob/living/autohiss.dm @@ -0,0 +1,95 @@ + +#define AUTOHISS_OFF 0 +#define AUTOHISS_BASIC 1 +#define AUTOHISS_FULL 2 + +#define AUTOHISS_NUM 3 + + +/mob/living/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.autohiss_mode == AUTOHISS_OFF) // no need to process if there's no client or they have autohiss off + return message + return species.handle_autohiss(message, L, client.autohiss_mode) + +/client + var/autohiss_mode = AUTOHISS_OFF + +/client/verb/toggle_autohiss() + set name = "Toggle Auto-Hiss" + set desc = "Toggle automatic hissing as Unathi and r-rolling as Taj" + set category = "OOC" + + autohiss_mode = (autohiss_mode + 1) % AUTOHISS_NUM + switch(autohiss_mode) + if(AUTOHISS_OFF) + src << "Auto-hiss is now OFF." + if(AUTOHISS_BASIC) + src << "Auto-hiss is now BASIC." + if(AUTOHISS_FULL) + src << "Auto-hiss is now FULL." + else + autohiss_mode = AUTOHISS_OFF + src << "Auto-hiss is now OFF." + +/datum/species + var/list/autohiss_basic_map = null + var/list/autohiss_extra_map = null + var/list/autohiss_exempt = null + +/datum/species/unathi + autohiss_basic_map = list( + "s" = list("ss", "sss", "ssss") + ) + autohiss_extra_map = list( + "x" = list("ks", "kss", "ksss") + ) + autohiss_exempt = list("Sinta'unathi") + +/datum/species/tajaran + autohiss_basic_map = list( + "r" = list("rr", "rrr", "rrrr") + ) + autohiss_exempt = list("Siik'tajr") + + +/datum/species/proc/handle_autohiss(message, datum/language/lang, mode) + if(!autohiss_basic_map) + return message + if(autohiss_exempt && (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(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(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(message, 1, min_index) + if(copytext(message, min_index, min_index+1) == uppertext(min_char)) + . += capitalize(pick(map[min_char])) + else + . += pick(map[min_char]) + message = copytext(message, min_index + 1) + + return list2text(.) + +#undef AUTOHISS_OFF +#undef AUTOHISS_BASIC +#undef AUTOHISS_FULL +#undef AUTOHISS_NUM diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index 5c0905ec72a..3c79879dd07 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -152,6 +152,8 @@ proc/get_radio_key_from_channel(var/channel) message = trim_left(message) + message = handle_autohiss(message, speaking) + var/list/handle_s = handle_speech_problems(message, verb) message = handle_s[1] verb = handle_s[2] diff --git a/paradise.dme b/paradise.dme index ad5582f1eda..fcd21bc1591 100644 --- a/paradise.dme +++ b/paradise.dme @@ -1270,6 +1270,7 @@ #include "code\modules\mob\dead\observer\observer.dm" #include "code\modules\mob\dead\observer\say.dm" #include "code\modules\mob\dead\observer\spells.dm" +#include "code\modules\mob\living\autohiss.dm" #include "code\modules\mob\living\bloodcrawl.dm" #include "code\modules\mob\living\damage_procs.dm" #include "code\modules\mob\living\default_language.dm"