diff --git a/OpenRA.Mods.Common/Activities/DonateSupplies.cs b/OpenRA.Mods.Common/Activities/DonateSupplies.cs index f4af59a294..9640f71fab 100644 --- a/OpenRA.Mods.Common/Activities/DonateSupplies.cs +++ b/OpenRA.Mods.Common/Activities/DonateSupplies.cs @@ -10,6 +10,7 @@ #endregion using OpenRA.Mods.Common.Effects; +using OpenRA.Mods.Common.Traits; using OpenRA.Traits; namespace OpenRA.Mods.Common.Activities @@ -18,12 +19,14 @@ namespace OpenRA.Mods.Common.Activities { readonly Actor target; readonly int payload; + readonly int experience; - public DonateSupplies(Actor self, Actor target, int payload) + public DonateSupplies(Actor self, Actor target, int payload, int playerExperience) : base(self, target, EnterBehaviour.Dispose) { this.target = target; this.payload = payload; + this.experience = playerExperience; } protected override void OnInside(Actor self) @@ -33,6 +36,10 @@ namespace OpenRA.Mods.Common.Activities target.Owner.PlayerActor.Trait().GiveCash(payload); + var exp = self.Owner.PlayerActor.TraitOrDefault(); + if (exp != null && target.Owner != self.Owner) + exp.GiveExperience(experience); + if (self.Owner.IsAlliedWith(self.World.RenderPlayer)) self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30))); } diff --git a/OpenRA.Mods.Common/Traits/SupplyTruck.cs b/OpenRA.Mods.Common/Traits/SupplyTruck.cs index 2f731b3636..20f52158fe 100644 --- a/OpenRA.Mods.Common/Traits/SupplyTruck.cs +++ b/OpenRA.Mods.Common/Traits/SupplyTruck.cs @@ -23,6 +23,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("The amount of cash the owner receives.")] public readonly int Payload = 500; + [Desc("The amount of experience the donating player receives.")] + public readonly int PlayerExperience = 0; + [VoiceReference] public readonly string Voice = "Action"; public object Create(ActorInitializer init) { return new SupplyTruck(this); } @@ -71,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits self.CancelActivity(); self.SetTargetLine(target, Color.Yellow); - self.QueueActivity(new DonateSupplies(self, target.Actor, info.Payload)); + self.QueueActivity(new DonateSupplies(self, target.Actor, info.Payload, info.PlayerExperience)); } class SupplyTruckOrderTargeter : UnitOrderTargeter