diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index b52f1dcb46..5360d6cf6b 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -43,10 +43,6 @@ namespace OpenRA.Traits public int HP { get { return hp; } } public readonly int MaxHP; - public float HPFraction - { - get { return hp * 1f / MaxHP; } - } public bool IsDead { get { return hp <= 0; } } public bool RemoveOnDeath = true; diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index be7ea1d263..97aec499b7 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -133,7 +133,7 @@ namespace OpenRA.Traits healthColor.G / 2, healthColor.B / 2); - var z = float2.Lerp(xy, Xy, health.HPFraction); + var z = float2.Lerp(xy, Xy, (float)health.HP / health.MaxHP); Game.Renderer.LineRenderer.DrawLine(xy + new float2(0, -4), Xy + new float2(0, -4), c, c); diff --git a/OpenRA.Mods.RA/Activities/Transform.cs b/OpenRA.Mods.RA/Activities/Transform.cs index 4b91112f87..376a5c2354 100644 --- a/OpenRA.Mods.RA/Activities/Transform.cs +++ b/OpenRA.Mods.RA/Activities/Transform.cs @@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Activities if (ForceHealthPercentage > 0) init.Add( new HealthInit( ForceHealthPercentage * 1f / 100 )); else - init.Add( new HealthInit( health.HPFraction )); + init.Add( new HealthInit( (float)health.HP / health.MaxHP )); } var a = w.CreateActor( ToActor, init ); diff --git a/OpenRA.Mods.RA/EmitInfantryOnSell.cs b/OpenRA.Mods.RA/EmitInfantryOnSell.cs index a93bcd19ec..24f0e12c63 100644 --- a/OpenRA.Mods.RA/EmitInfantryOnSell.cs +++ b/OpenRA.Mods.RA/EmitInfantryOnSell.cs @@ -17,8 +17,8 @@ namespace OpenRA.Mods.RA { class EmitInfantryOnSellInfo : TraitInfo { - public readonly float ValueFraction = .4f; - public readonly float MinHpFraction = .3f; + public readonly float ValuePercent = 40; + public readonly float MinHpPercent = 30; [ActorReference] public readonly string[] ActorTypes = { "e1" }; @@ -36,8 +36,11 @@ namespace OpenRA.Mods.RA var cost = csv != null ? csv.Value : (valued != null ? valued.Cost : 0); var health = self.TraitOrDefault(); - var hpFraction = (health == null) ? 1f : health.HPFraction; - var dudesValue = (int)(hpFraction * info.ValueFraction * cost); + var dudesValue = info.ValuePercent * cost; + if (health != null) + dudesValue = dudesValue*health.HP / health.MaxHP; + dudesValue /= 100; + var eligibleLocations = FootprintUtils.Tiles(self).ToList(); var actorTypes = info.ActorTypes.Select(a => new { Name = a, Cost = Rules.Info[a].Traits.Get().Cost }).ToArray(); diff --git a/OpenRA.Mods.RA/SelfHealing.cs b/OpenRA.Mods.RA/SelfHealing.cs index bd197a2f17..d2c3cb71f1 100644 --- a/OpenRA.Mods.RA/SelfHealing.cs +++ b/OpenRA.Mods.RA/SelfHealing.cs @@ -12,31 +12,36 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class SelfHealingInfo : TraitInfo, ITraitPrerequisite + class SelfHealingInfo : ITraitInfo, ITraitPrerequisite { public readonly int Step = 5; public readonly int Ticks = 5; public readonly float HealIfBelow = .5f; + + public virtual object Create(ActorInitializer init) { return new SelfHealing(this); } } class SelfHealing : ITick, ISync { [Sync] int ticks; + SelfHealingInfo Info; + + public SelfHealing(SelfHealingInfo info) { Info = info; } public void Tick(Actor self) { if (self.IsDead()) return; - var info = self.Info.Traits.Get(); - if (self.Trait().HPFraction >= info.HealIfBelow) + var health = self.Trait(); + if (health.HP >= Info.HealIfBelow*health.MaxHP) return; if (--ticks <= 0) { - ticks = info.Ticks; - self.InflictDamage(self, -info.Step, null); + ticks = Info.Ticks; + self.InflictDamage(self, -Info.Step, null); } } }