Files
Bubberstation/code/datums/elements/living_limb_initialiser.dm
Jacquerel 4019835b3e Living Limb fixes (feat: Basic mobs attack random body zones again) (#82556)
## About The Pull Request

Reworks Living Limb code to fix a bunch of runtimes and issues I saw
while testing Bioscrambler.
Specifically, the contained mobs are now initialised via element
following attachment so that signal registration can occur at the
correct time. This allows limbs to function correctly when added from
nullspace via admin panel or bioscrambler.

Secondarily (and more wide-ranging) at some point (probably #79563) we
inadvertently made basic mobs only attack the target's chest instead of
spreading damage.
This is problematic for Living Flesh which can only attach itself to
damaged limbs but was left unable to attack damaged limbs.

I've fixed this in a way which is maybe stupid: adding an element which
randomises attack zone pre-attack.
Living limbs also limit this to _only_ limbs (although it will fall back
to chest if you have no limbs at all).
This is _technically_ still different, the previous behaviour used
`adjustBruteLoss` and `adjustFireLoss` and would spread the damage
across your entire body, but there isn't a route to that via the new
interface and this seems close enough.

## Changelog

🆑
fix: Living Limbs created by Bioscrambler will be alive.
fix: Living Limbs can once more attach themselves to your body.
balance: Living Limbs will prioritise attacking your limbs.
fix: Basic Mobs will once again spread their damage across body zones
instead of only attacking your chest.
/🆑
2024-04-13 15:30:14 -06:00

20 lines
757 B
Plaintext

/// Spawns a living limb mob inside a limb upon attachment if it doesn't have one
/datum/element/living_limb_initialiser
/datum/element/living_limb_initialiser/Attach(atom/target)
. = ..()
if(!isbodypart(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_BODYPART_CHANGED_OWNER, PROC_REF(try_animate_limb))
/datum/element/living_limb_initialiser/Detach(atom/target)
UnregisterSignal(target, COMSIG_BODYPART_CHANGED_OWNER)
return ..()
/// Create a living limb mob inside the limb if it doesn't already have one
/datum/element/living_limb_initialiser/proc/try_animate_limb(obj/item/bodypart/part)
SIGNAL_HANDLER
if (locate(/mob/living/basic/living_limb_flesh) in part)
return
new /mob/living/basic/living_limb_flesh(part, part)