diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index 75e5bba3386..05f310eeef2 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -52,6 +52,11 @@ #define MOB_SPIRIT (1 << 9) #define MOB_PLANT (1 << 10) +//Lung respiration type flags +#define RESPIRATION_OXYGEN (1 << 0) +#define RESPIRATION_CO2 (1 << 1) +#define RESPIRATION_N2 (1 << 2) +#define RESPIRATION_PLASMA (1 << 3) //Organ defines for carbon mobs #define ORGAN_ORGANIC 1 diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index 71502718673..34ee9c4b4bf 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -411,6 +411,13 @@ DEFINE_BITFIELD(organ_flags, list( "ORGAN_UNREMOVABLE" = ORGAN_UNREMOVABLE, )) +DEFINE_BITFIELD(respiration_type, list( + "RESPIRATION_OXYGEN" = RESPIRATION_OXYGEN, + "RESPIRATION_CO2" = RESPIRATION_CO2, + "RESPIRATION_N2" = RESPIRATION_N2, + "RESPIRATION_PLASMA" = RESPIRATION_PLASMA, +)) + DEFINE_BITFIELD(sharpness, list( "SHARP_EDGED" = SHARP_EDGED, "SHARP_POINTY" = SHARP_POINTY, diff --git a/code/modules/admin/view_variables/topic.dm b/code/modules/admin/view_variables/topic.dm index d6934144a8c..4a7cbb621d3 100644 --- a/code/modules/admin/view_variables/topic.dm +++ b/code/modules/admin/view_variables/topic.dm @@ -82,25 +82,25 @@ var/newamt switch(Text) if("brute") - L.adjustBruteLoss(amount) + L.adjustBruteLoss(amount, forced = TRUE) newamt = L.getBruteLoss() if("fire") - L.adjustFireLoss(amount) + L.adjustFireLoss(amount, forced = TRUE) newamt = L.getFireLoss() if("toxin") - L.adjustToxLoss(amount) + L.adjustToxLoss(amount, forced = TRUE) newamt = L.getToxLoss() if("oxygen") - L.adjustOxyLoss(amount) + L.adjustOxyLoss(amount, forced = TRUE) newamt = L.getOxyLoss() if("brain") L.adjustOrganLoss(ORGAN_SLOT_BRAIN, amount) newamt = L.getOrganLoss(ORGAN_SLOT_BRAIN) if("clone") - L.adjustCloneLoss(amount) + L.adjustCloneLoss(amount, forced = TRUE) newamt = L.getCloneLoss() if("stamina") - L.adjustStaminaLoss(amount) + L.adjustStaminaLoss(amount, forced = TRUE) newamt = L.getStaminaLoss() else to_chat(usr, "You caused an error. DEBUG: Text:[Text] Mob:[L]", confidential = TRUE) diff --git a/code/modules/mob/living/basic/health_adjustment.dm b/code/modules/mob/living/basic/health_adjustment.dm index c69a4ae70e3..6355f809cf4 100644 --- a/code/modules/mob/living/basic/health_adjustment.dm +++ b/code/modules/mob/living/basic/health_adjustment.dm @@ -30,7 +30,7 @@ else if(damage_coeff[BURN]) . = adjust_health(amount * damage_coeff[BURN] * CONFIG_GET(number/damage_multiplier), updating_health, forced) -/mob/living/basic/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) +/mob/living/basic/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype, required_respiration_type) if(forced) . = adjust_health(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) else if(damage_coeff[OXY]) diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index 7a4c39190e3..96b66e26146 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -730,7 +730,7 @@ . = FALSE -/mob/living/carbon/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) +/mob/living/carbon/adjustOxyLoss(amount, updating_health = TRUE, forced, required_biotype, required_respiration_type) . = ..() check_passout(.) @@ -739,7 +739,7 @@ if(!limb) return -/mob/living/carbon/setOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) +/mob/living/carbon/setOxyLoss(amount, updating_health = TRUE, forced, required_biotype, required_respiration_type) . = ..() check_passout(.) diff --git a/code/modules/mob/living/damage_procs.dm b/code/modules/mob/living/damage_procs.dm index d3c0f34d25f..2b9bc9d2339 100644 --- a/code/modules/mob/living/damage_procs.dm +++ b/code/modules/mob/living/damage_procs.dm @@ -182,23 +182,27 @@ /mob/living/proc/getOxyLoss() return oxyloss -/mob/living/proc/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype = MOB_ORGANIC) +/mob/living/proc/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype, required_respiration_type = ALL) SEND_SIGNAL(src, COMSIG_MOB_LOSS_OXY, amount) //SKYRAT EDIT ADDITION if(!forced && (status_flags & GODMODE)) return - if(!forced && !(mob_biotypes & required_biotype)) - return + if(iscarbon(src)) + var/obj/item/organ/internal/lungs/affected_lungs = getorganslot(ORGAN_SLOT_LUNGS) + if(!forced && !(affected_lungs?.respiration_type & required_respiration_type)) + return . = oxyloss oxyloss = clamp((oxyloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) if(updating_health) updatehealth() -/mob/living/proc/setOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) +/mob/living/proc/setOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype, required_respiration_type = ALL) if(!forced && (status_flags & GODMODE)) return - if(required_biotype && !(mob_biotypes & required_biotype)) - return + if(iscarbon(src)) + var/obj/item/organ/internal/lungs/affected_lungs = getorganslot(ORGAN_SLOT_LUNGS) + if(!forced && !(affected_lungs?.respiration_type & required_respiration_type)) + return . = oxyloss oxyloss = amount if(updating_health) @@ -212,7 +216,7 @@ SEND_SIGNAL(src, COMSIG_MOB_LOSS_TOX, amount) //SKYRAT EDIT ADDITION if(!forced && (status_flags & GODMODE)) return FALSE - if(required_biotype && !(mob_biotypes & required_biotype)) + if(!forced && !(mob_biotypes & required_biotype)) return toxloss = clamp((toxloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) if(updating_health) @@ -222,7 +226,7 @@ /mob/living/proc/setToxLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) if(!forced && (status_flags & GODMODE)) return FALSE - if(required_biotype && !(mob_biotypes & required_biotype)) + if(!forced && !(mob_biotypes & required_biotype)) return toxloss = amount if(updating_health) diff --git a/code/modules/mob/living/silicon/damage_procs.dm b/code/modules/mob/living/silicon/damage_procs.dm index 3d98b858b69..828e16fb60b 100644 --- a/code/modules/mob/living/silicon/damage_procs.dm +++ b/code/modules/mob/living/silicon/damage_procs.dm @@ -39,7 +39,7 @@ /mob/living/silicon/setOrganLoss(slot, amount) return FALSE -/mob/living/silicon/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) //immune to oxygen damage +/mob/living/silicon/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype, required_respiration_type) //immune to oxygen damage if(isAI(src)) //ais are snowflakes and use oxyloss for being in AI cards and having no battery return ..() diff --git a/code/modules/mob/living/simple_animal/damage_procs.dm b/code/modules/mob/living/simple_animal/damage_procs.dm index cea569247d0..6345320d9d9 100644 --- a/code/modules/mob/living/simple_animal/damage_procs.dm +++ b/code/modules/mob/living/simple_animal/damage_procs.dm @@ -30,7 +30,7 @@ else if(damage_coeff[BURN]) . = adjustHealth(amount * damage_coeff[BURN] * CONFIG_GET(number/damage_multiplier), updating_health, forced) -/mob/living/simple_animal/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) +/mob/living/simple_animal/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype, required_respiration_type) if(forced) . = adjustHealth(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) else if(damage_coeff[OXY]) diff --git a/code/modules/reagents/chemistry/reagents.dm b/code/modules/reagents/chemistry/reagents.dm index a7736c3defa..fce9a881357 100644 --- a/code/modules/reagents/chemistry/reagents.dm +++ b/code/modules/reagents/chemistry/reagents.dm @@ -85,9 +85,12 @@ GLOBAL_LIST_INIT(name2reagent, build_name2reagent()) /// The affected bodytype, if the reagent damages/heals bodyparts (Brute/Fire) of an affected mob. /// See "Bodytype defines" in /code/_DEFINES/mobs.dm var/affected_bodytype = BODYTYPE_ORGANIC - /// The affected biotype, if the reagent damages/heals generic damage (Toxin/Oxygen) of an affected mob. + /// The affected biotype, if the reagent damages/heals toxin damage of an affected mob. /// See "Mob bio-types flags" in /code/_DEFINES/mobs.dm var/affected_biotype = MOB_ORGANIC + /// The affected respiration type, if the reagent damages/heals oxygen damage of an affected mob. + /// See "Mob bio-types flags" in /code/_DEFINES/mobs.dm + var/affected_respiration_type = RESPIRATION_OXYGEN /// The affected organtype, if the reagent damages/heals organ damage of an affected mob. /// See "Organ defines for carbon mobs" in /code/_DEFINES/mobs.dm var/affected_organtype = ORGAN_ORGANIC diff --git a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm index 9753f09f22d..c01f42cab05 100644 --- a/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/alcohol_reagents.dm @@ -730,7 +730,7 @@ cubano.adjustBruteLoss(-1 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) cubano.adjustFireLoss(-1 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) cubano.adjustToxLoss(-1 * REM * delta_time, FALSE, required_biotype = affected_biotype) - cubano.adjustOxyLoss(-5 * REM * delta_time, FALSE, required_biotype = affected_biotype) + cubano.adjustOxyLoss(-5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) . = TRUE return ..() || . @@ -1893,7 +1893,7 @@ drinker.adjustBruteLoss(-3 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) drinker.adjustFireLoss(-3 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) drinker.adjustCloneLoss(-5 * REM * delta_time, 0) - drinker.adjustOxyLoss(-4 * REM * delta_time, FALSE, required_biotype = affected_biotype) + drinker.adjustOxyLoss(-4 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) drinker.adjustToxLoss(-3 * REM * delta_time, FALSE, required_biotype = affected_biotype) . = TRUE return ..() || . @@ -2290,7 +2290,7 @@ drinker.adjustBruteLoss(-1, required_bodytype = affected_bodytype) drinker.adjustFireLoss(-1, required_bodytype = affected_bodytype) drinker.adjustToxLoss(-1, required_biotype = affected_biotype) - drinker.adjustOxyLoss(-1, required_biotype = affected_biotype) + drinker.adjustOxyLoss(-1, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) drinker.adjustStaminaLoss(-1, required_biotype = affected_biotype) drinker.visible_message(span_warning("[drinker] shivers with renewed vigor!"), span_notice("One taste of [lowertext(name)] fills you with energy!")) if(!drinker.stat && heal_points == 20) //brought us out of softcrit @@ -2301,7 +2301,7 @@ drinker.adjustBruteLoss(-1 * REM * delta_time, required_bodytype = affected_bodytype) drinker.adjustFireLoss(-1 * REM * delta_time, required_bodytype = affected_bodytype) drinker.adjustToxLoss(-0.5 * REM * delta_time, required_biotype = affected_biotype) - drinker.adjustOxyLoss(-3 * REM * delta_time, required_biotype = affected_biotype) + drinker.adjustOxyLoss(-3 * REM * delta_time, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) drinker.adjustStaminaLoss(-5 * REM * delta_time, required_biotype = affected_biotype) . = TRUE ..() @@ -2851,7 +2851,7 @@ //A healing drink similar to Quadruple Sec, Ling Stings, and Screwdrivers for the Wizznerds; the check is consistent with the changeling sting if(drinker?.mind?.has_antag_datum(/datum/antagonist/wizard)) drinker.heal_bodypart_damage(1 * REM * delta_time, 1 * REM * delta_time) - drinker.adjustOxyLoss(-1 * REM * delta_time, FALSE, required_biotype = affected_biotype) + drinker.adjustOxyLoss(-1 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) drinker.adjustToxLoss(-1 * REM * delta_time, FALSE, required_biotype = affected_biotype) drinker.adjustStaminaLoss(-1 * REM * delta_time, required_biotype = affected_biotype) return ..() diff --git a/code/modules/reagents/chemistry/reagents/atmos_gas_reagents.dm b/code/modules/reagents/chemistry/reagents/atmos_gas_reagents.dm index 2bc0e2ed638..89ed2f86fe3 100644 --- a/code/modules/reagents/chemistry/reagents/atmos_gas_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/atmos_gas_reagents.dm @@ -144,10 +144,12 @@ color = "90560B" taste_description = "bitter" chemical_flags = REAGENT_NO_RANDOM_RECIPE + affected_biotype = MOB_ORGANIC | MOB_MINERAL | MOB_PLANT // "toxic to all living beings" + affected_respiration_type = ALL /datum/reagent/zauker/on_mob_life(mob/living/breather, delta_time, times_fired) breather.adjustBruteLoss(6 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) - breather.adjustOxyLoss(1 * REM * delta_time, FALSE, required_biotype = affected_biotype) + breather.adjustOxyLoss(1 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) breather.adjustFireLoss(2 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) breather.adjustToxLoss(2 * REM * delta_time, FALSE, required_biotype = affected_biotype) return ..() diff --git a/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm index 3e5cf4382f4..bc73b9526eb 100644 --- a/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm @@ -34,10 +34,10 @@ switch(affected_mob.stat) if(CONSCIOUS) //bad thou_shall_heal = death_is_coming/50 - affected_mob.adjustOxyLoss(2 * REM * delta_time, TRUE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(2 * REM * delta_time, TRUE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) if(SOFT_CRIT) //meh convert thou_shall_heal = round(death_is_coming/47,0.1) - affected_mob.adjustOxyLoss(1 * REM * delta_time, TRUE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(1 * REM * delta_time, TRUE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) else //no convert thou_shall_heal = round(death_is_coming/45, 0.1) good_kind_of_healing = TRUE @@ -246,7 +246,7 @@ var/oxycalc = 2.5 * REM * current_cycle if(!overdosed) oxycalc = min(oxycalc, affected_mob.getOxyLoss() + 0.5) //if NOT overdosing, we lower our toxdamage to only the damage we actually healed with a minimum of 0.1*current_cycle. IE if we only heal 10 oxygen damage but we COULD have healed 20, we will only take toxdamage for the 10. We would take the toxdamage for the extra 10 if we were overdosing. - affected_mob.adjustOxyLoss(-oxycalc * delta_time * normalise_creation_purity(), FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-oxycalc * delta_time * normalise_creation_purity(), FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustToxLoss(oxycalc * delta_time / CONVERMOL_RATIO, FALSE, required_biotype = affected_biotype) if(DT_PROB(current_cycle / 2, delta_time) && affected_mob.losebreath) affected_mob.losebreath-- @@ -273,7 +273,7 @@ COOLDOWN_DECLARE(drowsycd) /datum/reagent/medicine/c2/tirimol/on_mob_life(mob/living/carbon/human/affected_mob, delta_time, times_fired) - affected_mob.adjustOxyLoss(-3 * REM * delta_time * normalise_creation_purity(), required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-3 * REM * delta_time * normalise_creation_purity(), required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustStaminaLoss(2 * REM * delta_time, required_biotype = affected_biotype) if(drowsycd && COOLDOWN_FINISHED(src, drowsycd)) affected_mob.adjust_drowsiness(20 SECONDS) @@ -528,7 +528,7 @@ H.adjustToxLoss(-2 * REM * delta_time, FALSE, required_biotype = affected_biotype) H.adjustBruteLoss(-2 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) H.adjustFireLoss(-2 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) - H.adjustOxyLoss(-6 * REM * delta_time, FALSE, required_biotype = affected_biotype) + H.adjustOxyLoss(-6 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) H.losebreath = 0 diff --git a/code/modules/reagents/chemistry/reagents/drink_reagents.dm b/code/modules/reagents/chemistry/reagents/drink_reagents.dm index c3ec0d345ae..294484fe3c1 100644 --- a/code/modules/reagents/chemistry/reagents/drink_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drink_reagents.dm @@ -28,7 +28,7 @@ /datum/reagent/consumable/orangejuice/on_mob_life(mob/living/carbon/affected_mob, delta_time, times_fired) if(affected_mob.getOxyLoss() && DT_PROB(16, delta_time)) - affected_mob.adjustOxyLoss(-1, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-1, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) . = TRUE ..() @@ -966,7 +966,7 @@ affected_mob.adjustBruteLoss(-0.5 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-0.5 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustToxLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) - affected_mob.adjustOxyLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) if(affected_mob.nutrition && (affected_mob.nutrition - 2 > 0)) var/obj/item/organ/internal/liver/liver = affected_mob.getorganslot(ORGAN_SLOT_LIVER) if(!(HAS_TRAIT(liver, TRAIT_MEDICAL_METABOLISM))) @@ -1491,7 +1491,7 @@ /datum/reagent/consumable/mushroom_tea/on_mob_life(mob/living/carbon/affected_mob, delta_time, times_fired) if(islizard(affected_mob)) - affected_mob.adjustOxyLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) ..() . = TRUE diff --git a/code/modules/reagents/chemistry/reagents/drug_reagents.dm b/code/modules/reagents/chemistry/reagents/drug_reagents.dm index b12db0a43e9..72a314feb75 100644 --- a/code/modules/reagents/chemistry/reagents/drug_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drug_reagents.dm @@ -97,7 +97,7 @@ /datum/reagent/drug/nicotine/overdose_process(mob/living/affected_mob, delta_time, times_fired) affected_mob.adjustToxLoss(0.1 * REM * delta_time, FALSE, required_biotype = affected_biotype) - affected_mob.adjustOxyLoss(1.1 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(1.1 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) ..() . = TRUE @@ -271,7 +271,7 @@ affected_mob.adjustToxLoss(0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) if(DT_PROB(30, delta_time)) affected_mob.losebreath++ - affected_mob.adjustOxyLoss(1, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(1, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) ..() . = TRUE diff --git a/code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm index 71ae5e291e6..27fdda61307 100644 --- a/code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/impure_reagents/impure_medicine_reagents.dm @@ -31,6 +31,8 @@ metabolization_rate = 1 * REM//This is fast addiction_types = list(/datum/addiction/medicine = 7.5) ph = 11 + affected_biotype = MOB_ORGANIC | MOB_MINERAL | MOB_PLANT // no healing ghosts + affected_respiration_type = ALL //Random healing of the 4 main groups /datum/reagent/impurity/healing/medicine_failure/on_mob_life(mob/living/carbon/owner, delta_time, times_fired) @@ -43,7 +45,7 @@ if("tox") owner.adjustToxLoss(-0.5, required_biotype = affected_biotype) if("oxy") - owner.adjustOxyLoss(-0.5, required_biotype = affected_biotype) + owner.adjustOxyLoss(-0.5, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) ..() // C2 medications diff --git a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm index f9230942c48..8b17ef3cf37 100644 --- a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm @@ -136,7 +136,7 @@ ..() return var/power = -0.00003 * (affected_mob.bodytemperature ** 2) + 3 - affected_mob.adjustOxyLoss(-3 * power * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-3 * power * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustBruteLoss(-power * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-power * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustToxLoss(-power * REM * delta_time, FALSE, TRUE, affected_biotype) //heals TOXINLOVERs @@ -193,7 +193,7 @@ if(affected_mob.on_fire) power *= 2 - affected_mob.adjustOxyLoss(-2 * power * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-2 * power * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustBruteLoss(-power * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-1.5 * power * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustToxLoss(-power * REM * delta_time, FALSE, TRUE, affected_biotype) @@ -378,7 +378,7 @@ /datum/reagent/medicine/omnizine/on_mob_life(mob/living/carbon/affected_mob, delta_time, times_fired) affected_mob.adjustToxLoss(-healing * REM * delta_time, FALSE, required_biotype = affected_biotype) - affected_mob.adjustOxyLoss(-healing * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-healing * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustBruteLoss(-healing * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-healing * REM * delta_time, FALSE, required_bodytype = affected_bodytype) ..() @@ -386,7 +386,7 @@ /datum/reagent/medicine/omnizine/overdose_process(mob/living/affected_mob, delta_time, times_fired) affected_mob.adjustToxLoss(1.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) - affected_mob.adjustOxyLoss(1.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(1.5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustBruteLoss(1.5 * REM * delta_time, FALSE, FALSE, BODYTYPE_ORGANIC) affected_mob.adjustFireLoss(1.5 * REM * delta_time, FALSE, FALSE, BODYTYPE_ORGANIC) ..() @@ -499,9 +499,11 @@ chemical_flags = REAGENT_CAN_BE_SYNTHESIZED /datum/reagent/medicine/salbutamol/on_mob_life(mob/living/carbon/affected_mob, delta_time, times_fired) - affected_mob.adjustOxyLoss(-3 * REM * delta_time, FALSE, required_biotype = affected_biotype) - if(affected_mob.losebreath >= 4) - affected_mob.losebreath -= 2 * REM * delta_time + affected_mob.adjustOxyLoss(-3 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) + var/obj/item/organ/internal/lungs/affected_lungs = affected_mob.getorganslot(ORGAN_SLOT_LUNGS) + if(affected_lungs?.respiration_type & affected_respiration_type) + if(affected_mob.losebreath >= 4) + affected_mob.losebreath -= 2 * REM * delta_time ..() . = TRUE @@ -756,9 +758,11 @@ affected_mob.adjustToxLoss(-2 * REM * delta_time, FALSE, required_biotype = affected_biotype) affected_mob.adjustBruteLoss(-2* REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-2 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) - affected_mob.adjustOxyLoss(-5 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) . = TRUE - affected_mob.losebreath = 0 + var/obj/item/organ/internal/lungs/affected_lungs = affected_mob.getorganslot(ORGAN_SLOT_LUNGS) + if(affected_lungs?.respiration_type & affected_respiration_type) + affected_mob.losebreath = 0 if(DT_PROB(10, delta_time)) affected_mob.set_dizzy_if_lower(10 SECONDS) affected_mob.set_jitter_if_lower(10 SECONDS) @@ -802,11 +806,13 @@ affected_mob.adjustToxLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) affected_mob.adjustBruteLoss(-0.5 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-0.5 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) - affected_mob.adjustOxyLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) - if(affected_mob.losebreath >= 4) - affected_mob.losebreath -= 2 * REM * delta_time - if(affected_mob.losebreath < 0) - affected_mob.losebreath = 0 + affected_mob.adjustOxyLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) + var/obj/item/organ/internal/lungs/affected_lungs = affected_mob.getorganslot(ORGAN_SLOT_LUNGS) + if(affected_lungs?.respiration_type & affected_respiration_type) + if(affected_mob.losebreath >= 4) + affected_mob.losebreath -= 2 * REM * delta_time + if(affected_mob.losebreath < 0) + affected_mob.losebreath = 0 affected_mob.adjustStaminaLoss(-0.5 * REM * delta_time, 0) if(DT_PROB(10, delta_time)) affected_mob.AdjustAllImmobility(-20) @@ -816,7 +822,9 @@ if(DT_PROB(18, REM * delta_time)) affected_mob.adjustStaminaLoss(2.5, 0) affected_mob.adjustToxLoss(1, FALSE, required_biotype = affected_biotype) - affected_mob.losebreath++ + var/obj/item/organ/internal/lungs/affected_lungs = affected_mob.getorganslot(ORGAN_SLOT_LUNGS) + if(affected_lungs?.respiration_type & affected_respiration_type) + affected_mob.losebreath++ . = TRUE ..() @@ -1074,7 +1082,7 @@ /datum/reagent/medicine/stimulants/on_mob_life(mob/living/carbon/affected_mob, delta_time, times_fired) if(affected_mob.health < 50 && affected_mob.health > 0) - affected_mob.adjustOxyLoss(-1 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-1 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustToxLoss(-1 * REM * delta_time, FALSE, required_biotype = affected_biotype) affected_mob.adjustBruteLoss(-1 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-1 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) @@ -1128,6 +1136,8 @@ color = "#CC23FF" taste_description = "jelly" chemical_flags = REAGENT_CAN_BE_SYNTHESIZED + affected_biotype = MOB_ORGANIC | MOB_MINERAL | MOB_PLANT // no healing ghosts + affected_respiration_type = ALL /datum/reagent/medicine/regen_jelly/expose_mob(mob/living/exposed_mob, reac_volume) . = ..() @@ -1145,7 +1155,7 @@ /datum/reagent/medicine/regen_jelly/on_mob_life(mob/living/carbon/affected_mob, delta_time, times_fired) affected_mob.adjustBruteLoss(-1.5 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-1.5 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) - affected_mob.adjustOxyLoss(-1.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-1.5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustToxLoss(-1.5 * REM * delta_time, FALSE, TRUE, affected_biotype) //heals TOXINLOVERs ..() . = TRUE @@ -1190,7 +1200,7 @@ if(current_cycle <= 25) //10u has to be processed before u get into THE FUN ZONE affected_mob.adjustBruteLoss(-1 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) affected_mob.adjustFireLoss(-1 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) - affected_mob.adjustOxyLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustToxLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) affected_mob.adjustCloneLoss(-0.1 * REM * delta_time, FALSE, required_biotype = affected_biotype) affected_mob.adjustStaminaLoss(-0.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) @@ -1198,7 +1208,7 @@ else affected_mob.adjustBruteLoss(-5 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) //slow to start, but very quick healing once it gets going affected_mob.adjustFireLoss(-5 * REM * delta_time, FALSE, required_bodytype = affected_bodytype) - affected_mob.adjustOxyLoss(-3 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(-3 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustToxLoss(-3 * REM * delta_time, FALSE, required_biotype = affected_biotype) affected_mob.adjustCloneLoss(-1 * REM * delta_time, FALSE, required_biotype = affected_biotype) affected_mob.adjustStaminaLoss(-3 * REM * delta_time, FALSE, required_biotype = affected_biotype) @@ -1414,7 +1424,7 @@ if(DT_PROB(30, delta_time)) affected_mob.losebreath++ if(41 to 80) - affected_mob.adjustOxyLoss(0.1 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(0.1 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustStaminaLoss(0.1 * REM * delta_time, FALSE, required_biotype = affected_biotype) affected_mob.adjust_jitter_up_to(2 SECONDS * REM * delta_time, 40 SECONDS) affected_mob.adjust_stutter_up_to(2 SECONDS * REM * delta_time, 40 SECONDS) @@ -1427,12 +1437,12 @@ affected_mob.Paralyze(20) // you should be in a bad spot at this point unless epipen has been used if(81) to_chat(affected_mob, span_userdanger("You feel too exhausted to continue!")) // at this point you will eventually die unless you get charcoal - affected_mob.adjustOxyLoss(0.1 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(0.1 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustStaminaLoss(0.1 * REM * delta_time, FALSE, required_biotype = affected_biotype) if(82 to INFINITY) REMOVE_TRAIT(affected_mob, TRAIT_SLEEPIMMUNE, type) affected_mob.Sleeping(100 * REM * delta_time) - affected_mob.adjustOxyLoss(1.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(1.5 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustStaminaLoss(1.5 * REM * delta_time, FALSE, required_biotype = affected_biotype) ..() return TRUE @@ -1618,12 +1628,12 @@ if(DT_PROB(7.5, delta_time)) affected_mob.losebreath += rand(2, 4) - affected_mob.adjustOxyLoss(rand(1, 3), required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(rand(1, 3), required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) if(prob(30)) to_chat(affected_mob, span_danger("You can feel your blood clotting up in your veins!")) else if(prob(10)) to_chat(affected_mob, span_userdanger("You feel like your blood has stopped moving!")) - affected_mob.adjustOxyLoss(rand(3, 4), required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(rand(3, 4), required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) if(prob(50)) var/obj/item/organ/internal/lungs/our_lungs = affected_mob.getorganslot(ORGAN_SLOT_LUNGS) diff --git a/code/modules/reagents/chemistry/reagents/toxin_reagents.dm b/code/modules/reagents/chemistry/reagents/toxin_reagents.dm index 04f0b3bbb73..10253811caf 100644 --- a/code/modules/reagents/chemistry/reagents/toxin_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/toxin_reagents.dm @@ -188,7 +188,7 @@ . = FALSE if(.) - affected_mob.adjustOxyLoss(5 * REM * normalise_creation_purity() * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(5 * REM * normalise_creation_purity() * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.losebreath += 2 * REM * normalise_creation_purity() * delta_time if(DT_PROB(10, delta_time)) affected_mob.emote("gasp") @@ -250,7 +250,7 @@ /datum/reagent/toxin/zombiepowder/on_mob_metabolize(mob/living/holder_mob) . = ..() - holder_mob.adjustOxyLoss(0.5*REM, FALSE, required_biotype = affected_biotype) + holder_mob.adjustOxyLoss(0.5*REM, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) if(data?["method"] & INGEST) holder_mob.fakedeath(type) @@ -303,7 +303,7 @@ ..() /datum/reagent/toxin/ghoulpowder/on_mob_life(mob/living/carbon/affected_mob, delta_time, times_fired) - affected_mob.adjustOxyLoss(1 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(1 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) ..() . = TRUE @@ -626,7 +626,7 @@ ..() /datum/reagent/toxin/histamine/overdose_process(mob/living/affected_mob, delta_time, times_fired) - affected_mob.adjustOxyLoss(2 * REM * delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(2 * REM * delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) affected_mob.adjustBruteLoss(2 * REM * delta_time, FALSE, FALSE, BODYTYPE_ORGANIC) affected_mob.adjustToxLoss(2 * REM * delta_time, FALSE, required_biotype = affected_biotype) ..() @@ -792,7 +792,7 @@ . = TRUE if(2) affected_mob.losebreath += 10 - affected_mob.adjustOxyLoss(rand(5,25), FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(rand(5,25), FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) . = TRUE if(3) if(!affected_mob.undergoing_cardiac_arrest() && affected_mob.can_heartattack()) @@ -801,7 +801,7 @@ affected_mob.visible_message(span_userdanger("[affected_mob] clutches at [affected_mob.p_their()] chest as if [affected_mob.p_their()] heart stopped!")) else affected_mob.losebreath += 10 - affected_mob.adjustOxyLoss(rand(5,25), FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(rand(5,25), FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) . = TRUE return ..() || . @@ -961,7 +961,7 @@ /datum/reagent/toxin/curare/on_mob_life(mob/living/carbon/affected_mob, delta_time, times_fired) if(current_cycle >= 11) affected_mob.Paralyze(60 * REM * delta_time) - affected_mob.adjustOxyLoss(0.5*REM*delta_time, FALSE, required_biotype = affected_biotype) + affected_mob.adjustOxyLoss(0.5*REM*delta_time, FALSE, required_biotype = affected_biotype, required_respiration_type = affected_respiration_type) . = TRUE ..() diff --git a/code/modules/surgery/organs/lungs.dm b/code/modules/surgery/organs/lungs.dm index 5015f3abd04..d4416fe1ba2 100644 --- a/code/modules/surgery/organs/lungs.dm +++ b/code/modules/surgery/organs/lungs.dm @@ -6,6 +6,8 @@ slot = ORGAN_SLOT_LUNGS gender = PLURAL w_class = WEIGHT_CLASS_SMALL + + var/respiration_type = NONE // The type(s) of gas this lung needs for respiration healing_factor = STANDARD_ORGAN_HEALING decay_factor = STANDARD_ORGAN_DECAY * 0.9 // fails around 16.5 minutes, lungs are one of the last organs to die (of the ones we have) @@ -87,6 +89,19 @@ var/crit_stabilizing_reagent = /datum/reagent/medicine/epinephrine +// assign the respiration_type +/obj/item/organ/internal/lungs/Initialize(mapload) + . = ..() + + if(safe_co2_min) + respiration_type |= RESPIRATION_CO2 + if(safe_nitro_min) + respiration_type |= RESPIRATION_N2 + if(safe_oxygen_min) + respiration_type |= RESPIRATION_OXYGEN + if(safe_plasma_min) + respiration_type |= RESPIRATION_PLASMA + ///Simply exists so that you don't keep any alerts from your previous lack of lungs. /obj/item/organ/internal/lungs/Insert(mob/living/carbon/receiver, special = FALSE, drop_if_replaced = TRUE) receiver.clear_alert(ALERT_NOT_ENOUGH_OXYGEN) @@ -238,6 +253,9 @@ if(o2_pp) gas_breathed = handle_suffocation(breather, o2_pp, safe_oxygen_min, breath_gases[/datum/gas/oxygen][MOLES]) breathe_gas_volume(breath_gases, /datum/gas/oxygen, /datum/gas/carbon_dioxide, volume = gas_breathed) + else + // No amount of O2, just suffocate + gas_breathed = handle_suffocation(breather, o2_pp, safe_oxygen_min, breath_gases[/datum/gas/oxygen][MOLES]) else // Enough oxygen to breathe. breather.failed_last_breath = FALSE @@ -271,6 +289,9 @@ if(n2_pp) gas_breathed = handle_suffocation(breather, n2_pp, safe_nitro_min, breath_gases[/datum/gas/nitrogen][MOLES]) breathe_gas_volume(breath_gases, /datum/gas/nitrogen, /datum/gas/carbon_dioxide, volume = gas_breathed) + else + // no amount of N2, just suffocate + gas_breathed = handle_suffocation(breather, n2_pp, safe_nitro_min, breath_gases[/datum/gas/nitrogen][MOLES]) else // Enough nitrogen to breathe. breather.failed_last_breath = FALSE @@ -316,6 +337,9 @@ if(co2_pp) gas_breathed = handle_suffocation(breather, co2_pp, safe_co2_min, breath_gases[/datum/gas/carbon_dioxide][MOLES]) breathe_gas_volume(breath_gases, /datum/gas/carbon_dioxide, /datum/gas/oxygen, volume = gas_breathed) + else + // No amount of CO2, just suffocate + gas_breathed = handle_suffocation(breather, co2_pp, safe_co2_min, breath_gases[/datum/gas/carbon_dioxide][MOLES]) else // Enough CO2 to breathe. breather.failed_last_breath = FALSE @@ -349,6 +373,9 @@ if(plasma_pp) gas_breathed = handle_suffocation(breather, plasma_pp, safe_plasma_min, breath_gases[/datum/gas/plasma][MOLES]) breathe_gas_volume(breath_gases, /datum/gas/plasma, /datum/gas/carbon_dioxide, volume = gas_breathed) + else + // No amount of plasma, just suffocate + gas_breathed = handle_suffocation(breather, plasma_pp, safe_plasma_min, breath_gases[/datum/gas/plasma][MOLES]) else // Enough Plasma to breathe. breather.failed_last_breath = FALSE diff --git a/modular_skyrat/modules/customization/modules/mob/living/carbon/damage_procs.dm b/modular_skyrat/modules/customization/modules/mob/living/carbon/damage_procs.dm index 3704ca63ef1..e2204e8a463 100644 --- a/modular_skyrat/modules/customization/modules/mob/living/carbon/damage_procs.dm +++ b/modular_skyrat/modules/customization/modules/mob/living/carbon/damage_procs.dm @@ -1,4 +1,4 @@ -/mob/living/carbon/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) +/mob/living/carbon/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype, required_respiration_type) if(HAS_TRAIT(src, TRAIT_OXYIMMUNE)) //Prevents oxygen damage amount = min(amount, 0) return ..()