Files
Bubberstation/code/game/objects/structures/headpike.dm
SkyratBot 53715b0a39 [MIRROR] Makes heads on pikes render correctly. [MDB IGNORE] (#25170)
* Makes heads on pikes render correctly. (#79863)

## About The Pull Request

Fixes #59037.

This PR makes heads on pikes actually appear properly offset so that
they're impaled on the spike instead of halfway down the shaft. In
addition, the heads will actually appear on the correct layer, rather
than sometimes being rendered on the _UI layer._ This means they will
not inexplicably be visible to blind players.

![image](https://github.com/tgstation/tgstation/assets/105025397/6fc16ef8-21d1-4399-b00d-3a6412b1c038)
## Why It's Good For The Game

Judging from the screenshots in the PR that added these six years ago,
this has actually _never_ looked correct. For the first time, this makes
heads on pikes actually look like they're meant to, rather than having
way too much of the spear shoved out the top of the head.

Also, fixes a fairly egregious rendering error that makes blind people
see mysterious heads in the void.
## Changelog
🆑
fix: Heads impaled on spears now render in the correct place on the tip,
instead of halfway down the shaft.
fix: Blind personnel are no longer able to magically see heads impaled
on spears from a distance.
/🆑

* Makes heads on pikes render correctly.

---------

Co-authored-by: lizardqueenlexi <105025397+lizardqueenlexi@users.noreply.github.com>
2023-11-21 10:40:26 -05:00

84 lines
2.0 KiB
Plaintext

/obj/structure/headpike
name = "spooky head on a spear"
desc = "When you really want to send a message."
icon = 'icons/obj/structures.dmi'
icon_state = "headpike"
density = FALSE
anchored = TRUE
var/obj/item/spear/spear
var/obj/item/spear/speartype = /obj/item/spear
var/obj/item/bodypart/head/victim
/obj/structure/headpike/bone //for bone spears
icon_state = "headpike-bone"
speartype = /obj/item/spear/bonespear
/obj/structure/headpike/bamboo //for bamboo spears
icon_state = "headpike-bamboo"
speartype = /obj/item/spear/bamboospear
/obj/structure/headpike/Initialize(mapload)
. = ..()
if(mapload)
CheckParts()
pixel_x = rand(-8, 8)
/obj/structure/headpike/Destroy()
QDEL_NULL(victim)
QDEL_NULL(spear)
return ..()
/obj/structure/headpike/CheckParts(list/parts_list)
victim = locate() in parts_list
if(!victim) //likely a mapspawned one
victim = new(src)
victim.real_name = random_unique_name(prob(50))
spear = locate(speartype) in parts_list
if(!spear)
spear = new speartype(src)
update_appearance()
return ..()
/obj/structure/headpike/update_name()
name = "[victim.real_name] on a [spear.name]"
return ..()
/obj/structure/headpike/update_overlays()
. = ..()
if(!victim)
return
var/mutable_appearance/appearance = new()
appearance.copy_overlays(victim)
appearance.pixel_y = 12
appearance.layer = layer + 0.1
. += appearance
/obj/structure/headpike/Exited(atom/movable/gone, direction)
. = ..()
if(gone != victim && gone != spear)
return
if(gone == victim)
victim = null
if(gone == spear)
spear = null
if(!QDELETED(src))
deconstruct(TRUE)
/obj/structure/headpike/deconstruct(disassembled)
var/obj/item/bodypart/head/our_head = victim
var/obj/item/spear/our_spear = spear
victim = null
spear = null
our_head?.forceMove(drop_location()) //Make sure the head always comes off
if(!disassembled)
return ..()
our_spear?.forceMove(drop_location())
return ..()
/obj/structure/headpike/attack_hand(mob/user, list/modifiers)
. = ..()
if(.)
return
to_chat(user, span_notice("You take down [src]."))
deconstruct(TRUE)