Add ValidStances to AutoTargetPriority.
This commit is contained in:
committed by
reaperrr
parent
25bc3ae2d2
commit
e7b8a56511
@@ -294,6 +294,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
foreach (var target in targetsInRange)
|
||||
{
|
||||
BitSet<TargetableType> targetTypes;
|
||||
Player owner;
|
||||
if (target.Type == TargetType.Actor)
|
||||
{
|
||||
// PERF: Most units can only attack enemy units. If this is the case but the target is not an enemy, we
|
||||
@@ -308,6 +309,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (PreventsAutoTarget(self, target.Actor) || !target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||
continue;
|
||||
|
||||
owner = target.Actor.Owner;
|
||||
}
|
||||
else if (target.Type == TargetType.FrozenActor)
|
||||
{
|
||||
@@ -315,6 +318,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
continue;
|
||||
|
||||
targetTypes = target.FrozenActor.TargetTypes;
|
||||
owner = target.FrozenActor.Owner;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
@@ -325,6 +329,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (ati.Priority < chosenTargetPriority)
|
||||
return false;
|
||||
|
||||
// Incompatible stances
|
||||
if (!ati.ValidStances.HasStance(self.Owner.Stances[owner]))
|
||||
return false;
|
||||
|
||||
// Incompatible target types
|
||||
if (!ati.ValidTargets.Overlaps(targetTypes) || ati.InvalidTargets.Overlaps(targetTypes))
|
||||
return false;
|
||||
|
||||
@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Target types that can't be AutoTargeted.", "Overrules ValidTargets.")]
|
||||
public readonly BitSet<TargetableType> InvalidTargets;
|
||||
|
||||
[Desc("Stances between actor's and target's owner which can be AutoTargeted.")]
|
||||
public readonly Stance ValidStances = Stance.Ally | Stance.Neutral | Stance.Enemy;
|
||||
|
||||
[Desc("ValidTargets with larger priorities will be AutoTargeted before lower priorities.")]
|
||||
public readonly int Priority = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user