fix off-by-one in IsInRange. use CenterLocation in combat code where appropriate

This commit is contained in:
Bob
2010-11-04 01:20:40 +13:00
committed by Chris Forbes
parent 5c0cd50797
commit 80caf1818b
4 changed files with 7 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA
if (!attack.target.IsValid)
return true; // he's dead.
if ((attack.target.CenterLocation - self.Location).LengthSquared > range * range + 2)
if( !Combat.IsInRange( self.CenterLocation, range, attack.target ) )
return true; // wandered off faster than we could follow
if (attack.target.IsActor
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA
.Where(a => a.IsInWorld && !a.IsDead())
.Where(a => a.HasTrait<Health>() && a.GetDamageState() > DamageState.Undamaged)
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
.OrderBy(a => (a.Location - self.Location).LengthSquared)
.OrderBy(a => (a.CenterLocation - self.CenterLocation).LengthSquared)
.FirstOrDefault();
}
}