From 32e3b2f8cb1e4c4c5b9535e3de081a62c46bf94d Mon Sep 17 00:00:00 2001 From: jwhitak <69739118+jwhitak@users.noreply.github.com> Date: Sat, 21 Sep 2024 19:18:04 -0500 Subject: [PATCH] ending damage cascades (#37110) --- .../mob/living/carbon/human/human_damage.dm | 15 +++++++++++++-- code/modules/organs/organ_external.dm | 19 ++++++++++++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/code/modules/mob/living/carbon/human/human_damage.dm b/code/modules/mob/living/carbon/human/human_damage.dm index 5c35e1e5cae2..e044be3f99a4 100644 --- a/code/modules/mob/living/carbon/human/human_damage.dm +++ b/code/modules/mob/living/carbon/human/human_damage.dm @@ -262,12 +262,23 @@ In most cases it makes more sense to use apply_damage() instead! And make sure t var/brute_was = picked.brute_dam var/burn_was = picked.burn_dam + var/damage_cap = picked.max_damage - picked.get_health() //the limb cannot take more than this much damage //Multiplied damage is already handled at the limb level update |= picked.take_damage(brute,burn,sharp,edge,used_weapon, no_damage_modifier = no_damage_change, spread_damage = FALSE) - brute -= (picked.brute_dam - brute_was) + if(!picked.is_existing()) + //the organ got cut off or removed! the organ takes no damage in these cases for some reason... + //So we'll rule in favor of the damage taker and assume the organ took the most it can accept from both + brute -= damage_cap + burn -= damage_cap + else if(picked.max_damage - picked.get_health() > 0) + //since the damage cannot spread: if we did not max out the limb's damage, then we're done! + break + else + //The organ has taken the maximum damage it's allowed, we will have leftover damage + brute -= (picked.brute_dam - brute_was) + burn -= (picked.burn_dam - burn_was) if(brute < 0) brute = 0 - burn -= (picked.burn_dam - burn_was) if(burn < 0) burn = 0 parts -= picked diff --git a/code/modules/organs/organ_external.dm b/code/modules/organs/organ_external.dm index f4ba398a8e4c..705c82b20c4a 100644 --- a/code/modules/organs/organ_external.dm +++ b/code/modules/organs/organ_external.dm @@ -107,6 +107,9 @@ to_chat(owner, "Your [display_name] malfunctions!") take_damage(damage, 0, 1, used_weapon = "EMP") +/** + * This returns the amount of DAMAGE on the limb, unlike what the proc suggests + */ /datum/organ/external/proc/get_health() return (burn_dam + brute_dam) @@ -169,6 +172,11 @@ if(!is_existing()) //No limb there return 0 + //These are here to prevent a 'weakness cascade' from dealing unfair damage amounts to species with weaknesses + var/bonus_brute_damage = 0 + var/bonus_burn_damage = 0 + var/original_brute = brute + var/original_burn = burn if(!no_damage_modifier) if(!is_organic()) brute *= 0.66 //~2/3 damage for ROBOLIMBS @@ -180,6 +188,11 @@ brute *= species.brute_mod if(species.burn_mod) burn *= species.burn_mod + //We only care about weaknesses, not resists + if(original_brute < brute) + bonus_brute_damage = brute - original_brute + if(original_burn < burn) + bonus_burn_damage = burn - original_burn //If limb took enough damage, try to cut or tear it off if(body_part != UPPER_TORSO && body_part != LOWER_TORSO) //As hilarious as it is, getting hit on the chest too much shouldn't effectively gib you. @@ -260,7 +273,11 @@ //How much burn damage is left to inflict burn = max(0, burn - can_inflict) //If there are still hurties to dispense - if(burn || brute) + //Then we need to be fair and remove the damage weaknesses applied for this limb + //After all, other limbs can have different weaknesses/resists + brute -= bonus_brute_damage + burn -= bonus_burn_damage + if(burn > 0 || brute > 0) if(!is_organic()) droplimb(1) //Non-organic limbs just drop off with no further complications else