/mob/living/carbon/Life() set invisibility = 0 set background = BACKGROUND_ENABLED if (notransform) return if(damageoverlaytemp) damageoverlaytemp = 0 update_damage_hud() if(..()) //not dead handle_blood() if(stat != DEAD) for(var/V in internal_organs) var/obj/item/organ/O = V O.on_life() if(stat == DEAD) stop_sound_channel(CHANNEL_HEARTBEAT) //Updates the number of stored chemicals for powers handle_changeling() if(stat != DEAD) handle_liver() if(stat != DEAD) return 1 /////////////// // BREATHING // /////////////// //Start of a breath chain, calls breathe() /mob/living/carbon/handle_breathing(times_fired) if((times_fired % 4) == 2 || failed_last_breath) breathe() //Breathe per 4 ticks, unless suffocating else if(istype(loc, /obj/)) var/obj/location_as_object = loc location_as_object.handle_internal_lifeform(src,0) //Second link in a breath chain, calls check_breath() /mob/living/carbon/proc/breathe() if(reagents.has_reagent("lexorin")) return if(istype(loc, /obj/machinery/atmospherics/components/unary/cryo_cell)) return if(istype(loc, /obj/item/device/dogborg/sleeper)) return if(ismob(loc)) return var/datum/gas_mixture/environment if(loc) environment = loc.return_air() var/datum/gas_mixture/breath if(health <= HEALTH_THRESHOLD_CRIT || (pulledby && pulledby.grab_state >= GRAB_KILL && !getorganslot("breathing_tube"))) losebreath++ //Suffocate if(losebreath > 0) losebreath-- if(prob(10)) emote("gasp") if(istype(loc, /obj/)) var/obj/loc_as_obj = loc loc_as_obj.handle_internal_lifeform(src,0) else //Breathe from internal breath = get_breath_from_internal(BREATH_VOLUME) if(!breath) if(isobj(loc)) //Breathe from loc as object var/obj/loc_as_obj = loc breath = loc_as_obj.handle_internal_lifeform(src, BREATH_VOLUME) else if(isturf(loc)) //Breathe from loc as turf var/breath_moles = 0 if(environment) breath_moles = environment.total_moles()*BREATH_PERCENTAGE breath = loc.remove_air(breath_moles) else //Breathe from loc as obj again if(istype(loc, /obj/)) var/obj/loc_as_obj = loc loc_as_obj.handle_internal_lifeform(src,0) check_breath(breath) if(breath) loc.assume_air(breath) air_update_turf() /mob/living/carbon/proc/has_smoke_protection() return 0 //Third link in a breath chain, calls handle_breath_temperature() /mob/living/carbon/proc/check_breath(datum/gas_mixture/breath) if((status_flags & GODMODE)) return var/lungs = getorganslot("lungs") if(!lungs) adjustOxyLoss(2) //CRIT if(!breath || (breath.total_moles() == 0) || !lungs) if(reagents.has_reagent("epinephrine") && lungs) return adjustOxyLoss(1) failed_last_breath = 1 throw_alert("not_enough_oxy", /obj/screen/alert/not_enough_oxy) return 0 var/safe_oxy_min = 16 var/safe_co2_max = 10 var/safe_tox_max = 0.05 var/SA_para_min = 1 var/SA_sleep_min = 5 var/oxygen_used = 0 var/breath_pressure = (breath.total_moles()*R_IDEAL_GAS_EQUATION*breath.temperature)/BREATH_VOLUME var/list/breath_gases = breath.gases breath.assert_gases("o2","plasma","co2","n2o", "bz") var/O2_partialpressure = (breath_gases["o2"][MOLES]/breath.total_moles())*breath_pressure var/Toxins_partialpressure = (breath_gases["plasma"][MOLES]/breath.total_moles())*breath_pressure var/CO2_partialpressure = (breath_gases["co2"][MOLES]/breath.total_moles())*breath_pressure //OXYGEN if(O2_partialpressure < safe_oxy_min) //Not enough oxygen if(prob(20)) emote("gasp") if(O2_partialpressure > 0) var/ratio = 1 - O2_partialpressure/safe_oxy_min adjustOxyLoss(min(5*ratio, 3)) failed_last_breath = 1 oxygen_used = breath_gases["o2"][MOLES]*ratio else adjustOxyLoss(3) failed_last_breath = 1 throw_alert("not_enough_oxy", /obj/screen/alert/not_enough_oxy) else //Enough oxygen failed_last_breath = 0 if(oxyloss) adjustOxyLoss(-5) oxygen_used = breath_gases["o2"][MOLES] clear_alert("not_enough_oxy") breath_gases["o2"][MOLES] -= oxygen_used breath_gases["co2"][MOLES] += oxygen_used //CARBON DIOXIDE if(CO2_partialpressure > safe_co2_max) if(!co2overloadtime) co2overloadtime = world.time else if(world.time - co2overloadtime > 120) Unconscious(60) adjustOxyLoss(3) if(world.time - co2overloadtime > 300) adjustOxyLoss(8) if(prob(20)) emote("cough") else co2overloadtime = 0 //TOXINS/PLASMA if(Toxins_partialpressure > safe_tox_max) var/ratio = (breath_gases["plasma"][MOLES]/safe_tox_max) * 10 adjustToxLoss(Clamp(ratio, MIN_TOXIC_GAS_DAMAGE, MAX_TOXIC_GAS_DAMAGE)) throw_alert("too_much_tox", /obj/screen/alert/too_much_tox) else clear_alert("too_much_tox") //NITROUS OXIDE if(breath_gases["n2o"]) var/SA_partialpressure = (breath_gases["n2o"][MOLES]/breath.total_moles())*breath_pressure if(SA_partialpressure > SA_para_min) Unconscious(60) if(SA_partialpressure > SA_sleep_min) Sleeping(max(AmountSleeping() + 40, 200)) else if(SA_partialpressure > 0.01) if(prob(20)) emote(pick("giggle","laugh")) //BZ (Facepunch port of their Agent B) if(breath_gases["bz"]) var/bz_partialpressure = (breath_gases["bz"][MOLES]/breath.total_moles())*breath_pressure if(bz_partialpressure > 1) hallucination += 20 else if(bz_partialpressure > 0.01) hallucination += 5//Removed at 2 per tick so this will slowly build up breath.garbage_collect() //BREATH TEMPERATURE handle_breath_temperature(breath) return 1 //Fourth and final link in a breath chain /mob/living/carbon/proc/handle_breath_temperature(datum/gas_mixture/breath) return /mob/living/carbon/proc/get_breath_from_internal(volume_needed) if(internal) if(internal.loc != src) internal = null update_internals_hud_icon(0) else if ((!wear_mask || !(wear_mask.flags_1 & MASKINTERNALS_1)) && !getorganslot("breathing_tube")) internal = null update_internals_hud_icon(0) else update_internals_hud_icon(1) return internal.remove_air_volume(volume_needed) /mob/living/carbon/proc/handle_blood() return /mob/living/carbon/handle_diseases() for(var/thing in viruses) var/datum/disease/D = thing if(prob(D.infectivity)) D.spread() if(stat != DEAD) D.stage_act() /mob/living/carbon/proc/handle_changeling() if(mind && hud_used && hud_used.lingchemdisplay) if(mind.changeling) mind.changeling.regenerate(src) hud_used.lingchemdisplay.invisibility = 0 hud_used.lingchemdisplay.maptext = "