Files
Bubberstation/code/datums/components/slippery.dm
SkyratBot 2ee5d422ae [MIRROR] Refactors how movetype flags are added and removed and the floating animation (#2096)
* Refactors how movetype flags are added and removed and the floating animation (#54963)

I wanted to refactor how movetype flags are added and removed into traits to prevent multiple sources of specific movement types from conflicting one other. I ended up also having to refactor the floating animation loop (the one that bobs up and down) code in the process.
Why It's Good For The Game

A way to avoid conflict from multiple sources of movement types.
This also stops melee attacks, jitteriness and update_transform() from temporarily disabling the floating movetype bitflag altogether until the next life tick.

Tested, but i'm pretty sure improvements could be made.
Changelog

cl
fix: jitteriness, melee attack animations and resting/standing up should no longer momentarily remove the floating movement type.
/cl

* Refactors how movetype flags are added and removed and the floating animation

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2020-12-09 23:43:42 +01:00

42 lines
1.6 KiB
Plaintext

/datum/component/slippery
var/force_drop_items = FALSE
var/knockdown_time = 0
var/paralyze_time = 0
var/lube_flags
var/datum/callback/callback
/datum/component/slippery/Initialize(_knockdown, _lube_flags = NONE, datum/callback/_callback, _paralyze, _force_drop = FALSE)
knockdown_time = max(_knockdown, 0)
paralyze_time = max(_paralyze, 0)
force_drop_items = _force_drop
lube_flags = _lube_flags
callback = _callback
RegisterSignal(parent, list(COMSIG_MOVABLE_CROSSED, COMSIG_ATOM_ENTERED), .proc/Slip)
RegisterSignal(parent, COMSIG_ITEM_WEARERCROSSED, .proc/Slip_on_wearer)
/datum/component/slippery/proc/Slip(datum/source, atom/movable/AM)
SIGNAL_HANDLER
var/mob/victim = AM
if(istype(victim) && !(victim.movement_type & FLYING) && victim.slip(knockdown_time, parent, lube_flags, paralyze_time, force_drop_items) && callback)
callback.Invoke(victim)
/datum/component/slippery/proc/Slip_on_wearer(datum/source, atom/movable/AM, mob/living/crossed)
SIGNAL_HANDLER
if(crossed.body_position == LYING_DOWN && !crossed.buckled)
Slip(source, AM)
/datum/component/slippery/clowning //used for making the clown PDA only slip if the clown is wearing his shoes and the elusive banana-skin belt
/datum/component/slippery/clowning/Slip_on_wearer(datum/source, atom/movable/AM, mob/living/crossed)
var/obj/item/I = crossed.get_item_by_slot(ITEM_SLOT_FEET)
if(crossed.body_position == LYING_DOWN && !crossed.buckled)
if(istype(I, /obj/item/clothing/shoes/clown_shoes))
Slip(source, AM)
else
to_chat(crossed,"<span class='warning'>[parent] failed to slip anyone. Perhaps I shouldn't have abandoned my legacy...</span>")