Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 85f314e

Browse files
committed
update
1 parent e34af45 commit 85f314e

File tree

3 files changed

+53
-24
lines changed

3 files changed

+53
-24
lines changed

code/__DEFINES/dcs/signals/signals_mob/signals_carbon.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
#define COMSIG_CARBON_GAIN_ORGAN "carbon_gain_organ"
6161
///from /item/organ/proc/Remove() (/obj/item/organ/)
6262
#define COMSIG_CARBON_LOSE_ORGAN "carbon_lose_organ"
63+
///from on_mob_metabolize and mob_end_metabolize for the liver
64+
#define COMSIG_CARBON_UPDATE_TOXINS "carbon_update_toxins_cache"
6365
///from /mob/living/carbon/doUnEquip(obj/item/I, force, newloc, no_move, invdrop, silent)
6466
#define COMSIG_CARBON_EQUIP_HAT "carbon_equip_hat"
6567
///from /mob/living/carbon/doUnEquip(obj/item/I, force, newloc, no_move, invdrop, silent)

code/modules/reagents/chemistry/reagents/toxin_reagents.dm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
var/toxpwr = 1.5
1313
var/silent_toxin = FALSE //won't produce a pain message when processed by liver/Life(seconds_per_tick = SSMOBS_DT, times_fired) if there isn't another non-silent toxin present.
1414

15+
/datum/reagent/toxin/on_mob_metabolize(mob/living/L)
16+
. = ..()
17+
SEND_SIGNAL(L, COMSIG_CARBON_UPDATE_TOXINS)
18+
19+
/datum/reagent/toxin/on_mob_end_metabolize(mob/living/L)
20+
. = ..()
21+
SEND_SIGNAL(L, COMSIG_CARBON_UPDATE_TOXINS)
22+
1523
/datum/reagent/toxin/amatoxin
1624
name = "Amatoxin"
1725
description = "A powerful poison derived from certain species of mushroom."

code/modules/surgery/organs/liver.dm

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,43 +17,62 @@
1717
var/alcohol_tolerance = ALCOHOL_RATE
1818
/// modifier to toxpwr for liver and toxin damage taken
1919
var/toxLethality = LIVER_DEFAULT_TOX_LETHALITY
20+
/// cached list of the toxinpower of toxins
21+
var/list/cached_toxpower = list()
22+
/// whether or not the toxin process can provide a message
23+
var/provide_pain_message = FALSE
2024

21-
/obj/item/organ/liver/on_life()
22-
var/mob/living/carbon/C = owner
23-
..() //perform general on_life()
24-
if(istype(C))
25-
if(!(organ_flags & ORGAN_FAILING))//can't process reagents with a failing liver
25+
/obj/item/organ/liver/Insert(mob/living/carbon/M, special, drop_if_replaced, special_zone)
26+
. = ..()
27+
RegisterSignal(M, COMSIG_CARBON_UPDATE_TOXINS, PROC_REF(update_toxin_cache))
2628

27-
var/provide_pain_message = FALSE
28-
var/damage_multiplier = 1 //reduced for every toxin
29-
var/list/toxpwr = list()
29+
/obj/item/organ/liver/Remove(mob/living/carbon/M, special)
30+
UnregisterSignal(M, COMSIG_CARBON_UPDATE_TOXINS)
31+
return ..()
3032

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
33+
/obj/item/organ/liver/proc/update_toxin_cache()
34+
var/mob/living/carbon/C = owner
35+
if(!istype(C))
36+
return
3637

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 / 2)
38+
provide_pain_message = FALSE
39+
cached_toxpower = list()
4340

44-
//metabolize reagents
45-
C.reagents.metabolize(C, can_overdose=TRUE)
41+
for(var/datum/reagent/toxin/T in C.reagents.reagent_list)
42+
cached_toxpower += T.toxpwr
43+
provide_pain_message = provide_pain_message || !T.silent_toxin
44+
45+
sort_list(cached_toxpower, cmp = /proc/cmp_numeric_dsc) //sort all toxpowers scaling from highest to lowest
4646

47-
if(provide_pain_message && damage > 10 && !HAS_TRAIT(owner, TRAIT_TOXINLOVER) && prob(damage/3))//the higher the damage the higher the probability
48-
to_chat(C, span_warning("You feel a dull pain in your abdomen."))
49-
else //for when our liver's failing
47+
/obj/item/organ/liver/on_life()
48+
var/mob/living/carbon/C = owner
49+
..() //perform general on_life()
50+
if(istype(C))
51+
if(organ_flags & ORGAN_FAILING)//for when our liver's failing
5052
C.reagents.end_metabolization(C, keep_liverless = TRUE) //Stops trait-based effects on reagents, to prevent permanent buffs
5153
C.reagents.metabolize(C, can_overdose=FALSE, liverless = TRUE)
5254
if(HAS_TRAIT(C, TRAIT_STABLELIVER))
5355
return
5456
C.adjustToxLoss(4, TRUE, TRUE)
5557
if(prob(30))
5658
to_chat(C, span_warning("You feel a stabbing pain in your abdomen!"))
59+
60+
else
61+
if(length(cached_toxpower)) //deal with toxins
62+
var/damage_multiplier = 1 //reduced for every subsequent toxin
63+
64+
for(var/dmg in cached_toxpower)
65+
var/real_damage = dmg * toxLethality * damage_multiplier
66+
damage_multiplier *= 0.5 //reduce the damage dealt for every subsequent toxin
67+
C.adjustToxLoss(real_damage)
68+
if(!HAS_TRAIT(owner, TRAIT_TOXINLOVER)) //don't hurt the liver if they like toxins
69+
damage += (real_damage / 2)
70+
71+
//metabolize reagents
72+
C.reagents.metabolize(C, can_overdose=TRUE)
73+
74+
if(provide_pain_message && damage > 10 && !HAS_TRAIT(owner, TRAIT_TOXINLOVER) && prob(damage/3))//the higher the damage the higher the probability
75+
to_chat(C, span_warning("You feel a dull pain in your abdomen."))
5776

5877
if(damage > maxHealth)//cap liver damage
5978
damage = maxHealth

0 commit comments

Comments
 (0)