diff --git a/OpenRA.Game/Traits/Health.cs b/OpenRA.Game/Traits/Health.cs index 4cb4b736ba..208ac0a1db 100755 --- a/OpenRA.Game/Traits/Health.cs +++ b/OpenRA.Game/Traits/Health.cs @@ -8,6 +8,7 @@ */ #endregion +using System; using System.Linq; using OpenRA.GameRules; @@ -42,7 +43,10 @@ namespace OpenRA.Traits Info = info; MaxHP = info.HP; - hp = init.Contains() ? (int)(init.Get() * MaxHP) : MaxHP; + hp = init.Contains() ? init.Get() * MaxHP / 100 : MaxHP; + if (hp <= 0) + hp = Math.Max(MaxHP / 100, 1); + DisplayHp = hp; } @@ -169,12 +173,12 @@ namespace OpenRA.Traits } } - public class HealthInit : IActorInit + public class HealthInit : IActorInit { - [FieldFromYamlKey] readonly float value = 1f; + [FieldFromYamlKey] readonly int value = 100; public HealthInit() { } - public HealthInit(float init) { value = init; } - public float Value(World world) { return value; } + public HealthInit(int init) { value = init; } + public int Value(World world) { return value; } } public static class HealthExts diff --git a/OpenRA.Mods.Common/Activities/Transform.cs b/OpenRA.Mods.Common/Activities/Transform.cs index 961ae74892..fc5bb12623 100644 --- a/OpenRA.Mods.Common/Activities/Transform.cs +++ b/OpenRA.Mods.Common/Activities/Transform.cs @@ -70,10 +70,7 @@ namespace OpenRA.Mods.Common.Activities var health = self.TraitOrDefault(); if (health != null) { - var newHP = (ForceHealthPercentage > 0) - ? ForceHealthPercentage / 100f - : (float)health.HP / health.MaxHP; - + var newHP = (ForceHealthPercentage > 0) ? ForceHealthPercentage : (health.HP * 100) / health.MaxHP; init.Add(new HealthInit(newHP)); } diff --git a/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs b/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs index e7fbe8d5ec..50b014f557 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Bridge.cs @@ -43,27 +43,27 @@ namespace OpenRA.Mods.Common.Traits public object Create(ActorInitializer init) { return new Bridge(init.Self, this); } - public IEnumerable> Templates + public IEnumerable> Templates { get { if (Template != 0) - yield return Pair.New(Template, 1f); + yield return Pair.New(Template, 100); if (DamagedTemplate != 0) - yield return Pair.New(DamagedTemplate, .5f); + yield return Pair.New(DamagedTemplate, 50); if (DestroyedTemplate != 0) - yield return Pair.New(DestroyedTemplate, 0f); + yield return Pair.New(DestroyedTemplate, 0); if (DestroyedPlusNorthTemplate != 0) - yield return Pair.New(DestroyedPlusNorthTemplate, 0f); + yield return Pair.New(DestroyedPlusNorthTemplate, 0); if (DestroyedPlusSouthTemplate != 0) - yield return Pair.New(DestroyedPlusSouthTemplate, 0f); + yield return Pair.New(DestroyedPlusSouthTemplate, 0); if (DestroyedPlusBothTemplate != 0) - yield return Pair.New(DestroyedPlusBothTemplate, 0f); + yield return Pair.New(DestroyedPlusBothTemplate, 0); } } } diff --git a/OpenRA.Mods.Common/Traits/World/BridgeLayer.cs b/OpenRA.Mods.Common/Traits/World/BridgeLayer.cs index e8915b6968..4603fe9e20 100644 --- a/OpenRA.Mods.Common/Traits/World/BridgeLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/BridgeLayer.cs @@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits { readonly BridgeLayerInfo info; readonly World world; - Dictionary> bridgeTypes = new Dictionary>(); + Dictionary> bridgeTypes = new Dictionary>(); CellLayer bridges; public BridgeLayer(Actor self, BridgeLayerInfo info) diff --git a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs index c7c9d55e6a..7b9b97f2c2 100644 --- a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs +++ b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs @@ -405,7 +405,7 @@ namespace OpenRA.Mods.Common.UtilityCommands players.Add(parts[0]); var loc = Exts.ParseIntegerInvariant(parts[3]); - var health = float.Parse(parts[2], NumberFormatInfo.InvariantInfo) / 256; + var health = Exts.ParseIntegerInvariant(parts[2]) * 100 / 256; var facing = (section == "INFANTRY") ? Exts.ParseIntegerInvariant(parts[6]) : Exts.ParseIntegerInvariant(parts[4]); var actor = new ActorReference(parts[1].ToLowerInvariant()) @@ -415,7 +415,7 @@ namespace OpenRA.Mods.Common.UtilityCommands }; var initDict = actor.InitDict; - if (health != 1) + if (health != 100) initDict.Add(new HealthInit(health)); if (facing != 0) initDict.Add(new FacingInit(facing));