Files
Bubberstation/code/game/objects/structures/headpike.dm
Ghom 1f3894e793 Crafting refactor, implementing materials (#89465)
My original plan was to just implement materials into crafting so that
items would inherit the materials of their components, allowing for some
interesting stuff if the material flags of the item allow it. However to
my dismay crafting is a pile of old tech debt, starting from the old
`del_reqs` and `CheckParts` which still contain lines about old janky
bandaids that are no longer in use nor reachable, up to the
`customizable_reagent_holder` component which has some harddel issues
when your custom food is sliced, and items used in food recipes not
being deleted and instead stored inside the result with no purpose as
well as other inconsistencies like stack recipes that transfer materials
having counterparts in the UI that don't do that.

EDIT: Several things have come up while working on this, so I apologise
that it ended up changing over 100+ files. I managed to atomize some of
the changes, but it's a bit tedious.

EDIT: TLDR because I was told this section is too vague and there's too
much going on. This PR:
- Improves the dated crafting code (not the UI).
- replaced `atom/CheckParts` and `crafting_recipe/on_craft_completion`
with `atom/on_craft_completion`.
- Reqs used in food recipes are now deleted by default and not stored
inside the result (they did nothing).
- Renames the customizable_reagent_holder comp and improves it (No
harddels/ref issues).
- Adds a unit test that tries to craft all recipes to see what's wrong
(it skips some of the much more specific reqs for now).
- In the unit test is also the code to make sure materials of the
crafted item and a non-crafted item of the same type are roughly the
same, so far only applied to food.
- Some mild material/food refactoring around the fact that food item
code has been changed to support materials.

Improving the backbone of the crafting system. Also materials and food
code.

🆑
refactor: Refactored crafting backend. Report possible pesky bugs.
balance: the MEAT backpack (from the MEAT cargo pack) may be a smidge
different because of code standardization.
/🆑
2025-06-05 20:05:13 -04:00

84 lines
2.1 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/military //for military spears
icon_state = "headpike-military"
speartype = /obj/item/spear/military
/obj/structure/headpike/Initialize(mapload)
. = ..()
if(mapload)
spear = new speartype(src)
victim = new(src)
victim.real_name = generate_random_name()
pixel_x = rand(-8, 8)
/obj/structure/headpike/Destroy()
QDEL_NULL(victim)
QDEL_NULL(spear)
return ..()
/obj/structure/headpike/on_craft_completion(list/components, datum/crafting_recipe/current_recipe, atom/crafter)
. = ..()
victim = locate() in contents
spear = locate(speartype) in contents
update_appearance()
/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_z = 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/atom_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())
/obj/structure/headpike/attack_hand(mob/user, list/modifiers)
. = ..()
if(.)
return
to_chat(user, span_notice("You take down [src]."))
deconstruct(TRUE)