Make attacking actors/turrets face the targeted position

This commit is contained in:
reaperrr
2017-05-05 14:16:28 +02:00
committed by Oliver Brakmann
parent 7acc6dacbc
commit 6a212eea53
4 changed files with 11 additions and 5 deletions

View File

@@ -100,8 +100,9 @@ namespace OpenRA.Mods.Common.Activities
minRange = armaments.Max(a => a.Weapon.MinRange);
maxRange = armaments.Min(a => a.MaxRange());
var pos = self.CenterPosition;
var mobile = move as Mobile;
if (!Target.IsInRange(self.CenterPosition, maxRange) || Target.IsInRange(self.CenterPosition, minRange)
if (!Target.IsInRange(pos, maxRange) || Target.IsInRange(pos, minRange)
|| (mobile != null && !mobile.CanInteractWithGroundLayer(self)))
{
// Try to move within range, drop the target otherwise
@@ -113,7 +114,8 @@ namespace OpenRA.Mods.Common.Activities
return NextActivity;
}
var desiredFacing = (Target.CenterPosition - self.CenterPosition).Yaw.Facing;
var targetedPosition = Target.Positions.PositionClosestTo(pos);
var desiredFacing = (targetedPosition - pos).Yaw.Facing;
if (facing.Facing != desiredFacing)
{
attackStatus |= AttackStatus.NeedsToTurn;