Files
GS13NG/code/modules/research/nanites/nanite_programs/healing.dm
2020-11-22 14:56:02 -07:00

251 lines
9.2 KiB
Plaintext

//Programs that heal the host in some way.
/datum/nanite_program/regenerative
name = "Accelerated Regeneration"
desc = "The nanites boost the host's natural regeneration, increasing their healing speed. Does not consume nanites if the host is unharmed."
use_rate = 0.5
rogue_types = list(/datum/nanite_program/necrotic)
/datum/nanite_program/regenerative/check_conditions()
if(!host_mob.getBruteLoss() && !host_mob.getFireLoss())
return FALSE
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
var/list/parts = C.get_damaged_bodyparts(TRUE,TRUE, status = list(BODYPART_ORGANIC, BODYPART_NANITES))
if(!parts.len)
return FALSE
return ..()
/datum/nanite_program/regenerative/active_effect()
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
var/list/parts = C.get_damaged_bodyparts(TRUE,TRUE, status = list(BODYPART_ORGANIC, BODYPART_NANITES))
if(!parts.len)
return
for(var/obj/item/bodypart/L in parts)
if(L.heal_damage(0.5/parts.len, 0.5/parts.len))
host_mob.update_damage_overlays()
else
host_mob.adjustBruteLoss(-0.5, TRUE)
host_mob.adjustFireLoss(-0.5, TRUE)
/datum/nanite_program/temperature
name = "Temperature Adjustment"
desc = "The nanites adjust the host's internal temperature to an ideal level."
use_rate = 3.5
rogue_types = list(/datum/nanite_program/skin_decay)
/datum/nanite_program/temperature/check_conditions()
if(host_mob.bodytemperature > (BODYTEMP_NORMAL - 30) && host_mob.bodytemperature < (BODYTEMP_NORMAL + 30))
return FALSE
return ..()
/datum/nanite_program/temperature/active_effect()
if(host_mob.bodytemperature > BODYTEMP_NORMAL)
host_mob.adjust_bodytemperature(-40 * TEMPERATURE_DAMAGE_COEFFICIENT, BODYTEMP_NORMAL)
else if(host_mob.bodytemperature < (BODYTEMP_NORMAL + 1))
host_mob.adjust_bodytemperature(40 * TEMPERATURE_DAMAGE_COEFFICIENT, 0, BODYTEMP_NORMAL)
/datum/nanite_program/purging
name = "Blood Purification"
desc = "The nanites purge toxins and chemicals from the host's bloodstream, however it is dangerous to slime biology due to inaccuracy."
use_rate = 1
rogue_types = list(/datum/nanite_program/suffocating, /datum/nanite_program/necrotic)
/datum/nanite_program/purging/check_conditions()
var/foreign_reagent = length(host_mob.reagents?.reagent_list)
if(!host_mob.getToxLoss() && !foreign_reagent)
return FALSE
return ..()
/datum/nanite_program/purging/active_effect()
host_mob.adjustToxLoss(-1)
for(var/datum/reagent/R in host_mob.reagents.reagent_list)
if(R.type == /datum/reagent/fermi/nanite_b_gone)
host_mob.adjustToxLoss(4)
continue
host_mob.reagents.remove_reagent(R.type,1)
/datum/nanite_program/brain_heal
name = "Neural Regeneration"
desc = "The nanites fix neural connections in the host's brain, reversing brain damage and minor traumas."
use_rate = 1.5
rogue_types = list(/datum/nanite_program/brain_decay)
/datum/nanite_program/brain_heal/check_conditions()
var/problems = FALSE
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
var/obj/item/organ/brain/B = C.getorganslot(ORGAN_SLOT_BRAIN)
if(length(B?.get_traumas_type(TRAUMA_RESILIENCE_BASIC)))
problems = TRUE
if(host_mob.getOrganLoss(ORGAN_SLOT_BRAIN) > 0)
problems = TRUE
return problems ? ..() : FALSE
/datum/nanite_program/brain_heal/active_effect()
host_mob.adjustOrganLoss(ORGAN_SLOT_BRAIN, -1)
if(iscarbon(host_mob) && prob(10))
var/mob/living/carbon/C = host_mob
C.cure_trauma_type(resilience = TRAUMA_RESILIENCE_BASIC)
/datum/nanite_program/blood_restoring
name = "Blood Regeneration"
desc = "The nanites stimulate and boost blood cell production in the host."
use_rate = 1
rogue_types = list(/datum/nanite_program/suffocating)
/datum/nanite_program/blood_restoring/check_conditions()
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
if(C.blood_volume >= (BLOOD_VOLUME_SAFE*C.blood_ratio) || (HAS_TRAIT(C, TRAIT_NOMARROW)))
return FALSE
else
return FALSE
return ..()
/datum/nanite_program/blood_restoring/active_effect()
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
C.blood_volume += 2
/datum/nanite_program/repairing
name = "Mechanical Repair"
desc = "The nanites fix damage in the host's mechanical limbs."
use_rate = 0.5
rogue_types = list(/datum/nanite_program/necrotic)
/datum/nanite_program/repairing/check_conditions()
if(!host_mob.getBruteLoss() && !host_mob.getFireLoss())
return FALSE
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
var/list/parts = C.get_damaged_bodyparts(TRUE, TRUE, status = list(BODYPART_ROBOTIC, BODYPART_HYBRID, BODYPART_NANITES))
if(!parts.len)
return FALSE
else
if(!(host_mob.mob_biotypes & MOB_ROBOTIC))
return FALSE
return ..()
/datum/nanite_program/repairing/active_effect(mob/living/M)
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
var/list/parts = C.get_damaged_bodyparts(TRUE, TRUE, status = list(BODYPART_ROBOTIC, BODYPART_HYBRID, BODYPART_NANITES))
if(!parts.len)
return
var/update = FALSE
for(var/obj/item/bodypart/L in parts)
if(L.heal_damage(1.5/parts.len, 1.5/parts.len, null, TRUE, FALSE)) //much faster than organic healing
update = TRUE
if(update)
host_mob.update_damage_overlays()
else
host_mob.adjustBruteLoss(-1.5, TRUE)
host_mob.adjustFireLoss(-1.5, TRUE)
/datum/nanite_program/purging_advanced
name = "Selective Blood Purification"
desc = "The nanites purge toxins and dangerous chemicals from the host's bloodstream, while ignoring beneficial chemicals. \
The added processing power required to analyze the chemicals severely increases the nanite consumption rate. This program is safe with slime biology due to the increased precision."
use_rate = 2
rogue_types = list(/datum/nanite_program/suffocating, /datum/nanite_program/necrotic)
/datum/nanite_program/purging_advanced/check_conditions()
var/foreign_reagent = FALSE
for(var/datum/reagent/toxin/R in host_mob.reagents.reagent_list)
foreign_reagent = TRUE
break
if(!host_mob.getToxLoss() && !foreign_reagent)
return FALSE
return ..()
/datum/nanite_program/purging_advanced/active_effect()
host_mob.adjustToxLoss(-1, forced = TRUE)
for(var/datum/reagent/toxin/R in host_mob.reagents.reagent_list)
host_mob.reagents.remove_reagent(R.type,1)
/datum/nanite_program/regenerative_advanced
name = "Bio-Reconstruction"
desc = "The nanites manually repair and replace organic cells, acting much faster than normal regeneration. \
However, this program cannot detect the difference between harmed and unharmed, causing it to consume nanites even if it has no effect."
use_rate = 5.5
rogue_types = list(/datum/nanite_program/suffocating, /datum/nanite_program/necrotic)
/datum/nanite_program/regenerative_advanced/active_effect()
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
var/list/parts = C.get_damaged_bodyparts(TRUE,TRUE, status = list(BODYPART_ORGANIC, BODYPART_NANITES))
if(!parts.len)
return
var/update = FALSE
for(var/obj/item/bodypart/L in parts)
if(L.heal_damage(3/parts.len, 3/parts.len, 0))
update = TRUE
if(update)
host_mob.update_damage_overlays()
else
host_mob.adjustBruteLoss(-3, TRUE)
host_mob.adjustFireLoss(-3, TRUE)
/datum/nanite_program/brain_heal_advanced
name = "Neural Reimaging"
desc = "The nanites are able to backup and restore the host's neural connections, potentially replacing entire chunks of missing or damaged brain matter."
use_rate = 3
rogue_types = list(/datum/nanite_program/brain_decay, /datum/nanite_program/brain_misfire)
/datum/nanite_program/brain_heal_advanced/check_conditions()
var/problems = FALSE
if(iscarbon(host_mob))
var/mob/living/carbon/C = host_mob
var/obj/item/organ/brain/B = C.getorganslot(ORGAN_SLOT_BRAIN)
if(length(B?.get_traumas_type(TRAUMA_RESILIENCE_SURGERY)))
problems = TRUE
if(host_mob.getOrganLoss(ORGAN_SLOT_BRAIN) > 0)
problems = TRUE
return problems ? ..() : FALSE
/datum/nanite_program/brain_heal_advanced/active_effect()
host_mob.adjustOrganLoss(ORGAN_SLOT_BRAIN, -2)
if(iscarbon(host_mob) && prob(10))
var/mob/living/carbon/C = host_mob
C.cure_trauma_type(resilience = TRAUMA_RESILIENCE_SURGERY)
/datum/nanite_program/defib
name = "Defibrillation"
desc = "The nanites shock the host's heart when triggered, bringing them back to life if the body can sustain it."
can_trigger = TRUE
trigger_cost = 25
trigger_cooldown = 120
rogue_types = list(/datum/nanite_program/shocking)
/datum/nanite_program/defib/on_trigger(comm_message)
host_mob.notify_ghost_cloning("Your heart is being defibrillated by nanites. Re-enter your corpse if you want to be revived!")
addtimer(CALLBACK(src, .proc/zap), 50)
/datum/nanite_program/defib/proc/check_revivable()
if(!iscarbon(host_mob)) //nonstandard biology
return FALSE
var/mob/living/carbon/C = host_mob
if(C.get_ghost())
return FALSE
return C.can_defib()
/datum/nanite_program/defib/proc/zap()
var/mob/living/carbon/C = host_mob
playsound(C, 'sound/machines/defib_charge.ogg', 50, FALSE)
sleep(30)
playsound(C, 'sound/machines/defib_zap.ogg', 50, FALSE)
if(check_revivable())
playsound(C, 'sound/machines/defib_success.ogg', 50, FALSE)
C.set_heartattack(FALSE)
C.revive(full_heal = FALSE, admin_revive = FALSE)
C.emote("gasp")
C.Jitter(100)
SEND_SIGNAL(C, COMSIG_LIVING_MINOR_SHOCK)
log_game("[C] has been successfully defibrillated by nanites.")
else
playsound(C, 'sound/machines/defib_failed.ogg', 50, FALSE)