From 4e22e37192ce1786d0cee89ab5644679dffe0103 Mon Sep 17 00:00:00 2001 From: alzeih Date: Thu, 22 Jul 2010 13:27:41 +1200 Subject: [PATCH] Fix the in range check --- OpenRA.Game/Traits/TraitsInterfaces.cs | 2 +- OpenRA.Mods.RA/AttackBase.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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,