Adjust body part hit difficulty to make critical hits matter for NPCs #3139
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Balance "Adjust hit_difficulty to that critical hits will target vital body parts more often than limbs"
Purpose of change
So, I'd been meaning to look into how melee attacks decide how a limb to target when fighting PCs and NPCs, having noticed that even after we fixed blocking with disabled limbs, it seemed like the game was picking what limb to hit completely at random. I figured that, since ranged attacks do try to gravitate towards the head the better your aim is, wouldn't it be nice to have it do something like that but for melee attacks?
Good news, that already exists in the code: https://github.com/cataclysmbnteam/Cataclysm-BN/blob/upload/src/anatomy.cpp#L139 Relevant bit is:
In a nutshell, the weight for each body part's size is further increased based on how solid the hit is as well as an exponential modifier provided for each part, separate from its basic relative size data. Problem is, exponential modifiers being fiddly as they are, the existing values don't really do all that much.
These shows the weight values for a few different hits ranging from "if it was any worse it'd probably be a miss" to "this was literally the most solid crit I could get without buffing my stats" with a middle of the road value in between:
And here's a table that summarizes the weights being worked with, in particular your odds of hitting a vital part (torso, head, or eyes which carry damage over to the head) vs. those unnecessary noodly things, and your overall odds of hitting a vital:
Doesn't improve much, needless to say. I got a hit roll up into the 130s once when I re-tested with 20 dexterity but even with 50 DEX hit rolls are all over the place, and you don't start getting triple-digit numbers consistently until you're well past 100 DEX. End result is, you need absurdly good hit (and rare with anything resembling a normal character) rolls before it even reaches 50/50.
So it's actively a tad WORSE than a purely even distribution like I first assumed it to be!
Describe the solution
In data/json/body_parts.json:
hit_difficulty
setting for the head from 1.35 to 1.4hit_difficulty
setting for the eyes from 1.15 to 1.2hit_difficulty
setting for both arms from 0.95 to 0.75hit_difficulty
setting for both legs from 0.975 to 0.9This increases the gap between the parts with higher than 1 difficulty and the ones with less than 1 diff, along with also making arms and legs less identical in terms of hit rate (so long as they have HP, they'll already soak up tons of hits so that'll more than make up for it). Also does so without buffing the exponents that're already above 1 by more than 0.05, so they won't get too out of hand. Aim is, more solid hits widen the gap and as a result make essential bodyparts a higher proportion of the total hit weight.
Well, also the eyes, but those are essential by proxy since a hit there damages the head instead, plus as can be seen below the weights still stay pretty low due to their diminutive base hit size.
Describe alternatives you've considered
hit_difficulty
isn't even used in any other function in the code it seems, so this seems like it'd be purely a flavor change in practice.Testing
Hit roll varies a fuckton even with maxed skills and high stats, so the main take here is that just-good-in-general hits will start to hit vitals more often than they hit limbs. Slight impact on bottom-tier hits but you still have higher odds of scoring a non-lethal hit than you do a lethal one, keeping in mind also that the arms are an automatic sword magnet as long as they have HP.
Additional context
Note: during testing I noticed sometimes the game would just abruptly closed. I decided to test this with the original hit difficulties and it still happened, so it doesn't seem to be caused by hit weight math. My guess is either it was because I had debug mode on, or because I gave both of us Debug Invincibility for safe, almost-sane, still-non-consensual brawling. Or maybe combining both, no idea.
It may even happen in normal gameplay too, but the crash seems to have low enough odds of triggering that it's hard to test that without going through NPCs like popcorn, spongy as they may be science is too rough on them so they break eventually.