Merge pull request #2867 from Crazylemon64/ipc_brain_fix

IPC multibrain fix
This commit is contained in:
TheDZD
2015-12-20 21:31:49 -05:00
8 changed files with 106 additions and 56 deletions
@@ -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)
@@ -59,33 +63,38 @@
/obj/item/organ/brain/removed(var/mob/living/user)
if(!owner) return ..() // Probably a redundant removal; just bail
name = "[owner.real_name]'s brain"
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))
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)
..()
/obj/item/organ/brain/replaced(var/mob/living/target)
if(target.key)
target.ghostize()
var/mob/living/carbon/C = target
if(istype(C))
C.brain_op_stage = 1.0
if(brainmob)
if(brainmob.mind)
brainmob.mind.transfer_to(target)
else
target.key = brainmob.key
var/brain_already_exists = 0
if(istype(target,/mob/living/carbon/human)) // No more IPC multibrain shenanigans
var/mob/living/carbon/human/H = target
if(organ_tag in H.internal_organs_by_name)
brain_already_exists = 1
if(!brain_already_exists)
if(target.key)
target.ghostize()
var/mob/living/carbon/C = target
if(istype(C))
C.brain_op_stage = 1.0
if(brainmob)
if(brainmob.mind)
brainmob.mind.transfer_to(target)
else
target.key = brainmob.key
..()
/obj/item/organ/brain/slime
+1 -1
View File
@@ -93,4 +93,4 @@
sight &= ~SEE_OBJS
see_in_dark = 2
see_invisible = SEE_INVISIBLE_LIVING
handle_hud_icons_health()
handle_hud_icons_health()
+21 -7
View File
@@ -256,13 +256,14 @@ var/list/organ_cache = list()
take_damage(0,3)
/obj/item/organ/proc/removed(var/mob/living/user)
if(!istype(owner))
return
owner.internal_organs_by_name[organ_tag] = null
owner.internal_organs_by_name -= organ_tag
owner.internal_organs_by_name -= null
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 // uh what does this line even do this seems silly
owner.internal_organs -= src
var/obj/item/organ/external/affected = owner.get_organ(parent_organ)
@@ -275,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)
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()]\]<font color='red'> removed a vital organ ([src]) from [key_name(owner)] (INTENT: [uppertext(user.a_intent)])</font>"
owner.attack_log += "\[[time_stamp()]\]<font color='orange'> had a vital organ ([src]) removed by [key_name(user)] (INTENT: [uppertext(user.a_intent)])</font>"
@@ -291,7 +292,8 @@ var/list/organ_cache = list()
processing_objects -= src
target.internal_organs |= src
affected.internal_organs |= src
target.internal_organs_by_name[organ_tag] = src
if (!(organ_tag in target.internal_organs_by_name))
target.internal_organs_by_name[organ_tag] = src // In case multiple of the same type are inserted, only the first one is the primary organ
src.loc = target
if(robotic)
status |= ORGAN_ROBOT
@@ -326,4 +328,16 @@ var/list/organ_cache = list()
qdel(src)
/obj/item/organ/proc/surgeryize()
return
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]
+9 -1
View File
@@ -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 <b>Your [name] melts away!</b>", \
"\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]
+1 -1
View File
@@ -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)
+29 -15
View File
@@ -206,18 +206,20 @@
return 0
target.op_stage.current_organ = null
target.op_stage.organ_ref = null
var/list/attached_organs = list()
for(var/organ in target.internal_organs_by_name)
var/obj/item/organ/I = target.internal_organs_by_name[organ]
for(var/organ in affected.internal_organs)
var/obj/item/organ/I = organ
if(I && !(I.status & ORGAN_CUT_AWAY) && I.parent_organ == target_zone)
attached_organs |= organ
attached_organs[I.organ_tag] = I
var/organ_to_remove = input(user, "Which organ do you want to prepare for removal?") as null|anything in attached_organs
if(!organ_to_remove)
return 0
target.op_stage.current_organ = organ_to_remove
target.op_stage.organ_ref = attached_organs[organ_to_remove]
return ..() && organ_to_remove
@@ -234,7 +236,7 @@
user.visible_message("\blue [user] has separated [target]'s [target.op_stage.current_organ] with \the [tool]." , \
"\blue You have separated [target]'s [target.op_stage.current_organ] with \the [tool].")
var/obj/item/organ/I = target.internal_organs_by_name[target.op_stage.current_organ]
var/obj/item/organ/I = target.op_stage.organ_ref
if(I && istype(I))
I.status |= ORGAN_CUT_AWAY
@@ -259,20 +261,26 @@
if (!..())
return 0
var/obj/item/organ/external/affected = target.get_organ(target_zone)
if(!istype(affected))
return 0
target.op_stage.current_organ = null
target.op_stage.organ_ref = null
var/list/removable_organs = list()
for(var/organ in target.internal_organs_by_name)
var/obj/item/organ/I = target.internal_organs_by_name[organ]
if((I.status & ORGAN_CUT_AWAY) && I.parent_organ == target_zone)
removable_organs |= organ
for(var/organ in affected.internal_organs)
var/obj/item/organ/I = organ
if(istype(I) && (I.status & ORGAN_CUT_AWAY) && I.parent_organ == target_zone)
removable_organs[I.organ_tag] = I
var/organ_to_remove = input(user, "Which organ do you want to remove?") as null|anything in removable_organs
if(!organ_to_remove)
return 0
target.op_stage.current_organ = organ_to_remove
target.op_stage.organ_ref = removable_organs[organ_to_remove]
return ..()
begin_step(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
@@ -287,10 +295,9 @@
// Extract the organ!
if(target.op_stage.current_organ)
var/obj/item/organ/O = target.internal_organs_by_name[target.op_stage.current_organ]
var/obj/item/organ/O = target.op_stage.organ_ref
if(O && istype(O))
O.removed(user)
target.op_stage.current_organ = null
fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
var/obj/item/organ/external/affected = target.get_organ(target_zone)
@@ -391,19 +398,26 @@
if (!..())
return 0
var/obj/item/organ/external/affected = target.get_organ(target_zone)
if(!istype(affected))
return 0
target.op_stage.current_organ = null
target.op_stage.organ_ref = null
var/list/removable_organs = list()
for(var/organ in target.internal_organs_by_name)
var/obj/item/organ/I = target.internal_organs_by_name[organ]
if(I && (I.status & ORGAN_CUT_AWAY) && !(I.status & ORGAN_ROBOT) && I.parent_organ == target_zone)
removable_organs |= organ
for(var/organ in affected.internal_organs)
var/obj/item/organ/I = organ
if(I && istype(I) && (I.status & ORGAN_CUT_AWAY) && !(I.status & ORGAN_ROBOT) && I.parent_organ == target_zone)
removable_organs[I.organ_tag] = I
var/organ_to_replace = input(user, "Which organ do you want to reattach?") as null|anything in removable_organs
if(!organ_to_replace)
return 0
target.op_stage.current_organ = organ_to_replace
target.op_stage.organ_ref = removable_organs[organ_to_replace]
return ..()
begin_step(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
@@ -416,7 +430,7 @@
user.visible_message("\blue [user] has reattached [target]'s [target.op_stage.current_organ] with \the [tool]." , \
"\blue You have reattached [target]'s [target.op_stage.current_organ] with \the [tool].")
var/obj/item/organ/I = target.internal_organs_by_name[target.op_stage.current_organ]
var/obj/item/organ/I = target.op_stage.organ_ref
if(I && istype(I))
I.status &= ~ORGAN_CUT_AWAY
+12 -8
View File
@@ -289,18 +289,20 @@
return 0
target.op_stage.current_organ = null
target.op_stage.organ_ref = null
var/list/attached_organs = list()
for(var/organ in target.internal_organs_by_name)
var/obj/item/organ/I = target.internal_organs_by_name[organ]
if(I && !(I.status & ORGAN_CUT_AWAY) && I.parent_organ == target_zone)
attached_organs |= organ
for(var/organ in affected.internal_organs)
var/obj/item/organ/I = organ
if(I && istype(I) && !(I.status & ORGAN_CUT_AWAY) && I.parent_organ == target_zone)
attached_organs[I.organ_tag] = I
var/organ_to_remove = input(user, "Which organ do you want to prepare for removal?") as null|anything in attached_organs
if(!organ_to_remove)
return 0
target.op_stage.current_organ = organ_to_remove
target.op_stage.organ_ref = attached_organs[organ_to_remove]
return ..() && organ_to_remove
@@ -338,18 +340,20 @@
return 0
target.op_stage.current_organ = null
target.op_stage.organ_ref = null
var/list/removable_organs = list()
for(var/organ in target.internal_organs_by_name)
var/obj/item/organ/I = target.internal_organs_by_name[organ]
if(I && (I.status & ORGAN_CUT_AWAY) && (I.status & ORGAN_ROBOT) && I.parent_organ == target_zone)
removable_organs |= organ
for(var/organ in affected.internal_organs)
var/obj/item/organ/I = organ
if(I && istype(I) && (I.status & ORGAN_CUT_AWAY) && (I.status & ORGAN_ROBOT) && I.parent_organ == target_zone)
removable_organs[I.organ_tag] = I
var/organ_to_replace = input(user, "Which organ do you want to reattach?") as null|anything in removable_organs
if(!organ_to_replace)
return 0
target.op_stage.current_organ = organ_to_replace
target.op_stage.organ_ref = removable_organs[organ_to_replace]
return ..()
begin_step(mob/user, mob/living/carbon/human/target, target_zone, obj/item/tool)
+1
View File
@@ -131,4 +131,5 @@
var/ribcage = 0
var/head_reattach = 0
var/current_organ = "organ"
var/obj/item/organ/organ_ref = null
var/list/in_progress = list()