add support for damage cooldown on SelfHealing
This commit is contained in:
@@ -17,14 +17,15 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly int Step = 5;
|
public readonly int Step = 5;
|
||||||
public readonly int Ticks = 5;
|
public readonly int Ticks = 5;
|
||||||
public readonly float HealIfBelow = .5f;
|
public readonly float HealIfBelow = .5f;
|
||||||
|
public readonly int DamageCooldown = 0;
|
||||||
|
|
||||||
public virtual object Create(ActorInitializer init) { return new SelfHealing(this); }
|
public virtual object Create(ActorInitializer init) { return new SelfHealing(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class SelfHealing : ITick, ISync
|
class SelfHealing : ITick, ISync, INotifyDamage
|
||||||
{
|
{
|
||||||
[Sync]
|
[Sync] int ticks;
|
||||||
int ticks;
|
[Sync] int damageTicks;
|
||||||
SelfHealingInfo Info;
|
SelfHealingInfo Info;
|
||||||
|
|
||||||
public SelfHealing(SelfHealingInfo info) { Info = info; }
|
public SelfHealing(SelfHealingInfo info) { Info = info; }
|
||||||
@@ -37,6 +38,12 @@ namespace OpenRA.Mods.RA
|
|||||||
var health = self.Trait<Health>();
|
var health = self.Trait<Health>();
|
||||||
if (health.HP >= Info.HealIfBelow*health.MaxHP)
|
if (health.HP >= Info.HealIfBelow*health.MaxHP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (damageTicks > 0)
|
||||||
|
{
|
||||||
|
--damageTicks;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (--ticks <= 0)
|
if (--ticks <= 0)
|
||||||
{
|
{
|
||||||
@@ -44,5 +51,11 @@ namespace OpenRA.Mods.RA
|
|||||||
self.InflictDamage(self, -Info.Step, null);
|
self.InflictDamage(self, -Info.Step, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Damaged (Actor self, AttackInfo e)
|
||||||
|
{
|
||||||
|
if (e.Damage > 0)
|
||||||
|
damageTicks = Info.DamageCooldown;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user