Introduce Weapon.TargetActorCenter and adapt projectiles
This also fixes issues with attackers that don't have their own Attack trait.
This commit is contained in:
@@ -57,9 +57,6 @@ 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;
|
||||
|
||||
@@ -160,7 +157,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
|
||||
if (args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||
{
|
||||
var guidedTargetPos = info.TargetCenterPosition ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(args.Source);
|
||||
var guidedTargetPos = args.Weapon.TargetActorCenter ? 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 +
|
||||
|
||||
@@ -21,9 +21,6 @@ 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;
|
||||
|
||||
@@ -60,9 +57,9 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
this.info = info;
|
||||
source = args.Source;
|
||||
|
||||
if (info.TargetCenterPosition)
|
||||
if (args.Weapon.TargetActorCenter)
|
||||
target = args.GuidedTarget;
|
||||
else if (!info.TargetCenterPosition && info.Inaccuracy.Length > 0)
|
||||
else 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;
|
||||
|
||||
@@ -49,9 +49,6 @@ 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;
|
||||
|
||||
@@ -131,7 +128,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
{
|
||||
// Beam tracks target
|
||||
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||
target = info.TargetCenterPosition ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(source);
|
||||
target = args.Weapon.TargetActorCenter ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(source);
|
||||
|
||||
// Check for blocking actors
|
||||
WPos blockedPos;
|
||||
|
||||
@@ -137,9 +137,6 @@ 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.")]
|
||||
@@ -802,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 = (info.TargetCenterPosition ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(args.Source))
|
||||
newTarPos = (args.Weapon.TargetActorCenter ? 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)
|
||||
|
||||
Reference in New Issue
Block a user