diff --git a/code/modules/organs/external/_external.dm b/code/modules/organs/external/_external.dm index 8ca1b7f233d3c..95a71c0f6219f 100644 --- a/code/modules/organs/external/_external.dm +++ b/code/modules/organs/external/_external.dm @@ -91,8 +91,8 @@ if(get_fingerprint()) A.add_partial_print(get_fingerprint()) -/obj/item/organ/external/New(mob/living/carbon/holder) - ..() +/obj/item/organ/external/Initialize() + . = ..() if(isnull(pain_disability_threshold)) pain_disability_threshold = (max_damage * 0.75) if(owner) diff --git a/code/modules/organs/external/stump.dm b/code/modules/organs/external/stump.dm index 8e931e0a2cb8e..c3f7762c74931 100644 --- a/code/modules/organs/external/stump.dm +++ b/code/modules/organs/external/stump.dm @@ -3,7 +3,7 @@ icon_name = "" dislocated = -1 -/obj/item/organ/external/stump/New(mob/living/carbon/holder, internal, obj/item/organ/external/limb) +/obj/item/organ/external/stump/Initialize(mapload, internal, obj/item/organ/external/limb) if(istype(limb)) SetName("stump of \a [limb.name]") organ_tag = limb.organ_tag @@ -13,7 +13,7 @@ parent_organ = limb.parent_organ artery_name = "mangled [limb.artery_name]" arterial_bleed_severity = limb.arterial_bleed_severity - ..(holder, internal) + . = ..(loc, internal) if(istype(limb)) max_damage = limb.max_damage if(BP_IS_ROBOTIC(limb) && (!parent || BP_IS_ROBOTIC(parent))) diff --git a/code/modules/organs/internal/_internal.dm b/code/modules/organs/internal/_internal.dm index 42ebfd2c1186f..9ece1ae690fb5 100644 --- a/code/modules/organs/internal/_internal.dm +++ b/code/modules/organs/internal/_internal.dm @@ -8,19 +8,18 @@ var/min_bruised_damage = 10 // Damage before considered bruised var/damage_reduction = 0.5 //modifier for internal organ injury -/obj/item/organ/internal/New(mob/living/carbon/holder) +/obj/item/organ/internal/Initialize() if(max_damage) min_bruised_damage = floor(max_damage / 4) - ..() - if(istype(holder) && !istype(src, /obj/item/organ/internal/augment)) + . = ..() + if(iscarbon(loc) && !istype(src, /obj/item/organ/internal/augment)) + var/mob/living/carbon/human/holder = loc holder.internal_organs |= src - - var/mob/living/carbon/human/H = holder - if(istype(H)) - var/obj/item/organ/external/E = H.get_organ(parent_organ) - if(!E) + if(ishuman(holder)) + var/obj/item/organ/external/external = holder.get_organ(parent_organ) + if(!external) CRASH("[src] spawned in [holder] without a parent organ: [parent_organ].") - E.internal_organs |= src + external.internal_organs |= src /obj/item/organ/internal/Destroy() if(owner) diff --git a/code/modules/organs/internal/brain.dm b/code/modules/organs/internal/brain.dm index 533edc1b9b4cb..6365a7c49f93b 100644 --- a/code/modules/organs/internal/brain.dm +++ b/code/modules/organs/internal/brain.dm @@ -43,8 +43,8 @@ . = ..() icon_state = "brain-prosthetic" -/obj/item/organ/internal/brain/New(mob/living/carbon/holder) - ..() +/obj/item/organ/internal/brain/Initialize() + . = ..() if(species) set_max_damage(species.total_health) else diff --git a/code/modules/organs/internal/eyes.dm b/code/modules/organs/internal/eyes.dm index 62789bf392add..aca3e1a51353f 100644 --- a/code/modules/organs/internal/eyes.dm +++ b/code/modules/organs/internal/eyes.dm @@ -85,8 +85,8 @@ if(is_broken()) owner.eye_blind = 20 -/obj/item/organ/internal/eyes/New() - ..() +/obj/item/organ/internal/eyes/Initialize() + . = ..() flash_mod = species.flash_mod darksight_range = species.darksight_range darksight_tint = species.darksight_tint @@ -101,8 +101,8 @@ name = "optical sensor" status = ORGAN_ROBOTIC -/obj/item/organ/internal/eyes/robot/New() - ..() +/obj/item/organ/internal/eyes/robot/Initialize() + . = ..() robotize() /obj/item/organ/internal/eyes/robotize() diff --git a/code/modules/organs/internal/species/fbp.dm b/code/modules/organs/internal/species/fbp.dm index 54e028196cdf6..6bb48c53ef14a 100644 --- a/code/modules/organs/internal/species/fbp.dm +++ b/code/modules/organs/internal/species/fbp.dm @@ -12,11 +12,11 @@ //at 0.26 completely depleted after 60ish minutes of constant walking or 130 minutes of standing still var/servo_cost = 0.26 -/obj/item/organ/internal/cell/New() +/obj/item/organ/internal/cell/Initialize() + . = ..() robotize() if(ispath(cell)) cell = new cell(src) - ..() /obj/item/organ/internal/cell/proc/percent() if(!cell) @@ -120,12 +120,16 @@ stored_mmi = null return ..() -/obj/item/organ/internal/mmi_holder/New(mob/living/carbon/human/new_owner, internal) - ..(new_owner, internal) +/obj/item/organ/internal/mmi_holder/Initialize() + . = ..() if(!stored_mmi) stored_mmi = new(src) - sleep(-1) + return INITIALIZE_HINT_LATELOAD + +/obj/item/organ/internal/mmi_holder/LateInitialize() update_from_mmi() + if (!owner) + return persistantMind = owner.mind ownerckey = owner.ckey diff --git a/code/modules/organs/internal/species/ipc.dm b/code/modules/organs/internal/species/ipc.dm index b30604df79803..8c8f344dbd707 100644 --- a/code/modules/organs/internal/species/ipc.dm +++ b/code/modules/organs/internal/species/ipc.dm @@ -32,10 +32,10 @@ ) var/shackle = 0 -/obj/item/organ/internal/posibrain/New(mob/living/carbon/H) - ..() - if(!brainmob && H) - init(H) +/obj/item/organ/internal/posibrain/Initialize() + . = ..() + if(!brainmob && iscarbon(loc)) + init(loc) robotize() unshackle() update_icon() diff --git a/code/modules/organs/internal/species/nabber.dm b/code/modules/organs/internal/species/nabber.dm index c5aa505ca5fd4..fe53a96ac77b7 100644 --- a/code/modules/organs/internal/species/nabber.dm +++ b/code/modules/organs/internal/species/nabber.dm @@ -60,7 +60,7 @@ /obj/item/organ/internal/eyes/insectoid/nabber/proc/remove_shield() owner.clear_fullscreen("eyeshield") -/obj/item/organ/internal/eyes/nabber/New(mob/living/carbon/holder) +/obj/item/organ/internal/eyes/nabber/Initialize() . = ..() if(dna) color = rgb(dna.GetUIValue(DNA_UI_EYES_R), dna.GetUIValue(DNA_UI_EYES_G), dna.GetUIValue(DNA_UI_EYES_B)) diff --git a/code/modules/organs/internal/species/vox.dm b/code/modules/organs/internal/species/vox.dm index bbafd5d7486da..c761deec4c3b3 100644 --- a/code/modules/organs/internal/species/vox.dm +++ b/code/modules/organs/internal/species/vox.dm @@ -174,8 +174,8 @@ var/datum/mind/backup var/prompting = FALSE // Are we waiting for a user prompt? -/obj/item/organ/internal/voxstack/New() - ..() +/obj/item/organ/internal/voxstack/Initialize() + . = ..() do_backup() robotize() diff --git a/code/modules/organs/internal/stomach.dm b/code/modules/organs/internal/stomach.dm index 6f0b0416967b4..e9809dcb55817 100644 --- a/code/modules/organs/internal/stomach.dm +++ b/code/modules/organs/internal/stomach.dm @@ -15,8 +15,8 @@ QDEL_NULL(ingested) . = ..() -/obj/item/organ/internal/stomach/New() - ..() +/obj/item/organ/internal/stomach/Initialize() + . = ..() var/ingested_atom = owner ? owner : src ingested = new/datum/reagents/metabolism(240, ingested_atom, CHEM_INGEST) if(species.gluttonous) diff --git a/code/modules/organs/organ.dm b/code/modules/organs/organ.dm index c1e80f908cafb..56e24bf82d74d 100644 --- a/code/modules/organs/organ.dm +++ b/code/modules/organs/organ.dm @@ -50,8 +50,8 @@ var/global/list/organ_cache = list() return (damage >= min_broken_damage || (status & ORGAN_CUT_AWAY) || (status & ORGAN_BROKEN)) //Second argument may be a dna datum; if null will be set to holder's dna. -/obj/item/organ/New(mob/living/carbon/holder, datum/dna/given_dna) - ..(holder) +/obj/item/organ/Initialize(mapload, datum/dna/given_dna) + . = ..() if(!istype(given_dna)) given_dna = null @@ -59,13 +59,12 @@ var/global/list/organ_cache = list() min_broken_damage = floor(max_damage / 2) else max_damage = min_broken_damage * 2 - - if(istype(holder)) - owner = holder - if(!given_dna && holder.dna) - given_dna = holder.dna + if (iscarbon(loc)) + owner = loc + if(!given_dna && owner.dna) + given_dna = owner.dna else - log_debug("[src] spawned in [holder] without a proper DNA.") + log_debug("[src] spawned in [owner] without a proper DNA.") if (given_dna) set_dna(given_dna)