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 NPCs hitting allies with reach attacks #59071

Merged
merged 1 commit into from
Jul 13, 2022

Conversation

natsirt721
Copy link
Contributor

Summary

Bugfixes "Fix NPCs hitting allies with reach attacks"

Purpose of change

Fixes #59056

Describe the solution

Before making a reach attack, have the NPC check for any FRIENDLY creatures in the way. If there are and the NPC is allowed to move, use the avoid_friendly_fire method to attempt to maneuver around the ally. If there are but the NPC is not allowed to move, have them complain.

Describe alternatives you've considered

Considered allowing NEUTRAL creatures to trigger the non-attack logic.
Considered tying the check to the 'avoid shooting allies' rule.

Can do either or both of the above easily. Figured I'd start simple and respond to feedback.

Testing

Used various combinations of a friendly NPC with a spear/long pole and debug monster/player/npc geometry. Also tested with NPC riding shotgun in a vehicle to make sure they behave properly and don't move unexpectedly. Tested with a few combinations of combat rules, but my no means did that exhaustively.

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Jul 8, 2022
@natsirt721
Copy link
Contributor Author

I noticed that avoid_friendly_fire doesn't work very well if the centroid of allies positions is on the line from the shooter to the target. I can also look into improving the behavior in that case as part of this, or do it separately, or not at all.

@Maleclypse
Copy link
Member

I noticed that avoid_friendly_fire doesn't work very well if the centroid of allies positions is on the line from the shooter to the target. I can also look into improving the behavior in that case as part of this, or do it separately, or not at all.

If it’s possible that it would be confusing what change is trying to make what behavior fix it might be best to make them separate PRs.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jul 8, 2022
@natsirt721 natsirt721 force-pushed the fix-npc-reach-hit-allies branch from e3caa81 to 12e55d8 Compare July 9, 2022 03:41

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@natsirt721 natsirt721 force-pushed the fix-npc-reach-hit-allies branch from 12e55d8 to 736c622 Compare July 10, 2022 17:11
@natsirt721
Copy link
Contributor Author

Not sure why one build is failing, looks like unrelated density test failures.

@anothersimulacrum
Copy link
Member

That doesn't cause the tests to fail. This is a failure due to the rock throwing sanity test (not your fault, should be fixed with a kick of the tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPCs with reach melee weapons can hit allies in the way
4 participants