diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 52ba39f694..df757835b1 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -170,7 +170,7 @@ namespace OpenRA.Traits public static readonly Target None = new Target(); public bool IsValid { get { return valid && (actor == null || actor.IsInWorld); } } - public float2 CenterLocation { get { return actor != null ? actor.CenterLocation : pos; } } + public float2 CenterLocation { get { return actor != null ? actor.CenterLocation : Util.CenterOfCell(pos.ToInt2()); } } public Actor Actor { get { return actor; } } public bool IsActor { get { return actor != null; } } diff --git a/OpenRA.Mods.RA/AttackBase.cs b/OpenRA.Mods.RA/AttackBase.cs index 80340b4add..ec4e0f2096 100755 --- a/OpenRA.Mods.RA/AttackBase.cs +++ b/OpenRA.Mods.RA/AttackBase.cs @@ -136,7 +136,9 @@ namespace OpenRA.Mods.RA var weapon = Rules.Weapons[weaponName.ToLowerInvariant()]; - //if (weapon.Range * weapon.Range < (target.CenterLocation - self.Location).LengthSquared) return false; + if (weapon.Range * weapon.Range * Game.CellSize * Game.CellSize + < (target.CenterLocation - self.CenterLocation).LengthSquared) return false; + if (!Combat.WeaponValidForTarget(weapon, target)) return false; var numOffsets = (localOffset.Length + 2) / 3; @@ -165,7 +167,7 @@ namespace OpenRA.Mods.RA weapon = Rules.Weapons[weaponName.ToLowerInvariant()], firedBy = self, - target = target.Actor, + target = this.target, src = self.CenterLocation.ToInt2() + Combat.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(), srcAltitude = unit != null ? unit.Altitude : 0,