Files
san7890andGitHub 0cd21f110c fixes silly mistake in can_be_held element (#96960)
## About The Pull Request

Error from #96917 (cb535cdfa6)

We shouldn't be calling `mob_try_pickup` on the other pathways, that's
the responsibility of the mousedrop proc. The other two signal handling
procs on this element exist only to block storage dumping/stripping when
the mousedrop proc is working. I think I didn't catch this in testing
because it's an invisible bug that gets obfuscated by the `do_after()`
but I pretty obviously fell asleep at the wheel here and added this
extra code when it's definitely not meant to work that way.

I'm gonna do a CL because I forgot to mention something in the original
refactor's changelog so people might be more aware of the new mechanic
that I forgot to mention (implemented to better reliably parse intent
and be less ambiguous)

🆑
refactor: Picking up your pets (or any holdable mob) requires an
aggressive grab now.
/🆑
2026-07-15 00:05:03 +01:00

50 lines
1.8 KiB
Plaintext

/datum/element/can_be_held
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/datum/element/can_be_held/Attach(datum/source)
. = ..()
if(!isliving(source))
return ELEMENT_INCOMPATIBLE
RegisterSignal(source, COMSIG_MOUSEDROP_ONTO, PROC_REF(on_mousedrop_onto))
RegisterSignal(source, COMSIG_MOB_STRIP_MENU_OPEN, PROC_REF(on_strip_menu_open))
RegisterSignal(source, COMSIG_STORAGE_DUMP_PRE_TRANSFER, PROC_REF(on_attempt_storage_dump))
/datum/element/can_be_held/Detach(datum/source)
UnregisterSignal(source, list(COMSIG_MOUSEDROP_ONTO, COMSIG_MOB_STRIP_MENU_OPEN, COMSIG_STORAGE_DUMP_PRE_TRANSFER))
return ..()
/// Used to determine the "intent" of the action that the user mob is trying to employ on the target.
/datum/element/can_be_held/proc/trying_to_hold_mob(mob/living/user, mob/living/target)
return isliving(user) && user.grab_state == GRAB_AGGRESSIVE && user.pulling == target
/// Handles the mob being dropped onto the user mob.
/datum/element/can_be_held/proc/on_mousedrop_onto(datum/source, atom/over, mob/user)
SIGNAL_HANDLER
if(!trying_to_hold_mob(user, source))
return
INVOKE_ASYNC(source, TYPE_PROC_REF(/mob/living, mob_try_pickup), user)
return COMPONENT_CANCEL_MOUSEDROP_ONTO
/// Blocks strip menu opening if we can reasonably assert that the mob is trying to be picked up
/datum/element/can_be_held/proc/on_strip_menu_open(datum/source, atom/over, mob/user)
SIGNAL_HANDLER
if(!trying_to_hold_mob(user, source))
return
return COMPONENT_BLOCK_STRIP_MENU_OPEN
/// Blocks storage dumping if we can reasonably assert that the mob is trying to be picked up
/datum/element/can_be_held/proc/on_attempt_storage_dump(datum/source, atom/over, mob/user)
SIGNAL_HANDLER
if(!trying_to_hold_mob(user, source))
return
return CANCEL_STORAGE_DUMP