This isn't adding to the total damage, it's subtracting any damage that puts a body part below 0. Notice the if statement.

The actual total damage is added at the end of the function. This is there to get an accurate count instead of adding in "overkill" damage that sends body parts into the negative.