Fix the in range check

This commit is contained in:
alzeih
2010-07-22 13:27:41 +12:00
parent 3395f97b20
commit 4e22e37192
2 changed files with 5 additions and 3 deletions

View File

@@ -170,7 +170,7 @@ namespace OpenRA.Traits
public static readonly Target None = new Target(); public static readonly Target None = new Target();
public bool IsValid { get { return valid && (actor == null || actor.IsInWorld); } } 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 Actor Actor { get { return actor; } }
public bool IsActor { get { return actor != null; } } public bool IsActor { get { return actor != null; } }

View File

@@ -136,7 +136,9 @@ namespace OpenRA.Mods.RA
var weapon = Rules.Weapons[weaponName.ToLowerInvariant()]; 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; if (!Combat.WeaponValidForTarget(weapon, target)) return false;
var numOffsets = (localOffset.Length + 2) / 3; var numOffsets = (localOffset.Length + 2) / 3;
@@ -165,7 +167,7 @@ namespace OpenRA.Mods.RA
weapon = Rules.Weapons[weaponName.ToLowerInvariant()], weapon = Rules.Weapons[weaponName.ToLowerInvariant()],
firedBy = self, firedBy = self,
target = target.Actor, target = this.target,
src = self.CenterLocation.ToInt2() + Combat.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(), src = self.CenterLocation.ToInt2() + Combat.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(),
srcAltitude = unit != null ? unit.Altitude : 0, srcAltitude = unit != null ? unit.Altitude : 0,