From daa49ced44a2645238c4f2b510e6ea0189783b9c Mon Sep 17 00:00:00 2001 From: Yoshax Date: Mon, 8 Aug 2016 20:35:14 +0100 Subject: [PATCH] Shamelessly steals HarpyEagle's code --- code/modules/mob/living/carbon/breathe.dm | 5 +++++ code/modules/mob/living/carbon/human/human.dm | 5 ++--- code/modules/mob/living/carbon/human/life.dm | 9 ++++++--- code/modules/organs/internal/lungs.dm | 9 ++++++++- code/modules/organs/organ.dm | 3 +++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/code/modules/mob/living/carbon/breathe.dm b/code/modules/mob/living/carbon/breathe.dm index 7f4dc972c4..6b8a3c43b3 100644 --- a/code/modules/mob/living/carbon/breathe.dm +++ b/code/modules/mob/living/carbon/breathe.dm @@ -24,6 +24,11 @@ breath = get_breath_from_internal() //First, check for air from internals if(!breath) breath = get_breath_from_environment() //No breath from internals so let's try to get air from our location + if(!breath) + var/static/datum/gas_mixture/vacuum //avoid having to create a new gas mixture for each breath in space + if(!vacuum) vacuum = new + + breath = vacuum //still nothing? must be vacuum handle_breath(breath) handle_post_breath(breath) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index df1bfc4667..08b36620b7 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -928,9 +928,8 @@ /mob/living/carbon/human/proc/rupture_lung() var/obj/item/organ/internal/lungs/L = internal_organs_by_name[O_LUNGS] - if(L && !L.is_bruised()) - src.custom_pain("You feel a stabbing pain in your chest!", 1) - L.damage = L.min_bruised_damage + if(L) + L.rupture() /* /mob/living/carbon/human/verb/simulate() diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index a58e1c3a68..1b55436106 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -332,6 +332,12 @@ adjustOxyLoss(-5) return + if(should_have_organ(O_LUNGS)) + var/obj/item/organ/internal/lungs/L = internal_organs_by_name[O_LUNGS] + if(breath.total_moles < BREATH_MOLES / 5 || breath.total_moles > BREATH_MOLES * 5) + if(!L.is_bruised() && prob(5)) + rupture_lung() + if(!breath || (breath.total_moles == 0) || suiciding) failed_last_breath = 1 if(suiciding) @@ -343,9 +349,6 @@ else adjustOxyLoss(HUMAN_CRIT_MAX_OXYLOSS) - if(prob(5)) - rupture_lung() - oxygen_alert = max(oxygen_alert, 1) return 0 diff --git a/code/modules/organs/internal/lungs.dm b/code/modules/organs/internal/lungs.dm index fae4bc5ee6..b8df5d4fde 100644 --- a/code/modules/organs/internal/lungs.dm +++ b/code/modules/organs/internal/lungs.dm @@ -23,4 +23,11 @@ owner.drip(10) if(prob(4)) spawn owner.emote("me", 1, "gasps for air!") - owner.losebreath += 15 \ No newline at end of file + owner.losebreath += 15 + + +/obj/item/organ/internal/lungs/proc/rupture() + var/obj/item/organ/external/parent = owner.get_organ(parent_organ) + if(istype(parent)) + owner.custom_pain("You feel a stabbing pain in your [parent.name]!", 1) + parent.bruise() \ No newline at end of file diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index e1cf0cad9e..fad60cc0d7 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -247,6 +247,9 @@ var/list/organ_cache = list() if(parent && !silent) owner.custom_pain("Something inside your [parent.name] hurts a lot.", 1) +/obj/item/organ/proc/bruise() + damage = max(damage, min_bruised_damage) + /obj/item/organ/proc/robotize() //Being used to make robutt hearts, etc robotic = ORGAN_ROBOT src.status &= ~ORGAN_BROKEN