Make repairing buildings and units grant experience

Using the repair button and repair pad, not using engineers and mechanics.
This commit is contained in:
Oliver Brakmann
2016-07-10 15:08:37 +02:00
parent ac07c81e08
commit dab7276601
3 changed files with 23 additions and 0 deletions

View File

@@ -49,6 +49,13 @@ namespace OpenRA.Mods.Common.Activities
if (health.DamageState == DamageState.Undamaged)
{
if (host.Owner != self.Owner)
{
var exp = host.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
if (exp != null)
exp.GiveExperience(repairsUnits.PlayerExperience);
}
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", repairsUnits.FinishRepairingNotification, self.Owner.Faction.InternalName);
return NextActivity;
}

View File

@@ -35,6 +35,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Suffixed by the internal repairing player name.")]
public readonly string IndicatorPalettePrefix = "player";
[Desc("Experience gained by a player for repairing structures of allied players.")]
public readonly int PlayerExperience = 0;
public override object Create(ActorInitializer init) { return new RepairableBuilding(init.Self, this); }
}
@@ -133,6 +136,16 @@ namespace OpenRA.Mods.Common.Traits
if (health.DamageState == DamageState.Undamaged)
{
Repairers.Do(r =>
{
if (r == self.Owner)
return;
var exp = r.PlayerActor.TraitOrDefault<PlayerExperience>();
if (exp != null)
exp.GiveExperience(Info.PlayerExperience);
});
Repairers.Clear();
RepairActive = false;
return;

View File

@@ -27,6 +27,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The sound played when repairing a unit is done.")]
public readonly string FinishRepairingNotification = null;
[Desc("Experience gained by the player owning this actor for repairing an allied unit.")]
public readonly int PlayerExperience = 0;
}
public class RepairsUnits { }