From ec808ddc54eb8c915d7cb08439e61f443b9b5712 Mon Sep 17 00:00:00 2001 From: Taryn Hill Date: Sat, 2 Jul 2016 11:05:33 -0500 Subject: [PATCH 1/3] GivesExperience: Replace FriendlyFire with ValidStances --- OpenRA.Mods.Common/Traits/GivesExperience.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/GivesExperience.cs b/OpenRA.Mods.Common/Traits/GivesExperience.cs index 670060b339..c08d066387 100644 --- a/OpenRA.Mods.Common/Traits/GivesExperience.cs +++ b/OpenRA.Mods.Common/Traits/GivesExperience.cs @@ -19,8 +19,8 @@ namespace OpenRA.Mods.Common.Traits [Desc("If -1, use the value of the unit cost.")] public readonly int Experience = -1; - [Desc("Grant experience for team-kills.")] - public readonly bool FriendlyFire = false; + [Desc("Stance the attacking player needs to receive the experience.")] + public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; public object Create(ActorInitializer init) { return new GivesExperience(init.Self, this); } } @@ -36,8 +36,10 @@ namespace OpenRA.Mods.Common.Traits public void Killed(Actor self, AttackInfo e) { - // Prevent TK from giving exp - if (e.Attacker == null || e.Attacker.Disposed || (!info.FriendlyFire && e.Attacker.Owner.Stances[self.Owner] == Stance.Ally)) + if (e.Attacker == null || e.Attacker.Disposed) + return; + + if (!info.ValidStances.HasStance(e.Attacker.Owner.Stances[self.Owner])) return; var valued = self.Info.TraitInfoOrDefault(); From 3f6f918b3d38446360f8afbdb5fb41d476bdbb69 Mon Sep 17 00:00:00 2001 From: Taryn Hill Date: Sat, 2 Jul 2016 11:06:23 -0500 Subject: [PATCH 2/3] GivesBounty: Replace Stances with ValidStances --- OpenRA.Mods.Common/Traits/GivesBounty.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/GivesBounty.cs b/OpenRA.Mods.Common/Traits/GivesBounty.cs index 4b11926664..c397852c80 100644 --- a/OpenRA.Mods.Common/Traits/GivesBounty.cs +++ b/OpenRA.Mods.Common/Traits/GivesBounty.cs @@ -10,7 +10,6 @@ #endregion using System.Collections.Generic; -using System.Linq; using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Warheads; using OpenRA.Traits; @@ -27,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits public readonly int LevelMod = 125; [Desc("Stance the attacking player needs to receive the bounty.")] - public readonly Stance[] Stances = { Stance.Neutral, Stance.Enemy }; + public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; [Desc("Whether to show a floating text announcing the won bounty.")] public readonly bool ShowBounty = true; @@ -64,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits if (e.Attacker == null || e.Attacker.Disposed) return; - if (!info.Stances.Contains(e.Attacker.Owner.Stances[self.Owner])) + if (!info.ValidStances.HasStance(e.Attacker.Owner.Stances[self.Owner])) return; var warhead = e.Warhead as DamageWarhead; From f731dc8d68c1674c54bc3040749f268bc902cfd8 Mon Sep 17 00:00:00 2001 From: Taryn Hill Date: Sat, 2 Jul 2016 11:06:44 -0500 Subject: [PATCH 3/3] Utility: Add upgrade rules for GivesExperience and GivesBounty changes --- .../UtilityCommands/UpgradeRules.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 2407280e8d..5678ecb606 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -185,6 +185,33 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + if (engineVersion < 20160702) + { + if (node.Key.StartsWith("GivesExperience")) + { + var ff = "FriendlyFire"; + var ffNode = node.Value.Nodes.FirstOrDefault(n => n.Key == ff); + if (ffNode != null) + { + var newStanceStr = ""; + if (FieldLoader.GetValue(ff, ffNode.Value.Value)) + newStanceStr = "Neutral, Enemy, Ally"; + else + newStanceStr = "Neutral, Enemy"; + + node.Value.Nodes.Add(new MiniYamlNode("ValidStances", newStanceStr)); + } + + node.Value.Nodes.Remove(ffNode); + } + else if (node.Key.StartsWith("GivesBounty")) + { + var stancesNode = node.Value.Nodes.FirstOrDefault(n => n.Key == "Stances"); + if (stancesNode != null) + stancesNode.Key = "ValidStances"; + } + } + UpgradeActorRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); }