Make captured hospitals in cnc/ra gradually heal all infantry units on the map
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
@@ -18,6 +19,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly int Ticks = 5;
|
||||
public readonly float HealIfBelow = .5f;
|
||||
public readonly int DamageCooldown = 0;
|
||||
public readonly string RequiresTech = null;
|
||||
|
||||
public virtual object Create(ActorInitializer init) { return new SelfHealing(this); }
|
||||
}
|
||||
@@ -35,6 +37,10 @@ namespace OpenRA.Mods.RA
|
||||
if (self.IsDead())
|
||||
return;
|
||||
|
||||
if (Info.RequiresTech != null && !self.World.ActorsWithTrait<SelfHealingTech>()
|
||||
.Any(a => !a.Actor.IsDead() && a.Actor.Owner.IsAlliedWith(self.Owner) && Info.RequiresTech == a.Trait.Type))
|
||||
return;
|
||||
|
||||
var health = self.Trait<Health>();
|
||||
if (health.HP >= Info.HealIfBelow*health.MaxHP)
|
||||
return;
|
||||
@@ -52,10 +58,29 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
}
|
||||
|
||||
public void Damaged (Actor self, AttackInfo e)
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.Damage > 0)
|
||||
damageTicks = Info.DamageCooldown;
|
||||
}
|
||||
}
|
||||
|
||||
class SelfHealingTechInfo : ITraitInfo
|
||||
{
|
||||
public readonly string Type = null;
|
||||
|
||||
public object Create(ActorInitializer init) { return new SelfHealingTech(this); }
|
||||
}
|
||||
|
||||
class SelfHealingTech
|
||||
{
|
||||
public string Type { get { return info.Type; } }
|
||||
|
||||
readonly SelfHealingTechInfo info;
|
||||
|
||||
public SelfHealingTech(SelfHealingTechInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user