diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm index d16adbe07a7..97e80bc0b51 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_living.dm @@ -55,9 +55,34 @@ ///from base of element/bane/activate(): (item/weapon, mob/user) #define COMSIG_OBJECT_ON_BANING "obj_on_baning" -///from base of mob/living/on_damage_adjustment -#define COMSIG_LIVING_ADJUST_DAMAGE "living_adjust_damage" - #define COMPONENT_IGNORE_CHANGE (1<<0) +// adjust_x_loss messages sent from /mob/living/proc/adjust[x]Loss +/// Returned from all the following messages if you actually aren't going to apply any change +#define COMPONENT_IGNORE_CHANGE (1<<0) +// Each of these messages sends the damagetype even though it is inferred by the signal so you can pass all of them to the same proc if required +/// Send when bruteloss is modified (type, amount, forced) +#define COMSIG_LIVING_ADJUST_BRUTE_DAMAGE "living_adjust_brute_damage" +/// Send when fireloss is modified (type, amount, forced) +#define COMSIG_LIVING_ADJUST_BURN_DAMAGE "living_adjust_burn_damage" +/// Send when oxyloss is modified (type, amount, forced) +#define COMSIG_LIVING_ADJUST_OXY_DAMAGE "living_adjust_oxy_damage" +/// Send when toxloss is modified (type, amount, forced) +#define COMSIG_LIVING_ADJUST_TOX_DAMAGE "living_adjust_tox_damage" +/// Send when cloneloss is modified (type, amount, forced) +#define COMSIG_LIVING_ADJUST_CLONE_DAMAGE "living_adjust_clone_damage" +/// Send when staminaloss is modified (type, amount, forced) +#define COMSIG_LIVING_ADJUST_STAMINA_DAMAGE "living_adjust_stamina_damage" + +/// List of signals sent when you receive any damage except stamina +#define COMSIG_LIVING_ADJUST_STANDARD_DAMAGE_TYPES list(\ + COMSIG_LIVING_ADJUST_BRUTE_DAMAGE,\ + COMSIG_LIVING_ADJUST_BURN_DAMAGE,\ + COMSIG_LIVING_ADJUST_CLONE_DAMAGE,\ + COMSIG_LIVING_ADJUST_OXY_DAMAGE,\ + COMSIG_LIVING_ADJUST_TOX_DAMAGE,\ +) +/// List of signals sent when you receive any kind of damage at all +#define COMSIG_LIVING_ADJUST_ALL_DAMAGE_TYPES (COMSIG_LIVING_ADJUST_STANDARD_DAMAGE_TYPES + COMSIG_LIVING_ADJUST_STAMINA_DAMAGE) + /// from base of mob/living/updatehealth() #define COMSIG_LIVING_HEALTH_UPDATE "living_health_update" diff --git a/code/datums/components/mob_chain.dm b/code/datums/components/mob_chain.dm index a2b16a849a5..8312d9d5504 100644 --- a/code/datums/components/mob_chain.dm +++ b/code/datums/components/mob_chain.dm @@ -25,6 +25,8 @@ if (!isnull(front)) SEND_SIGNAL(front, COMSIG_MOB_GAINED_CHAIN_TAIL, parent) parent.AddComponent(/datum/component/leash, owner = front, distance = 1) // Handles catching up gracefully + var/mob/living/living_parent = parent + living_parent.set_glide_size(front.glide_size) /datum/component/mob_chain/Destroy(force, silent) if (!isnull(front)) @@ -42,11 +44,13 @@ RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved)) RegisterSignal(parent, COMSIG_ATOM_CAN_BE_PULLED, PROC_REF(on_pulled)) RegisterSignals(parent, list(COMSIG_LIVING_UNARMED_ATTACK, COMSIG_HUMAN_EARLY_UNARMED_ATTACK, COMSIG_MOB_ATTACK_RANGED), PROC_REF(on_attack)) + RegisterSignal(parent, COMSIG_MOVABLE_UPDATE_GLIDE_SIZE, PROC_REF(on_glide_size_changed)) if (vary_icon_state) RegisterSignal(parent, COMSIG_ATOM_UPDATE_ICON_STATE, PROC_REF(on_update_icon_state)) update_mob_appearance() if (pass_damage_back) - RegisterSignal(parent, COMSIG_LIVING_ADJUST_DAMAGE, PROC_REF(on_adjust_damage)) + RegisterSignals(parent, COMSIG_LIVING_ADJUST_STANDARD_DAMAGE_TYPES, PROC_REF(on_adjust_damage)) + RegisterSignal(parent, COMSIG_LIVING_ADJUST_STAMINA_DAMAGE, PROC_REF(on_adjust_stamina)) RegisterSignal(parent, COMSIG_CARBON_LIMB_DAMAGED, PROC_REF(on_limb_damage)) var/datum/action/cooldown/worm_contract/shrink = new(parent) @@ -58,14 +62,20 @@ COMSIG_ATOM_UPDATE_ICON_STATE, COMSIG_CARBON_LIMB_DAMAGED, COMSIG_HUMAN_EARLY_UNARMED_ATTACK, - COMSIG_LIVING_ADJUST_DAMAGE, + COMSIG_LIVING_ADJUST_BRUTE_DAMAGE, + COMSIG_LIVING_ADJUST_BURN_DAMAGE, + COMSIG_LIVING_ADJUST_CLONE_DAMAGE, COMSIG_LIVING_DEATH, + COMSIG_LIVING_ADJUST_OXY_DAMAGE, + COMSIG_LIVING_ADJUST_STAMINA_DAMAGE, + COMSIG_LIVING_ADJUST_TOX_DAMAGE, COMSIG_LIVING_UNARMED_ATTACK, COMSIG_MOB_ATTACK_RANGED, COMSIG_MOB_CHAIN_CONTRACT, COMSIG_MOB_GAINED_CHAIN_TAIL, COMSIG_MOB_LOST_CHAIN_TAIL, COMSIG_MOVABLE_MOVED, + COMSIG_MOVABLE_UPDATE_GLIDE_SIZE, COMSIG_QDELETING, )) qdel(parent.GetComponent(/datum/component/leash)) @@ -153,14 +163,23 @@ return INVOKE_ASYNC(back, TYPE_PROC_REF(/mob, ClickOn), target) +/// Maintain glide size backwards +/datum/component/mob_chain/proc/on_glide_size_changed(mob/living/our_mob, new_size) + SIGNAL_HANDLER + back?.set_glide_size(new_size) + +/// On gain or lose stamina, adjust our tail too +/datum/component/mob_chain/proc/on_adjust_stamina(mob/living/our_mob, type, amount, forced) + SIGNAL_HANDLER + if (forced) + return + back?.adjustStaminaLoss(amount, forced = forced) + /// On damage or heal, affect our furthest segment /datum/component/mob_chain/proc/on_adjust_damage(mob/living/our_mob, type, amount, forced) SIGNAL_HANDLER if (isnull(back) || forced) return - if (type == STAMINA) - back.adjustStaminaLoss(amount, forced = forced) - return // Pass stamina changes all the way along so we maintain consistent speed switch (type) if(BRUTE) back.adjustBruteLoss(amount, forced = forced) diff --git a/code/modules/mob/living/basic/health_adjustment.dm b/code/modules/mob/living/basic/health_adjustment.dm index 4ae129d9d66..9644a1a6299 100644 --- a/code/modules/mob/living/basic/health_adjustment.dm +++ b/code/modules/mob/living/basic/health_adjustment.dm @@ -18,9 +18,7 @@ return . - bruteloss /mob/living/basic/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype) - if(!forced && (status_flags & GODMODE)) - return 0 - if(on_damage_adjustment(BRUTE, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_brute_loss(amount, forced, required_bodytype)) return 0 if(forced) . = adjust_health(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -28,9 +26,7 @@ . = adjust_health(amount * damage_coeff[BRUTE] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/basic/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype) - if(!forced && (status_flags & GODMODE)) - return 0 - if(on_damage_adjustment(BURN, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_fire_loss(amount, forced, required_bodytype)) return 0 if(forced) . = adjust_health(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -38,9 +34,7 @@ . = adjust_health(amount * damage_coeff[BURN] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/basic/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype, required_respiration_type) - if(!forced && (status_flags & GODMODE)) - return 0 - if(on_damage_adjustment(OXY, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_oxy_loss(amount, forced, required_biotype, required_respiration_type)) return 0 if(forced) . = adjust_health(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -48,9 +42,7 @@ . = adjust_health(amount * damage_coeff[OXY] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/basic/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) - if(!forced && (status_flags & GODMODE)) - return 0 - if(on_damage_adjustment(TOX, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_tox_loss(amount, forced, required_biotype)) return 0 if(forced) . = adjust_health(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -58,7 +50,7 @@ . = adjust_health(amount * damage_coeff[TOX] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/basic/adjustCloneLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) - if(on_damage_adjustment(CLONE, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_clone_loss(amount, forced, required_biotype)) return 0 if(forced) . = adjust_health(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -66,7 +58,7 @@ . = adjust_health(amount * damage_coeff[CLONE] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/basic/adjustStaminaLoss(amount, updating_stamina = TRUE, forced = FALSE, required_biotype) - if(on_damage_adjustment(STAMINA, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_stamina_loss(amount, forced, required_biotype)) return 0 . = staminaloss if(forced) diff --git a/code/modules/mob/living/carbon/damage_procs.dm b/code/modules/mob/living/carbon/damage_procs.dm index d297296a4ec..040bf76a3db 100644 --- a/code/modules/mob/living/carbon/damage_procs.dm +++ b/code/modules/mob/living/carbon/damage_procs.dm @@ -56,9 +56,7 @@ return amount /mob/living/carbon/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype) - if(!forced && (status_flags & GODMODE)) - return 0 - if(on_damage_adjustment(BRUTE, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_brute_loss(amount, forced, required_bodytype)) return 0 if(amount > 0) . = take_overall_damage(brute = amount, updating_health = updating_health, forced = forced, required_bodytype = required_bodytype) @@ -75,9 +73,7 @@ return adjustBruteLoss(diff, updating_health, forced, required_bodytype) /mob/living/carbon/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype) - if(!forced && (status_flags & GODMODE)) - return 0 - if(on_damage_adjustment(BURN, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_fire_loss(amount, forced, required_bodytype)) return 0 if(amount > 0) . = take_overall_damage(burn = amount, updating_health = updating_health, forced = forced, required_bodytype = required_bodytype) @@ -94,11 +90,7 @@ return adjustFireLoss(diff, updating_health, forced, required_bodytype) /mob/living/carbon/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype = ALL) - if(!forced && (status_flags & GODMODE)) - return 0 - if(!forced && !(mob_biotypes & required_biotype)) - return 0 - if(on_damage_adjustment(TOX, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_tox_loss(amount, forced, required_biotype)) return 0 if(!forced && HAS_TRAIT(src, TRAIT_TOXINLOVER)) //damage becomes healing and healing becomes damage amount = -amount diff --git a/code/modules/mob/living/damage_procs.dm b/code/modules/mob/living/damage_procs.dm index 82425b27a5b..45a35bb6e15 100644 --- a/code/modules/mob/living/damage_procs.dm +++ b/code/modules/mob/living/damage_procs.dm @@ -159,23 +159,24 @@ return TRUE -/// Should be called by any adjustXLoss proc to send signalling information, returns a bit flag which may indicate that we don't want to make any adjustment -/mob/living/proc/on_damage_adjustment(damage_type, amount, forced) - return SEND_SIGNAL(src, COMSIG_LIVING_ADJUST_DAMAGE, damage_type, amount, forced) - /mob/living/proc/getBruteLoss() return bruteloss -/mob/living/proc/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype = ALL) +/mob/living/proc/can_adjust_brute_loss(amount, forced, required_bodytype) if(!forced && (status_flags & GODMODE)) - return 0 - if(on_damage_adjustment(BRUTE, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + if(SEND_SIGNAL(src, COMSIG_LIVING_ADJUST_BRUTE_DAMAGE, BRUTE, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + return TRUE + +/mob/living/proc/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype = ALL) + if (!can_adjust_brute_loss(amount, forced, required_bodytype)) return 0 . = bruteloss bruteloss = clamp((bruteloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) . -= bruteloss if(!.) // no change, no need to update - return FALSE + return 0 if(updating_health) updatehealth() @@ -195,19 +196,24 @@ /mob/living/proc/getOxyLoss() return oxyloss -/mob/living/proc/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype = ALL, required_respiration_type = ALL) +/mob/living/proc/can_adjust_oxy_loss(amount, forced, required_biotype, required_respiration_type) if(!forced) if(status_flags & GODMODE) - return 0 + return FALSE + if (required_respiration_type) + var/obj/item/organ/internal/lungs/affected_lungs = get_organ_slot(ORGAN_SLOT_LUNGS) + if(isnull(affected_lungs)) + if(!(mob_respiration_type & required_respiration_type)) // if the mob has no lungs, use mob_respiration_type + return FALSE + else + if(!(affected_lungs.respiration_type & required_respiration_type)) // otherwise use the lungs' respiration_type + return FALSE + if(SEND_SIGNAL(src, COMSIG_LIVING_ADJUST_OXY_DAMAGE, OXY, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + return TRUE - var/obj/item/organ/internal/lungs/affected_lungs = get_organ_slot(ORGAN_SLOT_LUNGS) - if(isnull(affected_lungs)) - if(!(mob_respiration_type & required_respiration_type)) // if the mob has no lungs, use mob_respiration_type - return 0 - else - if(!(affected_lungs.respiration_type & required_respiration_type)) // otherwise use the lungs' respiration_type - return 0 - if(on_damage_adjustment(OXY, amount, forced) & COMPONENT_IGNORE_CHANGE) +/mob/living/proc/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype = ALL, required_respiration_type = ALL) + if(!can_adjust_oxy_loss(amount, forced, required_biotype, required_respiration_type)) return 0 . = oxyloss oxyloss = clamp((oxyloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) @@ -240,13 +246,16 @@ /mob/living/proc/getToxLoss() return toxloss +/mob/living/proc/can_adjust_tox_loss(amount, forced, required_biotype) + if(!forced && ((status_flags & GODMODE) || !(mob_biotypes & required_biotype))) + return FALSE + if(SEND_SIGNAL(src, COMSIG_LIVING_ADJUST_TOX_DAMAGE, TOX, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + return TRUE + /mob/living/proc/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype = ALL) - if(!forced && (status_flags & GODMODE)) - return FALSE - if(on_damage_adjustment(TOX, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_tox_loss(amount, forced, required_biotype)) return 0 - if(!forced && !(mob_biotypes & required_biotype)) - return FALSE . = toxloss toxloss = clamp((toxloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) . -= toxloss @@ -271,10 +280,15 @@ /mob/living/proc/getFireLoss() return fireloss -/mob/living/proc/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype = ALL) +/mob/living/proc/can_adjust_fire_loss(amount, forced, required_bodytype) if(!forced && (status_flags & GODMODE)) - return 0 - if(on_damage_adjustment(BURN, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + if(SEND_SIGNAL(src, COMSIG_LIVING_ADJUST_BURN_DAMAGE, BURN, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + return TRUE + +/mob/living/proc/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype = ALL) + if(!can_adjust_fire_loss(amount, forced, required_bodytype)) return 0 . = fireloss fireloss = clamp((fireloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) @@ -298,10 +312,15 @@ /mob/living/proc/getCloneLoss() return cloneloss -/mob/living/proc/adjustCloneLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype = ALL) +/mob/living/proc/can_adjust_clone_loss(amount, forced, required_biotype) if(!forced && (!(mob_biotypes & required_biotype) || status_flags & GODMODE || HAS_TRAIT(src, TRAIT_NOCLONELOSS))) - return 0 - if(on_damage_adjustment(CLONE, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + if(SEND_SIGNAL(src, COMSIG_LIVING_ADJUST_CLONE_DAMAGE, CLONE, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + return TRUE + +/mob/living/proc/adjustCloneLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype = ALL) + if(!can_adjust_clone_loss(amount, forced, required_biotype)) return 0 . = cloneloss cloneloss = clamp((cloneloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, maxHealth * 2) @@ -336,10 +355,15 @@ /mob/living/proc/getStaminaLoss() return staminaloss +/mob/living/proc/can_adjust_stamina_loss(amount, forced, required_biotype) + if(!forced && (!(mob_biotypes & required_biotype) || status_flags & GODMODE)) + return FALSE + if(SEND_SIGNAL(src, COMSIG_LIVING_ADJUST_STAMINA_DAMAGE, STAMINA, amount, forced) & COMPONENT_IGNORE_CHANGE) + return FALSE + return TRUE + /mob/living/proc/adjustStaminaLoss(amount, updating_stamina = TRUE, forced = FALSE, required_biotype = ALL) - if(!forced && ((status_flags & GODMODE) || required_biotype && !(mob_biotypes & required_biotype))) - return 0 - if(on_damage_adjustment(STAMINA, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_stamina_loss(amount, forced, required_biotype)) return 0 . = staminaloss staminaloss = clamp((staminaloss + (amount * CONFIG_GET(number/damage_multiplier))), 0, max_stamina) diff --git a/code/modules/mob/living/simple_animal/damage_procs.dm b/code/modules/mob/living/simple_animal/damage_procs.dm index 0c06049288d..9640dbb9de4 100644 --- a/code/modules/mob/living/simple_animal/damage_procs.dm +++ b/code/modules/mob/living/simple_animal/damage_procs.dm @@ -19,7 +19,7 @@ toggle_ai(AI_ON) /mob/living/simple_animal/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype) - if(on_damage_adjustment(BRUTE, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_brute_loss(amount, forced, required_bodytype)) return 0 if(forced) . = adjustHealth(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -27,7 +27,7 @@ . = adjustHealth(amount * damage_coeff[BRUTE] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/simple_animal/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype) - if(on_damage_adjustment(BURN, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_fire_loss(amount, forced, required_bodytype)) return 0 if(forced) . = adjustHealth(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -35,7 +35,7 @@ . = adjustHealth(amount * damage_coeff[BURN] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/simple_animal/adjustOxyLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype, required_respiration_type) - if(on_damage_adjustment(OXY, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_oxy_loss(amount, forced, required_biotype, required_respiration_type)) return 0 if(forced) . = adjustHealth(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -43,7 +43,7 @@ . = adjustHealth(amount * damage_coeff[OXY] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/simple_animal/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) - if(on_damage_adjustment(TOX, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_tox_loss(amount, forced, required_biotype)) return 0 if(forced) . = adjustHealth(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -51,7 +51,7 @@ . = adjustHealth(amount * damage_coeff[TOX] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/simple_animal/adjustCloneLoss(amount, updating_health = TRUE, forced = FALSE, required_biotype) - if(on_damage_adjustment(CLONE, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_clone_loss(amount, forced, required_biotype)) return 0 if(forced) . = adjustHealth(amount * CONFIG_GET(number/damage_multiplier), updating_health, forced) @@ -59,7 +59,7 @@ . = adjustHealth(amount * damage_coeff[CLONE] * CONFIG_GET(number/damage_multiplier), updating_health, forced) /mob/living/simple_animal/adjustStaminaLoss(amount, updating_stamina = TRUE, forced = FALSE, required_biotype) - if(on_damage_adjustment(STAMINA, amount, forced) & COMPONENT_IGNORE_CHANGE) + if(!can_adjust_stamina_loss(amount, forced, required_biotype)) return 0 if(forced) staminaloss = max(0, min(max_staminaloss, staminaloss + amount)) diff --git a/code/modules/pai/defense.dm b/code/modules/pai/defense.dm index b5eb177fddc..75c437c2546 100644 --- a/code/modules/pai/defense.dm +++ b/code/modules/pai/defense.dm @@ -65,7 +65,7 @@ /mob/living/silicon/pai/ignite_mob(silent) return FALSE -/mob/living/silicon/pai/proc/take_holo_damage(type, amount) +/mob/living/silicon/pai/proc/take_holo_damage(amount) holochassis_health = clamp((holochassis_health - amount), -50, HOLOCHASSIS_MAX_HEALTH) if(holochassis_health < 0) fold_in(force = TRUE) @@ -73,23 +73,17 @@ to_chat(src, span_userdanger("The impact degrades your holochassis!")) return amount -/mob/living/silicon/pai/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype) - if(on_damage_adjustment(BRUTE, amount, forced) & COMPONENT_IGNORE_CHANGE) - return 0 - return take_holo_damage(amount) +/// Called when we take burn or brute damage, pass it to the shell instead +/mob/living/silicon/pai/proc/on_shell_damaged(datum/hurt, type, amount, forced) + SIGNAL_HANDLER + take_holo_damage(amount) + return COMPONENT_IGNORE_CHANGE -/mob/living/silicon/pai/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE, required_bodytype) - if(on_damage_adjustment(BURN, amount, forced) & COMPONENT_IGNORE_CHANGE) - return 0 - return take_holo_damage(amount) - -/mob/living/silicon/pai/adjustStaminaLoss(amount, updating_stamina, forced = FALSE, required_biotype) - if(on_damage_adjustment(STAMINA, amount, forced) & COMPONENT_IGNORE_CHANGE) - return 0 - if(forced) - take_holo_damage(amount) - else - take_holo_damage(amount * 0.25) +/// Called when we take stamina damage, pass it to the shell instead +/mob/living/silicon/pai/proc/on_shell_weakened(datum/hurt, type, amount, forced) + SIGNAL_HANDLER + take_holo_damage(amount * ((forced) ? 1 : 0.25)) + return COMPONENT_IGNORE_CHANGE /mob/living/silicon/pai/getBruteLoss() return HOLOCHASSIS_MAX_HEALTH - holochassis_health diff --git a/code/modules/pai/pai.dm b/code/modules/pai/pai.dm index f38017dedf6..3998470f748 100644 --- a/code/modules/pai/pai.dm +++ b/code/modules/pai/pai.dm @@ -235,6 +235,8 @@ update_appearance(UPDATE_DESC) RegisterSignal(src, COMSIG_LIVING_CULT_SACRIFICED, PROC_REF(on_cult_sacrificed)) + RegisterSignals(src, list(COMSIG_LIVING_ADJUST_BRUTE_DAMAGE, COMSIG_LIVING_ADJUST_BURN_DAMAGE), PROC_REF(on_shell_damaged)) + RegisterSignal(src, COMSIG_LIVING_ADJUST_STAMINA_DAMAGE, PROC_REF(on_shell_weakened)) /mob/living/silicon/pai/make_laws() laws = new /datum/ai_laws/pai()