Skip to content

Commit

Permalink
[MIRROR] Fixes the energy cake slice's on-eat effect triggering befor…
Browse files Browse the repository at this point in the history
…e 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 <[email protected]>
Co-authored-by: Rhials <[email protected]>
  • Loading branch information
3 people authored Feb 11, 2024
1 parent 7e132fb commit 0a4428c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions code/game/objects/items/food/cake.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<font color='red' size='5'>As you eat the cake slice, you accidentally hurt yourself on the embedded energy dagger!</font>")
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, "<font color='red' size='5'>As you eat the cake slice, you accidentally hurt yourself on the embedded energy dagger!</font>")
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"
Expand Down

0 comments on commit 0a4428c

Please sign in to comment.