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; 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(); 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); }