From b797a66ee14fa148014ccbc79ad347ed60d70b4e Mon Sep 17 00:00:00 2001 From: Time-Green <7501474+Time-Green@users.noreply.github.com> Date: Sun, 6 Jul 2025 11:19:37 +0200 Subject: [PATCH] Fixes nightmare brain insertion (#91875) closes #91874 Our chain of events was a little wrong for the insertion Insert is called to insert the nightmare brain - on_mob_insert makes it a nightmare and regenerates all organs - bodypart_insert inserts the brai- WAIT THERE'S ALREADY A BRAIN FROM ON_MOB_INSERT CALLING SET_SPECIES AHHHH I added an option to not regenerate missing organs on species change, and use that for nightmare brain insertion Maybe I should redo the entire movement-insertion change, but I don't want to :cl: fix: Fixes inserting nightmare brains implanting the organ into their ??? /:cl: --- code/datums/dna.dm | 6 +++--- code/modules/antagonists/nightmare/nightmare_organs.dm | 2 +- code/modules/mob/living/carbon/human/_species.dm | 10 ++++++---- code/modules/mob/living/carbon/human/dummy.dm | 2 +- code/modules/mob/living/carbon/human/human.dm | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/code/datums/dna.dm b/code/datums/dna.dm index 0568d7e1b28..566a1d5e2d2 100644 --- a/code/datums/dna.dm +++ b/code/datums/dna.dm @@ -575,7 +575,7 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block()) stored_dna.species = mrace //not calling any species update procs since we're a brain, not a monkey/human -/mob/living/carbon/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, list/override_features, list/override_mutantparts, list/override_markings) // SKYRAT EDIT CHANGE - ORIGINAL: /mob/living/carbon/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE) +/mob/living/carbon/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, replace_missing = TRUE, list/override_features, list/override_mutantparts, list/override_markings) // SKYRAT EDIT CHANGE - ORIGINAL: /mob/living/carbon/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, replace_missing = TRUE) if(QDELETED(src)) CRASH("You're trying to change your species post deletion, this is a recipe for madness") if(isnull(mrace)) @@ -624,10 +624,10 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block()) dna.update_body_size() // SKYRAT EDIT ADDITION END - dna.species.on_species_gain(src, old_species, pref_load, regenerate_icons = icon_update) + dna.species.on_species_gain(src, old_species, pref_load, icon_update, replace_missing) log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]") -/mob/living/carbon/human/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, list/override_features, list/override_mutantparts, list/override_markings) // SKYRAT EDIT CHANGE - ORIGINAL: /mob/living/carbon/human/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE) +/mob/living/carbon/human/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, replace_missing = TRUE, list/override_features, list/override_mutantparts, list/override_markings) // SKYRAT EDIT CHANGE - ORIGINAL: /mob/living/carbon/human/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, replace_missing = TRUE) ..() if(icon_update) update_body(is_creating = TRUE) diff --git a/code/modules/antagonists/nightmare/nightmare_organs.dm b/code/modules/antagonists/nightmare/nightmare_organs.dm index b50880e025b..f3972d2e31c 100644 --- a/code/modules/antagonists/nightmare/nightmare_organs.dm +++ b/code/modules/antagonists/nightmare/nightmare_organs.dm @@ -18,7 +18,7 @@ . = ..() if(brain_owner.dna.species.id != SPECIES_NIGHTMARE) - brain_owner.set_species(/datum/species/shadow/nightmare) + brain_owner.set_species(/datum/species/shadow/nightmare, replace_missing = FALSE) visible_message(span_warning("[brain_owner] thrashes as [src] takes root in [brain_owner.p_their()] body!")) our_jaunt = new(brain_owner) diff --git a/code/modules/mob/living/carbon/human/_species.dm b/code/modules/mob/living/carbon/human/_species.dm index 16cd84c494d..77c7bcac671 100644 --- a/code/modules/mob/living/carbon/human/_species.dm +++ b/code/modules/mob/living/carbon/human/_species.dm @@ -297,8 +297,9 @@ GLOBAL_LIST_EMPTY(features_by_species) * * replace_current - boolean, forces all old organs to get deleted whether or not they pass the species' ability to keep that organ * * excluded_zones - list, add zone defines to block organs inside of the zones from getting handled. see headless mutation for an example * * visual_only - boolean, only load organs that change how the species looks. Do not use for normal gameplay stuff + * * replace_missing - Whether or not to replace missing organs */ -/datum/species/proc/regenerate_organs(mob/living/carbon/organ_holder, datum/species/old_species, replace_current = TRUE, list/excluded_zones, visual_only = FALSE) +/datum/species/proc/regenerate_organs(mob/living/carbon/organ_holder, datum/species/old_species, replace_current = TRUE, list/excluded_zones, visual_only = FALSE, replace_missing = TRUE) for(var/slot in get_all_slots()) var/obj/item/organ/existing_organ = organ_holder.get_organ_slot(slot) var/obj/item/organ/new_organ = get_mutant_organ_type_for_slot(slot) @@ -341,7 +342,7 @@ GLOBAL_LIST_EMPTY(features_by_species) existing_organ.Remove(organ_holder, special = TRUE) QDEL_NULL(existing_organ) - if(isnull(existing_organ) && should_have && !(new_organ.zone in excluded_zones) && organ_holder.get_bodypart(deprecise_zone(new_organ.zone))) + if(isnull(existing_organ) && should_have && !(new_organ.zone in excluded_zones) && organ_holder.get_bodypart(deprecise_zone(new_organ.zone)) && (replace_missing || remove_existing)) used_neworgan = TRUE new_organ.set_organ_damage(new_organ.maxHealth * (1 - health_pct)) new_organ.Insert(organ_holder, special = TRUE, movement_flags = DELETE_IF_REPLACED) @@ -377,8 +378,9 @@ GLOBAL_LIST_EMPTY(features_by_species) * * old_species - The species that the carbon used to be before becoming this race, used for regenerating organs. * * pref_load - Preferences to be loaded from character setup, loads in preferred mutant things like bodyparts, digilegs, skin color, etc. * * regenerate_icons - Whether or not to update the bodies icons + * * replace_missing - Whether or not to replace missing organs */ -/datum/species/proc/on_species_gain(mob/living/carbon/human/human_who_gained_species, datum/species/old_species, pref_load, regenerate_icons = TRUE) +/datum/species/proc/on_species_gain(mob/living/carbon/human/human_who_gained_species, datum/species/old_species, pref_load, regenerate_icons = TRUE, replace_missing = TRUE) SHOULD_CALL_PARENT(TRUE) human_who_gained_species.living_flags |= STOP_OVERLAY_UPDATE_BODY_PARTS //Don't call update_body_parts() for every single bodypart overlay added. @@ -405,7 +407,7 @@ GLOBAL_LIST_EMPTY(features_by_species) else if(old_species.exotic_bloodtype && isnull(exotic_bloodtype)) human_who_gained_species.set_blood_type(random_human_blood_type()) - regenerate_organs(human_who_gained_species, old_species, replace_current = human_who_gained_species.visual_only_organs, visual_only = human_who_gained_species.visual_only_organs) // SKYRAT EDIT - Allows existing organs to be properly removed when regenerating organs - ORIGINAL: regenerate_organs(human_who_gained_species, old_species, replace_current = FALSE, visual_only = human_who_gained_species.visual_only_organs) + regenerate_organs(human_who_gained_species, old_species, replace_current = human_who_gained_species.visual_only_organs, visual_only = human_who_gained_species.visual_only_organs, replace_missing = replace_missing) // SKYRAT EDIT - Allows existing organs to be properly removed when regenerating organs - ORIGINAL: regenerate_organs(human_who_gained_species, old_species, replace_current = FALSE, visual_only = human_who_gained_species.visual_only_organs, replace_missing = replace_missing) // Update locked slots AFTER all organ and body stuff is handled human_who_gained_species.hud_used?.update_locked_slots() // Drop the items the new species can't wear diff --git a/code/modules/mob/living/carbon/human/dummy.dm b/code/modules/mob/living/carbon/human/dummy.dm index 467b4e3f698..f28087efd15 100644 --- a/code/modules/mob/living/carbon/human/dummy.dm +++ b/code/modules/mob/living/carbon/human/dummy.dm @@ -22,7 +22,7 @@ INITIALIZE_IMMEDIATE(/mob/living/carbon/human/dummy) /mob/living/carbon/human/dummy/attach_rot(mapload) return -/mob/living/carbon/human/dummy/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, list/override_features, list/override_mutantparts, list/override_markings, retain_features = FALSE, retain_mutantparts = FALSE) // SKYRAT EDIT - Customization +/mob/living/carbon/human/dummy/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, replace_missing = TRUE, list/override_features, list/override_mutantparts, list/override_markings, retain_features = FALSE, retain_mutantparts = FALSE) // SKYRAT EDIT - Customization harvest_organs() return ..() diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 4c832614dc3..b85dcaa44dd 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1131,7 +1131,7 @@ if (!isnull(race)) dna.species = new race -/mob/living/carbon/human/species/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, list/override_features, list/override_mutantparts, list/override_markings, retain_features = FALSE, retain_mutantparts = FALSE) // SKYRAT EDIT - Customization +/mob/living/carbon/human/species/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, replace_missing = TRUE, list/override_features, list/override_mutantparts, list/override_markings, retain_features = FALSE, retain_mutantparts = FALSE) // SKYRAT EDIT - Customization . = ..() if(use_random_name)