mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-25 16:45:42 +00:00
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request <!-- Describe The Pull Request. Please be sure every change is documented or this can delay review and even discourage maintainers from merging your PR! --> Fixes #69798 Fixes #71621 When using hypnosis on a victim, the language should be accounted for and whether the victim can properly hear it. Before the hearing code would magically translate any message, this is no longer the case. This also fixes the language barrier involving hearing for: - Mind echo trauma - Phobia trauma - Hypnotic trigger trauma - Split Personality brainwashing trauma - Codeword hearing - Hypnotize status effect - Impure Inacusiate reagent ## Why It's Good For The Game <!-- Argue for the merits of your changes and how they benefit the game, especially if they are controversial and/or far reaching. If you can't actually explain WHY what you are doing will improve the game, then it probably isn't good for the game in the first place. --> Better consistency, improved readability, and less bugs in the future. ## Changelog <!-- If your PR modifies aspects of the game that can be concretely observed by players or admins you should add a changelog. If your change does NOT meet this description, remove this section. Be sure to properly mark your PRs to prevent unnecessary GBP loss. You can read up on GBP and it's effects on PRs in the tgstation guides for contributors. Please note that maintainers freely reserve the right to remove and add tags should they deem it appropriate. You can attempt to finagle the system all you want, but it's best to shoot for clear communication right off the bat. --> 🆑 fix: Fix hypnosis, mind echo trauma, phobia trauma, hypnotic trigger trauma, split personality brainwashing trauma, codeword hearing, and impure inacusiate reagent all bypassing language and hearing checks. If you try to give commands to a victim in a language they don't understand, they will no longer magically understand the words. fix: Fix sign language having accent modifications refactor: Refactored saycode to be more robust, readable, and have more unit tests. /🆑 <!-- Both 🆑's are required for the changelog to work! You can put your name to the right of the first 🆑 if you want to overwrite your GitHub username as author ingame. --> <!-- You can use multiple of the same prefix (they're only used for the icon ingame) and delete the unneeded ones. Despite some of the tags, changelogs should generally represent how a player might be affected by the changes rather than a summary of the PR's contents. --> Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
126 lines
3.7 KiB
Plaintext
126 lines
3.7 KiB
Plaintext
#define INCLUSIVE_MODE 1
|
|
#define EXCLUSIVE_MODE 2
|
|
#define RECOGNIZER_MODE 3
|
|
#define VOICE_SENSOR_MODE 4
|
|
|
|
/obj/item/assembly/voice
|
|
name = "voice analyzer"
|
|
desc = "A small electronic device able to record a voice sample, and send a signal when that sample is repeated."
|
|
icon_state = "voice"
|
|
custom_materials = list(/datum/material/iron=500, /datum/material/glass=50)
|
|
attachable = TRUE
|
|
verb_say = "beeps"
|
|
verb_ask = "beeps"
|
|
verb_exclaim = "beeps"
|
|
var/listening = FALSE
|
|
/// The activation message is tracked using this var.
|
|
var/recorded = ""
|
|
var/mode = INCLUSIVE_MODE
|
|
var/static/list/modes = list(
|
|
"inclusive",
|
|
"exclusive",
|
|
"recognizer",
|
|
"voice sensor",
|
|
)
|
|
drop_sound = 'sound/items/handling/component_drop.ogg'
|
|
pickup_sound = 'sound/items/handling/component_pickup.ogg'
|
|
|
|
/obj/item/assembly/voice/Initialize(mapload)
|
|
. = ..()
|
|
become_hearing_sensitive(ROUNDSTART_TRAIT)
|
|
|
|
/obj/item/assembly/voice/examine(mob/user)
|
|
. = ..()
|
|
. += span_notice("Use a multitool to swap between \"inclusive\", \"exclusive\", \"recognizer\", and \"voice sensor\" mode.")
|
|
|
|
/obj/item/assembly/voice/Hear(message, atom/movable/speaker, message_language, raw_message, radio_freq, list/spans, list/message_mods = list(), message_range)
|
|
. = ..()
|
|
if(message_mods[WHISPER_MODE]) //Too quiet lad
|
|
return
|
|
if(speaker == src)
|
|
return
|
|
|
|
// raw_message can contain multiple spaces between words etc which are not seen in chat due to HTML rendering
|
|
// this means if the teller records a message with e.g. double spaces or tabs, other people will not be able to trigger the sensor since they don't know how to perform the same combination
|
|
raw_message = htmlrendertext(raw_message)
|
|
|
|
if(listening && !radio_freq)
|
|
record_speech(speaker, raw_message, message_language)
|
|
else
|
|
if(check_activation(speaker, raw_message))
|
|
send_pulse()
|
|
|
|
/obj/item/assembly/voice/proc/record_speech(atom/movable/speaker, raw_message, datum/language/message_language)
|
|
switch(mode)
|
|
if(INCLUSIVE_MODE)
|
|
recorded = raw_message
|
|
listening = FALSE
|
|
say("Activation message is '[recorded]'.", sanitize = FALSE, language = message_language)
|
|
if(EXCLUSIVE_MODE)
|
|
recorded = raw_message
|
|
listening = FALSE
|
|
say("Activation message is '[recorded]'.", sanitize = FALSE, language = message_language)
|
|
if(RECOGNIZER_MODE)
|
|
recorded = speaker.GetVoice()
|
|
listening = FALSE
|
|
say("Your voice pattern is saved.", language = message_language)
|
|
if(VOICE_SENSOR_MODE)
|
|
if(length(raw_message))
|
|
send_pulse()
|
|
|
|
/obj/item/assembly/voice/proc/check_activation(atom/movable/speaker, raw_message)
|
|
if (recorded == "")
|
|
return FALSE
|
|
|
|
switch(mode)
|
|
if(INCLUSIVE_MODE)
|
|
if(findtext(raw_message, recorded))
|
|
return TRUE
|
|
if(EXCLUSIVE_MODE)
|
|
if(raw_message == recorded)
|
|
return TRUE
|
|
if(RECOGNIZER_MODE)
|
|
if(speaker.GetVoice() == recorded)
|
|
return TRUE
|
|
if(VOICE_SENSOR_MODE)
|
|
if(length(raw_message))
|
|
return TRUE
|
|
|
|
return FALSE
|
|
|
|
/obj/item/assembly/voice/proc/send_pulse()
|
|
visible_message("clicks", visible_message_flags = EMOTE_MESSAGE)
|
|
playsound(src, 'sound/effects/whirthunk.ogg', 30)
|
|
addtimer(CALLBACK(src, PROC_REF(pulse)), 2 SECONDS)
|
|
|
|
/obj/item/assembly/voice/multitool_act(mob/living/user, obj/item/I)
|
|
..()
|
|
mode %= modes.len
|
|
mode++
|
|
to_chat(user, span_notice("You set [src] into [modes[mode]] mode."))
|
|
listening = FALSE
|
|
recorded = ""
|
|
return TRUE
|
|
|
|
/obj/item/assembly/voice/activate()
|
|
if(!secured || holder)
|
|
return FALSE
|
|
listening = !listening
|
|
say("[listening ? "Now" : "No longer"] recording input.")
|
|
return TRUE
|
|
|
|
/obj/item/assembly/voice/attack_self(mob/user)
|
|
if(!user)
|
|
return FALSE
|
|
activate()
|
|
return TRUE
|
|
|
|
/obj/item/assembly/voice/toggle_secure()
|
|
. = ..()
|
|
listening = FALSE
|
|
|
|
#undef INCLUSIVE_MODE
|
|
#undef EXCLUSIVE_MODE
|
|
#undef RECOGNIZER_MODE
|
|
#undef VOICE_SENSOR_MODE
|