Doesn't Rejuvenate Limbs or Organs if ones Exist on Mob...

... with the same limb name (in the case of external organs) or the same slot (in the case of internal organs) to prevent duplication.
This commit is contained in:
KasparoVy
2016-05-18 03:08:38 -04:00
parent 763db82dca
commit 701df43ee0
5 changed files with 40 additions and 14 deletions
+23 -10
View File
@@ -1256,9 +1256,9 @@
germ_level += n
/mob/living/carbon/human/proc/check_and_regenerate_organs(var/mob/living/carbon/human/H) //Regenerates missing limbs/organs.
var/list/types_of_int_organs = list()
var/list/types_of_int_organs = list() //This will hold all the types of organs in the mob before rejuvenation.
for(var/obj/item/organ/internal/I in H.internal_organs)
types_of_int_organs |= I.type
types_of_int_organs |= I.type //Compiling the list of organ types. It is possible for organs to be missing from this list if they are absent from the mob.
//Removing stumps.
for(var/obj/item/organ/organ in H.contents)
@@ -1276,20 +1276,32 @@
H.organs_by_name -= organ_name //Making sure the list entry is removed.
//Replacing lost limbs with the species default.
var/mob/living/carbon/human/temp_holder
for(var/limb_type in H.species.has_limbs)
if(!(limb_type in H.organs_by_name))
var/list/organ_data = H.species.has_limbs[limb_type]
var/limb_path = organ_data["path"]
var/obj/item/organ/external/O = new limb_path(H)
O.owner = H
H.organs |= H.organs_by_name[O.limb_name]
var/obj/item/organ/external/O = new limb_path(temp_holder)
if(H.get_limb_by_name(O.name)) //Check to see if the user already has an limb with the same name as the 'missing limb'. If they do, skip regrowth.
continue //In an example, this will prevent duplication of the mob's right arm if the mob is a Human and they have a Diona right arm, since,
//while the limb with the name 'right_arm' the mob has may not be listed in their species' bodyparts definition, it is still viable and has the appropriate limb name.
else
O = new limb_path(H) //Create the limb on the player.
O.owner = H
H.organs |= H.organs_by_name[O.limb_name]
//Replacing lost organs with the species default.
temp_holder = new /mob/living/carbon/human()
for(var/index in H.species.has_organ)
var/organ = H.species.has_organ[index]
if(!(organ in types_of_int_organs))
var/obj/item/organ/internal/I = new organ(H)
I.insert(H)
if(!(organ in types_of_int_organs)) //If the mob is missing this particular organ...
var/obj/item/organ/internal/I = new organ(temp_holder) //Create the organ inside our holder so we can check it before implantation.
if(H.get_organ_slot(I.slot)) //Check to see if the user already has an organ in the slot the 'missing organ' belongs to. If they do, skip implantation.
continue //In an example, this will prevent duplication of the mob's eyes if the mob is a Human and they have Nucleation eyes, since,
//while the organ in the eyes slot may not be listed in the mob's species' organs definition, it is still viable and fits in the appropriate organ slot.
else
I = new organ(H) //Create the organ inside the player.
I.insert(H)
/mob/living/carbon/human/revive()
@@ -1299,8 +1311,9 @@
fixblood()
//Fix up all organs and replace lost ones.
restore_all_organs()
check_and_regenerate_organs(src)
restore_all_organs() //Rejuvenate and reset all existing organs.
check_and_regenerate_organs(src) //Regenerate limbs and organs only if they're really missing.
surgeries.Cut() //End all surgeries.
if(!client || !key) //Don't boot out anyone already in the mob.
for (var/obj/item/organ/internal/brain/H in world)
+1
View File
@@ -405,6 +405,7 @@
human_mob.decaylevel = 0
restore_all_organs()
surgeries.Cut() //End all surgeries.
if(stat == DEAD)
dead_mob_list -= src
living_mob_list += src
+6 -1
View File
@@ -40,4 +40,9 @@
return O
/proc/is_int_organ(atom/A)
return istype(A, /obj/item/organ/internal)
return istype(A, /obj/item/organ/internal)
/mob/living/carbon/human/proc/get_limb_by_name(limb_name) //Look for a limb with the given limb name in the source mob, and return it if found.
for(var/obj/item/organ/external/O in organs)
if(limb_name == O.limb_name)
return O
+6 -1
View File
@@ -176,7 +176,12 @@ var/list/organ_cache = list()
/obj/item/organ/proc/rejuvenate()
damage = 0
germ_level = 0
status &= ~ORGAN_DEAD
if(status & ORGAN_ROBOT) //Robotic organs stay robotic.
status = ORGAN_ROBOT
else if (status & ORGAN_ASSISTED) //Assisted organs stay assisted.
status = ORGAN_ASSISTED
else
status = 0
if(!owner)
processing_objects |= src
@@ -308,8 +308,10 @@ This function completely restores a damaged organ to perfect condition.
*/
/obj/item/organ/external/rejuvenate()
damage_state = "00"
if(status & 128) //Robotic organs stay robotic.
status = 128
if(status & ORGAN_ROBOT) //Robotic organs stay robotic.
status = ORGAN_ROBOT
else if (status & ORGAN_ASSISTED) //Assisted organs stay assisted.
status = ORGAN_ASSISTED
else
status = 0
germ_level = 0