diff --git a/OpenRA.Mods.Common/Activities/CaptureActor.cs b/OpenRA.Mods.Common/Activities/CaptureActor.cs index 25c80943ff..507b8cb0f7 100644 --- a/OpenRA.Mods.Common/Activities/CaptureActor.cs +++ b/OpenRA.Mods.Common/Activities/CaptureActor.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Activities if (actor.IsDead || capturable.BeingCaptured) return; - var lowEnoughHealth = health.HP <= capturable.Info.CaptureThreshold * health.MaxHP; + var lowEnoughHealth = health.HP <= capturable.Info.CaptureThreshold * health.MaxHP / 100; if (!capturesInfo.Sabotage || lowEnoughHealth || actor.Owner.NonCombatant) { var oldOwner = actor.Owner; @@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities } else { - var damage = (int)(health.MaxHP * capturesInfo.SabotageHPRemoval); + var damage = health.MaxHP * capturesInfo.SabotageHPRemoval / 100; actor.InflictDamage(self, damage, null); } diff --git a/OpenRA.Mods.Common/Traits/Capturable.cs b/OpenRA.Mods.Common/Traits/Capturable.cs index 3b81a98980..b55962b4d4 100644 --- a/OpenRA.Mods.Common/Traits/Capturable.cs +++ b/OpenRA.Mods.Common/Traits/Capturable.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits public readonly bool AllowNeutral = true; public readonly bool AllowEnemies = true; [Desc("Health percentage the target must be at (or below) before it can be captured.")] - public readonly float CaptureThreshold = 0.5f; + public readonly int CaptureThreshold = 50; public readonly bool CancelActivity = false; public object Create(ActorInitializer init) { return new Capturable(this); } diff --git a/OpenRA.Mods.Common/Traits/Captures.cs b/OpenRA.Mods.Common/Traits/Captures.cs index 975dce7895..8c584d5544 100644 --- a/OpenRA.Mods.Common/Traits/Captures.cs +++ b/OpenRA.Mods.Common/Traits/Captures.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits [Desc("Unit will do damage to the actor instead of capturing it. Unit is destroyed when sabotaging.")] public readonly bool Sabotage = true; [Desc("Only used if Sabotage=true. Sabotage damage expressed as a percentage of enemy health removed.")] - public readonly float SabotageHPRemoval = 0.5f; + public readonly int SabotageHPRemoval = 50; [VoiceReference] public readonly string Voice = "Action"; @@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits } var health = target.Trait(); - var lowEnoughHealth = health.HP <= c.CaptureThreshold * health.MaxHP; + var lowEnoughHealth = health.HP <= c.CaptureThreshold * health.MaxHP / 100; cursor = !sabotage || lowEnoughHealth || target.Owner.NonCombatant ? "enter" : "capture"; @@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits } var health = target.Info.TraitInfoOrDefault(); - var lowEnoughHealth = target.HP <= c.CaptureThreshold * health.HP; + var lowEnoughHealth = target.HP <= c.CaptureThreshold * health.HP / 100; cursor = !sabotage || lowEnoughHealth || target.Owner.NonCombatant ? "enter" : "capture"; diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 0875963d37..79a52456e4 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -736,6 +736,34 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // Migrated Captures and Capturable to use int percentage instead of float + if (engineVersion < 20160325) + { + if (node.Key == "Captures") + { + var sabotageHPRemNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "SabotageHPRemoval"); + if (sabotageHPRemNode != null) + { + // The SabotageHPRemoval value is now an int percentage, so multiply the float with 100. + var oldValue = FieldLoader.GetValue("SabotageHPRemoval", sabotageHPRemNode.Value.Value); + var newValue = (int)(oldValue * 100); + sabotageHPRemNode.Value.Value = newValue.ToString(); + } + } + + if (node.Key == "Capturable") + { + var captThreshNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "CaptureThreshold"); + if (captThreshNode != null) + { + // The CaptureThreshold value is now an int percentage, so multiply the float with 100. + var oldValue = FieldLoader.GetValue("CaptureThreshold", captThreshNode.Value.Value); + var newValue = (int)(oldValue * 100); + captThreshNode.Value.Value = newValue.ToString(); + } + } + } + UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1); } } diff --git a/mods/cnc/maps/nod03a/rules.yaml b/mods/cnc/maps/nod03a/rules.yaml index 4c20331bb0..4ca994bf35 100644 --- a/mods/cnc/maps/nod03a/rules.yaml +++ b/mods/cnc/maps/nod03a/rules.yaml @@ -89,4 +89,4 @@ MISS: Tooltip: Name: Prison Capturable: - CaptureThreshold: 1 + CaptureThreshold: 100 diff --git a/mods/cnc/maps/nod03b/rules.yaml b/mods/cnc/maps/nod03b/rules.yaml index 5bb60d3644..29d3bd212a 100644 --- a/mods/cnc/maps/nod03b/rules.yaml +++ b/mods/cnc/maps/nod03b/rules.yaml @@ -89,4 +89,4 @@ MISS: Tooltip: Name: Prison Capturable: - CaptureThreshold: 1 + CaptureThreshold: 100 diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index b2bb37611d..5b4595863d 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -688,7 +688,7 @@ Capturable: Type: husk AllowAllies: yes - CaptureThreshold: 1.0 + CaptureThreshold: 100 TransformOnCapture: ForceHealthPercentage: 25 Tooltip: diff --git a/mods/d2k/rules/defaults.yaml b/mods/d2k/rules/defaults.yaml index 8db6bc0a06..f45670e956 100644 --- a/mods/d2k/rules/defaults.yaml +++ b/mods/d2k/rules/defaults.yaml @@ -254,7 +254,7 @@ Adjacent: 3 GivesBuildableArea: Capturable: - CaptureThreshold: 1.0 + CaptureThreshold: 100 SoundOnDamageTransition: DamagedSounds: EXPLSML1.WAV DestroyedSounds: EXPLHG1.WAV diff --git a/mods/ra/maps/allies-03a/rules.yaml b/mods/ra/maps/allies-03a/rules.yaml index 8e2a2a0f3b..c35f69b523 100644 --- a/mods/ra/maps/allies-03a/rules.yaml +++ b/mods/ra/maps/allies-03a/rules.yaml @@ -52,7 +52,7 @@ World: ^Building: Capturable: - CaptureThreshold: 0.25 + CaptureThreshold: 25 Tooltip: GenericVisibility: Enemy ShowOwnerRow: false diff --git a/mods/ra/maps/allies-03b/rules.yaml b/mods/ra/maps/allies-03b/rules.yaml index 23e17388c3..e65f231e5d 100644 --- a/mods/ra/maps/allies-03b/rules.yaml +++ b/mods/ra/maps/allies-03b/rules.yaml @@ -52,7 +52,7 @@ World: ^Building: Capturable: - CaptureThreshold: 0.25 + CaptureThreshold: 25 Tooltip: GenericVisibility: Enemy ShowOwnerRow: false diff --git a/mods/ra/maps/intervention/rules.yaml b/mods/ra/maps/intervention/rules.yaml index 7d9dce836b..e917f4ea89 100644 --- a/mods/ra/maps/intervention/rules.yaml +++ b/mods/ra/maps/intervention/rules.yaml @@ -42,7 +42,7 @@ MISS: AllowAllies: False AllowNeutral: False AllowEnemies: True - CaptureThreshold: 1.0 + CaptureThreshold: 100 E6.MOD: Inherits: E6 diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 290498a08d..b8e787b123 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -112,7 +112,7 @@ AllowUnsuitableCell: false Capturable: Type: vehicle - CaptureThreshold: 1 + CaptureThreshold: 100 CancelActivity: True CaptureNotification: Notification: UnitStolen @@ -620,7 +620,7 @@ Capturable: Type: husk AllowAllies: true - CaptureThreshold: 1.0 + CaptureThreshold: 100 TransformOnCapture: ForceHealthPercentage: 25 DisabledOverlay: diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 8a964c00e9..eafcacf11c 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -418,7 +418,7 @@ ActorLostNotification: Capturable: Type: Vehicle - CaptureThreshold: 1 + CaptureThreshold: 100 CancelActivity: True Guard: Voice: Move