Ludeon Forums

RimWorld => Mods => Help => Topic started by: IHateRegistering on December 30, 2016, 04:09:39 PM

Title: How does the game calculate which body part is hit?
Post by: IHateRegistering on December 30, 2016, 04:09:39 PM
Yeah, I'd like to know that. I kinda want to change the chances regarding which body part is hit and which part of that body part is hit, i.e. torso -> lung, torso -> stomach or head -> brain etc.

As it is now, I want less damage to generic areas like 'head' or 'torso' and more injuries to organs. Also the probability of limbs being hit, I don't like that you are more likely to lose an arm than it is to take a bullet to the stomach.
Title: Re: How does the game calculate which body part is hit?
Post by: Wellenbrecher on December 30, 2016, 06:28:43 PM
Defs/Bodies/Bodies_Humanlike.xml defines how the humanoid bodies stick together. It also gives a coverage value for each.
You might get a long way towards what you're trying to do by just changing that.

According to the wiki <coverage>1.0</coverage> would be 100%.
Take it from there.
Title: Re: How does the game calculate which body part is hit?
Post by: IHateRegistering on December 31, 2016, 01:40:54 AM
So if I understand that right, the following for example

<def>LeftLeg</def>
          <coverage>0.1</coverage>
          <height>Bottom</height>
          <groups>
            <li>Legs</li>
          </groups>
          <parts>
            <li>
              <def>LeftFemur</def>
              <coverage>0.1</coverage>
              <depth>Inside</depth>
              <groups>
                <li>Legs</li>
              </groups>
            </li>
            <li>
              <def>LeftTibia</def>
              <coverage>0.1</coverage>
              <depth>Inside</depth>
              <groups>
                <li>Legs</li>
              </groups>
            </li>
            <li>
              <def>LeftFoot</def>
              <coverage>0.2</coverage>
              <groups>
                <li>Feet</li>
              </groups>


means that the left leg has a 10% chance to be hit, and if it is hit, there's a 10% chance for both the left femur and the left tibia and a 20% chance the foot to be affected. And if the left leg is hit, but the game doesn't roll the percent needed to hit a subtype of that bodytype, i.e. left leg -> left foot, the hit will be classified as a generic leg injury? And any hit that doesn't roll the number for a limb will be a torso hit since the torso is pretty much the 'root' body part for everything.

But if that would be true, the head with a coverage of 0.72 would have a chance of 72% to be hit, which obviously isn't the case. When looking at the sub body parts for the head though it starts making sense again, with an 18% chance to hit the skull (lol) and an 80% chance to hit the brain if the skull registers a hit. Which would explain how many headshots just deal damage to the head but almost everytime the skull is hit the brain will also be hit.
Title: Re: How does the game calculate which body part is hit?
Post by: IHateRegistering on January 06, 2017, 12:27:42 PM
bump
Title: Re: How does the game calculate which body part is hit?
Post by: RawCode on January 08, 2017, 01:24:01 AM
GetExactPartFromDamageInfo
Title: Re: How does the game calculate which body part is hit?
Post by: ison on January 08, 2017, 09:33:41 AM
Quote from: IHateRegistering on December 31, 2016, 01:40:54 AM
means that the left leg has a 10% chance to be hit, and if it is hit, there's a 10% chance for both the left femur and the left tibia and a 20% chance the foot to be affected. And if the left leg is hit, but the game doesn't roll the percent needed to hit a subtype of that bodytype, i.e. left leg -> left foot, the hit will be classified as a generic leg injury? And any hit that doesn't roll the number for a limb will be a torso hit since the torso is pretty much the 'root' body part for everything.
Correct.

Quote from: IHateRegistering on December 31, 2016, 01:40:54 AM
But if that would be true, the head with a coverage of 0.72 would have a chance of 72% to be hit, which obviously isn't the case.

"Head" is a child node of "Neck", not "Torso".