RimWorld

RimWorld

Grievous Wounds
SirProok  [developer] 6 Apr @ 1:22pm
What does this mod do and how does it do it?
The calculation is roughly this:
Four variables:
What is the damage applied (before armor or other reductions)? Lets say 25.
What is the damage after reductions? Lets say 10.
What is the max heath of the body part? Lets say 10.
What is the after damage health of the body part? Lets say 1 (the part was auto saved by Randy)

First, for any overflow, the raw damage amount must be greater than body part max health times

1-squishiness percentage in mod settings (default 50%). So in our example, minimum damage for overflow is 5. Anything smaller will never proc overflow. So no super squirrels.

Then it does is checks if the pre-damage is greater than the max health of the body part, and if then what is the total % of the part destroyed, squared then multiplied by the damage after reductions. Here that would be 15 vs 8.1. Functionally this estimates the difference between a pierce and raw force trauma of an impact.

Whichever of those totals is larger in number set as overflow damage.

Example:
1st Check: IF 25>(10*Squishiness): Overflow if true

2nd Check: Max(Piercing, Trauma)
Piercing = Predamage - Maxhealth
Piercing = 25 - 10 = 15
Trauma = (1-(remaining health/maxhealth))*(1-(remaining health/maxhealth))*Postdamage
Trauma = (1-(1/10))*(1-(1/10))*10 = .9*.9*10 = 8.1

In this situation it would overflow the 15 and "pierce through" the part.
If the predamage had been lower (say 10 instead of 25), then Trauma would kick in and spread 8.1.

