Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing nanite sensors as well as rule inversions, refactor nanite sensor code #1732

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion code/__DEFINES/nanites.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,26 @@

///Nanite Extra Settings - Note that these will also be the names displayed in the UI
#define NES_SENT_CODE "Sent Code"
#define NES_SENT_CODE_INVERTED "Sent Code (Inverted)"
#define NES_SENT_CODE_SIGNAL "Sent Code (Signal)"
#define NES_SENT_CODE_SIGNAL_INVERTED "Sent Code (Signal, Inverted)"
#define NES_SENT_CODE_TRIGGER "Sent Code (Trigger)"
#define NES_SENT_CODE_TRIGGER_INVERTED "Sent Code (Trigger, Inverted)"
#define NES_DELAY "Delay"
#define NES_MODE "Mode"
#define NES_COMM_CODE "Comm Code"
#define NES_RELAY_CHANNEL "Relay Channel"
#define NES_HEALTH_PERCENT "Health Percent"
#define NES_DIRECTION "Direction"
#define NES_NANITE_PERCENT "Nanite Percent"
#define NES_BLOOD_PERCENT "Blood Percent"
#define NES_NUTRITION_PERCENT "Nutrition Percent"
#define NES_DAMAGE_TYPE "Damage Type"
#define NES_DAMAGE "Damage"
#define NES_SENTENCE "Sentence"
#define NES_MESSAGE "Message"
#define NES_DIRECTIVE "Directive"
#define NES_INCLUSIVE_MODE "Inclusive Mode"
#define NES_MATCH_MODE "Match Mode"
#define NES_RACE "Race"
#define NES_HALLUCINATION_TYPE "Hallucination Type"
#define NES_HALLUCINATION_DETAIL "Hallucination Detail"
Expand Down
7 changes: 7 additions & 0 deletions monkestation/code/modules/datums/components/nanites.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
if(isliving(parent))
RegisterSignal(parent, COMSIG_ATOM_EMP_ACT, PROC_REF(on_emp))
RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(on_death))
RegisterSignal(parent, COMSIG_LIVING_REVIVE, PROC_REF(on_revive))
RegisterSignal(parent, COMSIG_MOB_TRIED_ACCESS, PROC_REF(check_access))
RegisterSignal(parent, COMSIG_LIVING_ELECTROCUTE_ACT, PROC_REF(on_shock))
RegisterSignal(parent, COMSIG_LIVING_MINOR_SHOCK, PROC_REF(on_minor_shock))
Expand Down Expand Up @@ -302,6 +303,12 @@
var/datum/nanite_program/NP = X
NP.on_death(gibbed)

/datum/component/nanites/proc/on_revive(datum/source, full_heal, admin_revive)
SIGNAL_HANDLER

for(var/datum/nanite_program/program in programs)
program.on_revive(full_heal, admin_revive)

/datum/component/nanites/proc/receive_signal(datum/source, code, signal_source = "an unidentified source")
SIGNAL_HANDLER

Expand Down
24 changes: 19 additions & 5 deletions monkestation/code/modules/research/designs/nanite_designs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@
name = "Signal Repeater"
desc = "When triggered, sends another signal to the nanites, optionally with a delay."
id = "repeater_nanites"
program_type = /datum/nanite_program/sensor/repeat
program_type = /datum/nanite_program/repeat
category = list("Utility Nanites")

/datum/design/nanites/relay_repeater
name = "Relay Signal Repeater"
desc = "When triggered, sends another signal to a relay channel, optionally with a delay."
id = "relay_repeater_nanites"
program_type = /datum/nanite_program/sensor/relay_repeat
program_type = /datum/nanite_program/relay_repeat
category = list("Utility Nanites")

/datum/design/nanites/emp
Expand Down Expand Up @@ -478,16 +478,30 @@
program_type = /datum/nanite_program/sensor/damage
category = list("Sensor Nanites")

