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:
@@ -40,41 +40,37 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
readonly ProjectileArgs args;
|
readonly ProjectileArgs args;
|
||||||
readonly InstantHitInfo info;
|
readonly InstantHitInfo info;
|
||||||
|
|
||||||
bool doneDamage;
|
Target target;
|
||||||
WPos target;
|
|
||||||
WPos source;
|
WPos source;
|
||||||
|
|
||||||
public InstantHit(InstantHitInfo info, ProjectileArgs args)
|
public InstantHit(InstantHitInfo info, ProjectileArgs args)
|
||||||
{
|
{
|
||||||
this.args = args;
|
this.args = args;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
target = args.PassiveTarget;
|
|
||||||
source = args.Source;
|
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)
|
public void Tick(World world)
|
||||||
{
|
{
|
||||||
// Check for blocking actors
|
// Check for blocking actors
|
||||||
WPos blockedPos;
|
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))
|
info.Width, info.TargetExtraSearchRadius, out blockedPos))
|
||||||
{
|
{
|
||||||
target = blockedPos;
|
target = Target.FromPos(blockedPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.Inaccuracy.Length > 0)
|
args.Weapon.Impact(target, args.SourceActor, args.DamageModifiers);
|
||||||
{
|
world.AddFrameEndTask(w => w.Remove(this));
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||||
|
|||||||
Reference in New Issue
Block a user