diff --git a/code/datums/atmosphere/_atmosphere.dm b/code/datums/atmosphere/_atmosphere.dm index 5323b070cd..7fe8e44d75 100644 --- a/code/datums/atmosphere/_atmosphere.dm +++ b/code/datums/atmosphere/_atmosphere.dm @@ -16,6 +16,9 @@ /datum/atmosphere/New() generate_gas_string() +/datum/atmosphere/proc/check_for_sanity(datum/gas_mixture/mix) + return + /datum/atmosphere/proc/generate_gas_string() var/list/spicy_gas = restricted_gases.Copy() var/target_pressure = rand(minimum_pressure, maximum_pressure) @@ -52,6 +55,8 @@ gasmix.adjust_moles(gastype, -moles_to_remove) gasmix.set_moles(gastype, FLOOR(gasmix.get_moles(gastype), 0.1)) + check_for_sanity(gasmix) + // Now finally lets make that string var/list/gas_string_builder = list() for(var/id in gasmix.get_gases()) diff --git a/code/datums/atmosphere/planetary.dm b/code/datums/atmosphere/planetary.dm index 69abba85e5..f1d2e85755 100644 --- a/code/datums/atmosphere/planetary.dm +++ b/code/datums/atmosphere/planetary.dm @@ -23,6 +23,12 @@ minimum_temp = 270 maximum_temp = 320 +/datum/atmosphere/lavaland/check_for_sanity(datum/gas_mixture/mix) + var/datum/breathing_class/o2_class = GLOB.gas_data.breathing_classes[BREATH_OXY] + while(o2_class.get_effective_pp(mix) < 10) + mix.adjust_moles(GAS_CO2, -0.5) + mix.adjust_moles(GAS_O2, 0.5) + /datum/atmosphere/icemoon id = ICEMOON_DEFAULT_ATMOS diff --git a/code/modules/atmospherics/auxgm/breathing_classes.dm b/code/modules/atmospherics/auxgm/breathing_classes.dm index 4abfab58ee..cfc82adbff 100644 --- a/code/modules/atmospherics/auxgm/breathing_classes.dm +++ b/code/modules/atmospherics/auxgm/breathing_classes.dm @@ -14,6 +14,12 @@ var/high_alert_category = "too_much_oxy" var/high_alert_datum = /atom/movable/screen/alert/too_much_oxy +/datum/breathing_class/proc/get_effective_pp(datum/gas_mixture/breath) + var/mol = 0 + for(var/gas in gases) + mol += breath.get_moles(gas) * gases[gas] + return (mol/breath.total_moles()) * breath.return_pressure() + /datum/breathing_class/oxygen gases = list( GAS_O2 = 1, diff --git a/code/modules/surgery/organs/lungs.dm b/code/modules/surgery/organs/lungs.dm index e10b05822b..5c914e3d4d 100644 --- a/code/modules/surgery/organs/lungs.dm +++ b/code/modules/surgery/organs/lungs.dm @@ -528,7 +528,8 @@ BZ_brain_damage_min += bz gas_max[GAS_N2] = PP(breath, GAS_N2) + 5 - var/o2_pp = PP(breath, GAS_O2) + var/datum/breathing_class/class = GLOB.gas_data.breathing_classes[breathing_class] + var/o2_pp = class.get_effective_pp(breath) safe_breath_min = 0.3 * o2_pp safe_breath_max = 1.3 * o2_pp ..()