Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

makes markings transfer over when ahealed/regenerating + aheals dont remove NIFs #5646

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/human/health.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// This is because the logic for being unconscious from damage is, for some reason, in UI. //
handle_regular_UI_updates()

/mob/living/carbon/human/rejuvenate(fix_missing, reset_to_slot)
/mob/living/carbon/human/rejuvenate(fix_missing, reset_to_slot, var/delete_nif = FALSE)
. = ..()
if(!.)
return
Expand All @@ -16,7 +16,7 @@

// todo: this obviously doesn't respect reset_to_slot.
if(fix_missing || reset_to_slot)
species.create_organs(src)
species.create_organs(src, delete_nif)
restore_all_organs()
client?.prefs?.copy_to(src)
if(dna)
Expand Down
19 changes: 4 additions & 15 deletions code/modules/organs/organ.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,11 @@
owner = loc
w_class = max(src.w_class + mob_size_difference(owner.mob_size, MOB_MEDIUM), 1) //smaller mobs have smaller organs.
if(internal)
if(!LAZYLEN(owner.internal_organs))
owner.internal_organs = list()
if(!LAZYLEN(owner.internal_organs_by_name))
owner.internal_organs_by_name = list()

owner.internal_organs |= src
owner.internal_organs_by_name[organ_tag] = src

LAZYDISTINCTADD(owner.internal_organs, src)
LAZYSET(owner.internal_organs_by_name, organ_tag, src)
else
if(!LAZYLEN(owner.organs))
owner.organs = list()
if(!LAZYLEN(owner.organs_by_name))
owner.organs_by_name = list()

owner.organs |= src
owner.organs_by_name[organ_tag] = src
LAZYDISTINCTADD(owner.organs, src)
LAZYSET(owner.organs_by_name, organ_tag, src)

if(!max_damage)
max_damage = min_broken_damage * 2
Expand Down
36 changes: 26 additions & 10 deletions code/modules/species/species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -622,9 +622,21 @@ GLOBAL_LIST_INIT(species_oxygen_tank_by_gas, list(
* called to ensure organs are consistent with our species's
* this is a destructive operation and will erase old organs!
*/
/datum/species/proc/create_organs(var/mob/living/carbon/human/H) //Handles creation of mob organs.

/datum/species/proc/create_organs(var/mob/living/carbon/human/H, var/delete_nif = FALSE) //Handles creation of mob organs.
H.mob_size = mob_size

// if we have a NIF, unimplant it before it gets wiped
var/obj/item/nif/our_nif = H.nif
if(H.nif)
H.nif.unimplant(H)

// store the markings for each limb we have so we can apply them to our new limbs
var/list/temporary_marking_store = list()
for(var/limb_type in has_limbs)
var/obj/item/organ/external/existing_limb = H.organs_by_name[limb_type]
if(existing_limb && istype(existing_limb))
temporary_marking_store[limb_type] = existing_limb.markings

for(var/obj/item/organ/organ in H.contents)
if((organ in H.organs) || (organ in H.internal_organs))
qdel(organ)
Expand All @@ -648,6 +660,12 @@ GLOBAL_LIST_INIT(species_oxygen_tank_by_gas, list(
organ_data = has_limbs[O.parent_organ]
organ_data["has_children"] = organ_data["has_children"]+1

// check if we had an old limb of the same type that had markings
var/obj/item/organ/external/limb = O
var/markings_for_limb = temporary_marking_store[limb_type]
if(istype(O) && markings_for_limb)
limb.markings = markings_for_limb

for(var/organ_tag in has_organ)
var/organ_type = has_organ[organ_tag]
var/obj/item/organ/O = new organ_type(H,1)
Expand All @@ -656,14 +674,12 @@ GLOBAL_LIST_INIT(species_oxygen_tank_by_gas, list(
O.organ_tag = organ_tag
H.internal_organs_by_name[organ_tag] = O

if(H.nif)
var/type = H.nif.type
var/durability = H.nif.durability
var/list/nifsofts = H.nif.nifsofts
var/list/nif_savedata = H.nif.save_data.Copy()

var/obj/item/nif/nif = new type(H,durability,nif_savedata)
nif.nifsofts = nifsofts
// if we had a NIF, decide if we want to delete it, or put it back
if(our_nif)
if(delete_nif)
QDEL_NULL(our_nif)
else
our_nif.quick_implant(H)

if(base_color)
H.r_skin = hex2num(copytext(base_color,2,4))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/species/station/xenochimera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
return
var/mob/living/carbon/human/H = owner
H.restore_blood()
H.species.create_organs(H)
H.species.create_organs(H, TRUE)
H.restore_all_organs()
H.adjustBruteLoss(-healing_amount)
H.adjustFireLoss(-healing_amount)
Expand Down
Loading