From e77afd5ab9d573daf559c9e194c6dad3ac91eda3 Mon Sep 17 00:00:00 2001 From: cib Date: Sat, 13 Oct 2012 09:09:11 -0700 Subject: [PATCH] Added bleeding and blood transfusion. --- code/modules/mob/living/carbon/human/human.dm | 40 +++++++++++ code/modules/mob/living/carbon/human/life.dm | 68 +++++++++++++++++++ .../reagents/reagent_containers/syringes.dm | 19 +++++- code/modules/recycling/disposal.dm | 10 +++ 4 files changed, 136 insertions(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 3cce88cde48..5ba2955e55f 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -5,6 +5,10 @@ icon = 'icons/mob/human.dmi' icon_state = "body_m_s" + var/datum/reagents/vessel + // TODO: make this actually affect the way the mob is rendered + var/pale = 0 + /mob/living/carbon/human/dummy real_name = "Test Dummy" @@ -72,6 +76,42 @@ prev_gender = gender // Debug for plural genders + vessel = new/datum/reagents(600) + vessel.my_atom = src + vessel.add_reagent("blood",560) + spawn(1) + fixblood() + +/mob/living/carbon/human/proc/drip(var/amt as num) + if(!amt) + return + + var/amm = 0.1 * amt + var/turf/T = get_turf(src) + var/list/obj/effect/decal/cleanable/blood/drip/nums = list() + var/list/iconL = list("1","2","3","4","5") + + vessel.remove_reagent("blood",amm) + + for(var/obj/effect/decal/cleanable/blood/drip/G in T) + nums += G + iconL.Remove(G.icon_state) + if(nums.len >= 3) + var/obj/effect/decal/cleanable/blood/drip/D = pick(nums) + D.blood_DNA[dna.unique_enzymes] = dna.b_type + return + + var/obj/effect/decal/cleanable/blood/drip/this = new(T) + this.icon_state = pick(iconL) + this.blood_DNA = list() + this.blood_DNA[dna.unique_enzymes] = dna.b_type + +/mob/living/carbon/human/proc/fixblood() + for(var/datum/reagent/blood/B in vessel.reagent_list) + if(B.id == "blood") + B.data = list("donor"=src,"viruses"=null,"blood_DNA"=dna.unique_enzymes,"blood_type"=dna.b_type,"resistances"=null,"trace_chem"=null) + + /mob/living/carbon/human/Bump(atom/movable/AM as mob|obj, yes) if ((!( yes ) || now_pushing)) return diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 4d5f22160b6..f15a26ece40 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -123,6 +123,73 @@ /mob/living/carbon/human + proc/handle_blood() + // take care of blood and blood loss + if(stat < 2) + var/blood_volume = round(vessel.get_reagent_amount("blood")) + if(blood_volume < 560 && blood_volume) + var/datum/reagent/blood/B = locate() in vessel.reagent_list //Grab some blood + if(B) // Make sure there's some blood at all + if(B.data["donor"] != src) //If it's not theirs, then we look for theirs + for(var/datum/reagent/blood/D in vessel.reagent_list) + if(D.data["donor"] == src) + B = D + break + var/datum/reagent/nutriment/F = locate() in vessel.reagent_list + if(F != null) + if(F.volume >= 1) + // nutriment speeds it up quite a bit + B.volume += 0.4 + F.volume -= 0.1 + else + //At this point, we dun care which blood we are adding to, as long as they get more blood. + B.volume = B.volume + 0.1 // regenerate blood VERY slowly + + + switch(blood_volume) + if(501 to 10000) + if(pale) + pale = 0 + update_body() + if(336 to 500) + if(!pale) + pale = 1 + update_body() + var/word = pick("dizzy","woosey","faint") + src << "\red You feel [word]" + if(prob(1)) + var/word = pick("dizzy","woosey","faint") + src << "\red You feel [word]" + if(oxyloss < 20) + // hint that they're getting close to suffocation + oxyloss += 3 + if(224 to 335) + if(!pale) + pale = 1 + update_body() + eye_blurry += 6 + if(oxyloss < 50) + oxyloss += 10 + oxyloss += 1 + if(prob(15)) + Paralyse(rand(1,3)) + if(122 to 244) + oxyloss += 5 + toxloss += 5 + if(0 to 122) + death() + + + var/blood_max = 0 + for(var/datum/organ/external/temp in organs) + if(!(temp.status & ORGAN_BLEEDING) || temp.status & ORGAN_ROBOT) + continue + for(var/datum/wound/W in temp.wounds) if(W.bleeding()) + blood_max += W.damage / 2 + if(temp.status & ORGAN_DESTROYED && !(temp.status & ORGAN_GAUZED)) + blood_max += 20 //Yer missing a fucking limb. + drip(blood_max) + proc/handle_disabilities() if (disabilities & EPILEPSY) if ((prob(1) && paralysis < 1)) @@ -888,6 +955,7 @@ else //ALIVE. LIGHTS ARE ON updatehealth() //TODO handle_organs() + handle_blood() if(health <= config.health_threshold_dead || brain_op_stage == 4.0) death() blinded = 1 diff --git a/code/modules/reagents/reagent_containers/syringes.dm b/code/modules/reagents/reagent_containers/syringes.dm index 3e0d85d766a..48249a67f93 100644 --- a/code/modules/reagents/reagent_containers/syringes.dm +++ b/code/modules/reagents/reagent_containers/syringes.dm @@ -75,6 +75,9 @@ if(NOCLONE in T.mutations) //target done been et, no more blood in him user << "\red You are unable to locate any blood." return + if(ishuman(T)) + if(T:vessel.get_reagent_amount("blood") < amount) + return B.holder = src B.volume = amount //set reagent data @@ -106,6 +109,9 @@ temp_chem[R.name] = R.volume B.data["trace_chem"] = list2params(temp_chem) + if(ishuman(T)) + T:vessel.remove_reagent("blood",amount) // Removes blood if human + src.reagents.reagent_list += B src.reagents.update_total() src.on_reagent_change() @@ -158,7 +164,18 @@ if(ismob(target) && target == user) src.reagents.reaction(target, INGEST) spawn(5) - var/trans = src.reagents.trans_to(target, amount_per_transfer_from_this) + var/datum/reagent/blood/B + for(var/datum/reagent/blood/d in src.reagents.reagent_list) + B = d + break + var/trans + if(B && ishuman(target)) + var/mob/living/carbon/human/H = target + trans = B.volume > 5? 5 : B.volume + H.vessel.add_reagent("blood",trans,B.data) + src.reagents.remove_reagent("blood",trans) + else + trans = src.reagents.trans_to(target, amount_per_transfer_from_this) user << "\blue You inject [trans] units of the solution. The syringe now contains [src.reagents.total_volume] units." if (reagents.total_volume <= 0 && mode==SYRINGE_INJECT) mode = SYRINGE_DRAW diff --git a/code/modules/recycling/disposal.dm b/code/modules/recycling/disposal.dm index 6343b00685f..76e4beb0ce6 100644 --- a/code/modules/recycling/disposal.dm +++ b/code/modules/recycling/disposal.dm @@ -1335,3 +1335,13 @@ dirs = alldirs.Copy() src.streak(dirs) + +/obj/effect/decal/cleanable/blood/drip + name = "drips of blood" + desc = "It's red." + gender = PLURAL + density = 0 + anchored = 1 + layer = 2 + icon = 'drip.dmi' + icon_state = "1" \ No newline at end of file