mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-10 17:52:36 +00:00
* ice demon basic mobs * Modular updates * Modular updates --------- Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: Giz <13398309+vinylspiders@users.noreply.github.com>
36 lines
1.2 KiB
Plaintext
36 lines
1.2 KiB
Plaintext
/*
|
|
* A component given to mobs to damage a linked mob
|
|
*/
|
|
/datum/component/joint_damage
|
|
///the mob we will damage
|
|
var/datum/weakref/overlord_mob
|
|
///our last health count
|
|
var/previous_health_count
|
|
|
|
/datum/component/joint_damage/Initialize(mob/overlord_mob)
|
|
if(!isliving(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
var/mob/living/parent_mob = parent
|
|
previous_health_count = parent_mob.health
|
|
if(overlord_mob)
|
|
src.overlord_mob = WEAKREF(overlord_mob)
|
|
|
|
/datum/component/joint_damage/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_LIVING_HEALTH_UPDATE, PROC_REF(damage_overlord))
|
|
RegisterSignal(parent, COMSIG_LIVING_DEATH, PROC_REF(damage_overlord))
|
|
|
|
/datum/component/joint_damage/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_LIVING_HEALTH_UPDATE, COMSIG_LIVING_DEATH))
|
|
|
|
/datum/component/joint_damage/Destroy()
|
|
overlord_mob = null
|
|
return ..()
|
|
|
|
/datum/component/joint_damage/proc/damage_overlord(mob/living/source)
|
|
SIGNAL_HANDLER
|
|
|
|
var/mob/living/overlord_to_damage = overlord_mob?.resolve()
|
|
if(!isnull(overlord_to_damage))
|
|
overlord_to_damage.adjustBruteLoss(previous_health_count - source.health) ///damage or heal overlord
|
|
previous_health_count = source.health
|