mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-01 12:31:32 +00:00
34 lines
1.2 KiB
Plaintext
34 lines
1.2 KiB
Plaintext
/**
|
|
* tenacious element; which makes the parent move faster while crawling
|
|
*
|
|
* Used by sparring sect!
|
|
*/
|
|
/datum/element/tenacious
|
|
element_flags = ELEMENT_DETACH
|
|
|
|
/datum/element/tenacious/Attach(datum/target)
|
|
. = ..()
|
|
|
|
if(!ishuman(target))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/mob/living/carbon/human/valid_target = target
|
|
on_stat_change(valid_target, new_stat = valid_target.stat) //immediately try adding movement bonus if they're in soft crit
|
|
RegisterSignal(target, COMSIG_MOB_STATCHANGE, .proc/on_stat_change)
|
|
ADD_TRAIT(target, TRAIT_TENACIOUS, ELEMENT_TRAIT(type))
|
|
|
|
/datum/element/tenacious/Detach(datum/target)
|
|
UnregisterSignal(target, COMSIG_MOB_STATCHANGE)
|
|
REMOVE_TRAIT(target, TRAIT_TENACIOUS, ELEMENT_TRAIT(type))
|
|
return ..()
|
|
|
|
///signal called by the stat of the target changing
|
|
/datum/element/tenacious/proc/on_stat_change(mob/living/carbon/human/target, new_stat)
|
|
SIGNAL_HANDLER
|
|
|
|
if(new_stat == SOFT_CRIT)
|
|
target.balloon_alert(target, "your tenacity kicks in")
|
|
target.add_movespeed_modifier(/datum/movespeed_modifier/tenacious)
|
|
else
|
|
target.balloon_alert(target, "your tenacity wears off")
|
|
target.remove_movespeed_modifier(/datum/movespeed_modifier/tenacious)
|