mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 18:22:14 +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>
59 lines
2.2 KiB
Plaintext
59 lines
2.2 KiB
Plaintext
/**
|
|
* Component that allows for highlighting of words or phrases in chat based on regular expressions.
|
|
*
|
|
* Hooks into the parent's COMSIG_MOVABLE_HEAR signal to wrap every regex match in the message
|
|
* between <span class=''></span> tags with the provided span class. This modifies the output that
|
|
* is sent to the parent's chat window.
|
|
*
|
|
* Removal of this component should be done by calling [GetComponents(/datum/component/codeword_hearing)]
|
|
* on the parent and then iterating through all components calling [delete_if_from_source(source)].
|
|
*/
|
|
/datum/component/codeword_hearing
|
|
dupe_mode = COMPONENT_DUPE_ALLOWED
|
|
|
|
/// Regex for matching words or phrases you want highlighted.
|
|
var/regex/replace_regex
|
|
/// The <span class=''> to use for highlighting matches.
|
|
var/span_class
|
|
/// The source of this component. Used to identify the source in delete_if_from_source since this component is COMPONENT_DUPE_ALLOWED.
|
|
var/source
|
|
|
|
/datum/component/codeword_hearing/Initialize(regex/codeword_regex, highlight_span_class, component_source)
|
|
if(!ismovable(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
replace_regex = codeword_regex
|
|
span_class = highlight_span_class
|
|
source = component_source
|
|
return ..()
|
|
|
|
/datum/component/codeword_hearing/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_MOVABLE_HEAR, PROC_REF(handle_hearing))
|
|
|
|
/datum/component/codeword_hearing/UnregisterFromParent()
|
|
UnregisterSignal(parent, COMSIG_MOVABLE_HEAR)
|
|
|
|
/// Callback for COMSIG_MOVABLE_HEAR which highlights syndicate code phrases in chat.
|
|
/datum/component/codeword_hearing/proc/handle_hearing(datum/source, list/hearing_args)
|
|
SIGNAL_HANDLER
|
|
|
|
var/mob/living/owner = parent
|
|
if(!istype(owner))
|
|
return
|
|
|
|
// don't skip codewords when owner speaks
|
|
if(!owner.can_hear() || !owner.has_language(hearing_args[HEARING_LANGUAGE]))
|
|
return
|
|
|
|
var/message = hearing_args[HEARING_RAW_MESSAGE]
|
|
message = replace_regex.Replace(message, "<span class='[span_class]'>$1</span>")
|
|
hearing_args[HEARING_RAW_MESSAGE] = message
|
|
|
|
/// Since a parent can have multiple of these components on them simultaneously, this allows a datum to delete components from a specific source.
|
|
/datum/component/codeword_hearing/proc/delete_if_from_source(component_source)
|
|
if(source == component_source)
|
|
qdel(src)
|
|
return TRUE
|
|
|
|
return FALSE
|