From 2160aae1ab303149b6929ef5df76dbef6bf5a11c Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 27 May 2014 02:20:15 -0400 Subject: [PATCH 1/5] New system for CO2 asphixyation Too much CO2 now makes you slowly gain oxyloss instead of making you fall unconscious immediately and quickly killing you after 30 seconds. --- code/modules/mob/living/carbon/human/life.dm | 77 ++++++++++++-------- 1 file changed, 47 insertions(+), 30 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 036a84b8b1a..52a74a8f267 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -24,6 +24,7 @@ /mob/living/carbon/human var/oxygen_alert = 0 var/phoron_alert = 0 + var/co2_alert = 0 var/fire_alert = 0 var/pressure_alert = 0 var/prev_gender = null // Debug for plural genders @@ -450,6 +451,9 @@ var/exhaling var/poison var/no_exhale + + var/failed_inhale = 0 + var/failed_exhale = 0 switch(species.breath_type) if("nitrogen") @@ -487,6 +491,7 @@ var/toxins_pp = (poison/breath.total_moles())*breath_pressure var/exhaled_pp = (exhaling/breath.total_moles())*breath_pressure + // Not enough to breathe if(inhale_pp < safe_pressure_min) if(prob(20)) spawn(0) emote("gasp") @@ -494,21 +499,20 @@ var/ratio = safe_pressure_min/inhale_pp // Don't fuck them up too fast (space only does HUMAN_MAX_OXYLOSS after all!) + // 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_last_breath = 1 + failed_inhale = 1 inhaled_gas_used = inhaling*ratio/6 else adjustOxyLoss(HUMAN_MAX_OXYLOSS) - failed_last_breath = 1 + failed_inhale = 1 oxygen_alert = max(oxygen_alert, 1) else // We're in safe limits - failed_last_breath = 0 - adjustOxyLoss(-5) inhaled_gas_used = inhaling/6 oxygen_alert = 0 @@ -529,32 +533,37 @@ if("C02") breath.carbon_dioxide += inhaled_gas_used - // CO2 does not affect failed_last_breath. So if there was enough oxygen in the air but too much co2, - // this will hurt you, but only once per 4 ticks, instead of once per tick. - + // Too much exhaled gas in the air if(exhaled_pp > safe_exhaled_max) - - // If it's the first breath with too much CO2 in it, lets start a counter, - // then have them pass out after 12s or so. - if(!co2overloadtime) - co2overloadtime = world.time - - else if(world.time - co2overloadtime > 120) - - // Lets hurt em a little, let them know we mean business - Paralyse(3) - adjustOxyLoss(3) - - // They've been in here 30s now, lets start to kill them for their own good! - if(world.time - co2overloadtime > 300) - adjustOxyLoss(8) - - // Lets give them some chance to know somethings not right though I guess. - if(prob(20)) - spawn(0) emote("cough") - + if (!co2_alert|| prob(15)) + var/word = pick("extremely dizzy","short of breath","faint","confused") + src << "\red You feel [word]." + + adjustOxyLoss(HUMAN_MAX_OXYLOSS) + co2_alert = 1 + failed_exhale = 1 + + else if(exhaled_pp > safe_exhaled_max * 0.7) + if (!co2_alert || prob(15)) + var/word = pick("dizzy","short of breath","faint","momentarily confused") + src << "\red You feel [word]." + + //scale linearly from 0 to 1 between safe_exhaled_max and safe_exhaled_max*0.7 + var/ratio = 1.0 - (safe_exhaled_max - exhaled_pp)/(safe_exhaled_max*0.3) + + //give them some oxyloss, up to the limit - we don't want people falling unconcious until they're pretty close to safe_exhaled_max + if (getOxyLoss() < 50*ratio) + adjustOxyLoss(HUMAN_MAX_OXYLOSS) + co2_alert = 1 + failed_exhale = 1 + + if(exhaled_pp > safe_exhaled_max * 0.6) + if (prob(1)) + var/word = pick("a little dizzy","short of breath") + src << "\red You feel [word]." + else - co2overloadtime = 0 + co2_alert = 0 // Too much poison in the air. if(toxins_pp > safe_toxins_max) @@ -586,8 +595,16 @@ if(prob(20)) spawn(0) emote(pick("giggle", "laugh")) SA.moles = 0 - - if( (abs(310.15 - breath.temperature) > 50) && !(COLD_RESISTANCE in mutations)) // Hot air hurts :( + + // Were we able to breathe? + if (failed_inhale || failed_exhale) + failed_last_breath = 1 + else + failed_last_breath = 0 + adjustOxyLoss(-5) + + // Hot air hurts :( + if( (abs(310.15 - breath.temperature) > 50) && !(COLD_RESISTANCE in mutations)) if(status_flags & GODMODE) return 1 From 32f6d89bea5b80eacafb68b801a3e06318780048 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Tue, 27 May 2014 03:00:31 -0400 Subject: [PATCH 2/5] Completed unfinished species.breath_type switch --- code/modules/mob/living/carbon/human/life.dm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 52a74a8f267..4775d4e9c09 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -519,6 +519,10 @@ switch(species.breath_type) if("nitrogen") breath.nitrogen -= inhaled_gas_used + if("phoron") + breath.phoron -= inhaled_gas_used + if("C02") + breath.carbon_dioxide-= inhaled_gas_used else breath.oxygen -= inhaled_gas_used @@ -551,7 +555,7 @@ //scale linearly from 0 to 1 between safe_exhaled_max and safe_exhaled_max*0.7 var/ratio = 1.0 - (safe_exhaled_max - exhaled_pp)/(safe_exhaled_max*0.3) - //give them some oxyloss, up to the limit - we don't want people falling unconcious until they're pretty close to safe_exhaled_max + //give them some oxyloss, up to the limit - we don't want people falling unconcious due to CO2 alone until they're pretty close to safe_exhaled_max. if (getOxyLoss() < 50*ratio) adjustOxyLoss(HUMAN_MAX_OXYLOSS) co2_alert = 1 From d677a91c3c5fadc7d1e4c73b370f73d0a465b029 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Wed, 28 May 2014 10:59:02 -0400 Subject: [PATCH 3/5] Adjusts co2 warning frequencies --- code/modules/mob/living/carbon/human/life.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 4775d4e9c09..07c875c90c7 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -548,7 +548,7 @@ failed_exhale = 1 else if(exhaled_pp > safe_exhaled_max * 0.7) - if (!co2_alert || prob(15)) + if (!co2_alert || prob(1)) var/word = pick("dizzy","short of breath","faint","momentarily confused") src << "\red You feel [word]." @@ -562,7 +562,7 @@ failed_exhale = 1 if(exhaled_pp > safe_exhaled_max * 0.6) - if (prob(1)) + if (prob(0.3)) var/word = pick("a little dizzy","short of breath") src << "\red You feel [word]." From 9747276eb1f6245a3f27cf7ec71b21c60413233e Mon Sep 17 00:00:00 2001 From: mwerezak Date: Wed, 28 May 2014 11:47:20 -0400 Subject: [PATCH 4/5] Fixes missing 'else' --- code/modules/mob/living/carbon/human/life.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 07c875c90c7..50f81f6138b 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -561,7 +561,7 @@ co2_alert = 1 failed_exhale = 1 - if(exhaled_pp > safe_exhaled_max * 0.6) + else if(exhaled_pp > safe_exhaled_max * 0.6) if (prob(0.3)) var/word = pick("a little dizzy","short of breath") src << "\red You feel [word]." From 06eb4c6edff1a24758fe85adb4c7f51f57b07cf0 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 29 May 2014 20:17:51 -0400 Subject: [PATCH 5/5] C02 -> carbon_dioxide Renamed carbon dioxide breathing type string to hopefully prevent confusion in the future. --- code/modules/mob/living/carbon/human/life.dm | 10 +++++----- code/modules/mob/living/carbon/species.dm | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 50f81f6138b..c3775212820 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -460,7 +460,7 @@ inhaling = breath.nitrogen if("phoron") inhaling = breath.phoron - if("C02") + if("carbon_dioxide") inhaling = breath.carbon_dioxide else inhaling = breath.oxygen @@ -470,13 +470,13 @@ poison = breath.oxygen if("nitrogen") poison = breath.nitrogen - if("C02") + if("carbon_dioxide") poison = breath.carbon_dioxide else poison = breath.phoron switch(species.exhale_type) - if("C02") + if("carbon_dioxide") exhaling = breath.carbon_dioxide if("oxygen") exhaling = breath.oxygen @@ -521,7 +521,7 @@ breath.nitrogen -= inhaled_gas_used if("phoron") breath.phoron -= inhaled_gas_used - if("C02") + if("carbon_dioxide") breath.carbon_dioxide-= inhaled_gas_used else breath.oxygen -= inhaled_gas_used @@ -534,7 +534,7 @@ breath.nitrogen += inhaled_gas_used if("phoron") breath.phoron += inhaled_gas_used - if("C02") + if("CO2") breath.carbon_dioxide += inhaled_gas_used // Too much exhaled gas in the air diff --git a/code/modules/mob/living/carbon/species.dm b/code/modules/mob/living/carbon/species.dm index 096631f2dd1..6014031e4f7 100644 --- a/code/modules/mob/living/carbon/species.dm +++ b/code/modules/mob/living/carbon/species.dm @@ -19,7 +19,7 @@ var/breath_type = "oxygen" // Non-oxygen gas breathed, if any. var/poison_type = "phoron" // Poisonous air. - var/exhale_type = "C02" // Exhaled gas type. + var/exhale_type = "carbon_dioxide" // Exhaled gas type. var/cold_level_1 = 260 // Cold damage level 1 below this point. var/cold_level_2 = 200 // Cold damage level 2 below this point.