From 860275f51d6ff31d86987738562657ca84089c53 Mon Sep 17 00:00:00 2001 From: Crazylemon64 Date: Thu, 17 Dec 2015 22:42:28 -0800 Subject: [PATCH] Splits the primary organ checking into another function Also fixes the head and brain renaming so it works off of DNA instead of the body you took it of --- .../mob/living/carbon/brain/brain_item.dm | 33 +++++++++---------- code/modules/organs/organ.dm | 28 +++++++++------- code/modules/organs/organ_external.dm | 10 +++++- code/modules/organs/subtypes/standard.dm | 2 +- 4 files changed, 41 insertions(+), 32 deletions(-) diff --git a/code/modules/mob/living/carbon/brain/brain_item.dm b/code/modules/mob/living/carbon/brain/brain_item.dm index 38a74cb8c1c..5a0132f6bd8 100644 --- a/code/modules/mob/living/carbon/brain/brain_item.dm +++ b/code/modules/mob/living/carbon/brain/brain_item.dm @@ -37,11 +37,15 @@ brainmob.client.screen.len = null //clear the hud /obj/item/organ/brain/proc/transfer_identity(var/mob/living/carbon/H) - name = "\the [H]'s [initial(src.name)]" brainmob = new(src) - brainmob.name = H.real_name - brainmob.real_name = H.real_name - brainmob.dna = H.dna.Clone() + if(isnull(dna)) // someone didn't set this right... + log_to_dd("[src] at [loc] did not contain a dna datum at time of removed.") + dna = H.dna.Clone() + name = "\the [dna.real_name]'s [initial(src.name)]" + brainmob.dna = dna.Clone() // Silly baycode, what you do +// brainmob.dna = H.dna.Clone() Putting in and taking out a brain doesn't make it a carbon copy of the original brain of the body you put it in + brainmob.name = dna.real_name + brainmob.real_name = dna.real_name brainmob.timeofhostdeath = H.timeofdeath if(H.mind) H.mind.transfer_to(brainmob) @@ -60,15 +64,14 @@ if(!owner) return ..() // Probably a redundant removal; just bail - var/mob/living/simple_animal/borer/borer = owner.has_brain_worms() - - if(borer) - borer.detatch() //Should remove borer if the brain is removed - RR - - owner.brain_op_stage = 4.0 - var/obj/item/organ/brain/B = src - if(istype(B) && istype(owner) && owner.internal_organs_by_name[organ_tag] == src) + if(istype(B) && istype(owner) && is_primary_organ()) + var/mob/living/simple_animal/borer/borer = owner.has_brain_worms() + + if(borer) + borer.detatch() //Should remove borer if the brain is removed - RR + + owner.brain_op_stage = 4.0 B.transfer_identity(owner) ..() @@ -94,12 +97,6 @@ target.key = brainmob.key ..() -/obj/item/organ/brain/die() - // Brains dying kills the internal consciousness -// if(brainmob) -// qdel(brainmob) I'll leave this in for my next PR, and so people can yell at me about it - ..() - /obj/item/organ/brain/slime name = "slime core" desc = "A complex, organic knot of jelly and crystalline particles." diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index ce26098a1e7..62449b727c1 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -256,21 +256,13 @@ var/list/organ_cache = list() take_damage(0,3) /obj/item/organ/proc/removed(var/mob/living/user) - - var/primary_organ = 1 if(!istype(owner)) return - if(owner.internal_organs_by_name[organ_tag] == src) + if(is_primary_organ()) owner.internal_organs_by_name[organ_tag] = null owner.internal_organs_by_name -= organ_tag - owner.internal_organs_by_name -= null - else if(istype(src,/obj/item/organ/external)) // Limbs being a subtype of internal organs is dumb - var/obj/item/organ/external/E = src - if(owner.organs_by_name[E.limb_name] != src) - primary_organ = 0 - else - primary_organ = 0 + owner.internal_organs_by_name -= null // uh what does this line even do this seems silly owner.internal_organs -= src @@ -284,7 +276,7 @@ var/list/organ_cache = list() if(!organ_blood || !organ_blood.data["blood_DNA"]) owner.vessel.trans_to(src, 5, 1, 1) - if(owner && vital && 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 + 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 if(user) user.attack_log += "\[[time_stamp()]\] removed a vital organ ([src]) from [key_name(owner)] (INTENT: [uppertext(user.a_intent)])" owner.attack_log += "\[[time_stamp()]\] had a vital organ ([src]) removed by [key_name(user)] (INTENT: [uppertext(user.a_intent)])" @@ -336,4 +328,16 @@ var/list/organ_cache = list() qdel(src) /obj/item/organ/proc/surgeryize() - return \ No newline at end of file + return + +/* +Returns 1 if this is the organ that is handling all the functionalities of that particular organ slot +Returns 0 if it isn't +I use this so that this can be made better once the organ overhaul rolls out -- Crazylemon +*/ +/obj/item/organ/proc/is_primary_organ(var/mob/living/carbon/human/O = null) + if (isnull(O)) + O = owner + if (!istype(owner)) // You're not the primary organ of ANYTHING, bucko + return 0 + return src == O.internal_organs_by_name[organ_tag] \ No newline at end of file diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index 1c6ca1d176b..e1ab07b028e 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -855,7 +855,8 @@ Note that amputating the affected organ does in fact remove the infection from t release_restraints(victim) victim.organs -= src - victim.organs_by_name[limb_name] = null // Remove from owner's vars. + if(is_primary_organ(victim)) + victim.organs_by_name[limb_name] = null // Remove from owner's vars. //Robotic limbs explode if sabotaged. if(is_robotic && sabotaged) @@ -885,3 +886,10 @@ Note that amputating the affected organ does in fact remove the infection from t "\red Your [name] melts away!", \ "\red You hear a sickening sizzle.") disfigured = 1 + +/obj/item/organ/external/is_primary_organ(var/mob/living/carbon/human/O = null) + if (isnull(O)) + O = owner + if (!istype(O)) // You're not the primary organ of ANYTHING, bucko + return 0 + return src == O.organs_by_name[limb_name] diff --git a/code/modules/organs/subtypes/standard.dm b/code/modules/organs/subtypes/standard.dm index 6663f833bef..c11b8e028ab 100644 --- a/code/modules/organs/subtypes/standard.dm +++ b/code/modules/organs/subtypes/standard.dm @@ -137,7 +137,7 @@ /obj/item/organ/external/head/removed() if(owner) - name = "[owner.real_name]'s head" + name = "[dna.real_name]'s head" owner.unEquip(owner.glasses) owner.unEquip(owner.head) owner.unEquip(owner.l_ear)