Fix armaments/projectiles to aim at closest Target.Positions

Instead of CenterPosition.
TargetablePositions were already used for targeting/attack decisions, but not armaments/projectiles.
This commit is contained in:
reaperrr
2017-04-21 14:06:56 +02:00
committed by Oliver Brakmann
parent 73577e3a7e
commit 7acc6dacbc
7 changed files with 13 additions and 6 deletions

View File

@@ -21,6 +21,9 @@ namespace OpenRA.Mods.Common.Projectiles
[Desc("Simple, invisible, usually direct-on-target projectile.")]
public class InstantHitInfo : IProjectileInfo, IRulesetLoaded<WeaponInfo>
{
[Desc("Apply warheads directly to center of target actor.")]
public readonly bool TargetCenterPosition = false;
[Desc("Maximum offset at the maximum range.")]
public readonly WDist Inaccuracy = WDist.Zero;
@@ -57,14 +60,16 @@ namespace OpenRA.Mods.Common.Projectiles
this.info = info;
source = args.Source;
if (info.Inaccuracy.Length > 0)
if (info.TargetCenterPosition)
target = args.GuidedTarget;
else if (!info.TargetCenterPosition && info.Inaccuracy.Length > 0)
{
var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
var maxOffset = inaccuracy * (args.PassiveTarget - source).Length / args.Weapon.Range.Length;
target = Target.FromPos(args.PassiveTarget + WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024);
}
else
target = args.GuidedTarget;
target = Target.FromPos(args.PassiveTarget);
}
public void Tick(World world)