From ef6fc627a6853e9d3f7c53c088122bf22578a0a3 Mon Sep 17 00:00:00 2001 From: ShizCalev Date: Fri, 10 Jul 2020 15:25:11 -0400 Subject: [PATCH] Fixes mapspawned headpikes --- code/game/objects/structures/headpike.dm | 48 ++++++++++++++++++------ 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/code/game/objects/structures/headpike.dm b/code/game/objects/structures/headpike.dm index ffdaf86bde5..df5ce50d5da 100644 --- a/code/game/objects/structures/headpike.dm +++ b/code/game/objects/structures/headpike.dm @@ -13,15 +13,46 @@ icon_state = "headpike-bone" bonespear = TRUE +/obj/structure/headpike/Initialize(mapload) + . = ..() + if(mapload) + CheckParts() + /obj/structure/headpike/CheckParts(list/parts_list) ..() victim = locate(/obj/item/bodypart/head) in parts_list - name = "[victim.name] on a spear" + if(!victim) //likely a mapspawned one + victim = new(src) + victim.real_name = random_unique_name(prob(50)) + name = "[victim.real_name] on a spear" update_icon() - if(bonespear) - spear = locate(/obj/item/spear/bonespear) in parts_list - else - spear = locate(/obj/item/spear) in parts_list + spear = locate(bonespear ? /obj/item/spear/bonespear : /obj/item/spear) in parts_list + if(!spear) + spear = bonespear ? new/obj/item/spear/bonespear(src) : new/obj/item/spear(src) + +/obj/structure/headpike/Destroy() + QDEL_NULL(victim) + QDEL_NULL(spear) + return ..() + +/obj/structure/headpike/handle_atom_del(atom/A) + if(A == victim) + victim = null + if(A == spear) + spear = null + deconstruct(TRUE) + return ..() + +/obj/structure/headpike/deconstruct(disassembled) + if(!disassembled) + return ..() + if(victim) + victim.forceMove(drop_location()) + victim = null + if(spear) + spear.forceMove(drop_location()) + spear = null + return ..() /obj/structure/headpike/Initialize() . = ..() @@ -41,9 +72,4 @@ if(.) return to_chat(user, "You take down [src].") - if(victim) - victim.forceMove(drop_location()) - victim = null - spear.forceMove(drop_location()) - spear = null - qdel(src) + deconstruct(TRUE)