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)
|
foreach (var target in targetsInRange)
|
||||||
{
|
{
|
||||||
BitSet<TargetableType> targetTypes;
|
BitSet<TargetableType> targetTypes;
|
||||||
|
Player owner;
|
||||||
if (target.Type == TargetType.Actor)
|
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
|
// 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))
|
if (PreventsAutoTarget(self, target.Actor) || !target.Actor.CanBeViewedByPlayer(self.Owner))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
owner = target.Actor.Owner;
|
||||||
}
|
}
|
||||||
else if (target.Type == TargetType.FrozenActor)
|
else if (target.Type == TargetType.FrozenActor)
|
||||||
{
|
{
|
||||||
@@ -315,6 +318,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
targetTypes = target.FrozenActor.TargetTypes;
|
targetTypes = target.FrozenActor.TargetTypes;
|
||||||
|
owner = target.FrozenActor.Owner;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
@@ -325,6 +329,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (ati.Priority < chosenTargetPriority)
|
if (ati.Priority < chosenTargetPriority)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Incompatible stances
|
||||||
|
if (!ati.ValidStances.HasStance(self.Owner.Stances[owner]))
|
||||||
|
return false;
|
||||||
|
|
||||||
// Incompatible target types
|
// Incompatible target types
|
||||||
if (!ati.ValidTargets.Overlaps(targetTypes) || ati.InvalidTargets.Overlaps(targetTypes))
|
if (!ati.ValidTargets.Overlaps(targetTypes) || ati.InvalidTargets.Overlaps(targetTypes))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Target types that can't be AutoTargeted.", "Overrules ValidTargets.")]
|
[Desc("Target types that can't be AutoTargeted.", "Overrules ValidTargets.")]
|
||||||
public readonly BitSet<TargetableType> InvalidTargets;
|
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.")]
|
[Desc("ValidTargets with larger priorities will be AutoTargeted before lower priorities.")]
|
||||||
public readonly int Priority = 1;
|
public readonly int Priority = 1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user