Add a percentage option to SelfHealing.

This commit is contained in:
Zimmermann Gyula
2016-07-06 16:42:58 +02:00
parent fc8a2b2ebe
commit 4fa70cdfb9

View File

@@ -16,10 +16,18 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Attach this to actors which should be able to regenerate their health points.")] [Desc("Attach this to actors which should be able to regenerate their health points.")]
class SelfHealingInfo : UpgradableTraitInfo, Requires<HealthInfo> class SelfHealingInfo : UpgradableTraitInfo, Requires<HealthInfo>
{ {
[Desc("Absolute amount of health points added in each step.")]
public readonly int Step = 5; public readonly int Step = 5;
[Desc("Relative percentages of health added in each step.",
"When both values are defined, their summary will be applied.")]
public readonly int PercentageStep = 0;
public readonly int Delay = 5; public readonly int Delay = 5;
[Desc("Heal if current health is below this percentage of full health.")] [Desc("Heal if current health is below this percentage of full health.")]
public readonly int HealIfBelow = 50; public readonly int HealIfBelow = 50;
public readonly int DamageCooldown = 0; public readonly int DamageCooldown = 0;
public override object Create(ActorInitializer init) { return new SelfHealing(init.Self, this); } public override object Create(ActorInitializer init) { return new SelfHealing(init.Self, this); }
@@ -55,7 +63,7 @@ namespace OpenRA.Mods.Common.Traits
if (--ticks <= 0) if (--ticks <= 0)
{ {
ticks = Info.Delay; ticks = Info.Delay;
self.InflictDamage(self, new Damage(-Info.Step)); self.InflictDamage(self, new Damage(-(Info.Step + Info.PercentageStep * health.MaxHP / 100)));
} }
} }