Fix actors returning fire at invisible attackers

This commit is contained in:
abcdefg30
2019-09-26 21:00:31 +02:00
committed by reaperrr
parent d20182f158
commit 980c0c9cd4

View File

@@ -243,6 +243,11 @@ namespace OpenRA.Mods.Common.Traits
attacker = passenger.Transport; attacker = passenger.Transport;
} }
// Don't fire at an invisible enemy when we can't move to reveal it
var allowMove = Info.AllowMovement && Stance > UnitStance.Defend;
if (!allowMove && !attacker.CanBeViewedByPlayer(self.Owner))
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?
var attackerAsTarget = Target.FromActor(attacker); var attackerAsTarget = Target.FromActor(attacker);
if (!ActiveAttackBases.Any(a => a.HasAnyValidWeapons(attackerAsTarget))) if (!ActiveAttackBases.Any(a => a.HasAnyValidWeapons(attackerAsTarget)))
@@ -254,7 +259,6 @@ namespace OpenRA.Mods.Common.Traits
Aggressor = attacker; Aggressor = attacker;
var allowMove = Info.AllowMovement && Stance > UnitStance.Defend;
Attack(self, Target.FromActor(Aggressor), allowMove); Attack(self, Target.FromActor(Aggressor), allowMove);
} }