From b6900a6d27ea7ca3ac442393ace5d5724f1c59cb Mon Sep 17 00:00:00 2001 From: san7890 Date: Thu, 15 Sep 2022 06:12:31 -0600 Subject: [PATCH] Fixes Bread Smite Causing Some Fucked Up Shit (#69853) * Fixes Bread Smite Causing Some Fucked Up Shit Hey there, So basically, when you had the bread smite done on you, you were _just_ added to the contents of the bread. Nothing more. That means that you could pick it up. You couldn't add it to your bag (it would always return back into your hand(?)), but it would create some weird oddities that was just cursed in general. Let's make it so you can't hold the container that you are contained within by giving you HANDS_BLOCKED. * actually we don't need the named arg lets get rid of the cursed thing entirely * removes sanity check * we do a bit of component trolling THIS TOOK ME TWO HOURS FUCK YOU * removes cruft comment * cleans up code a teeny bit, upgrades to incapacitated * wait that named arg is still there wtf * Review Time Co-authored-by: Seth Scherer * wrong operator and wrong order of operations * null out the container Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> * checks to see if container is qdeld * weakref time Co-authored-by: Seth Scherer Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> --- code/__DEFINES/traits.dm | 2 ++ code/datums/components/itembound.dm | 30 +++++++++++++++++++++++++++ code/game/objects/items/food/bread.dm | 4 ++++ code/modules/admin/verbs/adminfun.dm | 6 ++++-- tgstation.dme | 1 + 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 code/datums/components/itembound.dm diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 014cf189df2..e59a1f31680 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -676,6 +676,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define QUIRK_TRAIT "quirk_trait" /// (B)admins only. #define ADMIN_TRAIT "admin" +/// Any traits given through a smite. +#define SMITE_TRAIT "smite" #define CHANGELING_TRAIT "changeling" #define CULT_TRAIT "cult" #define LICH_TRAIT "lich" diff --git a/code/datums/components/itembound.dm b/code/datums/components/itembound.dm new file mode 100644 index 00000000000..3cd88a86fd6 --- /dev/null +++ b/code/datums/components/itembound.dm @@ -0,0 +1,30 @@ +/// When a movable has this component AND they are in the contents of a container, they will no longer be able to use their hands and be immobilized until they are removed from the container. So far, this is only useful for smites. +/datum/component/itembound + /// Weak reference to the container that the movable is inside of. + var/datum/weakref/containerref + /// Detect any movement of the container + var/datum/movement_detector/move_tracker + +/datum/component/itembound/Initialize(atom/movable/passed_container) + if(!ismovable(parent)) + return COMPONENT_INCOMPATIBLE + if(QDELETED(passed_container)) + return + containerref = WEAKREF(passed_container) + move_tracker = new(parent, CALLBACK(src, .proc/verify_containment)) + + ADD_TRAIT(parent, TRAIT_INCAPACITATED, SMITE_TRAIT) + +/// Ensure that when we move, we still are in the container. If not in the container, remove all the traits. +/datum/component/itembound/proc/verify_containment() + var/atom/movable/container = containerref.resolve() + if(!QDELETED(container) && container.contains(parent)) + return + REMOVE_TRAIT(parent, TRAIT_INCAPACITATED, SMITE_TRAIT) + qdel(src) + +/datum/component/itembound/Destroy(force, silent) + containerref = null + QDEL_NULL(move_tracker) + return ..() + diff --git a/code/game/objects/items/food/bread.dm b/code/game/objects/items/food/bread.dm index c0a33647e7b..487a3c2ff84 100644 --- a/code/game/objects/items/food/bread.dm +++ b/code/game/objects/items/food/bread.dm @@ -40,6 +40,10 @@ /obj/item/food/bread/plain/MakeProcessable() AddElement(/datum/element/processable, TOOL_KNIFE, /obj/item/food/breadslice/plain, 5, 3 SECONDS, table_required = TRUE) +// special subtype we use for the "Bread" Admin Smite (or the breadify proc) +/obj/item/food/bread/plain/smite + desc = "If you hold it up to your ear, you can hear the screams of the damned." + /obj/item/food/breadslice/plain name = "bread slice" desc = "A slice of home." diff --git a/code/modules/admin/verbs/adminfun.dm b/code/modules/admin/verbs/adminfun.dm index 1bb8e566ead..04baa88626f 100644 --- a/code/modules/admin/verbs/adminfun.dm +++ b/code/modules/admin/verbs/adminfun.dm @@ -217,9 +217,11 @@ return smite.effect(src, target) +///"Turns" people into bread. Really, we just add them to the contents of the bread food item. /proc/breadify(atom/movable/target) - var/obj/item/food/bread/plain/bread = new(get_turf(target)) - target.forceMove(bread) + var/obj/item/food/bread/plain/smite/tomb = new(get_turf(target)) + target.forceMove(tomb) + target.AddComponent(/datum/component/itembound, tomb) /** * firing_squad is a proc for the :B:erforate smite to shoot each individual bullet at them, so that we can add actual delays without sleep() nonsense diff --git a/tgstation.dme b/tgstation.dme index 1936d0d360a..e200dbd2f63 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -811,6 +811,7 @@ #include "code\datums\components\igniter.dm" #include "code\datums\components\infective.dm" #include "code\datums\components\irradiated.dm" +#include "code\datums\components\itembound.dm" #include "code\datums\components\itempicky.dm" #include "code\datums\components\jetpack.dm" #include "code\datums\components\jousting.dm"