Add upgrade rules to remove DamageWarhead.DeathType

and replace it with proper DamageTypes
This commit is contained in:
penev92
2015-05-15 21:29:06 +03:00
parent b5e4876b7f
commit 1c44fcbad4
31 changed files with 282 additions and 424 deletions

View File

@@ -75,6 +75,42 @@ namespace OpenRA.Mods.Common.UtilityCommands
input = world.ToString();
}
internal static void RenameDamageTypes(MiniYamlNode damageTypes)
{
var mod = Game.ModData.Manifest.Mod.Id;
if (mod == "cnc" || mod == "ra")
{
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType1", "DefaultDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType2", "BulletDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType3", "SmallExplosionDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType4", "ExplosionDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType5", "FireDeath");
}
if (mod == "cnc")
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType6", "TiberiumDeath");
if (mod == "ra")
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType6", "ElectricityDeath");
if (mod == "d2k")
{
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType1", "ExplosionDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType2", "SoundDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType3", "SmallExplosionDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType4", "BulletDeath");
}
if (mod == "ts")
{
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType1", "BulletDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType2", "SmallExplosionDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType3", "ExplosionDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType5", "FireDeath");
damageTypes.Value.Value = damageTypes.Value.Value.Replace("DeathType6", "EnergyDeath");
}
}
internal static void UpgradeActorRules(int engineVersion, ref List<MiniYamlNode> nodes, MiniYamlNode parent, int depth)
{
var parentKey = parent != null ? parent.Key.Split('@').First() : null;
@@ -1384,6 +1420,31 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
}
if (engineVersion < 20150517)
{
// Remove DeathType from DamageWarhead
if (node.Key.StartsWith("Warhead") && node.Value.Value == "SpreadDamage")
{
var deathTypeNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "DeathType");
var deathType = deathTypeNode == null ? "1" : FieldLoader.GetValue<string>("DeathType", deathTypeNode.Value.Value);
var damageTypes = node.Value.Nodes.FirstOrDefault(x => x.Key == "DamageTypes");
if (damageTypes != null)
damageTypes.Value.Value += ", DeathType" + deathType;
else
node.Value.Nodes.Add(new MiniYamlNode("DamageTypes", "DeathType" + deathType));
node.Value.Nodes.RemoveAll(x => x.Key == "DeathType");
}
// Replace "DeathTypeX" damage types with proper words
if (node.Key.StartsWith("Warhead") && node.Value.Value == "SpreadDamage")
{
var damageTypes = node.Value.Nodes.FirstOrDefault(x => x.Key == "DamageTypes");
if (damageTypes != null)
RenameDamageTypes(damageTypes);
}
}
UpgradeWeaponRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}