diff --git a/OpenRA.Mods.Common/Activities/CaptureActor.cs b/OpenRA.Mods.Common/Activities/CaptureActor.cs index b0351f5103..0378fbce5e 100644 --- a/OpenRA.Mods.Common/Activities/CaptureActor.cs +++ b/OpenRA.Mods.Common/Activities/CaptureActor.cs @@ -65,6 +65,13 @@ namespace OpenRA.Mods.Common.Activities if (building != null && building.Locked) building.Unlock(); + + if (self.Owner.Stances[oldOwner].HasStance(capturesInfo.PlayerExperienceStances)) + { + var exp = self.Owner.PlayerActor.TraitOrDefault(); + if (exp != null) + exp.GiveExperience(capturesInfo.PlayerExperience); + } } else { diff --git a/OpenRA.Mods.Common/Activities/ExternalCaptureActor.cs b/OpenRA.Mods.Common/Activities/ExternalCaptureActor.cs index f14477185d..05e8b4562f 100644 --- a/OpenRA.Mods.Common/Activities/ExternalCaptureActor.cs +++ b/OpenRA.Mods.Common/Activities/ExternalCaptureActor.cs @@ -77,6 +77,13 @@ namespace OpenRA.Mods.Common.Activities capturable.EndCapture(); + if (self.Owner.Stances[oldOwner].HasStance(capturesInfo.PlayerExperienceStances)) + { + var exp = self.Owner.PlayerActor.TraitOrDefault(); + if (exp != null) + exp.GiveExperience(capturesInfo.PlayerExperience); + } + if (capturesInfo != null && capturesInfo.ConsumeActor) self.Dispose(); }); diff --git a/OpenRA.Mods.Common/Traits/Captures.cs b/OpenRA.Mods.Common/Traits/Captures.cs index 8c584d5544..3ec469732c 100644 --- a/OpenRA.Mods.Common/Traits/Captures.cs +++ b/OpenRA.Mods.Common/Traits/Captures.cs @@ -22,11 +22,19 @@ namespace OpenRA.Mods.Common.Traits { [Desc("Types of actors that it can capture, as long as the type also exists in the Capturable Type: trait.")] public readonly HashSet CaptureTypes = new HashSet { "building" }; + [Desc("Unit will do damage to the actor instead of capturing it. Unit is destroyed when sabotaging.")] public readonly bool Sabotage = true; + [Desc("Only used if Sabotage=true. Sabotage damage expressed as a percentage of enemy health removed.")] public readonly int SabotageHPRemoval = 50; + [Desc("Experience granted to the capturing player.")] + public readonly int PlayerExperience = 0; + + [Desc("Stance that the structure's previous owner needs to have for the capturing player to receive Experience.")] + public readonly Stance PlayerExperienceStances = Stance.Enemy; + [VoiceReference] public readonly string Voice = "Action"; public object Create(ActorInitializer init) { return new Captures(init.Self, this); } diff --git a/OpenRA.Mods.Common/Traits/ExternalCaptures.cs b/OpenRA.Mods.Common/Traits/ExternalCaptures.cs index e72302c674..d3d2994399 100644 --- a/OpenRA.Mods.Common/Traits/ExternalCaptures.cs +++ b/OpenRA.Mods.Common/Traits/ExternalCaptures.cs @@ -26,6 +26,12 @@ namespace OpenRA.Mods.Common.Traits [Desc("Destroy the unit after capturing.")] public readonly bool ConsumeActor = false; + [Desc("Experience granted to the capturing player.")] + public readonly int PlayerExperience = 0; + + [Desc("Stance that the structure's previous owner needs to have for the capturing player to receive Experience.")] + public readonly Stance PlayerExperienceStances = Stance.Enemy; + [VoiceReference] public readonly string Voice = "Action"; public object Create(ActorInitializer init) { return new ExternalCaptures(init.Self, this); }