only retaliate if idle

This commit is contained in:
Chris Forbes
2010-03-27 20:41:37 +13:00
parent f6a52f4e50
commit e15fc6a425

View File

@@ -72,18 +72,15 @@ namespace OpenRA.Traits
public void Damaged(Actor self, AttackInfo e) public void Damaged(Actor self, AttackInfo e)
{ {
if (!self.IsIdle) return;
// 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?
if (!Combat.HasAnyValidWeapons(self, e.Attacker)) if (!Combat.HasAnyValidWeapons(self, e.Attacker)) return;
return;
if (self.Owner.Stances[e.Attacker.Owner] == Stance.Ally) // don't retaliate against own units force-firing on us. it's usually not what the player wanted.
return; // don't retaliate against own units force-firing on us. it's usually not what the player wanted. if (self.Owner.Stances[e.Attacker.Owner] == Stance.Ally) return;
if (e.Damage < 0) if (e.Damage < 0) return; // don't retaliate against healers
return; // don't retaliate against healers
var attack = self.traits.Get<AttackBase>();
if (attack.target != null) return;
AttackTarget(self, e.Attacker); AttackTarget(self, e.Attacker);
} }