Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AoE ammo hits NPCs once instead of spreading damage across all bodyparts #5387

Merged

Conversation

chaosvolt
Copy link
Member

Checklist

Required

Optional

Purpose of change

This aims to tinker with ranged AoE cones to be a bit less wonky against NPCs, fixing one of the many issues affecting it currently.

Fixes #2989

Describe the solution

In ranged_aoe.cpp, converted the hit behavior of execute_shaped_attack to depriciate ranged::hit_with_aoe in favor of using deal_projectile_attack. The idea here is make NPCs caught in the AoE only take a single hit to a random bodypart, with missed_by weighted more in favor of center mass.

This specifically fixes the issue of the function in question dividing the total damage by number of bodyparts, which would turn an amount of damage instantly lethal to a zombie to peppering an NPC with mild annoyance.

Finally, deleted the hit_with_aoe function from ranged.cpp and ranged.h, as execute_ranged_attack was the only function using it.

Describe alternatives you've considered

  1. Reworking hit_with_aoe to randomize how many body parts it hits instead of dividing up across all of them. I'm not sure if that'd really be worth it though.
  2. Figuring out how to make distance from shooter affect missed_by value instead of making it random.

Testing

  1. Compiled and load-tested.
  2. Blasted NPCs repeatedly with birdshot, as expected they now only take a conventional hit to a randomly-selected bodypart instead of having damage spread accross the entire body, with it hitting center mass reasonably often.
  3. Shot at a crowd of zombies with it, they still take damage as normal, and now the damage varies instead of hitting all of them for exactly 49 damage.
  4. Checked affected files for astyle.

image

Additional context

This doesn't yet re-add AoE to buckshot, since there are other issues with the code not yet sorted out, like gun range not adding to AoE cone length and ammo effect stuff not working right.

@github-actions github-actions bot added the src changes related to source code. label Sep 20, 2024
@Coolthulhu
Copy link
Member

This certainly sounds weird, but it might be OK enough.
It would definitely get weird if we had eye hits and similar.

Does it hit the head often enough to matter?

@chaosvolt
Copy link
Member Author

chaosvolt commented Sep 20, 2024

This certainly sounds weird, but it might be OK enough. It would definitely get weird if we had eye hits and similar.

Does it hit the head often enough to matter?

The hit range I gave it is 0.15 to 0.45. While game_constants.h says it needs to be below 0.1 to headshot, in practice NPCs get hit in the head by anything that's equal or less than 0.2: https://github.com/cataclysmbnteam/Cataclysm-BN/blob/main/src/creature.cpp#L820

Though I assume that's just because accuracy_headshot is just the game's name for a hit on a zombie that's considered good enough to call a headshot (faked by damage multipliers against a monster that's technically just a giant torso under the hood), while for creatures with an actual body anything that's accuracy_critical or better hits the head.

EDIT: So very rough math says head will be hit ~19% of the time, random limbs will be hit ~16% of the time, and torso the rest of the time.

Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while it's not the best solution seems it works so let's try this approach.

@chaosvolt chaosvolt merged commit 19c2c67 into cataclysmbnteam:main Sep 23, 2024
12 checks passed
@chaosvolt chaosvolt deleted the one-pellet-per-customer-please branch September 23, 2024 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AoE cone ammo spreads damage across all bodyparts when used on players and NPCs, rendering them ineffective
3 participants