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

Check for leaning pawns along shotLine for friendly fire avoidance. #2948

Draft
wants to merge 6 commits into
base: Development
Choose a base branch
from

Conversation

perkinslr
Copy link
Contributor

References

Links to the associated issues or other related pull requests, e.g.

Reasoning

Pawns leaning into the line of fire but with an origin not directly along the bullet flight path don't trigger friendly fire avoidance. This checks 1 cell to either side along the entire line for pawns and checks if the aim line intersects them.

For future work, it should probably also trigger on friendly factions.

Testing

Check tests you have performed:

  • Compiles without warnings
  • Game runs without errors
  • (For compatibility patches) ...with and without patched mod loaded
  • Playtested a colony (specify how long)

@perkinslr perkinslr requested review from a team as code owners January 13, 2024 06:14
Copy link

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7510758154.zip

@github-actions github-actions bot added the Download in Comments This PR has a zipfile download available. label Jan 13, 2024
Copy link

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7510851196.zip

Copy link

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7511231833.zip

Ray shotLine = new Ray(shotSource, (targetPos - shotSource));

foreach (Pawn pawn in shotSource.ToIntVec3().PawnsNearSegment(targetLoc, caster.Map, 1, behind: false, infront: true))
{
if (pawn.Faction == ShooterPawn?.Faction)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should use if (pawn.Faction != null && !ShooterPawn.HostileTo(pawn)) to avoid friendly fire with ally (wandering wild men/animals will be ignored)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

MaxDorob
MaxDorob previously approved these changes Jan 18, 2024
Copy link
Contributor

@N7Huntsman N7Huntsman left a comment

Choose a reason for hiding this comment

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

Does not appear to currently be working as intended.

I first ordered York to shoot at the center-right piece of wall. I then ordered Hairy to shoot the same piece of wall, and he leaned out of cover to do so--promptly getting shot in the back of the head by York.

It also happened if I did the reverse--having Hairy lean out and shoot first, and then ordered York to fire.

Would it be useful to add a debugging visualizer of some sort to show what cells are being checked?

20240119011112_1
20240119011120_1

Copy link

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7607016578.zip

Copy link

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7607058476.zip

@perkinslr perkinslr marked this pull request as draft January 22, 2024 06:45
@N7Huntsman N7Huntsman added the On Hold Being held until after the next release. label Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Download in Comments This PR has a zipfile download available. On Hold Being held until after the next release.
Projects
None yet
3 participants