From 1eba9a6df1f029ada0c20c09bb205b28ecee8069 Mon Sep 17 00:00:00 2001 From: Crazylemon Date: Thu, 10 Mar 2016 17:03:25 -0800 Subject: [PATCH 1/4] Skeletons and slime people should no longer bleed "blood" when hit --- code/_onclick/item_attack.dm | 2 -- code/modules/surgery/organs/blood.dm | 49 +++++++++++++++++++--------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/code/_onclick/item_attack.dm b/code/_onclick/item_attack.dm index 01953690274..8b77b80b769 100644 --- a/code/_onclick/item_attack.dm +++ b/code/_onclick/item_attack.dm @@ -62,8 +62,6 @@ else M.LAssailant = user - //spawn(1800) // this wont work right - // M.lastattacker = null ///////////////////////// if(istype(M, /mob/living/simple_animal)) diff --git a/code/modules/surgery/organs/blood.dm b/code/modules/surgery/organs/blood.dm index 60dd2f1f10c..46ce153254e 100644 --- a/code/modules/surgery/organs/blood.dm +++ b/code/modules/surgery/organs/blood.dm @@ -187,7 +187,7 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 //Gets blood from mob to the container, preserving all data in it. /mob/living/carbon/proc/take_blood(obj/item/weapon/reagent_containers/container, var/amount) var/datum/reagent/B = get_blood(container.reagents) - if(!B) B = new /datum/reagent/blood + if(!istype(B, /datum/reagent/blood)) B = new /datum/reagent/blood B.holder = container B.volume += amount @@ -241,7 +241,7 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 //Transfers blood from container ot vessels /mob/living/carbon/proc/inject_blood(obj/item/weapon/reagent_containers/container, var/amount) var/datum/reagent/blood/injected = get_blood(container.reagents) - if (!injected) + if (!istype(injected)) return var/list/sniffles = virus_copylist(injected.data["virus2"]) for(var/ID in sniffles) @@ -269,7 +269,7 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 var/datum/reagent/blood/our = get_blood(vessel) - if (!injected || !our) + if (!istype(injected) || !istype(our)) return if(blood_incompatible(injected.data["blood_type"],our.data["blood_type"]) ) reagents.add_reagent("toxin",amount * 0.5) @@ -289,6 +289,12 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 return D return res +/mob/living/carbon/human/get_blood(datum/reagents/container) + if(species.exotic_blood) + return container.reagent_list[species.exotic_blood] + else + return ..() + /proc/blood_incompatible(donor,receiver) var/donor_antigen = copytext(donor,1,lentext(donor)) @@ -307,15 +313,28 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 //AB is a universal receiver. return 0 -proc/blood_splatter(var/target,var/datum/reagent/blood/source,var/large) +/* +Target: Thing to get bloody +Source: Human or blood reagent +Large: Whether the splat should be big or not +*/ +/proc/blood_splatter(var/target,var/source,var/large) var/obj/effect/decal/cleanable/blood/B var/decal_type = /obj/effect/decal/cleanable/blood/splatter var/turf/T = get_turf(target) + var/datum/reagent/blood/bld if(istype(source,/mob/living/carbon/human)) - var/mob/living/carbon/human/M = source - source = M.get_blood(M.vessel) + var/mob/living/carbon/human/H = source + bld = H.get_blood(H.vessel) + if(H.species.exotic_blood) + H.vessel.reaction(T, TOUCH) + return + else if(H.species.flags & NO_BLOOD) + return + else + bld = source // Are we dripping or splattering? var/list/drips = list() @@ -337,24 +356,24 @@ proc/blood_splatter(var/target,var/datum/reagent/blood/source,var/large) drop.drips |= drips // If there's no data to copy, call it quits here. - if(!source) + if(!bld) return B // Update appearance. - if(source.data["blood_colour"]) - B.basecolor = source.data["blood_colour"] + if(bld.data["blood_colour"]) + B.basecolor = bld.data["blood_colour"] B.update_icon() // Update blood information. - if(source.data["blood_DNA"]) + if(bld.data["blood_DNA"]) B.blood_DNA = list() - if(source.data["blood_type"]) - B.blood_DNA[source.data["blood_DNA"]] = source.data["blood_type"] + if(bld.data["blood_type"]) + B.blood_DNA[bld.data["blood_DNA"]] = bld.data["blood_type"] else - B.blood_DNA[source.data["blood_DNA"]] = "O+" + B.blood_DNA[bld.data["blood_DNA"]] = "O+" // Update virus information. - if(source.data["virus2"]) - B.virus2 = virus_copylist(source.data["virus2"]) + if(bld.data["virus2"]) + B.virus2 = virus_copylist(bld.data["virus2"]) return B \ No newline at end of file From d9d0fff5a23fd000b0f00501e16e4d67343eff44 Mon Sep 17 00:00:00 2001 From: Crazylemon Date: Thu, 10 Mar 2016 17:13:29 -0800 Subject: [PATCH 2/4] Exotic blood other than water will work now, and slime people will now absorb water as blood --- code/modules/surgery/organs/blood.dm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/code/modules/surgery/organs/blood.dm b/code/modules/surgery/organs/blood.dm index 46ce153254e..4ca50e72fc9 100644 --- a/code/modules/surgery/organs/blood.dm +++ b/code/modules/surgery/organs/blood.dm @@ -41,14 +41,19 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 return if(stat != DEAD && bodytemperature >= 170) //Dead or cryosleep people do not pump the blood. if(species.exotic_blood) - blood_volume = round(vessel.get_reagent_amount(species.exotic_blood)) + var/blood_reagent = species.exotic_blood // This is a string of the name of the species' blood reagent + blood_volume = round(vessel.get_reagent_amount(blood_reagent)) if(blood_volume < 560 && blood_volume) - var/datum/reagent/water/W = locate() in vessel.reagent_list //Grab some blood - if(W) // Make sure there's some blood at all - W.volume += 0.1 // regenerate blood VERY slowly + var/datum/reagent/R = vessel.reagent_list[blood_reagent] //Grab some blood + if(R) // Make sure there's some blood at all + R.volume += 0.1 // regenerate blood VERY slowly if (reagents.has_reagent("nutriment")) //Getting food speeds it up - W.volume += 0.4 + R.volume += 0.4 reagents.remove_reagent("nutriment", 0.1) + else if (reagents.has_reagent(blood_reagent)) + R.volume += 0.4 + reagents.remove_reagent(blood_reagent, 0.4) + else blood_volume = round(vessel.get_reagent_amount("blood")) //Blood regeneration if there is some space @@ -191,8 +196,6 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 B.holder = container B.volume += amount - - //set reagent data B.data["donor"] = src if (!B.data["virus2"]) From 23a6c70b7b69beb3f4bdb08bacbadb6bd3b751db Mon Sep 17 00:00:00 2001 From: Crazylemon64 Date: Thu, 10 Mar 2016 22:01:07 -0800 Subject: [PATCH 3/4] ahahahaha it finally works --- code/game/atoms.dm | 9 ++- .../mob/living/carbon/carbon_defenses.dm | 6 -- code/modules/mob/living/carbon/human/human.dm | 3 +- code/modules/reagents/Chemistry-Holder.dm | 26 ++++++-- .../oldchem/reagents/reagents_water.dm | 14 +++-- code/modules/surgery/organs/blood.dm | 61 +++++++++++-------- code/modules/surgery/organs/organ.dm | 14 ++--- 7 files changed, 80 insertions(+), 53 deletions(-) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index c4d9820aad2..f7ee79f2619 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -354,12 +354,11 @@ blood_color = "#A10808" if(istype(M)) - if (!istype(M.dna, /datum/dna)) - M.dna = new /datum/dna(null) - M.dna.real_name = M.real_name + if(M.species.flags & NO_BLOOD) + return 0 M.check_dna() - if (M.species) - blood_color = M.species.blood_color + blood_color = M.species.blood_color + . = 1 return 1 diff --git a/code/modules/mob/living/carbon/carbon_defenses.dm b/code/modules/mob/living/carbon/carbon_defenses.dm index 45c15d35f8a..0f37ff365ba 100644 --- a/code/modules/mob/living/carbon/carbon_defenses.dm +++ b/code/modules/mob/living/carbon/carbon_defenses.dm @@ -1,15 +1,9 @@ /mob/living/carbon/hitby(atom/movable/AM) -// if(!skip) //ugly, but easy -// message_admins("Skip Check Passed") if(in_throw_mode && !get_active_hand()) //empty active hand and we're in throw mode -// message_admins("In Throw Mode and active hand check passed") if(canmove && !restrained()) -// message_admins("Restrained/moving check passed") if(istype(AM, /obj/item)) -// message_admins("Item check passed") var/obj/item/I = AM if(isturf(I.loc)) -// message_admins("Turf check passed") put_in_active_hand(I) visible_message("[src] catches [I]!") throw_mode_off() diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 05cf2458f2d..1cde4f801f8 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1308,7 +1308,8 @@ /mob/living/carbon/human/revive() if(species && !(species.flags & NO_BLOOD)) - vessel.add_reagent("blood",560-vessel.total_volume) + var/blood_reagent = species.exotic_blood ? species.exotic_blood : "blood" + vessel.add_reagent(blood_reagent, max_blood-vessel.total_volume) fixblood() // Fix up all organs. diff --git a/code/modules/reagents/Chemistry-Holder.dm b/code/modules/reagents/Chemistry-Holder.dm index 084883d55f9..6a5be72900a 100644 --- a/code/modules/reagents/Chemistry-Holder.dm +++ b/code/modules/reagents/Chemistry-Holder.dm @@ -91,12 +91,22 @@ var/const/INGEST = 2 return the_id -/datum/reagents/proc/trans_to(var/obj/target, var/amount=1, var/multiplier=1, var/preserve_data=1)//if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred. - if (!target ) +/datum/reagents/proc/trans_to(var/target, var/amount=1, var/multiplier=1, var/preserve_data=1)//if preserve_data=0, the reagents data will be lost. Usefull if you use data for some strange stuff and don't want it to be transferred. + if (!target) return - if (!target.reagents || src.total_volume<=0) + if(src.total_volume <= 0) return - var/datum/reagents/R = target.reagents + var/datum/reagents/R + if(istype(target, /obj)) + var/obj/O = target + if (!O.reagents ) + return + R = O.reagents + else if(istype(target, /datum/reagents)) + R = target + else + return + amount = min(min(amount, src.total_volume), R.maximum_volume-R.total_volume) var/part = amount / src.total_volume var/trans_data = null @@ -606,6 +616,14 @@ atom/proc/create_reagents(var/max_vol) reagents = new/datum/reagents(max_vol) reagents.my_atom = src +/datum/reagents/proc/get_reagent_from_id(var/id) + var/datum/reagent/result = null + for(var/datum/reagent/R in reagent_list) + if(R.id == id) + result = R + break + return result + /datum/reagents/Destroy() . = ..() processing_objects.Remove(src) diff --git a/code/modules/reagents/oldchem/reagents/reagents_water.dm b/code/modules/reagents/oldchem/reagents/reagents_water.dm index b7c296443b5..b6d77656ea9 100644 --- a/code/modules/reagents/oldchem/reagents/reagents_water.dm +++ b/code/modules/reagents/oldchem/reagents/reagents_water.dm @@ -184,16 +184,18 @@ if(!istype(T)) return var/datum/reagent/blood/self = src src = null - if(!(volume >= 3)) return + var/big_splash = 1 + if(volume < 3) + big_splash = 0 //var/datum/disease/D = self.data["virus"] if(!self.data["donor"] || istype(self.data["donor"], /mob/living/carbon/human)) + blood_splatter(T, src, big_splash) var/obj/effect/decal/cleanable/blood/blood_prop = locate() in T //find some blood here - if(!blood_prop) //first blood! - blood_prop = new(T) - blood_prop.blood_DNA[self.data["blood_DNA"]] = self.data["blood_type"] - if(self.data["virus2"]) - blood_prop.virus2 = virus_copylist(self.data["virus2"]) + if(blood_prop) + blood_prop.blood_DNA[self.data["blood_DNA"]] = self.data["blood_type"] + if(self.data["virus2"]) + blood_prop.virus2 = virus_copylist(self.data["virus2"]) else if(istype(self.data["donor"], /mob/living/carbon/alien)) var/obj/effect/decal/cleanable/blood/xeno/blood_prop = locate() in T diff --git a/code/modules/surgery/organs/blood.dm b/code/modules/surgery/organs/blood.dm index 4ca50e72fc9..29c8308c5d8 100644 --- a/code/modules/surgery/organs/blood.dm +++ b/code/modules/surgery/organs/blood.dm @@ -16,13 +16,13 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 if(vessel) return - vessel = new/datum/reagents(600) + vessel = new/datum/reagents(max_blood) vessel.my_atom = src if(species && species.exotic_blood) - vessel.add_reagent(species.exotic_blood,560) + vessel.add_reagent(species.exotic_blood, max_blood) else - vessel.add_reagent("blood",560) + vessel.add_reagent("blood", max_blood) spawn(1) fixblood() @@ -43,21 +43,19 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 if(species.exotic_blood) var/blood_reagent = species.exotic_blood // This is a string of the name of the species' blood reagent blood_volume = round(vessel.get_reagent_amount(blood_reagent)) - if(blood_volume < 560 && blood_volume) - var/datum/reagent/R = vessel.reagent_list[blood_reagent] //Grab some blood - if(R) // Make sure there's some blood at all - R.volume += 0.1 // regenerate blood VERY slowly - if (reagents.has_reagent("nutriment")) //Getting food speeds it up - R.volume += 0.4 - reagents.remove_reagent("nutriment", 0.1) - else if (reagents.has_reagent(blood_reagent)) - R.volume += 0.4 - reagents.remove_reagent(blood_reagent, 0.4) - + if(blood_volume < max_blood && blood_volume) + vessel.add_reagent(blood_reagent, 0.1) // regenerate blood VERY slowly + if (reagents.has_reagent("nutriment")) //Getting food speeds it up + vessel.add_reagent(blood_reagent, 0.4) + reagents.remove_reagent("nutriment", 0.1) + else if (reagents.has_reagent(blood_reagent)) + vessel.add_reagent(blood_reagent, 0.4) + reagents.remove_reagent(blood_reagent, 0.4) + else blood_volume = round(vessel.get_reagent_amount("blood")) //Blood regeneration if there is some space - if(blood_volume < 560 && blood_volume) + if(blood_volume < max_blood && 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 @@ -79,16 +77,16 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 B = D break - B.volume += 0.1 // regenerate blood VERY slowly + vessel.add_reagent("blood", 0.1) // regenerate blood VERY slowly if (reagents.has_reagent("nutriment")) //Getting food speeds it up - B.volume += 0.4 + vessel.add_reagent("blood", 0.4) reagents.remove_reagent("nutriment", 0.1) if (reagents.has_reagent("iron")) //Hematogen candy anyone? - B.volume += 0.8 + vessel.add_reagent("blood", 0.8) reagents.remove_reagent("iron", 0.1) if (reagents.has_reagent("salglu_solution")) //saline is good for blood regeneration if(prob(33)) - B.volume += 1.0 + vessel.add_reagent("blood", 1.0) // Damaged heart virtually reduces the blood volume, as the blood isn't // being pumped properly anymore. @@ -294,7 +292,16 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 /mob/living/carbon/human/get_blood(datum/reagents/container) if(species.exotic_blood) - return container.reagent_list[species.exotic_blood] + return container.get_reagent_from_id(species.exotic_blood) + else + return ..() + +/mob/living/carbon/proc/get_blood_name() + return "blood" + +/mob/living/carbon/human/get_blood_name() + if(species.exotic_blood) + return species.exotic_blood else return ..() @@ -317,16 +324,15 @@ var/const/BLOOD_VOLUME_SURVIVE = 122 return 0 /* -Target: Thing to get bloody +Target: Thing/tile to get bloody Source: Human or blood reagent Large: Whether the splat should be big or not */ -/proc/blood_splatter(var/target,var/source,var/large) +/proc/blood_splatter(var/target,var/source,var/large = 0) var/obj/effect/decal/cleanable/blood/B var/decal_type = /obj/effect/decal/cleanable/blood/splatter var/turf/T = get_turf(target) - var/datum/reagent/blood/bld if(istype(source,/mob/living/carbon/human)) var/mob/living/carbon/human/H = source @@ -336,8 +342,15 @@ Large: Whether the splat should be big or not return else if(H.species.flags & NO_BLOOD) return - else + else if(istype(source, /datum/reagent)) bld = source + if(!istype(bld, /datum/reagent/blood)) + var/datum/reagent/R = bld + if(istype(R)) + R.reaction_turf(T, R.volume) + return + else if(source) + log_to_dd("Non-human or reagent blood source. Area: [get_area(source)], Name: [source]") // Are we dripping or splattering? var/list/drips = list() diff --git a/code/modules/surgery/organs/organ.dm b/code/modules/surgery/organs/organ.dm index fee4aaa1eb6..e3b7f49abc4 100644 --- a/code/modules/surgery/organs/organ.dm +++ b/code/modules/surgery/organs/organ.dm @@ -86,11 +86,11 @@ var/list/organ_cache = list() return if(!owner) - if(reagents) - var/datum/reagent/blood/B = locate(/datum/reagent/blood) in reagents.reagent_list - if(B && prob(40)) - reagents.remove_reagent("blood",0.1) - blood_splatter(src,B,1) + if(reagents && prob(40)) + reagents.remove_any(0.1) + for(var/datum/reagent/R in reagents.reagent_list) + R.reaction_turf(get_turf(src), 0.1) + // Maybe scale it down a bit, have it REALLY kick in once past the basic infection threshold // Another mercy for surgeons preparing transplant organs germ_level++ @@ -268,8 +268,8 @@ var/list/organ_cache = list() loc = get_turf(owner) processing_objects |= src var/datum/reagent/blood/organ_blood - if(reagents) organ_blood = locate(/datum/reagent/blood) in reagents.reagent_list - if(!organ_blood || !organ_blood.data["blood_DNA"]) + if(reagents) organ_blood = reagents.get_reagent_from_id(owner.get_blood_name()) + if((!organ_blood || !organ_blood.data["blood_DNA"]) && (owner && !(owner.species.flags & NO_BLOOD))) owner.vessel.trans_to(src, 5, 1, 1) if(owner && vital && is_primary_organ()) // I'd do another check for species or whatever so that you couldn't "kill" an IPC by removing a human head from them, but it doesn't matter since they'll come right back from the dead From 40012496ffe995f6e6e46fb416029bbdfa596a1e Mon Sep 17 00:00:00 2001 From: Crazylemon64 Date: Thu, 10 Mar 2016 22:36:20 -0800 Subject: [PATCH 4/4] I unborked it --- code/modules/mob/living/carbon/human/human.dm | 2 +- code/modules/reagents/Chemistry-Holder.dm | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 1cde4f801f8..2cfa124b9a1 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1308,7 +1308,7 @@ /mob/living/carbon/human/revive() if(species && !(species.flags & NO_BLOOD)) - var/blood_reagent = species.exotic_blood ? species.exotic_blood : "blood" + var/blood_reagent = get_blood_name() vessel.add_reagent(blood_reagent, max_blood-vessel.total_volume) fixblood() diff --git a/code/modules/reagents/Chemistry-Holder.dm b/code/modules/reagents/Chemistry-Holder.dm index 6a5be72900a..57fe20f7520 100644 --- a/code/modules/reagents/Chemistry-Holder.dm +++ b/code/modules/reagents/Chemistry-Holder.dm @@ -102,6 +102,11 @@ var/const/INGEST = 2 if (!O.reagents ) return R = O.reagents + else if (istype(target, /mob/living)) + var/mob/living/M = target + if(!M.reagents) + return + R = M.reagents else if(istype(target, /datum/reagents)) R = target else