Merge pull request #10980 from GinjaNinja32/autohiss

Add autohiss/purr on a per-client toggle
This commit is contained in:
Zuhayr
2015-09-07 15:37:46 +09:30
4 changed files with 104 additions and 0 deletions

View File

@@ -1216,6 +1216,7 @@
#include "code\modules\mob\language\outsider.dm"
#include "code\modules\mob\language\station.dm"
#include "code\modules\mob\language\synthetic.dm"
#include "code\modules\mob\living\autohiss.dm"
#include "code\modules\mob\living\damage_procs.dm"
#include "code\modules\mob\living\default_language.dm"
#include "code\modules\mob\living\life.dm"

View File

@@ -0,0 +1,96 @@
#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
soft_assert(0, "invalid autohiss value [autohiss_mode]")
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

View File

@@ -182,6 +182,8 @@ proc/get_radio_key_from_channel(var/channel)
message = trim_left(message)
if(!(speaking && (speaking.flags & NO_STUTTER)))
message = handle_autohiss(message, speaking)
var/list/handle_s = handle_speech_problems(message, verb)
message = handle_s[1]
verb = handle_s[2]

View File

@@ -0,0 +1,5 @@
author: GinjaNinja32
delete-after: True
changes:
- rscadd: "Added an auto-hiss system for those who would prefer the game do their sss or rrr for them. Activate via Toggle Auto-Hiss in the OOC tab."
- rscadd: "Auto-hiss system in 'basic' mode will extend 's' for Unathi and 'r' for Tajara. 'Full' mode adds 'x' to 'ks' for Unathi, and is identical to 'basic' mode for Tajara."