Merge pull request #10488 from obrakmann/fix10451_printing_money_with_spies
Change guaranteed amount of stolen funds to spy's value
This commit is contained in:
@@ -2899,6 +2899,30 @@ 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"));
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System;
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA.Traits
|
||||
@@ -17,9 +18,15 @@ namespace OpenRA.Mods.RA.Traits
|
||||
[Desc("This structure can be infiltrated causing funds to be stolen.")]
|
||||
class InfiltrateForCashInfo : ITraitInfo
|
||||
{
|
||||
public readonly int Percentage = 50;
|
||||
public readonly int Minimum = 500;
|
||||
public readonly string SoundToVictim = "credit1.aud";
|
||||
[Desc("Percentage of the victim's resources that will be stolen.")]
|
||||
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 = -1;
|
||||
|
||||
[Desc("Sound the victim will hear when they get robbed.")]
|
||||
public readonly string Notification = null;
|
||||
|
||||
public object Create(ActorInitializer init) { return new InfiltrateForCash(this); }
|
||||
}
|
||||
@@ -34,14 +41,16 @@ namespace OpenRA.Mods.RA.Traits
|
||||
{
|
||||
var targetResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
var spyResources = infiltrator.Owner.PlayerActor.Trait<PlayerResources>();
|
||||
var spyValue = infiltrator.Info.TraitInfoOrDefault<ValuedInfo>();
|
||||
|
||||
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);
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
@@ -998,8 +998,7 @@ PROC:
|
||||
Facing: 64
|
||||
InfiltrateForCash:
|
||||
Percentage: 50
|
||||
Minimum: 500
|
||||
SoundToVictim: credit1.aud
|
||||
Notification: CreditsStolen
|
||||
WithIdleOverlay@TOP:
|
||||
Sequence: idle-top
|
||||
Power:
|
||||
|
||||
Reference in New Issue
Block a user