GivesExperience: Replace FriendlyFire with ValidStances

This commit is contained in:
Taryn Hill
2016-07-02 11:05:33 -05:00
parent a0a6d0705e
commit ec808ddc54

View File

@@ -19,8 +19,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("If -1, use the value of the unit cost.")] [Desc("If -1, use the value of the unit cost.")]
public readonly int Experience = -1; public readonly int Experience = -1;
[Desc("Grant experience for team-kills.")] [Desc("Stance the attacking player needs to receive the experience.")]
public readonly bool FriendlyFire = false; public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy;
public object Create(ActorInitializer init) { return new GivesExperience(init.Self, this); } 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) public void Killed(Actor self, AttackInfo e)
{ {
// Prevent TK from giving exp if (e.Attacker == null || e.Attacker.Disposed)
if (e.Attacker == null || e.Attacker.Disposed || (!info.FriendlyFire && e.Attacker.Owner.Stances[self.Owner] == Stance.Ally)) return;
if (!info.ValidStances.HasStance(e.Attacker.Owner.Stances[self.Owner]))
return; return;
var valued = self.Info.TraitInfoOrDefault<ValuedInfo>(); var valued = self.Info.TraitInfoOrDefault<ValuedInfo>();