Merge pull request #52149 from ShizCalev/headpike-fix

Fixes mapspawned headpikes
This commit is contained in:
skoglol
2020-07-12 11:35:48 +02:00
committed by GitHub
+37 -11
View File
@@ -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, "<span class='notice'>You take down [src].</span>")
if(victim)
victim.forceMove(drop_location())
victim = null
spear.forceMove(drop_location())
spear = null
qdel(src)
deconstruct(TRUE)