The system then checks the overflow chance for the body part (100% for eyes, 75% for head, ect... (see screenshot with default settings). It does a roll to see if it applies overflow.
If yes, then it rolls a number of connected parts inclusive-between the min and max in settings (1-3). The damage is then evenly applied to those body parts, respecting any armor coverage that is in place (no armored livers though!). This damage, so long as it is at least of the value of 1, then reprocesses the whole process.
This applies for every instance of damage received so doomsday rockets are significantly more lethal as they evaporate pawns rather than maiming.

The key to controlling the spread then is to tweak squishiness to a value that makes sense for you and your play-through. A very low value, and you will primarily see less general trauma punctuated by devastating critical hits, a very high value and there will be gore all around (including from shambler super squirrel bites).

If you set the min/max settings to apply damage to overflow to a small number of parts (1-2) means that the average damage they receive is higher and will cause more localized, domino style trauma injuries. Setting it to hit larger number of parts, (3-4) causes the overflow to more evenly distribute but causes more individual wounds and all the unpleasantness that entails.

You can, as well tweak the overflow percentages and that will allow you to see more or less injuries.
Last edited by SirProok; 12 Apr @ 8:20am
< >
Showing 1-11 of 11 comments
how heavy is this on system resources?
SirProok  [developer] 10 Apr @ 6:46pm 
I run it in my personal mod grouping of ~350 mods without noticeable issue. The methodology is that the mod is only called when damage is inflicted above a gating threshold. This means it will only impact during combat, resolves in one tick, and prevents it from drawing resources during normal play.

Likewise nothing is stored in memory as it uses a read of the recent wounds to determine where to overflow so it shouldn't impact performance there either.
Nishe 11 Apr @ 10:42pm 
Hey SirProok, would it be possible for you to write this part out as a simple math equation?:

"Then it does is checks if the pre-damage is greater than the max health of the body part, and if then what is the total % of the part destroyed, squared then multiplied by the damage after reductions. Here that would be 15 vs 20.25. Functionally this estimates the difference between a pierce and raw force trauma of an impact."

I'm having trouble figuring out exactly what is going on from a math perspective just from your wording.
SirProok  [developer] 12 Apr @ 6:14am 
Adding this to the body of the post for clarity.

1st Check: IF 25>(10*Squishiness): Overflow if true

2nd Check: Max(Piercing, Trauma)

Piercing = Predamage - Maxhealth
Piercing = 25 - 10 = 15
Trauma = (1-(remaining health/maxhealth))*(1-(remaining health/maxhealth))*Predamage
Trauma = (1-(1/10))*(1-(1/10))*25 = .9*.9*25 = 20.25
Nishe 12 Apr @ 7:02am 
Ok, thanks for the clarification. A couple points:

You said this: "what is the total % of the part destroyed, squared then multiplied by the damage after reductions", specifically the damage after reductions, but then in your formula you're using the "predamage" of 25, so that's a bit confusing.

It looks like you're using the "predamage", so does that mean you're using the full, unmitigated damage to calculate the overflow damage? Tbh, that seems like a slightly strange design choice, if an incoming shot could have its damage halved by armor, but then proc overflow damage that is a large percentage of the unmitigated damage value.
Last edited by Nishe; 12 Apr @ 7:03am
SirProok  [developer] 12 Apr @ 8:16am 
I've pulled up the code to double check and will update the original post. My explanation was wrong, apparently the original post was too confusing even for me...

The first calculation is using damage amount (predamage) and the second is using total damage dealt (post-reduction damage).

Piercing = Predamage - Maxhealth
Piercing = 25 - 10 = 15
Trauma = (1-(remaining health/maxhealth))*(1-(remaining health/maxhealth))*Postdamage
Trauma = (1-(1/10))*(1-(1/10))*10 = .9*.9*10 = 8.1

In this situation it would overflow the 15 and "pierce through" the part.
If the predamage had been lower (say 10), then Trauma would kick in and spread 8.1.

In both cases, it is spread evenly to the # of parts rolled based on the settings (default 1-3).
Last edited by SirProok; 12 Apr @ 8:17am
Nishe 12 Apr @ 9:53am 
Ok, so if I'm understanding it right that would mean that the game is potentially going to be generating extra damage over and above the total of the damage the bullet was supposed to do.

I don't know if I'm understanding it right, but that sounds like you could get some potentially major damage spikes that are well in excess of what that gun/weapon should theoretically be able to do in a single hit, depending on RNG.

To me what would make most sense would be for it to be just a literal overflow of the "remainder" of the damage. E.g., a bullet does 15 damage after armor mitigation, but destroys a body part that only had 10 hp before the bullet hit, leaving 5 "remaining" damage unassigned, which would then overflow to a connected body part.

This is obviously complicated somewhat by rimworld's damage formula though, and the fact that some body parts are "inside" other parts.
Nishe 12 Apr @ 9:56am 
At the very least, I'd suggest changing the "piercing" calculation to use the "postdamage" instead of predamage, as the way it is now seems like it has the potential to make armor useless for mitigating overflow damage. That is, as before, assuming I'm understanding it right.
SirProok  [developer] 12 Apr @ 10:45am 
Originally posted by Nishe:
Ok, so if I'm understanding it right that would mean that the game is potentially going to be generating extra damage over and above the total of the damage the bullet was supposed to do.

That is correct. This can/will result in excess damage to internals, as you pointed out with spine.

It is worth noting that only external body parts can overflow damage. so the mod does not double count the wound, but could apply excess damage to an internal part.

Originally posted by Nishe:
At the very least, I'd suggest changing the "piercing" calculation to use the "postdamage" instead of predamage, as the way it is now seems like it has the potential to make armor useless for mitigating overflow damage. That is, as before, assuming I'm understanding it right.

The theory here is that a wound could go through the part without destroying it to cause more severe internal damage.

As for armor, if the overflow goes to an external body part, its armor does apply. So I will address internal parts.

There is a hardcoded minimum damage dealt for overflow to be checked. That is 1.

If a pawn receives more than 1 damage, then it is assumed that the armor helped, but did not stop the attack. Max damage is then used to approximate the force of the blow. The idea being that a sufficiently large blow will pulp/punch regardless if the armor softens it. This is also why pierce checks max health of the part for mitigation.

In practice, this means soft parts like eyes, fingers, and such will pierce. Meanwhile torsos, will succumb to sustained trauma.

Originally posted by Nishe:
To me what would make most sense would be for it to be just a literal overflow of the "remainder" of the damage. E.g., a bullet does 15 damage after armor mitigation, but destroys a body part that only had 10 hp before the bullet hit, leaving 5 "remaining" damage unassigned, which would then overflow to a connected body part.

This is where I actually started. There is definitely room for me to add a "Simple Overflow" option to the mod settings. IIRC the issue I ran into was that the damage dealt was capped to the hp of the part. Thus rimworld was losing the overflow and I didn't see an "intended damage" value to pull.

This is how pierce became what it was, but it cannot handle multiple hits to the same part, so trauma was created.

If/when I get around to taking a look at armor calculations I may be able to recreate the math to improve this.
Zer0 12 Apr @ 6:01pm 
Originally posted by SirProok:
So I will address internal parts.

There is a hardcoded minimum damage dealt for overflow to be checked. That is 1.

If a pawn receives more than 1 damage, then it is assumed that the armor helped, but did not stop the attack. Max damage is then used to approximate the force of the blow. The idea being that a sufficiently large blow will pulp/punch regardless if the armor softens it. This is also why pierce checks max health of the part for mitigation.

In practice, this means soft parts like eyes, fingers, and such will pierce. Meanwhile torsos, will succumb to sustained trauma.

If I got everything right, then this right here is the reason why this mod would work well in vanilla combat but might cause trouble with combat mods. In vanilla combat you either take all the damage, half of it, or none at all. Which means "piercing" overflow will always be less than full damage. If the actual damage is halved you could end up with overflow bigger than actual damage, but it's never "twice as much". It's kind of believable.

However, consider the case with Yayo Combat, Armored Up, or any other mod that adds damage reduction based on armor penetration to armor resistance ratio. Let's say we have a pawn with some legendary cataphract armor. Then it takes a hit to the eye from a hand-held cannon or whatever, with base damage of 60 but somewhat mediocre armor piercing of 80. At 80%+ durability, your legendary helmet would stop it completely, but since it was damaged in the fight already, it leaks a bit of damage. Let's say 1.7 damage on the right eye. Well, This could have ended very badly. Then, the piercing overflow is calculated as 60 - 10 = 50. The pawn is dead in this case, right? His brains won't survive even the third of this overflow. With combat mods, there are bound to be cases where pre-reduced damage MASSIVELY outweighs post-reduction damage, and that might be an issue.
Last edited by Zer0; 12 Apr @ 6:41pm
SirProok  [developer] 13 Apr @ 5:35am 
I agree with your assesment.

Now, there is room for what we feel is realistic around taking a cannon, or other high damage hit to the face. Personally, I see this working as intended. Ie. if the helmet does not perfectly deflect it, you are likely dead.

However, I can see where for others this could easily become un-fun. The best option is probably to make the hard-coded value of 1 an option in the settings. At the very least, tweaking that could determine how hard the damage dealt needs to be.
< >
Showing 1-11 of 11 comments
Per page: 1530 50