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:
committed by
Oliver Brakmann
parent
73577e3a7e
commit
7acc6dacbc
@@ -157,7 +157,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
|
||||
if (args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||
{
|
||||
var guidedTargetPos = args.GuidedTarget.CenterPosition;
|
||||
var guidedTargetPos = args.GuidedTarget.Positions.PositionClosestTo(args.Source);
|
||||
var targetDistance = new WDist((guidedTargetPos - args.Source).Length);
|
||||
|
||||
// Only continue tracking target if it's within weapon range +
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
{
|
||||
// Beam tracks target
|
||||
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||
target = args.GuidedTarget.CenterPosition;
|
||||
target = args.GuidedTarget.Positions.PositionClosestTo(source);
|
||||
|
||||
// Check for blocking actors
|
||||
WPos blockedPos;
|
||||
|
||||
@@ -799,7 +799,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
// Check if target position should be updated (actor visible & locked on)
|
||||
var newTarPos = targetPosition;
|
||||
if (args.GuidedTarget.IsValidFor(args.SourceActor) && lockOn)
|
||||
newTarPos = args.GuidedTarget.CenterPosition
|
||||
newTarPos = args.GuidedTarget.Positions.PositionClosestTo(args.Source)
|
||||
+ new WVec(WDist.Zero, WDist.Zero, info.AirburstAltitude);
|
||||
|
||||
// Compute target's predicted velocity vector (assuming uniform circular motion)
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Source = muzzlePosition(),
|
||||
CurrentSource = muzzlePosition,
|
||||
SourceActor = self,
|
||||
PassiveTarget = target.CenterPosition,
|
||||
PassiveTarget = target.Positions.PositionClosestTo(muzzlePosition()),
|
||||
GuidedTarget = target
|
||||
};
|
||||
|
||||
|
||||
@@ -201,6 +201,7 @@ TurretLaserFire:
|
||||
|
||||
LaserFence:
|
||||
Projectile: InstantHit
|
||||
TargetCenterPosition: true
|
||||
Warhead@1Dam: TargetDamage
|
||||
DebugOverlayColor: FF0000
|
||||
Damage: 99999
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
Report: healer1.aud
|
||||
ValidTargets: Infantry
|
||||
Projectile: InstantHit
|
||||
TargetCenterPosition: true
|
||||
Warhead@1Dam: TargetDamage
|
||||
DebugOverlayColor: 00FF00
|
||||
Damage: -50
|
||||
|
||||
Reference in New Issue
Block a user