Files
Bubberstation/code/datums/elements/skittish.dm
AnturK 4d6a8bc537 515 Compatibility (#71161)
Makes the code compatible with 515.1594+

Few simple changes and one very painful one.
Let's start with the easy:
* puts call behind `LIBCALL` define, so call_ext is properly used in 515
* Adds `NAMEOF_STATIC(_,X)` macro for nameof in static definitions since
src is now invalid there.
* Fixes tgui and devserver. From 515 onward the tmp3333{procid} cache
directory is not appened to base path in browser controls so we don't
check for it in base js and put the dev server dummy window file in
actual directory not the byond root.
* Renames the few things that had /final/ in typepath to ultimate since
final is a new keyword

And the very painful change:
`.proc/whatever` format is no longer valid, so we're replacing it with
new nameof() function. All this wrapped in three new macros.
`PROC_REF(X)`,`TYPE_PROC_REF(TYPE,X)`,`GLOBAL_PROC_REF(X)`. Global is
not actually necessary but if we get nameof that does not allow globals
it would be nice validation.
This is pretty unwieldy but there's no real alternative.
If you notice anything weird in the commits let me know because majority
was done with regex replace.

@tgstation/commit-access Since the .proc/stuff is pretty big change.

Co-authored-by: san7890 <the@san7890.com>
Co-authored-by: Mothblocks <35135081+Mothblocks@users.noreply.github.com>
2022-11-15 03:50:11 +00:00

62 lines
1.7 KiB
Plaintext

/*
* An element that makes mobs run into lockers when they bump into them.
*/
/datum/element/skittish
/datum/element/skittish/Attach(datum/target)
. = ..()
if(!isliving(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_MOVABLE_BUMP, PROC_REF(Bump))
/datum/element/skittish/Detach(datum/target)
UnregisterSignal(target, COMSIG_MOVABLE_BUMP)
. = ..()
/datum/element/skittish/proc/Bump(mob/living/scooby, atom/target)
SIGNAL_HANDLER
if(scooby.stat != CONSCIOUS || scooby.m_intent != MOVE_INTENT_RUN)
return
if(!istype(target, /obj/structure/closet))
return
var/obj/structure/closet/closet = target
if(!closet.divable)
// Things like secure crates can blow up under certain circumstances
return
var/turf/closet_turf = get_turf(closet)
if(!closet.opened)
if(closet.locked)
closet.togglelock(scooby, silent = TRUE)
if(!closet.open(scooby))
// No message if unable to open, since this is on Bump, spammy potential
return
// If it's a crate, "dive for cover" and start resting so people can jump into crates without slamming the lid on their head
if(closet.horizontal)
// need to rest before moving, otherwise "can't get crate to close" message will be printed erroneously
scooby.set_resting(TRUE, silent = TRUE)
scooby.forceMove(closet_turf)
if(!closet.close(scooby))
to_chat(scooby, span_warning("You can't get [closet] to close!"))
if(closet.horizontal)
scooby.set_resting(FALSE, silent = TRUE)
return
closet.togglelock(scooby, silent = TRUE)
if(closet.horizontal)
scooby.set_resting(FALSE, silent = TRUE)
closet_turf.visible_message(span_warning("[scooby] dives into [closet]!"))
// If you run into a locker, you don't want to run out immediately
scooby.Immobilize(0.5 SECONDS)