From e8a7b58affde1dd75e8923802559e18f0e8e454b Mon Sep 17 00:00:00 2001 From: Atlantiscze Date: Wed, 13 Aug 2014 11:24:12 +0200 Subject: [PATCH] N2 buildup fix attempt. Putting this into separate commit in case it's not wanted. - Right now, air consists of 20% O2 80% N2 (approx.). Breathing takes O2 and turns it into CO2. CO2 gets scrubbed. Pressure drops, vents refill with air which again contains 80% N2 20% O2. - This means that only 20% of breathed-out oxygen is replenished. Rest is replaced by N2. In large areas, such as Bar, with many mobs this can eventually lead to dangerous atmosphere status. - This fix, while OOCly slightly unrealistic handles this issue by turning both O2 and N2 into CO2. Tested in CE's office with 5 human mobs without active scrubbers. Air lasts for 2~ hrs. Larger areas of course last significantly longer. --- code/modules/mob/living/carbon/human/life.dm | 34 ++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 4af096131fc..020d87f27a8 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -459,7 +459,6 @@ var/safe_toxins_max = 0.005 var/SA_para_min = 1 var/SA_sleep_min = 5 - var/inhaled_gas_used = 0 var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME @@ -518,7 +517,6 @@ // The hell? By definition ratio > 1, and HUMAN_MAX_OXYLOSS = 1... why do we even have this? adjustOxyLoss(min(5*ratio, HUMAN_MAX_OXYLOSS)) failed_inhale = 1 - inhaled_gas_used = inhaling*ratio/6 else @@ -529,29 +527,39 @@ else // We're in safe limits - inhaled_gas_used = inhaling/6 oxygen_alert = 0 - + var/exhale_amt = 0 switch(species.breath_type) if("nitrogen") - breath.nitrogen -= inhaled_gas_used + exhale_amt = breath.nitrogen + breath.nitrogen = 0 if("phoron") - breath.phoron -= inhaled_gas_used + exhale_amt = breath.phoron + breath.phoron = 0 if("carbon_dioxide") - breath.carbon_dioxide-= inhaled_gas_used + exhale_amt = breath.carbon_dioxide + breath.carbon_dioxide = 0 else - breath.oxygen -= inhaled_gas_used - + exhale_amt = (breath.oxygen + breath.nitrogen) // Haxy fix (see below) + breath.oxygen = 0 + breath.nitrogen = 0 + // Haxy fix - N2 buildup caused by breathing + // If you have room filled with breathing human mobs the oxygen level eventually reaches 0 even with vent. + // Our distro has 80% nitrogen and 20% oxygen (+-). However, humans take only part of this oxygen and convert it to CO2 + // Basically, we change some oxygen into CO2, CO2 gets scrubbed, pressure drops a little, vents refill with N2 O2 mix. + // However, we didn't breath any nitrogen which eventually leads to O2 being mostly replaced with N2. + // This only happens with lots of mobs on one place, but may be actual for, for example, Dormitories. + // This fix causes mobs to turn all inhaled gas into CO2, which while hacky prevents this from happening. if(!no_exhale) switch(species.exhale_type) if("oxygen") - breath.oxygen += inhaled_gas_used + breath.oxygen += exhale_amt if("nitrogen") - breath.nitrogen += inhaled_gas_used + breath.nitrogen += exhale_amt if("phoron") - breath.phoron += inhaled_gas_used + breath.phoron += exhale_amt if("carbon_dioxide") - breath.carbon_dioxide += inhaled_gas_used + breath.carbon_dioxide += exhale_amt // Too much exhaled gas in the air if(exhaled_pp > safe_exhaled_max)