From cac99407369f9a3545f01630e90c0f5b2e538a11 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 11 Oct 2020 14:44:34 +0200 Subject: [PATCH] Support 'inaccuracy' on effect warhead Purely cosmetic, allows to 'fake' slight inaccuracy without affecting game balance on weapons like light machine guns. --- OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index 9ae73da2a1..be36eb1d70 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -46,6 +46,9 @@ namespace OpenRA.Mods.Common.Warheads [Desc("Whether to consider actors in determining whether the explosion should happen. If false, only terrain will be considered.")] public readonly bool ImpactActors = true; + [Desc("The maximum inaccuracy of the effect spawn position relative to actual impact position.")] + public readonly WDist Inaccuracy = WDist.Zero; + static readonly BitSet TargetTypeAir = new BitSet("Air"); /// Checks if there are any actors at impact position and if the warhead is valid against any of them. @@ -109,6 +112,9 @@ namespace OpenRA.Mods.Common.Warheads var explosion = Explosions.RandomOrDefault(world.LocalRandom); if (Image != null && explosion != null) { + if (Inaccuracy.Length > 0) + pos += WVec.FromPDF(world.SharedRandom, 2) * Inaccuracy.Length / 1024; + if (ForceDisplayAtGroundLevel) { var dat = world.Map.DistanceAboveTerrain(pos);