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)
|
if (actor.IsDead || capturable.BeingCaptured)
|
||||||
return;
|
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)
|
if (!capturesInfo.Sabotage || lowEnoughHealth || actor.Owner.NonCombatant)
|
||||||
{
|
{
|
||||||
var oldOwner = actor.Owner;
|
var oldOwner = actor.Owner;
|
||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var damage = (int)(health.MaxHP * capturesInfo.SabotageHPRemoval);
|
var damage = health.MaxHP * capturesInfo.SabotageHPRemoval / 100;
|
||||||
actor.InflictDamage(self, damage, null);
|
actor.InflictDamage(self, damage, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly bool AllowNeutral = true;
|
public readonly bool AllowNeutral = true;
|
||||||
public readonly bool AllowEnemies = true;
|
public readonly bool AllowEnemies = true;
|
||||||
[Desc("Health percentage the target must be at (or below) before it can be captured.")]
|
[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 readonly bool CancelActivity = false;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new Capturable(this); }
|
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.")]
|
[Desc("Unit will do damage to the actor instead of capturing it. Unit is destroyed when sabotaging.")]
|
||||||
public readonly bool Sabotage = true;
|
public readonly bool Sabotage = true;
|
||||||
[Desc("Only used if Sabotage=true. Sabotage damage expressed as a percentage of enemy health removed.")]
|
[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";
|
[VoiceReference] public readonly string Voice = "Action";
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
var health = target.Trait<Health>();
|
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
|
cursor = !sabotage || lowEnoughHealth || target.Owner.NonCombatant
|
||||||
? "enter" : "capture";
|
? "enter" : "capture";
|
||||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
}
|
}
|
||||||
|
|
||||||
var health = target.Info.TraitInfoOrDefault<HealthInfo>();
|
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
|
cursor = !sabotage || lowEnoughHealth || target.Owner.NonCombatant
|
||||||
? "enter" : "capture";
|
? "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);
|
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,4 +89,4 @@ MISS:
|
|||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Prison
|
Name: Prison
|
||||||
Capturable:
|
Capturable:
|
||||||
CaptureThreshold: 1
|
CaptureThreshold: 100
|
||||||
|
|||||||
@@ -89,4 +89,4 @@ MISS:
|
|||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Prison
|
Name: Prison
|
||||||
Capturable:
|
Capturable:
|
||||||
CaptureThreshold: 1
|
CaptureThreshold: 100
|
||||||
|
|||||||
@@ -688,7 +688,7 @@
|
|||||||
Capturable:
|
Capturable:
|
||||||
Type: husk
|
Type: husk
|
||||||
AllowAllies: yes
|
AllowAllies: yes
|
||||||
CaptureThreshold: 1.0
|
CaptureThreshold: 100
|
||||||
TransformOnCapture:
|
TransformOnCapture:
|
||||||
ForceHealthPercentage: 25
|
ForceHealthPercentage: 25
|
||||||
Tooltip:
|
Tooltip:
|
||||||
|
|||||||
@@ -254,7 +254,7 @@
|
|||||||
Adjacent: 3
|
Adjacent: 3
|
||||||
GivesBuildableArea:
|
GivesBuildableArea:
|
||||||
Capturable:
|
Capturable:
|
||||||
CaptureThreshold: 1.0
|
CaptureThreshold: 100
|
||||||
SoundOnDamageTransition:
|
SoundOnDamageTransition:
|
||||||
DamagedSounds: EXPLSML1.WAV
|
DamagedSounds: EXPLSML1.WAV
|
||||||
DestroyedSounds: EXPLHG1.WAV
|
DestroyedSounds: EXPLHG1.WAV
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ World:
|
|||||||
|
|
||||||
^Building:
|
^Building:
|
||||||
Capturable:
|
Capturable:
|
||||||
CaptureThreshold: 0.25
|
CaptureThreshold: 25
|
||||||
Tooltip:
|
Tooltip:
|
||||||
GenericVisibility: Enemy
|
GenericVisibility: Enemy
|
||||||
ShowOwnerRow: false
|
ShowOwnerRow: false
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ World:
|
|||||||
|
|
||||||
^Building:
|
^Building:
|
||||||
Capturable:
|
Capturable:
|
||||||
CaptureThreshold: 0.25
|
CaptureThreshold: 25
|
||||||
Tooltip:
|
Tooltip:
|
||||||
GenericVisibility: Enemy
|
GenericVisibility: Enemy
|
||||||
ShowOwnerRow: false
|
ShowOwnerRow: false
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ MISS:
|
|||||||
AllowAllies: False
|
AllowAllies: False
|
||||||
AllowNeutral: False
|
AllowNeutral: False
|
||||||
AllowEnemies: True
|
AllowEnemies: True
|
||||||
CaptureThreshold: 1.0
|
CaptureThreshold: 100
|
||||||
|
|
||||||
E6.MOD:
|
E6.MOD:
|
||||||
Inherits: E6
|
Inherits: E6
|
||||||
|
|||||||
@@ -112,7 +112,7 @@
|
|||||||
AllowUnsuitableCell: false
|
AllowUnsuitableCell: false
|
||||||
Capturable:
|
Capturable:
|
||||||
Type: vehicle
|
Type: vehicle
|
||||||
CaptureThreshold: 1
|
CaptureThreshold: 100
|
||||||
CancelActivity: True
|
CancelActivity: True
|
||||||
CaptureNotification:
|
CaptureNotification:
|
||||||
Notification: UnitStolen
|
Notification: UnitStolen
|
||||||
@@ -620,7 +620,7 @@
|
|||||||
Capturable:
|
Capturable:
|
||||||
Type: husk
|
Type: husk
|
||||||
AllowAllies: true
|
AllowAllies: true
|
||||||
CaptureThreshold: 1.0
|
CaptureThreshold: 100
|
||||||
TransformOnCapture:
|
TransformOnCapture:
|
||||||
ForceHealthPercentage: 25
|
ForceHealthPercentage: 25
|
||||||
DisabledOverlay:
|
DisabledOverlay:
|
||||||
|
|||||||
@@ -418,7 +418,7 @@
|
|||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
Capturable:
|
Capturable:
|
||||||
Type: Vehicle
|
Type: Vehicle
|
||||||
CaptureThreshold: 1
|
CaptureThreshold: 100
|
||||||
CancelActivity: True
|
CancelActivity: True
|
||||||
Guard:
|
Guard:
|
||||||
Voice: Move
|
Voice: Move
|
||||||
|
|||||||
Reference in New Issue
Block a user