Skip to content

Commit

Permalink
Conversation Filter Nanite Program (#1853)
Browse files Browse the repository at this point in the history
* Initial Commit - Conversation Filter.

* Added multiple replacement modes

Whole sentence -> replaces the whole sentence with if the phrase is found. Phrase Only -> Only replaces the phrase in the message.

* tweaks

adds to correct node, changes default text

* One (1) comment

* Fixes error when trying to replace with ""

* Allow "" :D
  • Loading branch information
Oricana-16 authored Jun 6, 2024
1 parent c32bc8c commit 4af6786
Show file tree
Hide file tree
Showing 4 changed files with 58 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 @@ -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"
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,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

1 change: 1 addition & 0 deletions monkestation/code/modules/research/techweb/all_nodes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 4af6786

Please sign in to comment.