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

@@ -25,9 +25,11 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Damage all units hit by the beam instead of just the target?")]
public readonly bool DamageActorsInLine = false;
[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("Can this projectile be blocked when hitting actors with an IBlocksProjectiles trait.")]
public readonly bool Blockable = false;
@@ -130,6 +132,19 @@ namespace OpenRA.Mods.Common.Projectiles
BeamColor = beamColor;
HelixColor = helixColor;
if (info.Inaccuracy.Length > 0)
{
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
int maxOffset;
if (info.InaccuracyType == InaccuracyType.Maximum)
maxOffset = inaccuracy * (target - source).Length / args.Weapon.Range.Length;
else
maxOffset = inaccuracy * (target - source).Length / 1024;
target += WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024;
}
if (!string.IsNullOrEmpty(info.HitAnim))
hitanim = new Animation(args.SourceActor.World, info.HitAnim);