From 736d58bd9a52fad78ef9ae99be82d40930cf2c8b Mon Sep 17 00:00:00 2001 From: Zimmermann Gyula Date: Fri, 10 Jun 2016 14:31:03 +0200 Subject: [PATCH] Add a maximum limit to InfiltrateForCash. --- OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs index f74d2beaab..d2f9e6f36b 100644 --- a/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs +++ b/OpenRA.Mods.RA/Traits/Infiltration/InfiltrateForCash.cs @@ -26,6 +26,9 @@ namespace OpenRA.Mods.RA.Traits "When negative, the production price of the infiltrating actor will be used instead.")] public readonly int Minimum = -1; + [Desc("Maximum amount of funds which will be stolen.")] + public readonly int Maximum = int.MaxValue; + [Desc("Sound the victim will hear when they get robbed.")] public readonly string Notification = null; @@ -44,7 +47,7 @@ namespace OpenRA.Mods.RA.Traits var spyResources = infiltrator.Owner.PlayerActor.Trait(); var spyValue = infiltrator.Info.TraitInfoOrDefault(); - var toTake = (targetResources.Cash + targetResources.Resources) * info.Percentage / 100; + var toTake = Math.Min(info.Maximum, (targetResources.Cash + targetResources.Resources) * info.Percentage / 100); var toGive = Math.Max(toTake, info.Minimum >= 0 ? info.Minimum : spyValue != null ? spyValue.Cost : 0); targetResources.TakeCash(toTake);