diff --git a/code/__DEFINES/nanites.dm b/code/__DEFINES/nanites.dm index bbedb1ea6530..9ca8bdf11c6d 100644 --- a/code/__DEFINES/nanites.dm +++ b/code/__DEFINES/nanites.dm @@ -58,3 +58,7 @@ #define NES_SCAN_TYPE "Scan Type" #define NES_BUTTON_NAME "Button Name" #define NES_ICON "Icon" +// MONKESTATION ADDITIONS +#define NES_INVALID_PHRASE "Invalid Phrase" +#define NES_PHRASE_REPLACEMENT "Phrase Replacement" +#define NES_REPLACEMENT_MODE "Replacement Mode" diff --git a/monkestation/code/modules/research/designs/nanite_designs.dm b/monkestation/code/modules/research/designs/nanite_designs.dm index 544b639692f3..d91e9b32a770 100644 --- a/monkestation/code/modules/research/designs/nanite_designs.dm +++ b/monkestation/code/modules/research/designs/nanite_designs.dm @@ -469,6 +469,13 @@ program_type = /datum/nanite_program/bad_mood category = list("Suppression Nanites") +/datum/design/nanites/conversation_filter + name = "Conversation Filter" + desc = "The nanites pre-process words, granting the ability to filter out certain phrases." + id = "word_filter_nanites" + program_type = /datum/nanite_program/conversation_filter + category = list("Suppression Nanites") + ////////////////////SENSOR NANITES////////////////////////////////////// /datum/design/nanites/sensor_health diff --git a/monkestation/code/modules/research/nanites/nanite_programs/suppression.dm b/monkestation/code/modules/research/nanites/nanite_programs/suppression.dm index f0c21fc651fc..0a33beb70ec6 100644 --- a/monkestation/code/modules/research/nanites/nanite_programs/suppression.dm +++ b/monkestation/code/modules/research/nanites/nanite_programs/suppression.dm @@ -268,3 +268,49 @@ /datum/nanite_program/bad_mood/disable_passive_effect() . = ..() host_mob.clear_mood_event("nanite_sadness") + +/datum/nanite_program/conversation_filter + name = "Conversation Filter" + desc = "The nanites pre-process words, granting the ability to filter out certain phrases." + use_rate = 0.1 + unique = FALSE + rogue_types = list(/datum/nanite_program/brain_misfire) + +/datum/nanite_program/conversation_filter/register_extra_settings() + . = ..() + extra_settings[NES_INVALID_PHRASE] = new /datum/nanite_extra_setting/text("") + extra_settings[NES_PHRASE_REPLACEMENT] = new /datum/nanite_extra_setting/text("\[Invalid Phrase Detected.\]") + extra_settings[NES_REPLACEMENT_MODE] = new /datum/nanite_extra_setting/boolean(TRUE, "Whole Sentence", "Phrase Only") + +/datum/nanite_program/conversation_filter/on_mob_add() + . = ..() + RegisterSignal(host_mob, COMSIG_MOVABLE_HEAR, PROC_REF(on_hear)) + +/datum/nanite_program/conversation_filter/on_mob_remove() + UnregisterSignal(host_mob, COMSIG_MOVABLE_HEAR) + +/datum/nanite_program/conversation_filter/proc/on_hear(datum/source, list/hearing_args) + SIGNAL_HANDLER + + if(!activated) + return + + var/datum/nanite_extra_setting/phrase = extra_settings[NES_INVALID_PHRASE] + var/datum/nanite_extra_setting/replacement_mode = extra_settings[NES_REPLACEMENT_MODE] + var/datum/nanite_extra_setting/replacement_setting = extra_settings[NES_PHRASE_REPLACEMENT] + var/replacement_phrase = replacement_setting.get_value() + + if(!phrase.get_value()) + return + + if(!replacement_phrase) + replacement_phrase = "" + + if(findtext(hearing_args[HEARING_RAW_MESSAGE], phrase.get_value())) + if (replacement_mode.get_value()) + hearing_args[HEARING_RAW_MESSAGE] = replacement_phrase + else + var/message = hearing_args[HEARING_RAW_MESSAGE] + message = replacetext(message, phrase.get_value(), replacement_phrase) + hearing_args[HEARING_RAW_MESSAGE] = message + diff --git a/monkestation/code/modules/research/techweb/all_nodes.dm b/monkestation/code/modules/research/techweb/all_nodes.dm index 698a9c07f4fe..71a2f10f00bd 100644 --- a/monkestation/code/modules/research/techweb/all_nodes.dm +++ b/monkestation/code/modules/research/techweb/all_nodes.dm @@ -101,6 +101,7 @@ "paralyzing_nanites", "selfscan_nanites", "stun_nanites", + "word_filter_nanites", ) research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 1000, TECHWEB_POINT_TYPE_NANITES = 1000)