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:
@@ -69,6 +69,9 @@ namespace OpenRA.GameRules
|
|||||||
[Desc("The minimum range the weapon can fire.")]
|
[Desc("The minimum range the weapon can fire.")]
|
||||||
public readonly WDist MinRange = WDist.Zero;
|
public readonly WDist MinRange = WDist.Zero;
|
||||||
|
|
||||||
|
[Desc("Does this weapon aim at the target's center regardless of other targetable offsets?")]
|
||||||
|
public readonly bool TargetActorCenter = false;
|
||||||
|
|
||||||
[FieldLoader.LoadUsing("LoadProjectile")]
|
[FieldLoader.LoadUsing("LoadProjectile")]
|
||||||
public readonly IProjectileInfo Projectile;
|
public readonly IProjectileInfo Projectile;
|
||||||
|
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ namespace OpenRA.Mods.Cnc.Projectiles
|
|||||||
|
|
||||||
public readonly bool TrackTarget = true;
|
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); }
|
public IProjectile Create(ProjectileArgs args) { return new TeslaZap(this, args); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +64,7 @@ namespace OpenRA.Mods.Cnc.Projectiles
|
|||||||
|
|
||||||
// Zap tracks target
|
// Zap tracks target
|
||||||
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))
|
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))
|
||||||
target = info.TargetCenterPosition ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(args.Source);
|
target = args.Weapon.TargetActorCenter ? args.GuidedTarget.CenterPosition : args.GuidedTarget.Positions.PositionClosestTo(args.Source);
|
||||||
|
|
||||||
if (damageDuration-- > 0)
|
if (damageDuration-- > 0)
|
||||||
args.Weapon.Impact(Target.FromPos(target), args.SourceActor, args.DamageModifiers);
|
args.Weapon.Impact(Target.FromPos(target), args.SourceActor, args.DamageModifiers);
|
||||||
|
|||||||
@@ -57,9 +57,6 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
[Desc("Does the beam follow the target.")]
|
[Desc("Does the beam follow the target.")]
|
||||||
public readonly bool TrackTarget = false;
|
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.")]
|
[Desc("Should the beam be visually rendered? False = Beam is invisible.")]
|
||||||
public readonly bool RenderBeam = true;
|
public readonly bool RenderBeam = true;
|
||||||
|
|
||||||
@@ -160,7 +157,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
|
|
||||||
if (args.GuidedTarget.IsValidFor(args.SourceActor))
|
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);
|
var targetDistance = new WDist((guidedTargetPos - args.Source).Length);
|
||||||
|
|
||||||
// Only continue tracking target if it's within weapon range +
|
// 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.")]
|
[Desc("Simple, invisible, usually direct-on-target projectile.")]
|
||||||
public class InstantHitInfo : IProjectileInfo, IRulesetLoaded<WeaponInfo>
|
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.")]
|
[Desc("Maximum offset at the maximum range.")]
|
||||||
public readonly WDist Inaccuracy = WDist.Zero;
|
public readonly WDist Inaccuracy = WDist.Zero;
|
||||||
|
|
||||||
@@ -60,9 +57,9 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
source = args.Source;
|
source = args.Source;
|
||||||
|
|
||||||
if (info.TargetCenterPosition)
|
if (args.Weapon.TargetActorCenter)
|
||||||
target = args.GuidedTarget;
|
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 inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
|
||||||
var maxOffset = inaccuracy * (args.PassiveTarget - source).Length / args.Weapon.Range.Length;
|
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.")]
|
[Desc("Beam can be blocked.")]
|
||||||
public readonly bool Blockable = false;
|
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).")]
|
[Desc("Draw a second beam (for 'glow' effect).")]
|
||||||
public readonly bool SecondaryBeam = false;
|
public readonly bool SecondaryBeam = false;
|
||||||
|
|
||||||
@@ -131,7 +128,7 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
{
|
{
|
||||||
// Beam tracks target
|
// Beam tracks target
|
||||||
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))
|
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
|
// Check for blocking actors
|
||||||
WPos blockedPos;
|
WPos blockedPos;
|
||||||
|
|||||||
@@ -137,9 +137,6 @@ namespace OpenRA.Mods.Common.Projectiles
|
|||||||
"the missile enters the radius of the current speed around the target.")]
|
"the missile enters the radius of the current speed around the target.")]
|
||||||
public readonly bool AllowSnapping = false;
|
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.",
|
[Desc("Explodes when inside this proximity radius to target.",
|
||||||
"Note: If this value is lower than the missile speed, this check might",
|
"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.")]
|
"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)
|
// Check if target position should be updated (actor visible & locked on)
|
||||||
var newTarPos = targetPosition;
|
var newTarPos = targetPosition;
|
||||||
if (args.GuidedTarget.IsValidFor(args.SourceActor) && lockOn)
|
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);
|
+ new WVec(WDist.Zero, WDist.Zero, info.AirburstAltitude);
|
||||||
|
|
||||||
// Compute target's predicted velocity vector (assuming uniform circular motion)
|
// Compute target's predicted velocity vector (assuming uniform circular motion)
|
||||||
|
|||||||
@@ -102,8 +102,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly Barrel[] Barrels;
|
public readonly Barrel[] Barrels;
|
||||||
|
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
readonly AttackBase[] attackTraits;
|
|
||||||
AttackBase attack;
|
|
||||||
Turreted turret;
|
Turreted turret;
|
||||||
AmmoPool ammoPool;
|
AmmoPool ammoPool;
|
||||||
BodyOrientation coords;
|
BodyOrientation coords;
|
||||||
@@ -143,7 +141,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
barrels.Add(new Barrel { Offset = WVec.Zero, Yaw = WAngle.Zero });
|
barrels.Add(new Barrel { Offset = WVec.Zero, Yaw = WAngle.Zero });
|
||||||
|
|
||||||
Barrels = barrels.ToArray();
|
Barrels = barrels.ToArray();
|
||||||
attackTraits = self.TraitsImplementing<AttackBase>().Where(a => a.Info.Armaments.Contains(Info.Name)).ToArray();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual WDist MaxRange()
|
public virtual WDist MaxRange()
|
||||||
@@ -206,10 +203,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
// The world coordinate model uses Actor.Orientation
|
// The world coordinate model uses Actor.Orientation
|
||||||
public virtual Barrel CheckFire(Actor self, IFacing facing, Target target)
|
public virtual Barrel CheckFire(Actor self, IFacing facing, Target target)
|
||||||
{
|
{
|
||||||
attack = attackTraits.FirstOrDefault(Exts.IsTraitEnabled);
|
|
||||||
if (attack == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (IsReloading)
|
if (IsReloading)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -246,7 +239,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Source = muzzlePosition(),
|
Source = muzzlePosition(),
|
||||||
CurrentSource = muzzlePosition,
|
CurrentSource = muzzlePosition,
|
||||||
SourceActor = self,
|
SourceActor = self,
|
||||||
PassiveTarget = attack.Info.AttackTargetCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition()),
|
PassiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition()),
|
||||||
GuidedTarget = target
|
GuidedTarget = target
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ ArtilleryShell:
|
|||||||
Range: 11c0
|
Range: 11c0
|
||||||
MinRange: 3c0
|
MinRange: 3c0
|
||||||
Report: tnkfire2.aud
|
Report: tnkfire2.aud
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: Bullet
|
Projectile: Bullet
|
||||||
Speed: 204
|
Speed: 204
|
||||||
Blockable: false
|
Blockable: false
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ MammothMissiles:
|
|||||||
BurstDelay: 4
|
BurstDelay: 4
|
||||||
Report: rocket1.aud
|
Report: rocket1.aud
|
||||||
ValidTargets: Ground
|
ValidTargets: Ground
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: Bullet
|
Projectile: Bullet
|
||||||
Inaccuracy: 853
|
Inaccuracy: 853
|
||||||
LaunchAngle: 62
|
LaunchAngle: 62
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ TurretGun:
|
|||||||
Inherits: ^Artillery
|
Inherits: ^Artillery
|
||||||
MinRange: 3c0
|
MinRange: 3c0
|
||||||
Report: tank5.aud
|
Report: tank5.aud
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: Bullet
|
Projectile: Bullet
|
||||||
ContrailLength: 30
|
ContrailLength: 30
|
||||||
|
|
||||||
@@ -116,6 +117,7 @@ TurretGun:
|
|||||||
Range: 16c0
|
Range: 16c0
|
||||||
Burst: 2
|
Burst: 2
|
||||||
Report: turret1.aud
|
Report: turret1.aud
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: Bullet
|
Projectile: Bullet
|
||||||
Inaccuracy: 2c938
|
Inaccuracy: 2c938
|
||||||
ContrailLength: 30
|
ContrailLength: 30
|
||||||
|
|||||||
@@ -295,6 +295,7 @@ TorpTube:
|
|||||||
SubMissile:
|
SubMissile:
|
||||||
Inherits: ^SubMissileDefault
|
Inherits: ^SubMissileDefault
|
||||||
Range: 16c0
|
Range: 16c0
|
||||||
|
TargetActorCenter: true
|
||||||
-Projectile:
|
-Projectile:
|
||||||
Projectile: Bullet
|
Projectile: Bullet
|
||||||
Speed: 162
|
Speed: 162
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ RPGTower:
|
|||||||
Inherits: ^ArtilleryWeapon
|
Inherits: ^ArtilleryWeapon
|
||||||
ReloadDelay: 110
|
ReloadDelay: 110
|
||||||
Range: 18c0
|
Range: 18c0
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: Bullet
|
Projectile: Bullet
|
||||||
Speed: 384
|
Speed: 384
|
||||||
LaunchAngle: 165
|
LaunchAngle: 165
|
||||||
@@ -117,6 +118,7 @@ Jugg90mm:
|
|||||||
BurstDelay: 3
|
BurstDelay: 3
|
||||||
-Report:
|
-Report:
|
||||||
StartBurstReport: jugger1.aud
|
StartBurstReport: jugger1.aud
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: Bullet
|
Projectile: Bullet
|
||||||
Speed: 384
|
Speed: 384
|
||||||
LaunchAngle: 165
|
LaunchAngle: 165
|
||||||
|
|||||||
@@ -200,8 +200,8 @@ TurretLaserFire:
|
|||||||
Damage: 30
|
Damage: 30
|
||||||
|
|
||||||
LaserFence:
|
LaserFence:
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: InstantHit
|
Projectile: InstantHit
|
||||||
TargetCenterPosition: true
|
|
||||||
Warhead@1Dam: TargetDamage
|
Warhead@1Dam: TargetDamage
|
||||||
DebugOverlayColor: FF0000
|
DebugOverlayColor: FF0000
|
||||||
Damage: 99999
|
Damage: 99999
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
Range: 2c849
|
Range: 2c849
|
||||||
Report: healer1.aud
|
Report: healer1.aud
|
||||||
ValidTargets: Infantry
|
ValidTargets: Infantry
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: InstantHit
|
Projectile: InstantHit
|
||||||
TargetCenterPosition: true
|
|
||||||
Warhead@1Dam: TargetDamage
|
Warhead@1Dam: TargetDamage
|
||||||
DebugOverlayColor: 00FF00
|
DebugOverlayColor: 00FF00
|
||||||
Damage: -50
|
Damage: -50
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Bomb:
|
|||||||
Burst: 5
|
Burst: 5
|
||||||
BurstDelay: 6
|
BurstDelay: 6
|
||||||
Range: 2c512
|
Range: 2c512
|
||||||
|
TargetActorCenter: true
|
||||||
Projectile: GravityBomb
|
Projectile: GravityBomb
|
||||||
Velocity: 72, 0, -90
|
Velocity: 72, 0, -90
|
||||||
Acceleration: 0, 0, -8
|
Acceleration: 0, 0, -8
|
||||||
|
|||||||
Reference in New Issue
Block a user