Make repairing buildings and units grant experience
Using the repair button and repair pad, not using engineers and mechanics.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 { }
|
||||
|
||||
Reference in New Issue
Block a user