Add ScaleDefaultHealth and subclass update rules
This commit is contained in:
@@ -591,6 +591,9 @@
|
|||||||
<Compile Include="UpdateRules\Rules\DecoupleSelfReloading.cs" />
|
<Compile Include="UpdateRules\Rules\DecoupleSelfReloading.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\RemovePlayerPaletteTileset.cs" />
|
<Compile Include="UpdateRules\Rules\RemovePlayerPaletteTileset.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\RenameWithTurreted.cs" />
|
<Compile Include="UpdateRules\Rules\RenameWithTurreted.cs" />
|
||||||
|
<Compile Include="UpdateRules\Rules\ScaleModHealth.cs" />
|
||||||
|
<Compile Include="UpdateRules\Rules\ScaleModHealthBy10.cs" />
|
||||||
|
<Compile Include="UpdateRules\Rules\ScaleModHealthBy100.cs" />
|
||||||
<Compile Include="UtilityCommands\CheckYaml.cs" />
|
<Compile Include="UtilityCommands\CheckYaml.cs" />
|
||||||
<Compile Include="UtilityCommands\ConvertPngToShpCommand.cs" />
|
<Compile Include="UtilityCommands\ConvertPngToShpCommand.cs" />
|
||||||
<Compile Include="UtilityCommands\ConvertSpriteToPngCommand.cs" />
|
<Compile Include="UtilityCommands\ConvertSpriteToPngCommand.cs" />
|
||||||
@@ -876,6 +879,7 @@
|
|||||||
<Compile Include="UpdateRules\UpdateUtils.cs" />
|
<Compile Include="UpdateRules\UpdateUtils.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\RemoveMobileOnRails.cs" />
|
<Compile Include="UpdateRules\Rules\RemoveMobileOnRails.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\AircraftCanHoverGeneralization.cs" />
|
<Compile Include="UpdateRules\Rules\AircraftCanHoverGeneralization.cs" />
|
||||||
|
<Compile Include="UpdateRules\Rules\ScaleDefaultModHealth.cs" />
|
||||||
<Compile Include="UtilityCommands\UpdateMapCommand.cs" />
|
<Compile Include="UtilityCommands\UpdateMapCommand.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\RemoveTerrainTypeIsWaterFlag.cs" />
|
<Compile Include="UpdateRules\Rules\RemoveTerrainTypeIsWaterFlag.cs" />
|
||||||
<Compile Include="UpdateRules\Rules\RemoveWeaponScanRadius.cs" />
|
<Compile Include="UpdateRules\Rules\RemoveWeaponScanRadius.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Primitives;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class ScaleDefaultModHealth : ScaleModHealth
|
||||||
|
{
|
||||||
|
static readonly Dictionary<string, int> ModScales = new Dictionary<string, int>()
|
||||||
|
{
|
||||||
|
{ "cnc", 100 },
|
||||||
|
{ "ra", 100 },
|
||||||
|
{ "d2k", 10 },
|
||||||
|
{ "ts", 100 }
|
||||||
|
};
|
||||||
|
|
||||||
|
public override IEnumerable<string> BeforeUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
ModScales.TryGetValue(modData.Manifest.Id, out scale);
|
||||||
|
return base.BeforeUpdate(modData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
111
OpenRA.Mods.Common/UpdateRules/Rules/ScaleModHealth.cs
Normal file
111
OpenRA.Mods.Common/UpdateRules/Rules/ScaleModHealth.cs
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Primitives;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class ScaleModHealth : UpdateRule
|
||||||
|
{
|
||||||
|
public override string Name { get { return "Scale health and damage in the default OpenRA mods"; } }
|
||||||
|
public override string Description
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return "All health and damage values are increased by a factor of 100 (ra, cnc, ts) or 10 (d2k)\n"
|
||||||
|
+ "in order to reduce numerical inaccuracies in damage calculations.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static readonly Dictionary<string, Pair<string, string>[]> TraitMapping = new Dictionary<string, Pair<string, string>[]>()
|
||||||
|
{
|
||||||
|
{ "Health", new[] { Pair.New("HP", string.Empty) } },
|
||||||
|
{ "SelfHealing", new[] { Pair.New("Step", "500") } },
|
||||||
|
{ "RepairsUnits", new[] { Pair.New("HpPerStep", "1000") } },
|
||||||
|
{ "RepairableBuilding", new[] { Pair.New("RepairStep", "700") } },
|
||||||
|
{ "Burns", new[] { Pair.New("Damage", "100") } },
|
||||||
|
{ "DamagedByTerrain", new[] { Pair.New("Damage", string.Empty) } },
|
||||||
|
};
|
||||||
|
|
||||||
|
static readonly Dictionary<string, string> WarheadMapping = new Dictionary<string, string>()
|
||||||
|
{
|
||||||
|
{ "SpreadDamage", "Damage" },
|
||||||
|
{ "TargetDamage", "Damage" },
|
||||||
|
};
|
||||||
|
|
||||||
|
public ScaleModHealth(int scale = 100)
|
||||||
|
{
|
||||||
|
this.scale = scale;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int scale;
|
||||||
|
|
||||||
|
bool updated;
|
||||||
|
|
||||||
|
public override IEnumerable<string> BeforeUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
updated = false;
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> AfterUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
if (updated)
|
||||||
|
yield return "Health and damage values have been muliplied by a factor of {0}.\n".F(scale)
|
||||||
|
+ "The increased calculation precision will affect game balance and may need to be manually adjusted.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||||
|
{
|
||||||
|
foreach (var kv in TraitMapping)
|
||||||
|
{
|
||||||
|
foreach (var trait in actorNode.ChildrenMatching(kv.Key))
|
||||||
|
{
|
||||||
|
foreach (var parameter in kv.Value)
|
||||||
|
{
|
||||||
|
var node = trait.LastChildMatching(parameter.First);
|
||||||
|
if (node != null)
|
||||||
|
node.ReplaceValue((scale * node.NodeValue<int>()).ToString());
|
||||||
|
else if (!string.IsNullOrEmpty(parameter.Second))
|
||||||
|
trait.AddNode(parameter.First, parameter.Second);
|
||||||
|
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override IEnumerable<string> UpdateWeaponNode(ModData modData, MiniYamlNode weaponNode)
|
||||||
|
{
|
||||||
|
foreach (var warheadNode in weaponNode.ChildrenMatching("Warhead"))
|
||||||
|
{
|
||||||
|
var name = warheadNode.NodeValue<string>();
|
||||||
|
if (name == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string parameterName;
|
||||||
|
if (!WarheadMapping.TryGetValue(name, out parameterName))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var node in warheadNode.ChildrenMatching(parameterName))
|
||||||
|
{
|
||||||
|
node.ReplaceValue((scale * node.NodeValue<int>()).ToString());
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
yield break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
OpenRA.Mods.Common/UpdateRules/Rules/ScaleModHealthBy10.cs
Normal file
24
OpenRA.Mods.Common/UpdateRules/Rules/ScaleModHealthBy10.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class ScaleModHealthBy10 : ScaleModHealth
|
||||||
|
{
|
||||||
|
public override IEnumerable<string> BeforeUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
scale = 10;
|
||||||
|
return base.BeforeUpdate(modData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
OpenRA.Mods.Common/UpdateRules/Rules/ScaleModHealthBy100.cs
Normal file
24
OpenRA.Mods.Common/UpdateRules/Rules/ScaleModHealthBy100.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2018 The OpenRA Developers (see AUTHORS)
|
||||||
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
|
* available to you under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation, either version 3 of
|
||||||
|
* the License, or (at your option) any later version. For more
|
||||||
|
* information, see COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||||
|
{
|
||||||
|
public class ScaleModHealthBy100 : ScaleModHealth
|
||||||
|
{
|
||||||
|
public override IEnumerable<string> BeforeUpdate(ModData modData)
|
||||||
|
{
|
||||||
|
scale = 100;
|
||||||
|
return base.BeforeUpdate(modData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,7 +42,8 @@ namespace OpenRA.Mods.Common.UpdateRules
|
|||||||
new CapturableChanges(),
|
new CapturableChanges(),
|
||||||
new DecoupleSelfReloading(),
|
new DecoupleSelfReloading(),
|
||||||
new RemovePlayerPaletteTileset(),
|
new RemovePlayerPaletteTileset(),
|
||||||
new RenameWithTurreted()
|
new RenameWithTurreted(),
|
||||||
|
new ScaleDefaultModHealth()
|
||||||
}),
|
}),
|
||||||
|
|
||||||
new UpdatePath("release-20180218", "release-20180307", new UpdateRule[0]),
|
new UpdatePath("release-20180218", "release-20180307", new UpdateRule[0]),
|
||||||
|
|||||||
Reference in New Issue
Block a user