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

[MIRROR] Splits reagent metabolization from reagent effects. #733

Merged
merged 1 commit into from
Nov 20, 2023
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
11 changes: 7 additions & 4 deletions code/modules/reagents/chemistry/holder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,13 @@

if(reagent.overdosed)
need_mob_update += reagent.overdose_process(owner, seconds_per_tick, times_fired)
if(!dead)
need_mob_update += reagent.on_mob_life(owner, seconds_per_tick, times_fired)
if(dead)
need_mob_update += reagent.on_mob_dead(owner, seconds_per_tick)
reagent.current_cycle++
need_mob_update += reagent.on_mob_life(owner, seconds_per_tick, times_fired)
if(dead && !QDELETED(owner) && !QDELETED(reagent))
need_mob_update += reagent.on_mob_dead(owner, seconds_per_tick)
if(!QDELETED(owner) && !QDELETED(reagent))
reagent.metabolize_reagent(owner, seconds_per_tick, times_fired)

return need_mob_update

/**
Expand Down
18 changes: 9 additions & 9 deletions code/modules/reagents/chemistry/reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@
*/
/datum/reagent/proc/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
SHOULD_CALL_PARENT(TRUE)
current_cycle++

///Metabolizes a portion of the reagent after on_mob_life() is called
/datum/reagent/proc/metabolize_reagent(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
if(length(reagent_removal_skip_list))
return
if(isnull(holder))
Expand All @@ -170,6 +172,7 @@

holder.remove_reagent(type, metabolizing_out)


/// Called in burns.dm *if* the reagent has the REAGENT_AFFECTS_WOUNDS process flag
/datum/reagent/proc/on_burn_wound_processing(datum/wound/burn/flesh/burn_wound)
return
Expand Down Expand Up @@ -203,15 +206,12 @@ Primarily used in reagents/reaction_agents
/datum/reagent/proc/on_mob_end_metabolize(mob/living/affected_mob)
return

/// Called when a reagent is inside of a mob when they are dead. Returning UPDATE_MOB_HEALTH will cause updatehealth() to be called on the holder mob by /datum/reagents/proc/metabolize.
/**
* Called when a reagent is inside of a mob when they are dead if the reagent has the REAGENT_DEAD_PROCESS flag
* Returning UPDATE_MOB_HEALTH will cause updatehealth() to be called on the holder mob by /datum/reagents/proc/metabolize.
*/
/datum/reagent/proc/on_mob_dead(mob/living/carbon/affected_mob, seconds_per_tick)
if(!(chemical_flags & REAGENT_DEAD_PROCESS))
return
current_cycle++
if(length(reagent_removal_skip_list))
return
if(holder)
holder.remove_reagent(type, metabolization_rate * affected_mob.metabolism_efficiency * seconds_per_tick)
SHOULD_CALL_PARENT(TRUE)

/// Called after add_reagents creates a new reagent.
/datum/reagent/proc/on_new(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@
if(!HAS_TRAIT(breather, TRAIT_KNOCKEDOUT))
return

. = ..()
for(var/obj/item/organ/organ_being_healed as anything in breather.organs)
if(!organ_being_healed.damage)
continue

if(organ_being_healed.apply_organ_damage(-0.5 * REM * seconds_per_tick, required_organ_flag = ORGAN_ORGANIC))
return UPDATE_MOB_HEALTH
. = UPDATE_MOB_HEALTH

/datum/reagent/zauker
name = "Zauker"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

/datum/reagent/medicine/c2/helbital/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
var/death_is_coming = (affected_mob.getToxLoss() + affected_mob.getOxyLoss() + affected_mob.getFireLoss() + affected_mob.getBruteLoss())*normalise_creation_purity()
var/thou_shall_heal = 0
var/good_kind_of_healing = FALSE
Expand Down Expand Up @@ -78,7 +79,6 @@
affected_mob.revive(HEAL_ALL)
holder.del_reagent(type)
return
return ..() || .

/datum/reagent/medicine/c2/helbital/overdose_process(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,9 +653,9 @@
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

/datum/reagent/consumable/ethanol/bloody_mary/on_mob_life(mob/living/carbon/drinker, seconds_per_tick, times_fired)
. = ..()
if(drinker.blood_volume < BLOOD_VOLUME_NORMAL)
drinker.blood_volume = min(drinker.blood_volume + (1 * REM * seconds_per_tick), BLOOD_VOLUME_NORMAL) //Bloody Mary quickly restores blood loss. // SKYRAT EDIT - Bloodshot is now the go-to drink for bloodloss, not Bloody Mary - ORIGINAL: drinker.blood_volume = min(drinker.blood_volume + (3 * REM * delta_time), BLOOD_VOLUME_NORMAL)
..()

/datum/reagent/consumable/ethanol/brave_bull
name = "Brave Bull"
Expand Down Expand Up @@ -1751,6 +1751,7 @@
/datum/reagent/consumable/ethanol/alexander/on_mob_life(mob/living/drinker, seconds_per_tick, times_fired)
if(mighty_shield && !(mighty_shield in drinker.contents)) //If you had a shield and lose it, you lose the reagent as well. Otherwise this is just a normal drink.
holder.remove_reagent(type, volume)
return
return ..()

/datum/reagent/consumable/ethanol/alexander/on_mob_end_metabolize(mob/living/drinker)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,9 @@
default_container = /obj/item/reagent_containers/cup/glass/bottle/juice/cream

/datum/reagent/consumable/cream/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
if(affected_mob.getBruteLoss() && SPT_PROB(10, seconds_per_tick))
affected_mob.heal_bodypart_damage(1, 0)
. = TRUE
..()
. = ..()
if(SPT_PROB(10, seconds_per_tick) && affected_mob.heal_bodypart_damage(1, 0))
return UPDATE_MOB_HEALTH

/datum/reagent/consumable/coffee
name = "Coffee"
Expand All @@ -272,14 +271,14 @@
affected_mob.set_jitter_if_lower(10 SECONDS * REM * seconds_per_tick)

/datum/reagent/consumable/coffee/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
affected_mob.adjust_dizzy(-10 SECONDS * REM * seconds_per_tick)
affected_mob.adjust_drowsiness(-6 SECONDS * REM * seconds_per_tick)
affected_mob.AdjustSleeping(-40 * REM * seconds_per_tick)
//310.15 is the normal bodytemp.
affected_mob.adjust_bodytemperature(25 * REM * TEMPERATURE_DAMAGE_COEFFICIENT * seconds_per_tick, 0, affected_mob.get_body_temp_normal())
if(holder.has_reagent(/datum/reagent/consumable/frostoil))
holder.remove_reagent(/datum/reagent/consumable/frostoil, 5 * REM * seconds_per_tick)
return ..() || .

/datum/reagent/consumable/tea
name = "Tea"
Expand Down
3 changes: 1 addition & 2 deletions code/modules/reagents/chemistry/reagents/drug_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,6 @@

/datum/reagent/drug/blastoff/on_mob_life(mob/living/carbon/dancer, seconds_per_tick, times_fired)
. = ..()

if(dancer.adjustOrganLoss(ORGAN_SLOT_LUNGS, 0.3 * REM * seconds_per_tick, required_organ_flag = affected_organ_flags))
. = UPDATE_MOB_HEALTH
dancer.AdjustKnockdown(-20)
Expand Down Expand Up @@ -818,7 +817,7 @@
//I wish i could give it some kind of bonus when smoked, but we don't have an INHALE method.

/datum/reagent/drug/kronkaine/on_mob_life(mob/living/carbon/kronkaine_fiend, seconds_per_tick, times_fired)
. = ..() || TRUE
. = ..()
kronkaine_fiend.add_mood_event("tweaking", /datum/mood_event/stimulant_medium)
if(kronkaine_fiend.adjustOrganLoss(ORGAN_SLOT_HEART, 0.4 * REM * seconds_per_tick, required_organ_flag = affected_organ_flags))
. = UPDATE_MOB_HEALTH
Expand Down
12 changes: 6 additions & 6 deletions code/modules/reagents/chemistry/reagents/food_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
reagent_state = SOLID
nutriment_factor = 15
color = "#664330" // rgb: 102, 67, 48
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED|REAGENT_DEAD_PROCESS
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

var/brute_heal = 1
var/burn_heal = 0
Expand Down Expand Up @@ -345,6 +345,7 @@
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

/datum/reagent/consumable/capsaicin/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
var/heating = 0
switch(current_cycle)
if(1 to 15)
Expand All @@ -366,7 +367,6 @@
if(isslime(affected_mob))
heating = rand(20, 25)
affected_mob.adjust_bodytemperature(heating * TEMPERATURE_DAMAGE_COEFFICIENT * REM * seconds_per_tick)
return ..()

/datum/reagent/consumable/frostoil
name = "Frost Oil"
Expand All @@ -380,6 +380,7 @@
default_container = /obj/item/reagent_containers/cup/bottle/frostoil

/datum/reagent/consumable/frostoil/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
var/cooling = 0
switch(current_cycle)
if(1 to 15)
Expand All @@ -405,7 +406,6 @@
if(isslime(affected_mob))
cooling = -rand(20, 25)
affected_mob.adjust_bodytemperature(cooling * TEMPERATURE_DAMAGE_COEFFICIENT * REM * seconds_per_tick, 50)
return ..()

/datum/reagent/consumable/frostoil/expose_turf(turf/exposed_turf, reac_volume)
. = ..()
Expand Down Expand Up @@ -464,10 +464,10 @@
return ..()

/datum/reagent/consumable/condensedcapsaicin/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
if(!holder.has_reagent(/datum/reagent/consumable/milk))
if(SPT_PROB(5, seconds_per_tick))
affected_mob.visible_message(span_warning("[affected_mob] [pick("dry heaves!","coughs!","splutters!")]"))
return ..()

/datum/reagent/consumable/salt
name = "Table Salt"
Expand Down Expand Up @@ -807,8 +807,8 @@
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

/datum/reagent/consumable/corn_syrup/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
holder.add_reagent(/datum/reagent/consumable/sugar, 3 * REM * seconds_per_tick)
return ..()

/datum/reagent/consumable/honey
name = "Honey"
Expand All @@ -830,8 +830,8 @@
mytray.adjust_pestlevel(rand(1, 2))

/datum/reagent/consumable/honey/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
holder.add_reagent(/datum/reagent/consumable/sugar, 3 * REM * seconds_per_tick)
. = ..()
holder.add_reagent(/datum/reagent/consumable/sugar, 3 * REM * seconds_per_tick)
var/need_mob_update
if(SPT_PROB(33, seconds_per_tick))
need_mob_update = affected_mob.adjustBruteLoss(-1, updating_health = FALSE, required_bodytype = affected_bodytype)
Expand Down
9 changes: 6 additions & 3 deletions code/modules/reagents/chemistry/reagents/impure_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@
cryostylane_alert.attached_effect = src //so the alert can reference us, if it needs to

/datum/reagent/inverse/cryostylane/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
if(current_cycle >= 60)
holder.remove_reagent(type, volume) // remove it all if we're past 60 cycles
return ..()
. = ..()
if(!cube || affected_mob.loc != cube)
metabolization_rate += 0.01

/datum/reagent/inverse/cryostylane/metabolize_reagent(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
if(current_cycle >= 60)
holder.remove_reagent(type, volume) // remove it all if we're past 60 cycles
return
return ..()

/datum/reagent/inverse/cryostylane/on_mob_delete(mob/living/carbon/affected_mob, amount)
Expand Down
38 changes: 21 additions & 17 deletions code/modules/reagents/chemistry/reagents/medicine_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

/datum/reagent/medicine/synaptizine/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
affected_mob.adjust_drowsiness(-10 SECONDS * REM * seconds_per_tick)
affected_mob.AdjustStun(-20 * REM * seconds_per_tick)
affected_mob.AdjustKnockdown(-20 * REM * seconds_per_tick)
Expand All @@ -93,7 +94,6 @@
affected_mob.AdjustParalyzed(-20 * REM * seconds_per_tick)
if(holder.has_reagent(/datum/reagent/toxin/mindbreaker))
holder.remove_reagent(/datum/reagent/toxin/mindbreaker, 5 * REM * seconds_per_tick)
. = ..()
affected_mob.adjust_hallucinations(-20 SECONDS * REM * seconds_per_tick)
if(SPT_PROB(16, seconds_per_tick))
if(affected_mob.adjustToxLoss(1, updating_health = FALSE, required_biotype = affected_biotype))
Expand All @@ -107,12 +107,12 @@
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

/datum/reagent/medicine/synaphydramine/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
affected_mob.adjust_drowsiness(-10 SECONDS * REM * seconds_per_tick)
if(holder.has_reagent(/datum/reagent/toxin/mindbreaker))
holder.remove_reagent(/datum/reagent/toxin/mindbreaker, 5 * REM * seconds_per_tick)
if(holder.has_reagent(/datum/reagent/toxin/histamine))
holder.remove_reagent(/datum/reagent/toxin/histamine, 5 * REM * seconds_per_tick)
. = ..()
affected_mob.adjust_hallucinations(-20 SECONDS * REM * seconds_per_tick)
if(SPT_PROB(16, seconds_per_tick))
if(affected_mob.adjustToxLoss(1 * REM * seconds_per_tick, updating_health = FALSE, required_biotype = affected_biotype))
Expand Down Expand Up @@ -655,11 +655,11 @@
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

/datum/reagent/medicine/diphenhydramine/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
if(SPT_PROB(5, seconds_per_tick))
affected_mob.adjust_drowsiness(2 SECONDS)
affected_mob.adjust_jitter(-2 SECONDS * REM * seconds_per_tick)
holder.remove_reagent(/datum/reagent/toxin/histamine, 3 * REM * seconds_per_tick)
return ..()

/datum/reagent/medicine/morphine
name = "Morphine"
Expand Down Expand Up @@ -874,14 +874,11 @@
REMOVE_TRAIT(affected_mob, TRAIT_NOCRITDAMAGE, type)

/datum/reagent/medicine/epinephrine/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
if(holder.has_reagent(/datum/reagent/toxin/lexorin))
holder.remove_reagent(/datum/reagent/toxin/lexorin, 2 * REM * seconds_per_tick)
holder.remove_reagent(/datum/reagent/medicine/epinephrine, 1 * REM * seconds_per_tick)
if(SPT_PROB(10, seconds_per_tick))
holder.add_reagent(/datum/reagent/toxin/histamine, 4)
return ..()

. = ..()
return

var/need_mob_update
if(affected_mob.health <= affected_mob.crit_threshold)
Expand All @@ -905,6 +902,12 @@
if(need_mob_update)
return UPDATE_MOB_HEALTH

/datum/reagent/medicine/epinephrine/metabolize_reagent(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
if(holder.has_reagent(/datum/reagent/toxin/lexorin))
holder.remove_reagent(/datum/reagent/toxin/lexorin, 2 * REM * seconds_per_tick)
holder.remove_reagent(/datum/reagent/medicine/epinephrine, 1 * REM * seconds_per_tick)
return ..()

/datum/reagent/medicine/epinephrine/overdose_process(mob/living/affected_mob, seconds_per_tick, times_fired)
. = ..()
if(SPT_PROB(18, REM * seconds_per_tick))
Expand Down Expand Up @@ -1100,11 +1103,11 @@
affected_carbon.setOrganLoss(ORGAN_SLOT_BRAIN, initial_bdamage)

/datum/reagent/medicine/neurine/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
if(holder.has_reagent(/datum/reagent/consumable/ethanol/neurotoxin))
holder.remove_reagent(/datum/reagent/consumable/ethanol/neurotoxin, 5 * REM * seconds_per_tick * normalise_creation_purity())
if(SPT_PROB(8 * normalise_creation_purity(), seconds_per_tick))
affected_mob.cure_trauma_type(resilience = TRAUMA_RESILIENCE_BASIC)
return ..()

/datum/reagent/medicine/neurine/on_mob_dead(mob/living/carbon/affected_mob, seconds_per_tick)
. = ..()
Expand Down Expand Up @@ -1212,9 +1215,9 @@
chemical_flags = REAGENT_CAN_BE_SYNTHESIZED

/datum/reagent/medicine/insulin/on_mob_life(mob/living/carbon/affected_mob, seconds_per_tick, times_fired)
. = ..()
affected_mob.AdjustSleeping(-20 * REM * seconds_per_tick)
holder.remove_reagent(/datum/reagent/consumable/sugar, 3 * REM * seconds_per_tick)
return ..()

//Trek Chems, used primarily by medibots. Only heals a specific damage type, but is very efficient.

Expand Down Expand Up @@ -1506,13 +1509,14 @@

/datum/reagent/medicine/modafinil/on_mob_life(mob/living/carbon/metabolizer, seconds_per_tick, times_fired)
. = ..()
if(!overdosed) // We do not want any effects on OD
overdose_threshold = overdose_threshold + ((rand(-10, 10) / 10) * REM * seconds_per_tick) // for extra fun
metabolizer.AdjustAllImmobility(-5 * REM * seconds_per_tick)
metabolizer.adjustStaminaLoss(-0.5 * REM * seconds_per_tick, updating_stamina = FALSE, required_biotype = affected_biotype)
metabolizer.set_jitter_if_lower(1 SECONDS * REM * seconds_per_tick)
metabolization_rate = 0.005 * REAGENTS_METABOLISM * rand(5, 20) // randomizes metabolism between 0.02 and 0.08 per second
return UPDATE_MOB_HEALTH
if(overdosed) // We do not want any effects on OD
return
overdose_threshold = overdose_threshold + ((rand(-10, 10) / 10) * REM * seconds_per_tick) // for extra fun
metabolizer.AdjustAllImmobility(-5 * REM * seconds_per_tick)
metabolizer.adjustStaminaLoss(-0.5 * REM * seconds_per_tick, updating_stamina = FALSE, required_biotype = affected_biotype)
metabolizer.set_jitter_if_lower(1 SECONDS * REM * seconds_per_tick)
metabolization_rate = 0.005 * REAGENTS_METABOLISM * rand(5, 20) // randomizes metabolism between 0.02 and 0.08 per second
return UPDATE_MOB_HEALTH

/datum/reagent/medicine/modafinil/overdose_start(mob/living/affected_mob)
. = ..()
Expand Down
Loading
Loading