Files
Bubberstation/code/datums/elements/web_walker.dm
SkyratBot f194b57feb [MIRROR] Basic Mob Spiders II: Elements [MDB IGNORE] (#19268)
* Basic Mob Spiders II: Elements

* Update giant_spider.dm

---------

Co-authored-by: Jacquerel <hnevard@gmail.com>
Co-authored-by: lessthanthree <83487515+lessthnthree@users.noreply.github.com>
Co-authored-by: lessthnthree <three@lessthanthree.dk>
2023-03-01 11:57:49 -08:00

33 lines
998 B
Plaintext

/**
* # Web Walker element
*
* A mob with this element will move more slowly when it's not stood on a webbed turf.
*/
/datum/element/web_walker
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
/// Move speed modifier to apply when not stood on webs
var/datum/movespeed_modifier/off_web_slowdown
/datum/element/web_walker/Attach(datum/target, datum/movespeed_modifier/off_web_slowdown)
. = ..()
if (!isliving(target))
return ELEMENT_INCOMPATIBLE
src.off_web_slowdown = off_web_slowdown
RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
/datum/element/web_walker/Detach(datum/source)
. = ..()
UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
/// When we move, check if we're still on a web
/datum/element/web_walker/proc/on_moved(mob/living/source)
SIGNAL_HANDLER
var/obj/structure/spider/stickyweb/web = locate() in get_turf(source)
if (web)
source.remove_movespeed_modifier(off_web_slowdown)
else
source.add_movespeed_modifier(off_web_slowdown)