From a56ffb581f3fe30edaf9941251408bd49716832d Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Sun, 10 Jan 2016 00:59:33 +0100 Subject: [PATCH 1/3] Move some checks in *AttackNotifier to improve performance --- OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs | 8 ++++---- .../Traits/Player/HarvesterAttackNotifier.cs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs index 9d0a4a58e8..307bc296f8 100644 --- a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs +++ b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs @@ -47,10 +47,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,6 +56,10 @@ 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; 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) From 79829c5270ac4de8191787683a794b9a41c20e65 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Fri, 22 Jan 2016 18:21:13 +0100 Subject: [PATCH 2/3] Add support for playing a "Our ally is under attack" notification --- .../Traits/Player/BaseAttackNotifier.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs b/OpenRA.Mods.Common/Traits/Player/BaseAttackNotifier.cs index 307bc296f8..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); } } @@ -65,7 +69,13 @@ namespace OpenRA.Mods.Common.Traits 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); From a2753ad1e4af8839619281be36aee283d178dc2a Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Fri, 22 Jan 2016 18:35:40 +0100 Subject: [PATCH 3/3] Make use of the OurAllyIsUnderAttack notification in ts --- mods/ts/rules/player.yaml | 1 + 1 file changed, 1 insertion(+) 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: