Added InaccuracyType.Absolute to projectiles

This commit is contained in:
Pavel Penev
2020-05-02 00:31:27 +03:00
committed by Matthias Mailänder
parent a2dbd5e013
commit 134d47e48c
6 changed files with 86 additions and 36 deletions

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Projectiles
public readonly WDist Inaccuracy = WDist.Zero;
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' and 'PerCellIncrement'.")]
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' - scale from 0 to max with range, 'PerCellIncrement' - scale from 0 with range and 'Absolute' - use set value regardless of range.")]
public readonly InaccuracyType InaccuracyType = InaccuracyType.Maximum;
[Desc("Image to display.")]
@@ -152,11 +152,19 @@ namespace OpenRA.Mods.Common.Projectiles
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
var range = Util.ApplyPercentageModifiers(args.Weapon.Range.Length, args.RangeModifiers);
int maxOffset;
if (info.InaccuracyType == InaccuracyType.Maximum)
maxOffset = inaccuracy * (target - pos).Length / range;
else
maxOffset = inaccuracy * (target - pos).Length / 1024;
var maxOffset = 0;
switch (info.InaccuracyType)
{
case InaccuracyType.Maximum:
maxOffset = inaccuracy * (target - pos).Length / range;
break;
case InaccuracyType.PerCellIncrement:
maxOffset = inaccuracy * (target - pos).Length / 1024;
break;
case InaccuracyType.Absolute:
maxOffset = inaccuracy;
break;
}
target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024;
}