mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-26 09:03:37 +00:00
* Cosmic Ascension Balance Patch * conflict --------- Co-authored-by: Comxy <tijntensen@gmail.com> Co-authored-by: Tom <8881105+tf-4@users.noreply.github.com>
30 lines
926 B
Plaintext
30 lines
926 B
Plaintext
/**
|
|
* ## death linkage element!
|
|
*
|
|
* Bespoke element that when the owner dies, the linked mob dies too.
|
|
*/
|
|
/datum/element/death_linked
|
|
element_flags = ELEMENT_BESPOKE
|
|
argument_hash_start_idx = 3
|
|
///The mob that also dies when the user dies
|
|
var/datum/weakref/linked_mob
|
|
|
|
/datum/element/death_linked/Attach(datum/target, mob/living/target_mob)
|
|
. = ..()
|
|
if(!isliving(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
if(!target_mob)
|
|
stack_trace("[type] added to [target] with NO MOB.")
|
|
src.linked_mob = WEAKREF(target_mob)
|
|
RegisterSignal(target, COMSIG_LIVING_DEATH, PROC_REF(on_death))
|
|
|
|
/datum/element/death_linked/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, COMSIG_LIVING_DEATH)
|
|
|
|
///signal called by the stat of the target changing
|
|
/datum/element/death_linked/proc/on_death(mob/living/target, gibbed)
|
|
SIGNAL_HANDLER
|
|
var/mob/living/linked_mob_resolved = linked_mob?.resolve()
|
|
linked_mob_resolved?.death(TRUE)
|