Added InaccuracyType enum and updated projectiles accordingly

Also updated the inaccuracy calculations to account for the new inaccuracy type - either based on distance up to a max defined inaccuracy at max range (old style) or based on distance with each cell (1024 range) increasing the inaccuracy with a set step.
This commit is contained in:
Pavel Penev
2020-04-30 19:52:51 +03:00
committed by Matthias Mailänder
parent 4143aba595
commit c27412c83a
6 changed files with 68 additions and 12 deletions

View File

@@ -27,9 +27,11 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Projectile speed in WDist / tick, two values indicate variable velocity.")]
public readonly WDist[] Speed = { new WDist(17) };
[Desc("Maximum offset at the maximum range.")]
public readonly WDist Inaccuracy = WDist.Zero;
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' and 'PerCellIncrement'.")]
public readonly InaccuracyType InaccuracyType = InaccuracyType.Maximum;
[Desc("Image to display.")]
public readonly string Image = null;
@@ -149,7 +151,13 @@ namespace OpenRA.Mods.Common.Projectiles
{
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
var range = Util.ApplyPercentageModifiers(args.Weapon.Range.Length, args.RangeModifiers);
var maxOffset = inaccuracy * (target - pos).Length / range;
int maxOffset;
if (info.InaccuracyType == InaccuracyType.Maximum)
maxOffset = inaccuracy * (target - pos).Length / range;
else
maxOffset = inaccuracy * (target - pos).Length / 1024;
target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024;
}