Add a percentage option to SelfHealing.
This commit is contained in:
@@ -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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user