Files
Bubberstation/code/datums/elements/orbit_twitcher.dm
T
MrMelbertandGitHub 024a276dcc Recovered crew/Thanatorenasia bodies are shown as "revivable" when orbited in a morgue tray (+makes it shake) (#95602)
## About The Pull Request

If you orbit a recovered crewmember or thanatorenasia body situated in a
morgue, the indicated will change from red to green, indicating the body
is revivable

Additionally, orbiting a recovered crewmember or thanatorenasia body
will cause morgues or bodybags to shake. This is an extension of the
existing behavior where orbiting the body causes it to twitch.

## Why It's Good For The Game

Allows doctors to store bodies in a safe place while they wait for a
ghost to occupy it, also means you don't have to repeatedly defib them.

## Changelog

🆑 Melbert
qol: Recovered crew/Thanatorenasia bodies in morgue trays change the
indicator to green when a ghost is orbiting them (to allow ghosts to
signal they want it to be revived)
qol: Recovered crew/Thanatorenasia bodies now cause morgue trays /
bodybags to shake when orbited, much like how the body itself shakes
when orbited (to allow ghosts to signal they want it to be revived)
/🆑
2026-04-03 22:56:37 +02:00

56 lines
1.7 KiB
Plaintext

/datum/element/orbit_twitcher
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH_ON_HOST_DESTROY
argument_hash_start_idx = 2
/// Chance we have to twitch per second
var/twitch_chance
/// Those who are being orbited and should twitch
var/list/twitchers = list()
/datum/element/orbit_twitcher/Attach(datum/target, twitch_chance)
. = ..()
if(!isliving(target))
return ELEMENT_INCOMPATIBLE
src.twitch_chance = twitch_chance
RegisterSignal(target, COMSIG_ATOM_ORBIT_BEGIN, PROC_REF(orbit_begin))
RegisterSignal(target, COMSIG_ATOM_ORBIT_STOP, PROC_REF(orbit_stop))
/datum/element/orbit_twitcher/Detach(datum/source, ...)
. = ..()
twitchers.Remove(source)
UnregisterSignal(source, list(COMSIG_ATOM_ORBIT_BEGIN, COMSIG_ATOM_ORBIT_STOP))
/datum/element/orbit_twitcher/process(seconds_per_tick)
for(var/mob/living/living as anything in twitchers)
if(SPT_PROB(twitch_chance, seconds_per_tick))
if(prob(60))
living.emote("twitch_s", forced = TRUE)
else
living.emote("twitch", forced = TRUE)
// if we're in a bodybag or morgue slab go up a level and shake that as well
var/obj/container = get(living, /obj/structure/bodycontainer) || get(living, /obj/structure/closet/body_bag)
if(!isnull(container))
container.Shake(2, 1, 0.3 SECONDS, 0.1 SECONDS)
/datum/element/orbit_twitcher/proc/orbit_begin(atom/source, atom/orbiter)
SIGNAL_HANDLER
twitchers.Add(source)
// It checks if we're already processing so it's fine to always call
START_PROCESSING(SSdcs, src)
/datum/element/orbit_twitcher/proc/orbit_stop(atom/source, atom/orbiter)
SIGNAL_HANDLER
twitchers.Remove(source)
if(!twitchers.len)
STOP_PROCESSING(SSdcs, src)
/datum/element/orbit_twitcher/OnTargetDelete(datum/source)
twitchers.Remove(source)
return ..()