Files
Bubberstation/code/datums/components/itembound.dm
SkyratBot cb4f6915d9 [MIRROR] Fixes Bread Smite Causing Some Fucked Up Shit [MDB IGNORE] (#16254)
* 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 <supernovaa41@ gmx.com>

* 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 <supernovaa41@ gmx.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@ users.noreply.github.com>

* Fixes Bread Smite Causing Some Fucked Up Shit

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Seth Scherer <supernovaa41@ gmx.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@ users.noreply.github.com>
2022-09-15 11:32:16 -07:00

31 lines
1.2 KiB
Plaintext

/// 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 ..()