Migrate Captures.SabotageHPRemoval and Capturable.CaptureThreshold to int percentages

This commit is contained in:
reaperrr
2016-03-24 14:25:00 +01:00
parent 82f23210d9
commit 4894211789
13 changed files with 44 additions and 16 deletions

View File

@@ -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);
}

View File

@@ -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); }

View File

@@ -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";

View File

@@ -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);
}
}

View File

@@ -89,4 +89,4 @@ MISS:
Tooltip:
Name: Prison
Capturable:
CaptureThreshold: 1
CaptureThreshold: 100

View File

@@ -89,4 +89,4 @@ MISS:
Tooltip:
Name: Prison
Capturable:
CaptureThreshold: 1
CaptureThreshold: 100

View File

@@ -688,7 +688,7 @@
Capturable:
Type: husk
AllowAllies: yes
CaptureThreshold: 1.0
CaptureThreshold: 100
TransformOnCapture:
ForceHealthPercentage: 25
Tooltip:

View File

@@ -254,7 +254,7 @@
Adjacent: 3
GivesBuildableArea:
Capturable:
CaptureThreshold: 1.0
CaptureThreshold: 100
SoundOnDamageTransition:
DamagedSounds: EXPLSML1.WAV
DestroyedSounds: EXPLHG1.WAV

View File

@@ -52,7 +52,7 @@ World:
^Building:
Capturable:
CaptureThreshold: 0.25
CaptureThreshold: 25
Tooltip:
GenericVisibility: Enemy
ShowOwnerRow: false

View File

@@ -52,7 +52,7 @@ World:
^Building:
Capturable:
CaptureThreshold: 0.25
CaptureThreshold: 25
Tooltip:
GenericVisibility: Enemy
ShowOwnerRow: false

View File

@@ -42,7 +42,7 @@ MISS:
AllowAllies: False
AllowNeutral: False
AllowEnemies: True
CaptureThreshold: 1.0
CaptureThreshold: 100
E6.MOD:
Inherits: E6

View File

@@ -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:

View File

@@ -418,7 +418,7 @@
ActorLostNotification:
Capturable:
Type: Vehicle
CaptureThreshold: 1
CaptureThreshold: 100
CancelActivity: True
Guard:
Voice: Move