Files
Bubberstation/code/datums/components/strong_pull.dm
SkyratBot c760326d93 [MIRROR] Trying to grab something restricted by HAUL gauntlets now has a Balloon alert. [MDB IGNORE] (#18824)
Trying to grab something restricted by HAUL gauntlets now has a Balloon alert. (#72758)

## About The Pull Request

Part of #72710 that I think is useful to be PRed even if the original is
closed. When you try to grab someone or something restrained by HAUL
gauntlets theres now a balloon alert telling you that its gripped too
strongly, rather than no indication at all.
## Why It's Good For The Game

There being no player facing indication to attempting to steal an item
being pulled by HAUL gauntlets seemed odd to me as without the feedback
its easy to mistake it for just missing the grab.
## Changelog
🆑
qol: Theres now a visual indicator when you attempt to grab an object or
person restrained by the HAUL gauntlets.
/🆑

Co-authored-by: NamelessFairy <40036527+NamelessFairy@users.noreply.github.com>
2023-01-19 16:10:35 -05:00

59 lines
2.1 KiB
Plaintext

/*
This component attaches to mobs, and makes their pulls !strong!
Basically, the items they pull cannot be pulled (except by the puller)
*/
/datum/component/strong_pull
var/atom/movable/strongpulling
/datum/component/strong_pull/Initialize()
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
/datum/component/strong_pull/Destroy(force, silent)
if(strongpulling)
lose_strong_grip()
return ..()
/datum/component/strong_pull/RegisterWithParent()
. = ..()
RegisterSignal(parent, COMSIG_LIVING_START_PULL, PROC_REF(on_pull))
/**
* Called when the parent grabs something, adds signals to the object to reject interactions
*/
/datum/component/strong_pull/proc/on_pull(datum/source, atom/movable/pulled, state, force)
SIGNAL_HANDLER
strongpulling = pulled
RegisterSignal(strongpulling, COMSIG_ATOM_CAN_BE_PULLED, PROC_REF(reject_further_pulls))
RegisterSignal(strongpulling, COMSIG_ATOM_NO_LONGER_PULLED, PROC_REF(on_no_longer_pulled))
if(istype(strongpulling, /obj/structure/closet) && !istype(strongpulling, /obj/structure/closet/body_bag))
var/obj/structure/closet/grabbed_closet = strongpulling
grabbed_closet.strong_grab = TRUE
/**
* Signal for rejecting further grabs
*/
/datum/component/strong_pull/proc/reject_further_pulls(datum/source, mob/living/puller)
SIGNAL_HANDLER
if(puller != parent) //for increasing grabs, you need to have a valid pull. thus, parent should be able to pull the same object again
strongpulling.balloon_alert(puller, "gripped too tightly!")
return COMSIG_ATOM_CANT_PULL
/*
* Unregisters signals and stops any buffs to pulling.
*/
/datum/component/strong_pull/proc/lose_strong_grip()
UnregisterSignal(strongpulling, list(COMSIG_ATOM_CAN_BE_PULLED, COMSIG_ATOM_NO_LONGER_PULLED))
if(istype(strongpulling, /obj/structure/closet))
var/obj/structure/closet/ungrabbed_closet = strongpulling
ungrabbed_closet.strong_grab = FALSE
strongpulling = null
/**
* Called when the hooked object is no longer pulled and removes the strong grip.
*/
/datum/component/strong_pull/proc/on_no_longer_pulled(datum/source, atom/movable/last_puller)
SIGNAL_HANDLER
lose_strong_grip()