From 0e81abc21be0e0bb8b301459b3b248b2b21e03f2 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 22 May 2020 12:22:39 +0200 Subject: [PATCH] Fix weapons not accounting for Air If a weapon was aiming at a target position rather than an actor target, it would always check target types of the terrain below, ignoring altitude (and therefore ignoring "InvalidTargets: Air"). --- OpenRA.Game/GameRules/WeaponInfo.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index f1afbb77c6..49ad380049 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -102,6 +102,12 @@ namespace OpenRA.GameRules [Desc("What types of targets are unaffected.", "Overrules ValidTargets.")] public readonly BitSet InvalidTargets; + static readonly BitSet TargetTypeAir = new BitSet("Air"); + + [Desc("If weapon is not directly targeting an actor and targeted position is above this altitude,", + "the weapon will ignore terrain target types and only check TargetTypeAir for validity.")] + public readonly WDist AirThreshold = new WDist(128); + [Desc("Delay in ticks between firing shots from the same ammo magazine. If one entry, it will be used for all bursts.", "If multiple entries, their number needs to match Burst - 1.")] public readonly int[] BurstDelays = { 5 }; @@ -165,6 +171,10 @@ namespace OpenRA.GameRules if (target.Type == TargetType.Terrain) { + var dat = world.Map.DistanceAboveTerrain(target.CenterPosition); + if (dat > AirThreshold) + return IsValidTarget(TargetTypeAir); + var cell = world.Map.CellContaining(target.CenterPosition); if (!world.Map.Contains(cell)) return false;