Files
Bubberstation/code/datums/elements/mob_grabber.dm
MrMelbert 9664d24c13 Refactors UnarmedAttack so we don't have like 4 Unarmed Attack signals, kills two more snowflake species procs (#78991)
## About The Pull Request

- Deletes `spec_unarmedattack`
- Deletes `spec_unarmedattacked`
- Replaces `COMSIG_HUMAN_EARLY_UNARMED_ATTACK` with
`COMSIG_LIVING_EARLY_UNARMED_ATTACK`
- Replaces uses of `COMSIG_HUMAN_MELEE_UNARMED_ATTACK` with
`COMSIG_LIVING_EARLY_UNARMED_ATTACK`
- Fixes(?)(I've never seen this work) / Elementizes Monkey ability to
bite while handcuffed
- Monkey clever `attack paw` / `attack hand` thing is now handled the
same on the human level (via `resolve_unarmed_attack`)

## Why It's Good For The Game

Atomized from swing branch. I was really annoyed with these two signals,
this kinda unifies the behavior between living and human mobs (they were
already quite similar).

One thing of note is that this will make dis-coordinated humans use
`attack_paw` rather than `attack_hand`, so they'll bite people instead
of punching them. I'm not sure if this is what we want, if we wanna
tweak that before then I can by all means.

## Changelog

🆑 Melbert
refactor: Refactored unarmed attacking mechanisms, this means
dis-coordinated humans will now bite people like monkeys (like how
coordinated monkeys punch people like humans?)
refactor: Dis-coordinated humans smashing up machines now use their
hands, rather than their paws
/🆑

---------

Co-authored-by: san7890 <the@san7890.com>
2023-10-15 22:25:19 -06:00

32 lines
1.2 KiB
Plaintext

/// Grab onto mobs we attack
/datum/element/mob_grabber
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// What state must the mob be in to be grabbed?
var/minimum_stat
/// If someone else is already grabbing this, will we take it?
var/steal_from_others
/datum/element/mob_grabber/Attach(datum/target, minimum_stat = SOFT_CRIT, steal_from_others = TRUE)
. = ..()
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
src.minimum_stat = minimum_stat
src.steal_from_others = steal_from_others
RegisterSignals(target, list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_HOSTILE_PRE_ATTACKINGTARGET), PROC_REF(grab_mob))
/datum/element/mob_grabber/Detach(datum/source)
UnregisterSignal(source, list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_HOSTILE_PRE_ATTACKINGTARGET))
. = ..()
/// Try and grab something we attacked
/datum/element/mob_grabber/proc/grab_mob(mob/living/source, mob/living/target, proximity, modifiers)
SIGNAL_HANDLER
if (!isliving(target) || !proximity || target.stat < minimum_stat)
return NONE
var/atom/currently_pulled = target.pulledby
if (!isnull(currently_pulled) && (!steal_from_others || currently_pulled == source))
return NONE
INVOKE_ASYNC(target, TYPE_PROC_REF(/mob/living, grabbedby), source)
return COMPONENT_CANCEL_ATTACK_CHAIN