-
Notifications
You must be signed in to change notification settings - Fork 259
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
base: Development
Are you sure you want to change the base?
Conversation
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7510758154.zip |
30e05f4
to
ec009a5
Compare
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7510851196.zip |
ec009a5
to
52c4f12
Compare
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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!
There was a problem hiding this 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?
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7607016578.zip |
You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-7607058476.zip |
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: