diff --git a/OpenRA.Mods.Cnc/Projectiles/TeslaZap.cs b/OpenRA.Mods.Cnc/Projectiles/TeslaZap.cs index 368435704f..da7eb8a067 100644 --- a/OpenRA.Mods.Cnc/Projectiles/TeslaZap.cs +++ b/OpenRA.Mods.Cnc/Projectiles/TeslaZap.cs @@ -36,6 +36,9 @@ namespace OpenRA.Mods.Cnc.Projectiles public readonly bool TrackTarget = true; + [Desc("Ignore any other targetable positions and aim directly at center of target actor.")] + public readonly bool TargetCenterPosition = false; + public IProjectile Create(ProjectileArgs args) { return new TeslaZap(this, args); } } @@ -64,7 +67,7 @@ namespace OpenRA.Mods.Cnc.Projectiles // Zap tracks target if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor)) - target = args.GuidedTarget.Positions.PositionClosestTo(args.Source); + target = info.TargetCenterPosition ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(args.Source); if (damageDuration-- > 0) args.Weapon.Impact(Target.FromPos(target), args.SourceActor, args.DamageModifiers); diff --git a/OpenRA.Mods.Common/Projectiles/AreaBeam.cs b/OpenRA.Mods.Common/Projectiles/AreaBeam.cs index 6879b3eaf9..5df9e9bfba 100644 --- a/OpenRA.Mods.Common/Projectiles/AreaBeam.cs +++ b/OpenRA.Mods.Common/Projectiles/AreaBeam.cs @@ -57,6 +57,9 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Does the beam follow the target.")] public readonly bool TrackTarget = false; + [Desc("Ignore any other targetable positions and aim directly at center of target actor.")] + public readonly bool TargetCenterPosition = false; + [Desc("Should the beam be visually rendered? False = Beam is invisible.")] public readonly bool RenderBeam = true; @@ -157,7 +160,7 @@ namespace OpenRA.Mods.Common.Projectiles if (args.GuidedTarget.IsValidFor(args.SourceActor)) { - var guidedTargetPos = args.GuidedTarget.Positions.PositionClosestTo(args.Source); + var guidedTargetPos = info.TargetCenterPosition ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(args.Source); var targetDistance = new WDist((guidedTargetPos - args.Source).Length); // Only continue tracking target if it's within weapon range + diff --git a/OpenRA.Mods.Common/Projectiles/LaserZap.cs b/OpenRA.Mods.Common/Projectiles/LaserZap.cs index c8ec89be47..c12c12a0d9 100644 --- a/OpenRA.Mods.Common/Projectiles/LaserZap.cs +++ b/OpenRA.Mods.Common/Projectiles/LaserZap.cs @@ -49,6 +49,9 @@ namespace OpenRA.Mods.Common.Projectiles [Desc("Beam can be blocked.")] public readonly bool Blockable = false; + [Desc("Ignore any other targetable positions and aim directly at center of target actor.")] + public readonly bool TargetCenterPosition = false; + [Desc("Draw a second beam (for 'glow' effect).")] public readonly bool SecondaryBeam = false; @@ -128,7 +131,7 @@ namespace OpenRA.Mods.Common.Projectiles { // Beam tracks target if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor)) - target = args.GuidedTarget.Positions.PositionClosestTo(source); + target = info.TargetCenterPosition ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(source); // Check for blocking actors WPos blockedPos; diff --git a/OpenRA.Mods.Common/Projectiles/Missile.cs b/OpenRA.Mods.Common/Projectiles/Missile.cs index 2e37c8b432..3e11417157 100644 --- a/OpenRA.Mods.Common/Projectiles/Missile.cs +++ b/OpenRA.Mods.Common/Projectiles/Missile.cs @@ -137,6 +137,9 @@ namespace OpenRA.Mods.Common.Projectiles "the missile enters the radius of the current speed around the target.")] public readonly bool AllowSnapping = false; + [Desc("Ignore any other targetable positions and aim directly at center of target actor.")] + public readonly bool TargetCenterPosition = false; + [Desc("Explodes when inside this proximity radius to target.", "Note: If this value is lower than the missile speed, this check might", "not trigger fast enough, causing the missile to fly past the target.")] @@ -799,7 +802,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.Positions.PositionClosestTo(args.Source) + newTarPos = (info.TargetCenterPosition ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(args.Source)) + new WVec(WDist.Zero, WDist.Zero, info.AirburstAltitude); // Compute target's predicted velocity vector (assuming uniform circular motion)