Skip to content

Commit

Permalink
Butching effect
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert committed Nov 4, 2024
1 parent 1895a6f commit 6c660f0
Showing 1 changed file with 46 additions and 6 deletions.
52 changes: 46 additions & 6 deletions code/datums/components/butchering.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@
SIGNAL_HANDLER

if(!user.combat_mode)
return
return NONE
if(M.stat == DEAD && (M.butcher_results || M.guaranteed_butcher_results)) //can we butcher it?
if(butchering_enabled && (can_be_blunt || source.get_sharpness()))
INVOKE_ASYNC(src, PROC_REF(startButcher), source, M, user)
return COMPONENT_CANCEL_ATTACK_CHAIN
if(!DOING_INTERACTION(user, "[REF(M)]_butchering"))
INVOKE_ASYNC(src, PROC_REF(startButcher), source, M, user)
return COMPONENT_CANCEL_ATTACK_CHAIN
return NONE

if(ishuman(M) && source.force && source.get_sharpness())
var/mob/living/carbon/human/H = M
Expand All @@ -56,17 +58,34 @@
return COMPONENT_CANCEL_ATTACK_CHAIN

if(H.has_status_effect(/datum/status_effect/neck_slice))
return
return NONE

INVOKE_ASYNC(src, PROC_REF(startNeckSlice), source, H, user)
return COMPONENT_CANCEL_ATTACK_CHAIN

return NONE

/datum/component/butchering/proc/startButcher(obj/item/source, mob/living/M, mob/living/user)
to_chat(user, span_notice("You begin to butcher [M]..."))
playsound(M.loc, butcher_sound, 50, TRUE, -1)
if(do_after(user, speed, M) && M.Adjacent(source))
playsound(M, butcher_sound, 50, TRUE, -1)
if(do_after(user, speed, M, extra_checks = CALLBACK(src, PROC_REF(butcher_effects), source, M, user), interaction_key = "[REF(M)]_butchering") && M.Adjacent(source))
on_butchering(user, M)

/datum/component/butchering/proc/butcher_effects(obj/item/source, mob/living/butchering, mob/living/user)
if(user.next_move <= world.time)
user.face_atom(butchering)
// performs an attack against the mob
var/old_combat_mode = user.combat_mode
user.set_combat_mode(TRUE, TRUE)
source.melee_attack_chain(user, butchering)
user.set_combat_mode(old_combat_mode, TRUE)
// and play the sound
playsound(butchering, butcher_sound, 50, TRUE, -1)
// start our own click cd
user.changeNext_move(0.6 SECONDS)
// so the butchering doesn't stop
return TRUE

/datum/component/butchering/proc/startNeckSlice(obj/item/source, mob/living/carbon/human/H, mob/living/user)
if(DOING_INTERACTION_WITH_TARGET(user, H))
to_chat(user, span_warning("You're already interacting with [H]!"))
Expand Down Expand Up @@ -221,6 +240,9 @@
if(victim.stat == DEAD && (victim.butcher_results || victim.guaranteed_butcher_results))
on_butchering(parent, victim)

/datum/component/butchering/recycler/butcher_effects(obj/item/source, mob/living/butchering, mob/living/user)
return TRUE // p sure this won't work

/datum/component/butchering/mecha

/datum/component/butchering/mecha/RegisterWithParent()
Expand All @@ -242,6 +264,9 @@
SIGNAL_HANDLER
INVOKE_ASYNC(src, PROC_REF(on_butchering), chassis, target)

/datum/component/butchering/mecha/butcher_effects(obj/item/source, mob/living/butchering, mob/living/user)
return TRUE // could give this one, unsure if it's needed though

/datum/component/butchering/wearable

/datum/component/butchering/wearable/RegisterWithParent()
Expand Down Expand Up @@ -276,3 +301,18 @@
if(!isliving(target))
return NONE
return onItemAttack(parent, target, user)

/datum/component/butchering/wearable/butcher_effects(obj/item/source, mob/living/butchering, mob/living/user)
if(user.next_move <= world.time)
user.face_atom(butchering)
// performs an attack against the mob
var/old_combat_mode = user.combat_mode
user.set_combat_mode(TRUE, TRUE)
user.UnarmedAttack(butchering, TRUE)
user.set_combat_mode(old_combat_mode, TRUE)
// and play the sound
playsound(butchering, butcher_sound, 50, TRUE, -1)
// start our own click cd
user.changeNext_move(0.6 SECONDS)
// so the butchering doesn't stop
return TRUE

0 comments on commit 6c660f0

Please sign in to comment.