Remove TargetWhenIdle and TargetWhenDamaged from AutoTarget

This commit is contained in:
abcdefg30
2017-07-22 20:31:38 +02:00
committed by reaperrr
parent 0209c1c848
commit de7a0c9861
4 changed files with 90 additions and 26 deletions

View File

@@ -60,10 +60,6 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Ticks to wait until next AutoTarget: attempt.")]
public readonly int MaximumScanTimeInterval = 8;
public readonly bool TargetWhenIdle = true;
public readonly bool TargetWhenDamaged = true;
public override object Create(ActorInitializer init) { return new AutoTarget(init, this); }
public override void RulesetLoaded(Ruleset rules, ActorInfo info)
@@ -157,17 +153,18 @@ namespace OpenRA.Mods.Common.Traits
public void Damaged(Actor self, AttackInfo e)
{
if (IsTraitDisabled)
if (IsTraitDisabled || !self.IsIdle || Stance < UnitStance.ReturnFire)
return;
if (!self.IsIdle || !Info.TargetWhenDamaged)
// Don't retaliate against healers
if (e.Damage.Value < 0)
return;
var attacker = e.Attacker;
if (attacker.Disposed || Stance < UnitStance.ReturnFire)
if (attacker.Disposed)
return;
if (!attacker.IsInWorld && !attacker.Disposed)
if (!attacker.IsInWorld)
{
// If the aggressor is in a transport, then attack the transport instead
var passenger = attacker.TraitOrDefault<Passenger>();
@@ -175,19 +172,15 @@ namespace OpenRA.Mods.Common.Traits
attacker = passenger.Transport;
}
// not a lot we can do about things we can't hurt... although maybe we should automatically run away?
// Not a lot we can do about things we can't hurt... although maybe we should automatically run away?
var attackerAsTarget = Target.FromActor(attacker);
if (!activeAttackBases.Any(a => a.HasAnyValidWeapons(attackerAsTarget)))
return;
// don't retaliate against own units force-firing on us. It's usually not what the player wanted.
// Don't retaliate against own units force-firing on us. It's usually not what the player wanted.
if (attacker.AppearsFriendlyTo(self))
return;
// don't retaliate against healers
if (e.Damage.Value < 0)
return;
Aggressor = attacker;
bool allowMove;
@@ -197,10 +190,7 @@ namespace OpenRA.Mods.Common.Traits
public void TickIdle(Actor self)
{
if (IsTraitDisabled)
return;
if (Stance < UnitStance.Defend || !Info.TargetWhenIdle)
if (IsTraitDisabled || Stance < UnitStance.Defend)
return;
bool allowMove;