diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index f38d139888..5dad7ac1ab 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -244,6 +244,7 @@ + diff --git a/OpenRa.Game/Traits/SelfHealing.cs b/OpenRa.Game/Traits/SelfHealing.cs new file mode 100644 index 0000000000..e6fe64f48f --- /dev/null +++ b/OpenRa.Game/Traits/SelfHealing.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.Game.GameRules; + +namespace OpenRa.Game.Traits +{ + class SelfHealingInfo : ITraitInfo + { + public readonly int Step = 5; + public readonly int Ticks = 5; + public readonly float HealIfBelow = .5f; + + public object Create(Actor self) { return new SelfHealing(); } + } + + class SelfHealing : ITick + { + int ticks; + + + public void Tick(Actor self) + { + var info = self.Info.Traits.Get(); + + if ((float)self.Health / self.GetMaxHP() >= info.HealIfBelow) + return; + + if (--ticks <= 0) + { + ticks = info.Ticks; + self.InflictDamage(self, -info.Step, Rules.WarheadInfo["Super"]); + } + } + } +}