From 5ec11fba8f73d6c93a840a04b25045dafb9badef Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Mon, 11 Jan 2016 20:42:36 +0100 Subject: [PATCH 1/5] Allow falling back to infiltrator's value in InfiltrateForCash --- OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs index e033993aac..65237782b2 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs @@ -10,6 +10,7 @@ using System; using OpenRA.Mods.Common.Effects; +using OpenRA.Mods.Common.Traits; using OpenRA.Traits; namespace OpenRA.Mods.RA.Traits @@ -34,9 +35,10 @@ namespace OpenRA.Mods.RA.Traits { var targetResources = self.Owner.PlayerActor.Trait(); var spyResources = infiltrator.Owner.PlayerActor.Trait(); + var spyValue = infiltrator.Info.TraitInfoOrDefault(); var toTake = (targetResources.Cash + targetResources.Resources) * info.Percentage / 100; - var toGive = Math.Max(toTake, info.Minimum); + var toGive = Math.Max(toTake, info.Minimum >= 0 ? info.Minimum : spyValue != null ? spyValue.Cost : 0); targetResources.TakeCash(toTake); spyResources.GiveCash(toGive); From ee8323373bfe7dbd4985b424558149ad30d06255 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Mon, 11 Jan 2016 20:46:09 +0100 Subject: [PATCH 2/5] Add trait documentation to InfiltrateForCash --- OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs index 65237782b2..71d8906417 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs @@ -18,8 +18,14 @@ namespace OpenRA.Mods.RA.Traits [Desc("This structure can be infiltrated causing funds to be stolen.")] class InfiltrateForCashInfo : ITraitInfo { + [Desc("Percentage of the victim's resources that will be stolen.")] public readonly int Percentage = 50; + + [Desc("Amount of guaranteed funds to claim when the victim does not have enough resources.", + "When negative, the production price of the infiltrating actor will be used instead.")] public readonly int Minimum = 500; + + [Desc("Sound the victim will hear when they get robbed.")] public readonly string SoundToVictim = "credit1.aud"; public object Create(ActorInitializer init) { return new InfiltrateForCash(this); } From c40b64ad024b1d706c39c320c16a3d9b2f4c50b5 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Mon, 11 Jan 2016 20:47:00 +0100 Subject: [PATCH 3/5] Fix arbitrary defaults in InfiltrateForCashInfo. --- .../UtilityCommands/UpgradeRules.cs | 16 ++++++++++++++++ .../Traits/Infiltration/InfiltrateForCash.cs | 9 +++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 594b30558a..acb3ca3cc0 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2899,6 +2899,22 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // Removed arbitrary defaults from InfiltrateForCash + if (engineVersion < 20160118) + { + if (node.Key == "InfiltrateForCash") + { + if (!node.Value.Nodes.Any(n => n.Key == "Percentage")) + node.Value.Nodes.Add(new MiniYamlNode("Percentage", "50")); + + if (!node.Value.Nodes.Any(n => n.Key == "Minimum")) + node.Value.Nodes.Add(new MiniYamlNode("Minimum", "500")); + + if (!node.Value.Nodes.Any(n => n.Key == "SoundToVictim")) + node.Value.Nodes.Add(new MiniYamlNode("SoundToVictim", "credit1.aud")); + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs index 71d8906417..1492fc915d 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs @@ -19,14 +19,14 @@ namespace OpenRA.Mods.RA.Traits class InfiltrateForCashInfo : ITraitInfo { [Desc("Percentage of the victim's resources that will be stolen.")] - public readonly int Percentage = 50; + public readonly int Percentage = 100; [Desc("Amount of guaranteed funds to claim when the victim does not have enough resources.", "When negative, the production price of the infiltrating actor will be used instead.")] - public readonly int Minimum = 500; + public readonly int Minimum = -1; [Desc("Sound the victim will hear when they get robbed.")] - public readonly string SoundToVictim = "credit1.aud"; + public readonly string SoundToVictim = null; public object Create(ActorInitializer init) { return new InfiltrateForCash(this); } } @@ -49,7 +49,8 @@ namespace OpenRA.Mods.RA.Traits targetResources.TakeCash(toTake); spyResources.GiveCash(toGive); - Game.Sound.PlayToPlayer(self.Owner, info.SoundToVictim); + if (info.SoundToVictim != null) + Game.Sound.PlayToPlayer(self.Owner, info.SoundToVictim); self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, infiltrator.Owner.Color.RGB, FloatingText.FormatCashTick(toGive), 30))); } From 2e157b82f4d2e582441a31b0f007fca1298fe81e Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Mon, 11 Jan 2016 20:47:45 +0100 Subject: [PATCH 4/5] Limit InfiltrateForCash's guaranteed amount to spy's value in RA --- mods/ra/rules/structures.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 153d351814..3965b43c33 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -998,7 +998,6 @@ PROC: Facing: 64 InfiltrateForCash: Percentage: 50 - Minimum: 500 SoundToVictim: credit1.aud WithIdleOverlay@TOP: Sequence: idle-top From a612ca9c5fc1bb3184d54544c37f1ab3157cc9d1 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Wed, 13 Jan 2016 21:55:19 +0100 Subject: [PATCH 5/5] Use proper speech notification for InfiltrateForCash --- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 12 ++++++++++-- .../Traits/Infiltration/InfiltrateForCash.cs | 6 +++--- mods/ra/rules/structures.yaml | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index acb3ca3cc0..46e23067a4 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -2910,8 +2910,16 @@ namespace OpenRA.Mods.Common.UtilityCommands if (!node.Value.Nodes.Any(n => n.Key == "Minimum")) node.Value.Nodes.Add(new MiniYamlNode("Minimum", "500")); - if (!node.Value.Nodes.Any(n => n.Key == "SoundToVictim")) - node.Value.Nodes.Add(new MiniYamlNode("SoundToVictim", "credit1.aud")); + var sound = node.Value.Nodes.FirstOrDefault(n => n.Key == "SoundToVictim"); + if (sound != null) + { + node.Value.Nodes.Remove(sound); + Console.WriteLine("The 'SoundToVictim' property of the 'InfiltrateForCash' trait has been"); + Console.WriteLine("replaced with a 'Notification' property. Please add the sound file"); + Console.WriteLine("'{0}' to your mod's audio notification yaml and".F(sound.Value.Value)); + Console.WriteLine("update your mod's rules accordingly."); + Console.WriteLine(); + } } } diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs index 1492fc915d..f5dcf241df 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Traits public readonly int Minimum = -1; [Desc("Sound the victim will hear when they get robbed.")] - public readonly string SoundToVictim = null; + public readonly string Notification = null; public object Create(ActorInitializer init) { return new InfiltrateForCash(this); } } @@ -49,8 +49,8 @@ namespace OpenRA.Mods.RA.Traits targetResources.TakeCash(toTake); spyResources.GiveCash(toGive); - if (info.SoundToVictim != null) - Game.Sound.PlayToPlayer(self.Owner, info.SoundToVictim); + if (info.Notification != null) + Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.Notification, self.Owner.Faction.InternalName); self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, infiltrator.Owner.Color.RGB, FloatingText.FormatCashTick(toGive), 30))); } diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 3965b43c33..8446c84bae 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -998,7 +998,7 @@ PROC: Facing: 64 InfiltrateForCash: Percentage: 50 - SoundToVictim: credit1.aud + Notification: CreditsStolen WithIdleOverlay@TOP: Sequence: idle-top Power: