|
1 | | -#define LIVER_DEFAULT_TOX_TOLERANCE 3 //amount of toxins the liver can filter out |
2 | | -#define LIVER_DEFAULT_TOX_LETHALITY 0.01 //lower values lower how harmful toxins are to the liver |
| 1 | +#define LIVER_DEFAULT_TOX_LETHALITY 1 //lower values lower how harmful toxins are to the liver |
3 | 2 |
|
4 | 3 | /obj/item/organ/liver |
5 | 4 | name = "liver" |
|
12 | 11 | maxHealth = STANDARD_ORGAN_THRESHOLD |
13 | 12 | healing_factor = STANDARD_ORGAN_HEALING |
14 | 13 | decay_factor = STANDARD_ORGAN_DECAY // smack in the middle of decay times |
15 | | - var/operated = FALSE //whether we can still have our damages fixed through surgery |
16 | | - var/alcohol_tolerance = ALCOHOL_RATE//affects how much damage the liver takes from alcohol |
17 | | - var/toxTolerance = LIVER_DEFAULT_TOX_TOLERANCE//maximum amount of toxins the liver can just shrug off |
18 | | - var/toxLethality = LIVER_DEFAULT_TOX_LETHALITY//affects how much damage toxins do to the liver |
19 | | - var/filterToxins = TRUE //whether to filter toxins |
20 | | - |
21 | | -#define HAS_SILENT_TOXIN 0 //don't provide a feedback message if this is the only toxin present |
22 | | -#define HAS_NO_TOXIN 1 |
23 | | -#define HAS_PAINFUL_TOXIN 2 |
| 14 | + /// whether we can still have our damages fixed through surgery |
| 15 | + var/operated = FALSE |
| 16 | + /// affects how much damage the liver takes from alcohol |
| 17 | + var/alcohol_tolerance = ALCOHOL_RATE |
| 18 | + /// modifier to toxpwr for liver and toxin damage taken |
| 19 | + var/toxLethality = LIVER_DEFAULT_TOX_LETHALITY |
24 | 20 |
|
25 | 21 | /obj/item/organ/liver/on_life() |
26 | 22 | var/mob/living/carbon/C = owner |
27 | 23 | ..() //perform general on_life() |
28 | 24 | if(istype(C)) |
29 | 25 | if(!(organ_flags & ORGAN_FAILING))//can't process reagents with a failing liver |
30 | 26 |
|
31 | | - var/provide_pain_message = HAS_NO_TOXIN |
32 | | - if(filterToxins && !HAS_TRAIT(owner, TRAIT_TOXINLOVER)) |
33 | | - //handle liver toxin filtration |
34 | | - for(var/datum/reagent/toxin/T in C.reagents.reagent_list) |
35 | | - var/thisamount = C.reagents.get_reagent_amount(T.type) |
36 | | - if (thisamount && thisamount <= toxTolerance) |
37 | | - C.reagents.remove_reagent(T.type, 1) |
38 | | - else |
39 | | - damage += (thisamount*toxLethality) |
40 | | - if(provide_pain_message != HAS_PAINFUL_TOXIN) |
41 | | - provide_pain_message = T.silent_toxin ? HAS_SILENT_TOXIN : HAS_PAINFUL_TOXIN |
| 27 | + var/provide_pain_message = FALSE |
| 28 | + var/damage_multiplier = 1 //reduced for every toxin |
| 29 | + var/list/toxpwr = list() |
| 30 | + |
| 31 | + for(var/datum/reagent/toxin/T in C.reagents.reagent_list) |
| 32 | + toxpwr += T.toxpwr |
| 33 | + provide_pain_message = provide_pain_message || !T.silent_toxin |
| 34 | + |
| 35 | + sort_list(toxpwr, cmp = /proc/cmp_numeric_dsc) //sort all toxpowers scaling from highest to lowest |
| 36 | + |
| 37 | + for(var/dmg in toxpwr) |
| 38 | + var/real_damage = dmg * toxLethality * damage_multiplier |
| 39 | + damage_multiplier *= 0.5 //reduce the damage dealt for every subsequent toxin |
| 40 | + C.adjustToxLoss(real_damage) |
| 41 | + if(!HAS_TRAIT(owner, TRAIT_TOXINLOVER)) //don't hurt the liver if they like toxins |
| 42 | + damage += (real_damage) |
42 | 43 |
|
43 | 44 | //metabolize reagents |
44 | 45 | C.reagents.metabolize(C, can_overdose=TRUE) |
45 | 46 |
|
46 | | - if(provide_pain_message && damage > 10 && prob(damage/3))//the higher the damage the higher the probability |
| 47 | + if(provide_pain_message && damage > 10 && !HAS_TRAIT(owner, TRAIT_TOXINLOVER) && prob(damage/3))//the higher the damage the higher the probability |
47 | 48 | to_chat(C, span_warning("You feel a dull pain in your abdomen.")) |
48 | 49 | else //for when our liver's failing |
49 | 50 | C.reagents.end_metabolization(C, keep_liverless = TRUE) //Stops trait-based effects on reagents, to prevent permanent buffs |
|
57 | 58 | if(damage > maxHealth)//cap liver damage |
58 | 59 | damage = maxHealth |
59 | 60 |
|
60 | | -#undef HAS_SILENT_TOXIN |
61 | | -#undef HAS_NO_TOXIN |
62 | | -#undef HAS_PAINFUL_TOXIN |
63 | | - |
64 | 61 | /obj/item/organ/liver/prepare_eat() |
65 | 62 | var/obj/S = ..() |
66 | 63 | S.reagents.add_reagent(/datum/reagent/iron, 5) |
|
84 | 81 | name = "alien liver" // doesnt matter for actual aliens because they dont take toxin damage |
85 | 82 | icon_state = "liver-x" // Same sprite as fly-person liver. |
86 | 83 | desc = "A liver that used to belong to a killer alien, who knows what it used to eat." |
87 | | - toxLethality = LIVER_DEFAULT_TOX_LETHALITY * 2.5 // rejects its owner early after too much punishment |
88 | | - toxTolerance = 15 // complete toxin immunity like xenos have would be too powerful |
| 84 | + toxLethality = LIVER_DEFAULT_TOX_LETHALITY * 0.5 |
89 | 85 |
|
90 | 86 | /obj/item/organ/liver/cybernetic |
91 | 87 | name = "cybernetic liver" |
|
94 | 90 | organ_flags = ORGAN_SYNTHETIC |
95 | 91 | alcohol_tolerance = 0.001 |
96 | 92 | maxHealth = 2 * STANDARD_ORGAN_THRESHOLD |
97 | | - toxTolerance = 3.3 |
98 | | - toxLethality = 0.009 |
| 93 | + toxLethality = LIVER_DEFAULT_TOX_LETHALITY * 0.9 |
99 | 94 |
|
100 | 95 | /obj/item/organ/liver/cybernetic/upgraded |
101 | 96 | name = "upgraded cybernetic liver" |
|
104 | 99 | alcohol_tolerance = 0.0005 |
105 | 100 | maxHealth = 3 * STANDARD_ORGAN_THRESHOLD //300% health of a normal liver |
106 | 101 | healing_factor = 2 * STANDARD_ORGAN_HEALING //Can regenerate from damage quicker |
107 | | - toxTolerance = 20 |
108 | | - toxLethality = 0.007 |
| 102 | + toxLethality = LIVER_DEFAULT_TOX_LETHALITY * 0.7 |
109 | 103 |
|
110 | 104 | /obj/item/organ/liver/cybernetic/upgraded/on_life() |
111 | 105 | . = ..() |
|
125 | 119 | attack_verb = list("processed") |
126 | 120 | desc = "A machine component, installed in the chest. This grants the machine the ability to process chemicals that enter its systems." |
127 | 121 | alcohol_tolerance = 0 |
128 | | - toxTolerance = -1 |
129 | 122 | toxLethality = 0 |
130 | 123 | status = ORGAN_ROBOTIC |
131 | 124 | compatible_biotypes = ALL_BIOTYPES |
|
0 commit comments