Allow Attack activities to target FrozenActors directly.

Removing the legacy FrozenActor to Actor workaround
fixes a number of long-standing bugs.

This also prevents units from losing their target when
it transforms into a different actor type.
This commit is contained in:
Paul Chote
2018-12-16 13:01:01 +13:00
committed by Oliver Brakmann
parent 0406b89a96
commit c34dd4b824
12 changed files with 133 additions and 47 deletions

View File

@@ -31,6 +31,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Does the attack type require the attacker to enter the target's cell?")]
public readonly bool AttackRequiresEnteringCell = false;
[Desc("Allow firing into the fog to target frozen actors without requiring force-fire.")]
public readonly bool TargetFrozenActors = false;
[VoiceReference] public readonly string Voice = "Action";
public override abstract object Create(ActorInitializer init);
@@ -154,12 +157,11 @@ namespace OpenRA.Mods.Common.Traits
var forceAttack = order.OrderString == forceAttackOrderName;
if (forceAttack || order.OrderString == attackOrderName)
{
var target = self.ResolveFrozenActorOrder(order, Color.Red);
if (!target.IsValidFor(self))
if (!order.Target.IsValidFor(self))
return;
self.SetTargetLine(target, Color.Red);
AttackTarget(target, order.Queued, true, forceAttack);
self.SetTargetLine(order.Target, Color.Red);
AttackTarget(order.Target, order.Queued, true, forceAttack);
}
if (order.OrderString == "Stop")
@@ -417,7 +419,8 @@ namespace OpenRA.Mods.Common.Traits
if (a == null)
a = armaments.First();
cursor = !target.IsInRange(self.CenterPosition, a.MaxRange())
cursor = !target.IsInRange(self.CenterPosition, a.MaxRange()) ||
(!forceAttack && target.Type == TargetType.FrozenActor && !ab.Info.TargetFrozenActors)
? ab.Info.OutsideRangeCursor ?? a.Info.OutsideRangeCursor
: ab.Info.Cursor ?? a.Info.Cursor;