/datum/design/nanites/sensor_blood
name = "Blood Sensor"
desc = "The nanites receive a signal when the host's blood volume is above/below a target percentage."
id = "sensor_blood_nanites"
program_type = /datum/nanite_program/sensor/blood
category = list("Sensor Nanites")

/datum/design/nanites/sensor_nutrition
name = "Nutrition Sensor"
desc = "The nanites receive a signal when the host's nutrition level is above/below a target percentage."
id = "sensor_nutrition_nanites"
program_type = /datum/nanite_program/sensor/nutrition
category = list("Sensor Nanites")

/datum/design/nanites/sensor_crit
name = "Critical Health Sensor"
desc = "The nanites receive a signal when the host first reaches critical health."
desc = "The nanites receive a signal when the host enters/leaves critical condition."
id = "sensor_crit_nanites"
program_type = /datum/nanite_program/sensor/crit
category = list("Sensor Nanites")

/datum/design/nanites/sensor_death
name = "Death Sensor"
desc = "The nanites receive a signal when they detect the host is dead."
desc = "The nanites receive a signal when the host dies/revives."
id = "sensor_death_nanites"
program_type = /datum/nanite_program/sensor/death
category = list("Sensor Nanites")
Expand All @@ -508,7 +522,7 @@

/datum/design/nanites/sensor_species
name = "Species Sensor"
desc = "When triggered, the nanites scan the host to determine their species and output a signal depending on the conditions set in the settings."
desc = "The nanites receive a singal when they detect that the host is/isn't the target species."
id = "sensor_species_nanites"
program_type = /datum/nanite_program/sensor/species
category = list("Sensor Nanites")
Expand Down
28 changes: 25 additions & 3 deletions monkestation/code/modules/research/nanites/nanite_programs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,10 @@
if(timer_trigger && world.time > timer_trigger_next)
trigger()
timer_trigger_next = world.time + timer_trigger
return

if(timer_trigger_delay_next && world.time > timer_trigger_delay_next)
trigger(delayed = TRUE)
timer_trigger_delay_next = 0
return

if(check_conditions() && consume_nanites(use_rate))
if(!passive_enabled)
Expand Down Expand Up @@ -268,7 +266,10 @@
host_mob.investigate_log("[src] nanite program received a software error due to minor shock.", INVESTIGATE_NANITES)
software_error()

/datum/nanite_program/proc/on_death()
/datum/nanite_program/proc/on_death(gibbed)
return

/datum/nanite_program/proc/on_revive(full_heal, admin_revive)
return

/datum/nanite_program/proc/software_error(type)
Expand Down Expand Up @@ -300,6 +301,8 @@
qdel(src)

/datum/nanite_program/proc/receive_signal(code, source)
if (!code) // makes code 0 invalid
return
if(activation_code && code == activation_code && !activated)
activate()
host_mob.investigate_log("'s [name] nanite program was activated by [source] with code [code].", INVESTIGATE_NANITES)
Expand All @@ -313,6 +316,25 @@
host_mob.investigate_log("'s [name] nanite program was deleted by [source] with code [code].", INVESTIGATE_NANITES)
qdel(src)

/datum/nanite_program/proc/send_code_any(setting)
if (!activated)
return

var/datum/nanite_extra_setting/code_setting = extra_settings[setting]
SEND_SIGNAL(host_mob, COMSIG_NANITE_SIGNAL, code_setting.get_value(), "a [name] program")

/datum/nanite_program/proc/send_code()
send_code_any(NES_SENT_CODE)

/datum/nanite_program/proc/send_code_inverted()
send_code_any(NES_SENT_CODE_INVERTED)

/datum/nanite_program/proc/send_trigger_code()
send_code_any(NES_SENT_CODE_TRIGGER)

/datum/nanite_program/proc/send_trigger_code_inverted()
send_code_any(NES_SENT_CODE_TRIGGER_INVERTED)

///A nanite program containing a behaviour protocol. Only one protocol of each class can be active at once.
/datum/nanite_program/protocol
name = "Nanite Protocol"
Expand Down
Loading
Loading