Skip to content

Commit

Permalink
ending damage cascades (#37110)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhitak authored Sep 22, 2024
1 parent ac2e48f commit 32e3b2f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
15 changes: 13 additions & 2 deletions code/modules/mob/living/carbon/human/human_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion code/modules/organs/organ_external.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@
to_chat(owner, "<span class = 'warning'>Your [display_name] malfunctions!</span>")
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)

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 32e3b2f

Please sign in to comment.