Make attacking actors/turrets face the targeted position
This commit is contained in:
committed by
Oliver Brakmann
parent
7acc6dacbc
commit
6a212eea53
@@ -39,7 +39,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return false;
|
||||
|
||||
var f = facing.Facing;
|
||||
var delta = target.CenterPosition - self.CenterPosition;
|
||||
var pos = self.CenterPosition;
|
||||
var targetedPosition = target.Positions.PositionClosestTo(pos);
|
||||
var delta = targetedPosition - pos;
|
||||
var facingToTarget = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : f;
|
||||
|
||||
if (Math.Abs(facingToTarget - f) % 256 > info.FacingTolerance)
|
||||
|
||||
@@ -146,7 +146,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
var pos = self.CenterPosition;
|
||||
var targetYaw = (target.CenterPosition - self.CenterPosition).Yaw;
|
||||
var targetedPosition = target.Positions.PositionClosestTo(pos);
|
||||
var targetYaw = (targetedPosition - pos).Yaw;
|
||||
|
||||
foreach (var a in Armaments)
|
||||
{
|
||||
|
||||
@@ -130,7 +130,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (self.IsDisabled())
|
||||
return false;
|
||||
|
||||
var delta = target.CenterPosition - self.CenterPosition;
|
||||
var pos = self.CenterPosition;
|
||||
var delta = target.Positions.PositionClosestTo(pos) - pos;
|
||||
DesiredFacing = delta.HorizontalLengthSquared != 0 ? delta.Yaw.Facing : TurretFacing;
|
||||
MoveTurret();
|
||||
return HasAchievedDesiredFacing;
|
||||
|
||||
Reference in New Issue
Block a user