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 high-shields not intercepting indirect fire shells #3515

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,17 @@ protected bool CheckIntercept(Thing interceptorThing, CompProjectileInterceptor
{
return false;
}
if (CE_Utility.IntersectionPoint(LastPos, newExactPos, shieldPosition, radius, out Vector3[] sect))
if (CE_Utility.IntersectionPoint(
LastPos,
newExactPos,
shieldPosition,
radius,
out Vector3[] sect,
// Don't normalize away the 3D component of the projectile position when checking for collisions
// between indirect fire projectiles and shields that protect against them
// (e.g. mortar shells targeting a high-shield).
spherical: interceptorComp.Props.interceptAirProjectiles && def.projectile.flyOverhead
))
{
ExactPosition = newExactPos = sect.OrderBy(x => (OriginIV3.ToVector3() - x).sqrMagnitude).First();
landed = true;
Expand Down Expand Up @@ -720,12 +730,23 @@ protected bool CheckForCollisionBetween()
List<Thing> list = base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ProjectileInterceptor);
for (int i = 0; i < list.Count; i++)
{
if (CheckIntercept(list[i], list[i].TryGetComp<CompProjectileInterceptor>()))
if (!CheckIntercept(list[i], list[i].TryGetComp<CompProjectileInterceptor>()))
{
landed = true;
this.Impact(null);
continue;
}

// Have high-shields absorb intercepted indirect fire projectiles without detonating them.
// Since CE simulates a 3D trajectory for such shells but explosions occur on ground level,
// detonating the shell would cause damage to objects under the high-shield.
if (def.projectile.flyOverhead)
{
this.Destroy();
return true;
}

landed = true;
this.Impact(null);
return true;
}
if (BlockerRegistry.CheckForCollisionBetweenCallback(this, LastPos, ExactPosition))
{
Expand Down
Loading