Fix the in range check
This commit is contained in:
@@ -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; } }
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user