export health, cost and damage per section into a CSV file
closes #3855
This commit is contained in:
3
Makefile
3
Makefile
@@ -219,10 +219,11 @@ crashdialog: $(crashdialog_TARGET)
|
||||
utility_SRCS := $(shell find OpenRA.Utility/ -iname '*.cs')
|
||||
utility_TARGET = OpenRA.Utility.exe
|
||||
utility_KIND = exe
|
||||
utility_DEPS = $(game_TARGET)
|
||||
utility_DEPS = $(game_TARGET) $(mod_ra_TARGET)
|
||||
utility_LIBS = $(COMMON_LIBS) $(utility_DEPS) thirdparty/ICSharpCode.SharpZipLib.dll
|
||||
PROGRAMS += utility
|
||||
utility: $(utility_TARGET)
|
||||
@$(CP) $(mod_ra_TARGET) .
|
||||
|
||||
|
||||
# Patches binary headers to work around a mono bug
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Text;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Scripting;
|
||||
using OpenRA.Traits;
|
||||
|
||||
@@ -544,5 +545,53 @@ namespace OpenRA.Utility
|
||||
map.Save(dest);
|
||||
Console.WriteLine(dest + " saved.");
|
||||
}
|
||||
|
||||
[Desc("MOD", "Export the game rules into a CSV file to inspect in a spreadheet.")]
|
||||
public static void ExportCharacterSeparatedRules(string[] args)
|
||||
{
|
||||
var mod = args[1];
|
||||
Game.modData = new ModData(mod);
|
||||
var rules = Game.modData.RulesetCache.LoadDefaultRules();
|
||||
var dump = new StringBuilder();
|
||||
dump.AppendLine("Name;Faction;Health;Cost;Damage per Second");
|
||||
foreach (var actorInfo in rules.Actors.Values)
|
||||
{
|
||||
if (actorInfo.Name.StartsWith("^"))
|
||||
continue;
|
||||
|
||||
var buildable = actorInfo.Traits.GetOrDefault<BuildableInfo>();
|
||||
if (buildable == null)
|
||||
continue;
|
||||
var faction = FieldSaver.FormatValue(buildable.Owner, buildable.Owner.GetType());
|
||||
|
||||
var damagePerSecond = 0f;
|
||||
var armaments = actorInfo.Traits.WithInterface<ArmamentInfo>();
|
||||
if (armaments.Any())
|
||||
{
|
||||
var weapons = armaments.Select(a => a.Weapon).Select(w => rules.Weapons[w.ToLowerInvariant()]);
|
||||
if (weapons.Any())
|
||||
{
|
||||
var damage = weapons.Select(w => new { ROF = w.ROF > 0 ? w.ROF : 1, Damage = w.Burst * w.Warheads.Sum(z => z.Damage) });
|
||||
damagePerSecond = damage.Sum(d => (float)d.Damage / d.ROF * 25);
|
||||
}
|
||||
}
|
||||
|
||||
var tooltip = actorInfo.Traits.GetOrDefault<TooltipInfo>();
|
||||
var name = tooltip != null ? tooltip.Name : actorInfo.Name;
|
||||
|
||||
var health = actorInfo.Traits.GetOrDefault<HealthInfo>();
|
||||
var hp = health != null ? health.HP : 0;
|
||||
|
||||
var value = actorInfo.Traits.GetOrDefault<ValuedInfo>();
|
||||
var cost = value != null ? value.Cost : 0;
|
||||
|
||||
dump.AppendLine("{0};{1};{2};{3};{4}".F(name, faction, hp, cost, damagePerSecond));
|
||||
}
|
||||
|
||||
var filename = "{0}-mod-rules.csv".F(mod);
|
||||
using (StreamWriter outfile = new StreamWriter(filename))
|
||||
outfile.Write(dump.ToString());
|
||||
Console.WriteLine("{0} has been saved.\nOpen in a spreadsheet application as values separated by semicolon.".F(filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@
|
||||
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||
<Name>OpenRA.Game</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\OpenRA.Mods.RA\OpenRA.Mods.RA.csproj">
|
||||
<Project>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</Project>
|
||||
<Name>OpenRA.Mods.RA</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace OpenRA.Utility
|
||||
{ "--upgrade-map", UpgradeRules.UpgradeMap },
|
||||
{ "--upgrade-mod", UpgradeRules.UpgradeMod },
|
||||
{ "--map-import", Command.ImportLegacyMap },
|
||||
{ "--extract-language-strings", ExtractLanguageStrings.FromMod }
|
||||
{ "--extract-language-strings", ExtractLanguageStrings.FromMod },
|
||||
{ "--csv", Command.ExportCharacterSeparatedRules }
|
||||
};
|
||||
|
||||
static void Main(string[] args)
|
||||
|
||||
Reference in New Issue
Block a user