Pass InstantHit target directly if inaccuracy is zero

This is required to make the TargetDamage warhead deal damage only to a specific target.
This commit is contained in:
reaperrr
2017-01-27 18:35:50 +01:00
parent e2419f4faa
commit 090c015b27

View File

@@ -40,41 +40,37 @@ namespace OpenRA.Mods.Common.Projectiles
readonly ProjectileArgs args;
readonly InstantHitInfo info;
bool doneDamage;
WPos target;
Target target;
WPos source;
public InstantHit(InstantHitInfo info, ProjectileArgs args)
{
this.args = args;
this.info = info;
target = args.PassiveTarget;
source = args.Source;
if (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;
}
public void Tick(World world)
{
// Check for blocking actors
WPos blockedPos;
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, source, target,
if (info.Blockable && BlocksProjectiles.AnyBlockingActorsBetween(world, source, target.CenterPosition,
info.Width, info.TargetExtraSearchRadius, out blockedPos))
{
target = blockedPos;
target = Target.FromPos(blockedPos);
}
if (info.Inaccuracy.Length > 0)
{
var inaccuracy = OpenRA.Mods.Common.Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
var maxOffset = inaccuracy * (target - source).Length / args.Weapon.Range.Length;
target += WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * maxOffset / 1024;
}
if (!doneDamage)
{
args.Weapon.Impact(Target.FromPos(target), args.SourceActor, args.DamageModifiers);
doneDamage = true;
world.AddFrameEndTask(w => w.Remove(this));
}
args.Weapon.Impact(target, args.SourceActor, args.DamageModifiers);
world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<IRenderable> Render(WorldRenderer wr)