From 0b9fb4420bb06e0a29094c7f38e46713aaccb127 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 11 Aug 2015 14:10:02 +0200 Subject: [PATCH] Add margin to CreateEffectWarhead isAir check --- OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index 84cf2e9bef..ce8e8e4858 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -39,8 +39,13 @@ namespace OpenRA.Mods.Common.Warheads public static ImpactType GetImpactType(World world, CPos cell, WPos pos) { + // Missiles need a margin because they sometimes explode a little above ground + // due to their explosion check triggering slightly too early (because of CloseEnough). + // TODO: Base ImpactType on target altitude instead of explosion altitude. + var airMargin = new WDist(128); + var dat = world.Map.DistanceAboveTerrain(pos); - var isAir = dat.Length > 0; + var isAir = dat.Length > airMargin.Length; var isWater = dat.Length <= 0 && world.Map.GetTerrainInfo(cell).IsWater; var isDirectHit = GetDirectHit(world, cell, pos);