Skip to content

Commit

Permalink
Initial Commit - Conversation Filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oricana-16 committed May 4, 2024
1 parent 85218b6 commit 96d11bb
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/nanites.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,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"
7 changes: 7 additions & 0 deletions monkestation/code/modules/research/designs/nanite_designs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,44 @@
/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_decay)

/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, Sentence Revoked.\]")
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
var/datum/nanite_extra_setting/phrase = extra_settings[NES_INVALID_PHRASE]

if(!phrase.get_value())
return

var/datum/nanite_extra_setting/replacement_phrase = extra_settings[NES_PHRASE_REPLACEMENT]

if(!replacement_phrase.get_value())
replacement_phrase = new /datum/nanite_extra_setting/text("\[Invalid Phrase Detected, Sentence Revoked.\]")

if(findtext(hearing_args[HEARING_RAW_MESSAGE], phrase.get_value()))
if (extra_settings[NES_REPLACEMENT_MODE])
hearing_args[HEARING_RAW_MESSAGE] = replacement_phrase.get_value()
else
var/message = hearing_args[HEARING_RAW_MESSAGE]
message = replacetext(message, phrase.get_value(), replacement_phrase.get_value())
hearing_args[HEARING_RAW_MESSAGE] = message

3 changes: 3 additions & 0 deletions monkestation/code/modules/research/techweb/all_nodes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"repairing_nanites",
"repeater_nanites",
"sensor_nanite_volume",
// DEBUG
"word_filter_nanites",
)
research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 1000)

Expand Down Expand Up @@ -99,6 +101,7 @@
"paralyzing_nanites",
"selfscan_nanites",
"stun_nanites",
// "word_filter_nanites", DEBUG
)
research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 1000, TECHWEB_POINT_TYPE_NANITES = 1000)

Expand Down

0 comments on commit 96d11bb

Please sign in to comment.