refactor human butchering trait (#28725)

* refactor human butchering trait

* Update code/datums/elements/butchers_humans.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Signed-off-by: warriorstar-orion <orion@snowfrost.garden>

---------

Signed-off-by: warriorstar-orion <orion@snowfrost.garden>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
This commit is contained in:
warriorstar-orion
2025-03-25 11:13:37 +00:00
committed by GitHub
co-authored by Contrabang
parent c6c4e82ff4
commit 23bb467991
9 changed files with 58 additions and 25 deletions
-1
View File
@@ -278,7 +278,6 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_SUPERMATTER_IMMUNE "supermatter_immune"
//***** ITEM TRAITS *****//
#define TRAIT_BUTCHERS_HUMANS "butchers_humans"
#define TRAIT_CMAGGED "cmagged"
/// An item that is being wielded.
#define TRAIT_WIELDED "wielded"
-1
View File
@@ -132,7 +132,6 @@ GLOBAL_LIST_INIT(traits_by_type, list(
/obj/item = list(
"TRAIT_SHOW_WIRE_INFO" = TRAIT_SHOW_WIRE_INFO,
"TRAIT_SUPERMATTER_IMMUNE" = TRAIT_SUPERMATTER_IMMUNE,
"TRAIT_BUTCHER_HUMANS" = TRAIT_BUTCHERS_HUMANS,
"TRAIT_CMAGGED" = TRAIT_CMAGGED,
"TRAIT_OBSCURED_WIRES" = TRAIT_OBSCURED_WIRES,
"TRAIT_XENO_INTERACTABLE" = TRAIT_XENO_INTERACTABLE,
+54
View File
@@ -0,0 +1,54 @@
/// An element for items that butcher human corpses into meat when attacked on
/// harm intent.
/datum/element/butchers_humans
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY
/datum/element/butchers_humans/Attach(datum/target)
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
RegisterSignal(target, COMSIG_ATTACK, PROC_REF(on_attack))
/datum/element/butchers_humans/Detach(datum/source, force)
. = ..()
UnregisterSignal(source, list(COMSIG_PARENT_EXAMINE, COMSIG_ATTACK))
/datum/element/butchers_humans/proc/on_examine(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER // COMSIG_PARENT_EXAMINE
examine_list += "<span class='warning'>Can be used to butcher dead people into meat while on harm intent.</span>"
/datum/element/butchers_humans/proc/on_attack(datum/source, mob/living/victim, mob/living/user, params)
SIGNAL_HANDLER // COMSIG_ATTACK
if(!ishuman(victim) || !isitem(source))
return
var/mob/living/carbon/human/human = victim
var/obj/item/item = source
if(human.stat == DEAD && user.a_intent == INTENT_HARM)
var/obj/item/food/meat/human/newmeat = new /obj/item/food/meat/human(get_turf(human))
newmeat.name = human.real_name + newmeat.name
newmeat.reagents.add_reagent("nutriment", (human.nutrition / 15) / 3)
human.reagents.trans_to(newmeat, round((human.reagents.total_volume) / 3, 1))
human.add_mob_blood(human)
human.meatleft--
if(human.meatleft)
to_chat(user, "<span class='warning'>You hack off a chunk of meat from [human]!</span>")
// fallthrough so we get side-effects like blood splatter and limb
// flyoff from human attacked_by while we still have a corpse around
return
human.send_item_attack_message(item, user)
// Handle a few tiny things normally done in attack chain
user.do_attack_animation(human)
item.add_fingerprint(user)
if(item.hitsound)
playsound(get_turf(item), item.hitsound, item.get_clamped_volume(), TRUE, extrarange = item.stealthy_audio ? SILENCED_SOUND_EXTRARANGE : -1, falloff_distance = 0)
add_attack_logs(user, human, "Chopped up into meat with [item.name] ([uppertext(user.a_intent)])", human.ckey ? null : ATKLOG_ALMOSTALL)
to_chat(user, "<span class='warning'>You reduce [human] to a pile of meat!</span>")
qdel(human)
return COMPONENT_CANCEL_ATTACK_CHAIN
-3
View File
@@ -299,9 +299,6 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
. += "<span class='notice'>Has [length(attached_bits)] bits attached.</span>"
. += "<span class='notice'>Bits can be removed with Alt-Click.</span>"
if(HAS_TRAIT(src, TRAIT_BUTCHERS_HUMANS))
. += "<span class='warning'>Can be used to butcher dead people into meat while on harm intent.</span>"
/obj/item/burn()
if(!QDELETED(src))
var/turf/T = get_turf(src)
+1 -1
View File
@@ -183,7 +183,7 @@
/obj/item/kitchen/knife/butcher/meatcleaver/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_BUTCHERS_HUMANS, ROUNDSTART_TRAIT)
AddElement(/datum/element/butchers_humans)
/obj/item/kitchen/knife/combat
name = "combat knife"
+1 -1
View File
@@ -521,7 +521,7 @@
/obj/item/butcher_chainsaw/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_BUTCHERS_HUMANS, ROUNDSTART_TRAIT)
AddElement(/datum/element/butchers_humans)
AddComponent(/datum/component/two_handed, \
force_wielded = 40, \
force_unwielded = force, \
@@ -34,8 +34,6 @@
/obj/item/food/meat/human
name = "-meat"
var/subjectname = ""
var/subjectjob = null
tastes = list("salty meat" = 1)
/obj/item/food/meat/slab/meatproduct
@@ -462,24 +462,9 @@ emp_act
return ..()
/mob/living/carbon/human/attacked_by(obj/item/I, mob/living/user, def_zone)
if(!I || !user)
if(!I || !user || QDELETED(src))
return
if(HAS_TRAIT(I, TRAIT_BUTCHERS_HUMANS) && stat == DEAD && user.a_intent == INTENT_HARM)
var/obj/item/food/meat/human/newmeat = new /obj/item/food/meat/human(get_turf(loc))
newmeat.name = real_name + newmeat.name
newmeat.subjectname = real_name
newmeat.subjectjob = job
newmeat.reagents.add_reagent("nutriment", (nutrition / 15) / 3)
reagents.trans_to(newmeat, round((reagents.total_volume) / 3, 1))
add_mob_blood(src)
--meatleft
to_chat(user, "<span class='warning'>You hack off a chunk of meat from [name]</span>")
if(!meatleft)
add_attack_logs(user, src, "Chopped up into meat")
qdel(src)
return
var/obj/item/organ/external/affecting = get_organ(ran_zone(user.zone_selected))
// if the targeted limb doesn't exist, pick a new one at random so you don't have to swap target zone
+1
View File
@@ -563,6 +563,7 @@
#include "code\datums\elements\atmos_requirements.dm"
#include "code\datums\elements\body_temperature.dm"
#include "code\datums\elements\bombable_turf.dm"
#include "code\datums\elements\butchers_humans.dm"
#include "code\datums\elements\connect_loc.dm"
#include "code\datums\elements\decal_element.dm"
#include "code\datums\elements\earhealing.dm"