Files
Yogstation/code/modules/surgery/organs/liver.dm
SapphicOverload b53139af62 Refactors process_flags to use mob biotypes (#20601)
* why do i keep doing this

* unused defines

* uh oh fix

* missed a spot

* why won't you die
2023-10-13 00:00:13 -05:00

139 lines
5.5 KiB
Plaintext
Executable File

#define LIVER_DEFAULT_TOX_TOLERANCE 3 //amount of toxins the liver can filter out
#define LIVER_DEFAULT_TOX_LETHALITY 0.01 //lower values lower how harmful toxins are to the liver
/obj/item/organ/liver
name = "liver"
icon_state = "liver"
visual = FALSE
w_class = WEIGHT_CLASS_SMALL
zone = BODY_ZONE_CHEST
slot = ORGAN_SLOT_LIVER
desc = "Pairing suggestion: chianti and fava beans."
maxHealth = STANDARD_ORGAN_THRESHOLD
healing_factor = STANDARD_ORGAN_HEALING
decay_factor = STANDARD_ORGAN_DECAY // smack in the middle of decay times
var/operated = FALSE //whether we can still have our damages fixed through surgery
var/alcohol_tolerance = ALCOHOL_RATE//affects how much damage the liver takes from alcohol
var/toxTolerance = LIVER_DEFAULT_TOX_TOLERANCE//maximum amount of toxins the liver can just shrug off
var/toxLethality = LIVER_DEFAULT_TOX_LETHALITY//affects how much damage toxins do to the liver
var/filterToxins = TRUE //whether to filter toxins
#define HAS_SILENT_TOXIN 0 //don't provide a feedback message if this is the only toxin present
#define HAS_NO_TOXIN 1
#define HAS_PAINFUL_TOXIN 2
/obj/item/organ/liver/on_life()
var/mob/living/carbon/C = owner
..() //perform general on_life()
if(istype(C))
if(!(organ_flags & ORGAN_FAILING))//can't process reagents with a failing liver
var/provide_pain_message = HAS_NO_TOXIN
if(filterToxins && !HAS_TRAIT(owner, TRAIT_TOXINLOVER))
//handle liver toxin filtration
for(var/datum/reagent/toxin/T in C.reagents.reagent_list)
var/thisamount = C.reagents.get_reagent_amount(T.type)
if (thisamount && thisamount <= toxTolerance)
C.reagents.remove_reagent(T.type, 1)
else
damage += (thisamount*toxLethality)
if(provide_pain_message != HAS_PAINFUL_TOXIN)
provide_pain_message = T.silent_toxin ? HAS_SILENT_TOXIN : HAS_PAINFUL_TOXIN
//metabolize reagents
C.reagents.metabolize(C, can_overdose=TRUE)
if(provide_pain_message && damage > 10 && prob(damage/3))//the higher the damage the higher the probability
to_chat(C, span_warning("You feel a dull pain in your abdomen."))
else //for when our liver's failing
C.reagents.end_metabolization(C, keep_liverless = TRUE) //Stops trait-based effects on reagents, to prevent permanent buffs
C.reagents.metabolize(C, can_overdose=FALSE, liverless = TRUE)
if(HAS_TRAIT(C, TRAIT_STABLELIVER))
return
C.adjustToxLoss(4, TRUE, TRUE)
if(prob(30))
to_chat(C, span_warning("You feel a stabbing pain in your abdomen!"))
if(damage > maxHealth)//cap liver damage
damage = maxHealth
#undef HAS_SILENT_TOXIN
#undef HAS_NO_TOXIN
#undef HAS_PAINFUL_TOXIN
/obj/item/organ/liver/prepare_eat()
var/obj/S = ..()
S.reagents.add_reagent(/datum/reagent/iron, 5)
return S
/obj/item/organ/liver/get_availability(datum/species/species)
return !(NOLIVER in species.species_traits)
/obj/item/organ/liver/fly
name = "insectoid liver"
icon_state = "liver-x" //xenomorph liver? It's just a black liver so it fits.
desc = "A mutant liver designed to handle the unique diet of a flyperson."
alcohol_tolerance = 0.007 //flies eat vomit, so a lower alcohol tolerance is perfect!
/obj/item/organ/liver/plasmaman
name = "reagent processing crystal"
icon_state = "liver-p"
desc = "A large crystal that is somehow capable of metabolizing chemicals, these are found in plasmamen."
/obj/item/organ/liver/alien
name = "alien liver" // doesnt matter for actual aliens because they dont take toxin damage
icon_state = "liver-x" // Same sprite as fly-person liver.
desc = "A liver that used to belong to a killer alien, who knows what it used to eat."
toxLethality = LIVER_DEFAULT_TOX_LETHALITY * 2.5 // rejects its owner early after too much punishment
toxTolerance = 15 // complete toxin immunity like xenos have would be too powerful
/obj/item/organ/liver/cybernetic
name = "cybernetic liver"
icon_state = "liver-c"
desc = "An electronic device designed to mimic the functions of a human liver. Handles toxins slightly better than an organic liver."
organ_flags = ORGAN_SYNTHETIC
alcohol_tolerance = 0.001
maxHealth = 2 * STANDARD_ORGAN_THRESHOLD
toxTolerance = 3.3
toxLethality = 0.009
/obj/item/organ/liver/cybernetic/upgraded
name = "upgraded cybernetic liver"
icon_state = "liver-c-u"
desc = "An upgraded version of the cybernetic liver, designed to handle extreme levels of toxins. It can even heal minor amounts of toxin damage."
alcohol_tolerance = 0.0005
maxHealth = 3 * STANDARD_ORGAN_THRESHOLD //300% health of a normal liver
healing_factor = 2 * STANDARD_ORGAN_HEALING //Can regenerate from damage quicker
toxTolerance = 20
toxLethality = 0.007
/obj/item/organ/liver/cybernetic/upgraded/on_life()
. = ..()
var/mob/living/carbon/C = owner
if(!(organ_flags & ORGAN_FAILING)) //Passive Toxin damage healing
C.adjustToxLoss(-0.5, TRUE, FALSE)
/obj/item/organ/liver/cybernetic/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_SELF)
return
damage += 50/severity
/obj/item/organ/liver/cybernetic/upgraded/ipc
name = "substance processor"
icon_state = "substance_processor"
attack_verb = list("processed")
desc = "A machine component, installed in the chest. This grants the machine the ability to process chemicals that enter its systems."
alcohol_tolerance = 0
toxTolerance = -1
toxLethality = 0
status = ORGAN_ROBOTIC
compatible_biotypes = ALL_BIOTYPES
/obj/item/organ/liver/cybernetic/upgraded/ipc/emp_act(severity)
if(prob(10))
return
to_chat(owner, "<span class='warning'>Alert: Your Substance Processor has been damaged. An internal chemical leak is affecting performance.</span>")
owner.adjustToxLoss(10/severity)