Migrate Captures.SabotageHPRemoval and Capturable.CaptureThreshold to int percentages
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -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<Health>();
|
||||
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<HealthInfo>();
|
||||
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";
|
||||
|
||||
@@ -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<float>("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<float>("CaptureThreshold", captThreshNode.Value.Value);
|
||||
var newValue = (int)(oldValue * 100);
|
||||
captThreshNode.Value.Value = newValue.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,4 @@ MISS:
|
||||
Tooltip:
|
||||
Name: Prison
|
||||
Capturable:
|
||||
CaptureThreshold: 1
|
||||
CaptureThreshold: 100
|
||||
|
||||
@@ -89,4 +89,4 @@ MISS:
|
||||
Tooltip:
|
||||
Name: Prison
|
||||
Capturable:
|
||||
CaptureThreshold: 1
|
||||
CaptureThreshold: 100
|
||||
|
||||
@@ -688,7 +688,7 @@
|
||||
Capturable:
|
||||
Type: husk
|
||||
AllowAllies: yes
|
||||
CaptureThreshold: 1.0
|
||||
CaptureThreshold: 100
|
||||
TransformOnCapture:
|
||||
ForceHealthPercentage: 25
|
||||
Tooltip:
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
Adjacent: 3
|
||||
GivesBuildableArea:
|
||||
Capturable:
|
||||
CaptureThreshold: 1.0
|
||||
CaptureThreshold: 100
|
||||
SoundOnDamageTransition:
|
||||
DamagedSounds: EXPLSML1.WAV
|
||||
DestroyedSounds: EXPLHG1.WAV
|
||||
|
||||
@@ -52,7 +52,7 @@ World:
|
||||
|
||||
^Building:
|
||||
Capturable:
|
||||
CaptureThreshold: 0.25
|
||||
CaptureThreshold: 25
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
ShowOwnerRow: false
|
||||
|
||||
@@ -52,7 +52,7 @@ World:
|
||||
|
||||
^Building:
|
||||
Capturable:
|
||||
CaptureThreshold: 0.25
|
||||
CaptureThreshold: 25
|
||||
Tooltip:
|
||||
GenericVisibility: Enemy
|
||||
ShowOwnerRow: false
|
||||
|
||||
@@ -42,7 +42,7 @@ MISS:
|
||||
AllowAllies: False
|
||||
AllowNeutral: False
|
||||
AllowEnemies: True
|
||||
CaptureThreshold: 1.0
|
||||
CaptureThreshold: 100
|
||||
|
||||
E6.MOD:
|
||||
Inherits: E6
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -418,7 +418,7 @@
|
||||
ActorLostNotification:
|
||||
Capturable:
|
||||
Type: Vehicle
|
||||
CaptureThreshold: 1
|
||||
CaptureThreshold: 100
|
||||
CancelActivity: True
|
||||
Guard:
|
||||
Voice: Move
|
||||
|
||||
Reference in New Issue
Block a user