Disable AutoTarget if targeting a persistent fallback.
This commit is contained in:
@@ -68,6 +68,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
attackAircraft.OpportunityTarget = attackAircraft.RequestedTarget;
|
attackAircraft.OpportunityTarget = attackAircraft.RequestedTarget;
|
||||||
attackAircraft.OpportunityForceAttack = attackAircraft.RequestedForceAttack;
|
attackAircraft.OpportunityForceAttack = attackAircraft.RequestedForceAttack;
|
||||||
|
attackAircraft.OpportunityTargetIsPersistentTarget = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
attackAircraft.RequestedTarget = Target.Invalid;
|
attackAircraft.RequestedTarget = Target.Invalid;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
attackAircraft.OpportunityTarget = attackAircraft.RequestedTarget;
|
attackAircraft.OpportunityTarget = attackAircraft.RequestedTarget;
|
||||||
attackAircraft.OpportunityForceAttack = attackAircraft.RequestedForceAttack;
|
attackAircraft.OpportunityForceAttack = attackAircraft.RequestedForceAttack;
|
||||||
|
attackAircraft.OpportunityTargetIsPersistentTarget = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
attackAircraft.RequestedTarget = Target.Invalid;
|
attackAircraft.RequestedTarget = Target.Invalid;
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override object Create(ActorInitializer init) { return new AttackFollow(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new AttackFollow(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AttackFollow : AttackBase, INotifyOwnerChanged
|
public class AttackFollow : AttackBase, INotifyOwnerChanged, IDisableAutoTarget
|
||||||
{
|
{
|
||||||
public new readonly AttackFollowInfo Info;
|
public new readonly AttackFollowInfo Info;
|
||||||
public Target RequestedTarget;
|
public Target RequestedTarget;
|
||||||
@@ -37,6 +37,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public int RequestedTargetLastTick;
|
public int RequestedTargetLastTick;
|
||||||
public Target OpportunityTarget;
|
public Target OpportunityTarget;
|
||||||
public bool OpportunityForceAttack;
|
public bool OpportunityForceAttack;
|
||||||
|
public bool OpportunityTargetIsPersistentTarget;
|
||||||
|
|
||||||
Mobile mobile;
|
Mobile mobile;
|
||||||
AutoTarget autoTarget;
|
AutoTarget autoTarget;
|
||||||
|
|
||||||
@@ -74,7 +76,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
protected override void Tick(Actor self)
|
protected override void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsTraitDisabled)
|
if (IsTraitDisabled)
|
||||||
|
{
|
||||||
RequestedTarget = OpportunityTarget = Target.Invalid;
|
RequestedTarget = OpportunityTarget = Target.Invalid;
|
||||||
|
OpportunityTargetIsPersistentTarget = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (RequestedTargetLastTick != self.World.WorldTick)
|
if (RequestedTargetLastTick != self.World.WorldTick)
|
||||||
{
|
{
|
||||||
@@ -106,6 +111,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
OpportunityTarget = autoTarget.ScanForTarget(self, false, false);
|
OpportunityTarget = autoTarget.ScanForTarget(self, false, false);
|
||||||
OpportunityForceAttack = false;
|
OpportunityForceAttack = false;
|
||||||
|
OpportunityTargetIsPersistentTarget = false;
|
||||||
|
|
||||||
if (OpportunityTarget.Type != TargetType.Invalid)
|
if (OpportunityTarget.Type != TargetType.Invalid)
|
||||||
IsAiming = CanAimAtTarget(self, OpportunityTarget, OpportunityForceAttack);
|
IsAiming = CanAimAtTarget(self, OpportunityTarget, OpportunityForceAttack);
|
||||||
@@ -139,12 +145,20 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override void OnStopOrder(Actor self)
|
public override void OnStopOrder(Actor self)
|
||||||
{
|
{
|
||||||
RequestedTarget = OpportunityTarget = Target.Invalid;
|
RequestedTarget = OpportunityTarget = Target.Invalid;
|
||||||
|
OpportunityTargetIsPersistentTarget = false;
|
||||||
base.OnStopOrder(self);
|
base.OnStopOrder(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
void INotifyOwnerChanged.OnOwnerChanged(Actor self, Player oldOwner, Player newOwner)
|
||||||
{
|
{
|
||||||
RequestedTarget = OpportunityTarget = Target.Invalid;
|
RequestedTarget = OpportunityTarget = Target.Invalid;
|
||||||
|
OpportunityTargetIsPersistentTarget = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IDisableAutoTarget.DisableAutoTarget(Actor self)
|
||||||
|
{
|
||||||
|
return RequestedTarget.Type != TargetType.Invalid ||
|
||||||
|
(OpportunityTargetIsPersistentTarget && OpportunityTarget.Type != TargetType.Invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
class AttackActivity : Activity
|
class AttackActivity : Activity
|
||||||
@@ -198,6 +212,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
attack.OpportunityTarget = attack.RequestedTarget;
|
attack.OpportunityTarget = attack.RequestedTarget;
|
||||||
attack.OpportunityForceAttack = attack.RequestedForceAttack;
|
attack.OpportunityForceAttack = attack.RequestedForceAttack;
|
||||||
|
attack.OpportunityTargetIsPersistentTarget = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
attack.RequestedTarget = Target.Invalid;
|
attack.RequestedTarget = Target.Invalid;
|
||||||
|
|||||||
Reference in New Issue
Block a user