Support 'inaccuracy' on effect warhead

Purely cosmetic, allows to 'fake' slight inaccuracy without
affecting game balance on weapons like light machine guns.
This commit is contained in:
reaperrr
2020-10-11 14:44:34 +02:00
committed by abcdefg30
parent 559b143265
commit cac9940736

View File

@@ -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<TargetableType> TargetTypeAir = new BitSet<TargetableType>("Air");
/// <summary>Checks if there are any actors at impact position and if the warhead is valid against any of them.</summary>
@@ -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);