diff --git a/OpenRA.Mods.RA/SelfHealing.cs b/OpenRA.Mods.RA/SelfHealing.cs index 4de5a560e4..50876e86a3 100644 --- a/OpenRA.Mods.RA/SelfHealing.cs +++ b/OpenRA.Mods.RA/SelfHealing.cs @@ -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() + .Any(a => !a.Actor.IsDead() && a.Actor.Owner.IsAlliedWith(self.Owner) && Info.RequiresTech == a.Trait.Type)) + return; + var health = self.Trait(); 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; + } + } } diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index bf06a9dc7a..44c5360e2b 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -146,13 +146,16 @@ Probability: 2 CrushableInfantry: WarnProbability: 60 - RepairableNear: - Buildings: hosp - CloseEnough: 1 DebugMuzzlePositions: Guard: Guardable: BodyOrientation: + SelfHealing: + Step: 5 + Ticks: 100 + HealIfBelow: 1 + DamageCooldown: 125 + RequiresTech: InfantryHealing ^CivInfantry: Inherits: ^Infantry diff --git a/mods/cnc/rules/tech.yaml b/mods/cnc/rules/tech.yaml index 79f0ea6bfe..174de04d59 100644 --- a/mods/cnc/rules/tech.yaml +++ b/mods/cnc/rules/tech.yaml @@ -21,15 +21,20 @@ V19.Husk: # Hospital HOSP: - Inherits: ^CivBuilding + Inherits: ^TechBuilding + Selectable: + Priority: 0 Building: Footprint: xx xx Dimensions: 2,2 + Health: + HP: 1000 + SelfHealingTech: + Type: InfantryHealing Tooltip: Name: Hospital LeavesHusk: HuskActor: HOSP.Husk - RepairsUnits: HOSP.Husk: Inherits: ^CivBuildingHusk diff --git a/mods/ra/rules/civilian.yaml b/mods/ra/rules/civilian.yaml index ecdb0a7336..f71314c42d 100644 --- a/mods/ra/rules/civilian.yaml +++ b/mods/ra/rules/civilian.yaml @@ -72,12 +72,20 @@ FCOM: HOSP: Inherits: ^TechBuilding + Selectable: + Priority: 0 Building: Footprint: xx xx Dimensions: 2,2 + Health: + HP: 1000 + Capturable: + CapturableBar: + EngineerRepairable: + SelfHealingTech: + Type: InfantryHealing Tooltip: Name: Hospital - RepairsUnits: V01: Inherits: ^CivBuilding @@ -299,8 +307,6 @@ OILB: Dimensions: 2,2 Health: HP: 1000 - Armor: - Type: Wood Bib: RevealsShroud: Range: 3 diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 44a2daeff9..0a63ac8370 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -121,14 +121,17 @@ Offset: 0,0,427 CrushableInfantry: CrushSound: squishy2.aud - RepairableNear: - Buildings: hosp - CloseEnough: 1 UpdatesPlayerStatistics: DebugMuzzlePositions: Guard: Guardable: BodyOrientation: + SelfHealing: + Step: 5 + Ticks: 100 + HealIfBelow: 1 + DamageCooldown: 125 + RequiresTech: InfantryHealing ^Ship: AppearsOnRadar: