Moved projectile inaccuracy calculations to Common.Util
Also moved the InaccuracyType enum there. This also quietly adds the RangeModifiers to the calculations for all projectiles, while they were only used on Bullet so far, which seemed very wrong.
This commit is contained in:
committed by
Matthias Mailänder
parent
134d47e48c
commit
76dfda164e
@@ -21,8 +21,6 @@ using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Projectiles
|
||||
{
|
||||
public enum InaccuracyType { Maximum, PerCellIncrement, Absolute }
|
||||
|
||||
public class AreaBeamInfo : IProjectileInfo
|
||||
{
|
||||
[Desc("Projectile speed in WDist / tick, two values indicate a randomly picked velocity per beam.")]
|
||||
@@ -132,23 +130,8 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
target = args.PassiveTarget;
|
||||
if (info.Inaccuracy.Length > 0)
|
||||
{
|
||||
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||
|
||||
var maxOffset = 0;
|
||||
switch (info.InaccuracyType)
|
||||
{
|
||||
case InaccuracyType.Maximum:
|
||||
maxOffset = inaccuracy * (target - headPos).Length / args.Weapon.Range.Length;
|
||||
break;
|
||||
case InaccuracyType.PerCellIncrement:
|
||||
maxOffset = inaccuracy * (target - headPos).Length / 1024;
|
||||
break;
|
||||
case InaccuracyType.Absolute:
|
||||
maxOffset = inaccuracy;
|
||||
break;
|
||||
}
|
||||
|
||||
target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024;
|
||||
var maxInaccuracyOffset = Util.GetProjectileInaccuracy(info.Inaccuracy.Length, info.InaccuracyType, args);
|
||||
target += WVec.FromPDF(world.SharedRandom, 2) * maxInaccuracyOffset / 1024;
|
||||
}
|
||||
|
||||
towardsTargetFacing = (target - headPos).Yaw;
|
||||
|
||||
Reference in New Issue
Block a user