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.
This commit is contained in:
mwerezak
2014-05-27 02:20:15 -04:00
parent bf3e3db0d7
commit 2160aae1ab

View File

@@ -24,6 +24,7 @@
/mob/living/carbon/human /mob/living/carbon/human
var/oxygen_alert = 0 var/oxygen_alert = 0
var/phoron_alert = 0 var/phoron_alert = 0
var/co2_alert = 0
var/fire_alert = 0 var/fire_alert = 0
var/pressure_alert = 0 var/pressure_alert = 0
var/prev_gender = null // Debug for plural genders var/prev_gender = null // Debug for plural genders
@@ -450,6 +451,9 @@
var/exhaling var/exhaling
var/poison var/poison
var/no_exhale var/no_exhale
var/failed_inhale = 0
var/failed_exhale = 0
switch(species.breath_type) switch(species.breath_type)
if("nitrogen") if("nitrogen")
@@ -487,6 +491,7 @@
var/toxins_pp = (poison/breath.total_moles())*breath_pressure var/toxins_pp = (poison/breath.total_moles())*breath_pressure
var/exhaled_pp = (exhaling/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(inhale_pp < safe_pressure_min)
if(prob(20)) if(prob(20))
spawn(0) emote("gasp") spawn(0) emote("gasp")
@@ -494,21 +499,20 @@
var/ratio = safe_pressure_min/inhale_pp var/ratio = safe_pressure_min/inhale_pp
// Don't fuck them up too fast (space only does HUMAN_MAX_OXYLOSS after all!) // 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)) adjustOxyLoss(min(5*ratio, HUMAN_MAX_OXYLOSS))
failed_last_breath = 1 failed_inhale = 1
inhaled_gas_used = inhaling*ratio/6 inhaled_gas_used = inhaling*ratio/6
else else
adjustOxyLoss(HUMAN_MAX_OXYLOSS) adjustOxyLoss(HUMAN_MAX_OXYLOSS)
failed_last_breath = 1 failed_inhale = 1
oxygen_alert = max(oxygen_alert, 1) oxygen_alert = max(oxygen_alert, 1)
else else
// We're in safe limits // We're in safe limits
failed_last_breath = 0
adjustOxyLoss(-5)
inhaled_gas_used = inhaling/6 inhaled_gas_used = inhaling/6
oxygen_alert = 0 oxygen_alert = 0
@@ -529,32 +533,37 @@
if("C02") if("C02")
breath.carbon_dioxide += inhaled_gas_used 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, // Too much exhaled gas in the air
// this will hurt you, but only once per 4 ticks, instead of once per tick.
if(exhaled_pp > safe_exhaled_max) if(exhaled_pp > safe_exhaled_max)
if (!co2_alert|| prob(15))
// If it's the first breath with too much CO2 in it, lets start a counter, var/word = pick("extremely dizzy","short of breath","faint","confused")
// then have them pass out after 12s or so. src << "\red <b>You feel [word].</b>"
if(!co2overloadtime)
co2overloadtime = world.time adjustOxyLoss(HUMAN_MAX_OXYLOSS)
co2_alert = 1
else if(world.time - co2overloadtime > 120) failed_exhale = 1
// Lets hurt em a little, let them know we mean business else if(exhaled_pp > safe_exhaled_max * 0.7)
Paralyse(3) if (!co2_alert || prob(15))
adjustOxyLoss(3) var/word = pick("dizzy","short of breath","faint","momentarily confused")
src << "\red You feel [word]."
// They've been in here 30s now, lets start to kill them for their own good!
if(world.time - co2overloadtime > 300) //scale linearly from 0 to 1 between safe_exhaled_max and safe_exhaled_max*0.7
adjustOxyLoss(8) var/ratio = 1.0 - (safe_exhaled_max - exhaled_pp)/(safe_exhaled_max*0.3)
// Lets give them some chance to know somethings not right though I guess. //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(prob(20)) if (getOxyLoss() < 50*ratio)
spawn(0) emote("cough") 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 else
co2overloadtime = 0 co2_alert = 0
// Too much poison in the air. // Too much poison in the air.
if(toxins_pp > safe_toxins_max) if(toxins_pp > safe_toxins_max)
@@ -586,8 +595,16 @@
if(prob(20)) if(prob(20))
spawn(0) emote(pick("giggle", "laugh")) spawn(0) emote(pick("giggle", "laugh"))
SA.moles = 0 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) if(status_flags & GODMODE)
return 1 return 1