feat: add dumper
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<BaseIntermediateOutputPath>..\..\proj\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,124 @@
|
||||
using CUE4Parse.Compression;
|
||||
using CUE4Parse.Encryption.Aes;
|
||||
using CUE4Parse.FileProvider;
|
||||
using CUE4Parse.MappingsProvider;
|
||||
using CUE4Parse.UE4.Assets.Exports.Engine;
|
||||
using CUE4Parse.UE4.Assets.Exports.Texture;
|
||||
using CUE4Parse.UE4.Objects.Core.Misc;
|
||||
using CUE4Parse.UE4.Versions;
|
||||
using CUE4Parse.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
class DumpByDaylight
|
||||
{
|
||||
private const string _pakDir = "E:\\Program Files (x86)\\Steam\\steamapps\\common\\Dead by Daylight\\DeadByDaylight\\Content\\Paks";
|
||||
private const string _aesKey = "0x22B1639B548124925CF7B9CBAA09F9AC295FCF0324586D6B37EE1D42670B39B3";
|
||||
private const string _mappingURL = "https://github.com/Masusder/FModel-DbdMappings/raw/refs/heads/main/Mappings/9.5.0/5.4.4-3172922+++DeadByDaylight+Quiche_REL-DeadByDaylight.usmap";
|
||||
|
||||
public static async Task<string?> DownloadMappingFileAsync(string url, string savePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
Console.WriteLine("downloading mapping file...");
|
||||
var bytes = await httpClient.GetByteArrayAsync(url);
|
||||
await File.WriteAllBytesAsync(savePath, bytes);
|
||||
Console.WriteLine($"mapping file downloaded to: {savePath}");
|
||||
return savePath;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"failed to download mapping: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
// mapping
|
||||
string mappingPath = Path.Combine(Path.GetTempPath(), "DeadByDaylight.usmap");
|
||||
string? downloadedMapping = await DownloadMappingFileAsync(_mappingURL, mappingPath);
|
||||
|
||||
if (string.IsNullOrEmpty(downloadedMapping))
|
||||
{
|
||||
Console.WriteLine("failed to download mapping file, press any key to exit");
|
||||
Console.ReadKey();
|
||||
return;
|
||||
}
|
||||
|
||||
ZlibHelper.Initialize();
|
||||
OodleHelper.Initialize();
|
||||
|
||||
// parsing setup
|
||||
var version = new VersionContainer(EGame.GAME_DeadByDaylight, ETexturePlatform.DesktopMobile);
|
||||
var provider = new DefaultFileProvider(_pakDir, SearchOption.TopDirectoryOnly, version);
|
||||
provider.MappingsContainer = new FileUsmapTypeMappingsProvider(downloadedMapping);
|
||||
|
||||
provider.Initialize();
|
||||
provider.SubmitKey(new FGuid(), new FAesKey(_aesKey));
|
||||
provider.Mount();
|
||||
|
||||
Console.WriteLine("\nProvider Initialized. Extracting Databases...");
|
||||
|
||||
string[] dbNames = { "ItemDB", "OfferingDB", "ItemAddonDB" };
|
||||
var dataPak = provider.GetArchive("pakchunk4-Windows.utoc");
|
||||
|
||||
foreach (var dbName in dbNames)
|
||||
{
|
||||
var searchPaths = dataPak.Files.Keys
|
||||
.Where(x => x.Contains($"/{dbName}.uasset", StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
|
||||
var standard = new List<string>();
|
||||
var special = new List<string>();
|
||||
|
||||
foreach (var path in searchPaths)
|
||||
{
|
||||
var cleanPath = path.Contains('.') ? path.Substring(0, path.LastIndexOf('.')) : path;
|
||||
|
||||
if (provider.TryLoadPackageObject<UDataTable>(cleanPath, out var dataTable))
|
||||
{
|
||||
Console.WriteLine($"- Processing {dbName} (from {Path.GetFileName(path)})...");
|
||||
foreach (var row in dataTable.RowMap)
|
||||
{
|
||||
bool isInventory = row.Value.GetOrDefault<bool>("Inventory");
|
||||
bool isBloodweb = row.Value.GetOrDefault<bool>("Bloodweb");
|
||||
|
||||
if (isBloodweb)
|
||||
{
|
||||
standard.Add(row.Key.Text);
|
||||
}
|
||||
else if (isInventory)
|
||||
{
|
||||
special.Add(row.Key.Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (standard.Count > 0 || special.Count > 0)
|
||||
{
|
||||
var result = new
|
||||
{
|
||||
Standard = standard.OrderBy(x => x).ToList(),
|
||||
Special = special.OrderBy(x => x).ToList()
|
||||
};
|
||||
|
||||
string outputPath = $"{dbName}_Names.json";
|
||||
File.WriteAllText(outputPath, JsonConvert.SerializeObject(result, Formatting.Indented));
|
||||
Console.WriteLine($" -> Saved {standard.Count} standard and {special.Count} special entries to {outputPath}");
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("\nAll dumper operations finished. Press any key to Close.");
|
||||
Console.ReadKey();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user