Files
Bubberstation/code/datums/elements/window_smash.dm
GhomandGitHub 54df8cab2d Moved a few monkeys features out of species code (+ updated a couple infusion organs) (#96735)
## About The Pull Request
Title. I'm moving a few monkey features away from the species and into
its bodyparts and organs. I plan on following up with another PR for the
various `ismonkey()` in the code, as these are necessary changes for a
niche thing I'm ultimately working on.

Also one carp organ and one stoat organ both had bits of code made
redundant by available traits. This takes care of them.
Also removed the passwindow_on/off and passtable_on/off procs. We can
just register the associated trait signals on init for living mobs (plus
they were being misused on non-mobs).

## Why It's Good For The Game
Less code associated directly to the species and more to its body parts
and organs, which is basically something we've been doing for a few
years ~~(also I need it for skeletonized monkeys)~~.

## Changelog
N/A
2026-07-11 21:51:39 +01:00

34 lines
1.3 KiB
Plaintext

/**
* # Window Smashing
* An element you put on mobs to let them smash through walls on movement
* For example, throwing someone through a glass window
*/
/datum/element/window_smashing
/datum/element/window_smashing/Attach(datum/target, duration = 1.5 SECONDS)
. = ..()
if(!isliving(target))
return ELEMENT_INCOMPATIBLE
var/mob/living/living_target = target
RegisterSignal(living_target, COMSIG_MOVABLE_MOVED, PROC_REF(flying_window_smash))
ADD_TRAIT(target, TRAIT_PASSWINDOW, TRAM_PASSENGER_TRAIT)
addtimer(CALLBACK(src, PROC_REF(Detach), living_target), duration)
/// Smash any windows that the mob is flying through
/datum/element/window_smashing/proc/flying_window_smash(atom/movable/flying_mob, atom/old_loc, direction)
SIGNAL_HANDLER
var/turf/target_turf = get_turf(flying_mob)
for(var/obj/structure/tram/tram_wall in target_turf)
tram_wall.smash_and_injure(flying_mob, old_loc, direction)
for(var/obj/structure/window/window in target_turf)
window.smash_and_injure(flying_mob, old_loc, direction)
for(var/obj/structure/grille/grille in target_turf)
grille.smash_and_injure(flying_mob, old_loc, direction)
/datum/element/window_smashing/Detach(datum/source)
UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
REMOVE_TRAIT(source, TRAIT_PASSWINDOW, TRAM_PASSENGER_TRAIT)
return ..()