From 0a4428c96ac0eb97ba739fe1caf9c2efb883ee2d Mon Sep 17 00:00:00 2001
From: Iajret Creature <122297233+Steals-The-PRs@users.noreply.github.com>
Date: Sun, 11 Feb 2024 06:06:24 +0300
Subject: [PATCH] [MIRROR] Fixes the energy cake slice's on-eat effect
triggering before it is eaten (#897) (#1928)
* Fixes the energy cake slice's on-eat effect triggering before it is eaten (#81382)
## About The Pull Request
This makes the energy cake deal its damage/effects AFTER being fed,
instead of before.
It also adds combat logging to force-fed energy cakes, just in case.
Also, this adds a balloon alert to the pacifist check. Cool!
## Why It's Good For The Game
Fixes a wacky combat bug, and adds some minor adjustments made along the
way.
Closes #81351.
## Changelog
:cl: Rhials
fix: The Energy Cake slice now does its on-eat effect AFTER being eaten,
instead of before.
/:cl:
* Fixes the energy cake slice's on-eat effect triggering before it is eaten
---------
Co-authored-by: NovaBot <154629622+NovaBot13@users.noreply.github.com>
Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com>
---
code/game/objects/items/food/cake.dm | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/code/game/objects/items/food/cake.dm b/code/game/objects/items/food/cake.dm
index 07d5818b466..0b443554bb3 100644
--- a/code/game/objects/items/food/cake.dm
+++ b/code/game/objects/items/food/cake.dm
@@ -288,16 +288,23 @@
tastes = list("cake" = 3, "a Vlad's Salad" = 1)
crafting_complexity = FOOD_COMPLEXITY_4
-/obj/item/food/cakeslice/birthday/energy/proc/energy_bite(mob/living/user)
- to_chat(user, "As you eat the cake slice, you accidentally hurt yourself on the embedded energy dagger!")
- user.apply_damage(18, BRUTE, BODY_ZONE_HEAD)
- playsound(user, 'sound/weapons/blade1.ogg', 5, TRUE)
+/obj/item/food/cakeslice/birthday/energy/Initialize(mapload)
+ . = ..()
+ RegisterSignal(src, COMSIG_FOOD_EATEN, PROC_REF(bite_taken))
/obj/item/food/cakeslice/birthday/energy/attack(mob/living/target_mob, mob/living/user)
- . = ..()
if(HAS_TRAIT(user, TRAIT_PACIFISM) && target_mob != user) //Prevents pacifists from attacking others directly
- return
- energy_bite(target_mob, user)
+ balloon_alert(user, "that's dangerous!")
+ return FALSE
+ return ..()
+
+/obj/item/food/cakeslice/birthday/energy/proc/bite_taken(datum/source, mob/living/eater, mob/living/feeder)
+ SIGNAL_HANDLER
+ to_chat(eater, "As you eat the cake slice, you accidentally hurt yourself on the embedded energy dagger!")
+ if(eater != feeder)
+ log_combat(feeder, eater, "fed an energy cake to", src)
+ eater.apply_damage(18, BRUTE, BODY_ZONE_HEAD)
+ playsound(eater, 'sound/weapons/blade1.ogg', 5, TRUE)
/obj/item/food/cake/apple
name = "apple cake"