Skip to content

Commit

Permalink
Check for leaning pawns along shotLine for friendly fire avoidance.
Browse files Browse the repository at this point in the history
  • Loading branch information
perkinslr committed Jan 13, 2024
1 parent da066ed commit 30e05f4
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,25 @@ private bool CanHitCellFromCellIgnoringRange(Vector3 shotSource, IntVec3 targetL
{
targetPos = targetLoc.ToVector3Shifted();
}

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)
{
if (pawn == ShooterPawn || pawn.Downed)
{
continue;
}
var bounds = CE_Utility.GetBoundsFor(pawn);
if (bounds.IntersectRay(shotLine, out var dist))
{
return false;
}
}
}

// Create validator to check for intersection with partial cover
var aimMode = CompFireModes?.CurrentAimMode;

Expand Down

0 comments on commit 30e05f4

Please sign in to comment.