diff --git a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs index 9d0a4a58e8..78a2f0072e 100644 --- a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs +++ b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs @@ -28,6 +28,10 @@ namespace OpenRA.Mods.Common.Traits [Desc("The audio notification type to play.")] public string Notification = "BaseAttack"; + [Desc("The audio notification to play to allies when under attack.", + "Won't play a notification to allies if this is null.")] + public string AllyNotification = null; + public object Create(ActorInitializer init) { return new BaseAttackNotifier(init.Self, this); } } @@ -47,10 +51,6 @@ namespace OpenRA.Mods.Common.Traits public void Damaged(Actor self, AttackInfo e) { - // only track last hit against our base - if (!self.Info.HasTraitInfo()) - return; - if (e.Attacker == null) return; @@ -60,12 +60,22 @@ namespace OpenRA.Mods.Common.Traits if (e.Attacker == self.World.WorldActor) return; + // Only track last hit against our base + if (!self.Info.HasTraitInfo()) + return; + if (e.Attacker.Owner.IsAlliedWith(self.Owner) && e.Damage <= 0) return; if (self.World.WorldTick - lastAttackTime > info.NotifyInterval * 25) { - Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.Notification, self.Owner.Faction.InternalName); + var rules = self.World.Map.Rules; + Game.Sound.PlayNotification(rules, self.Owner, "Speech", info.Notification, self.Owner.Faction.InternalName); + + if (info.AllyNotification != null) + foreach (Player p in self.World.Players) + if (p != self.Owner && p.IsAlliedWith(self.Owner) && p != e.Attacker.Owner) + Game.Sound.PlayNotification(rules, p, "Speech", info.AllyNotification, p.Faction.InternalName); if (radarPings != null) radarPings.Add(() => self.Owner.IsAlliedWith(self.World.RenderPlayer), self.CenterPosition, info.RadarPingColor, info.RadarPingDuration); diff --git a/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs b/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs index dd809207ac..fa9260ca6a 100644 --- a/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs +++ b/OpenRA.Mods.Common/Traits/Player/HarvesterAttackNotifier.cs @@ -47,12 +47,12 @@ namespace OpenRA.Mods.Common.Traits public void Damaged(Actor self, AttackInfo e) { - // only track last hit against our harvesters - if (!self.Info.HasTraitInfo()) + // Don't track self-damage + if (e.Attacker != null && e.Attacker.Owner == self.Owner) return; - // don't track self-damage - if (e.Attacker != null && e.Attacker.Owner == self.Owner) + // Only track last hit against our harvesters + if (!self.Info.HasTraitInfo()) return; if (self.World.WorldTick - lastAttackTime > info.NotifyInterval * 25) diff --git a/mods/ts/rules/player.yaml b/mods/ts/rules/player.yaml index 344eb99949..9758e01dd0 100644 --- a/mods/ts/rules/player.yaml +++ b/mods/ts/rules/player.yaml @@ -44,6 +44,7 @@ Player: Shroud: FrozenActorLayer: BaseAttackNotifier: + AllyNotification: OurAllyIsUnderAttack HarvesterAttackNotifier: PlayerStatistics: PlaceBeacon: