Files
Bubberstation/code/datums/elements/basic_stamina_slowdown.dm
Jacquerel d19b8de989 Most fleshy mobs are vulnerable to stamina and stuns (#90675)
## About The Pull Request

This PR enables most mobs to take stamina damage, become slowed as a
result of taking stamina damage.
It also gives most mobs CANSTUN which not only allows them to enter
stamcrit from taking stamina damage but also makes them vulnerable to
mechanics like stun batons.

Mobs which already took stamina damage (Spiders and Space Dragons) still
work the same way.
Mechanical or artificial mobs, mining mobs, simple xenomorphs, ghosts,
and most kinds of mob closely associated with antagonists still don't
take stamina damage.

## Why It's Good For The Game

A new player armed with a disabler will probably try and use it on
aggressive animals and be disappointed, but I don't think there is any
_reason_ for them to be disappointed when it's already something they
are doing merely to delay being attacked rather than to kill the target.
It's not intuitive for these mechanics not to function against simple
mobs when they do against humans, _especially_ the kinds of mobs which
look like humans, and there isn't any technical reason why it _couldn't_
work against most mobs which it looks like they should work against.

While this reduces the threat level of some mobs against Security
players I think the greater interaction with the sandbox is beneficial.
I'm hopeful it doesn't have that much effect on many of the most common
places you encounter dangerous mobs like Space Ruins or Gateways as they
are also places where you can't reliably recharge your energy-based
stamina weapons as most that don't require energy do require getting
into melee and endangering yourself.

## Changelog

🆑
balance: Most biological mobs are now slowed by taking stamina damage,
and can be stunned. Mechanical mobs, mining mobs, and several other
special kinds (chiefly those invoked by antagonists) are unaffected. If
this seems to effect any mob it probably shouldn't, please report it as
a bug.
/🆑
2025-05-11 05:05:53 +10:00

34 lines
1.5 KiB
Plaintext

/// Applies a simple scaling slowdown as a mob's stamina is depleted
/datum/element/basic_stamina_slowdown
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// How much stamina damage need we take before we start moving slower?
var/minium_stamina_threshold
/// How much stamina damage can we have at maximum?
var/maximum_stamina
/// How slow do we move with the maximum stamina damage?
var/maximum_slowdown
/datum/element/basic_stamina_slowdown/Attach(datum/target, minium_stamina_threshold = 40, maximum_stamina = 120, maximum_slowdown = 12)
. = ..()
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
src.minium_stamina_threshold = minium_stamina_threshold
src.maximum_stamina = maximum_stamina
src.maximum_slowdown = maximum_slowdown
RegisterSignal(target, COMSIG_LIVING_STAMINA_UPDATE, PROC_REF(on_stamina_changed))
/datum/element/basic_stamina_slowdown/Detach(datum/source)
. = ..()
UnregisterSignal(source, COMSIG_LIVING_STAMINA_UPDATE)
/// When our stamina changes check how slow we should be
/datum/element/basic_stamina_slowdown/proc/on_stamina_changed(mob/living/source)
SIGNAL_HANDLER
if (source.staminaloss >= minium_stamina_threshold)
var/current_slowdown = (source.staminaloss / maximum_stamina) * maximum_slowdown
source.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/basic_stamina_slowdown, TRUE, multiplicative_slowdown = current_slowdown)
else
source.remove_movespeed_modifier(/datum/movespeed_modifier/basic_stamina_slowdown)