mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: more shit
This commit is contained in:
1 parent
920ef6e5c4
commit
8b0f95c53d
7 files changed
+129
-174
No files matched your search
@@ -21,12 +21,12 @@ message Tank {
|
||||
required ModuleHealth fuel_tank_health = 12;
|
||||
repeated CrewHealth crew_health = 13;
|
||||
required float max_health = 14;
|
||||
required float health_burn_per_second = 15;
|
||||
required float health_burn_per_sec = 15;
|
||||
required float fire_starting_chance = 16;
|
||||
|
||||
required float concealment_stationary = 17;
|
||||
required float concealment_moving = 18;
|
||||
required float concealment_factor_on_shot = 19;
|
||||
required float concealment_factor_at_shot = 19;
|
||||
|
||||
required float turret_turn_rate = 20;
|
||||
required float circular_vision_radius = 21;
|
||||
@@ -46,7 +46,6 @@ message Tank {
|
||||
required float rotation_speed = 33;
|
||||
required float terrain_resistance_hard = 34;
|
||||
required float brake_force = 35;
|
||||
required bool b_rotation_is_around_center = 36;
|
||||
}
|
||||
|
||||
enum CrewType {
|
||||
|
||||
@@ -79,11 +79,11 @@ export interface Tank {
|
||||
fuel_tank_health: ModuleHealth;
|
||||
crew_health: CrewHealth[];
|
||||
max_health: number;
|
||||
health_burn_per_second: number;
|
||||
health_burn_per_sec: number;
|
||||
fire_starting_chance: number;
|
||||
concealment_stationary: number;
|
||||
concealment_moving: number;
|
||||
concealment_factor_on_shot: number;
|
||||
concealment_factor_at_shot: number;
|
||||
turret_turn_rate: number;
|
||||
circular_vision_radius: number;
|
||||
shells: Shell[];
|
||||
@@ -100,7 +100,6 @@ export interface Tank {
|
||||
rotation_speed: number;
|
||||
terrain_resistance_hard: number;
|
||||
brake_force: number;
|
||||
b_rotation_is_around_center: boolean;
|
||||
}
|
||||
|
||||
export interface CrewHealth {
|
||||
@@ -165,11 +164,11 @@ function createBaseTank(): Tank {
|
||||
fuel_tank_health: createBaseModuleHealth(),
|
||||
crew_health: [],
|
||||
max_health: 0,
|
||||
health_burn_per_second: 0,
|
||||
health_burn_per_sec: 0,
|
||||
fire_starting_chance: 0,
|
||||
concealment_stationary: 0,
|
||||
concealment_moving: 0,
|
||||
concealment_factor_on_shot: 0,
|
||||
concealment_factor_at_shot: 0,
|
||||
turret_turn_rate: 0,
|
||||
circular_vision_radius: 0,
|
||||
shells: [],
|
||||
@@ -186,7 +185,6 @@ function createBaseTank(): Tank {
|
||||
rotation_speed: 0,
|
||||
terrain_resistance_hard: 0,
|
||||
brake_force: 0,
|
||||
b_rotation_is_around_center: false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -234,8 +232,8 @@ export const Tank: MessageFns<Tank> = {
|
||||
if (message.max_health !== 0) {
|
||||
writer.uint32(117).float(message.max_health);
|
||||
}
|
||||
if (message.health_burn_per_second !== 0) {
|
||||
writer.uint32(125).float(message.health_burn_per_second);
|
||||
if (message.health_burn_per_sec !== 0) {
|
||||
writer.uint32(125).float(message.health_burn_per_sec);
|
||||
}
|
||||
if (message.fire_starting_chance !== 0) {
|
||||
writer.uint32(133).float(message.fire_starting_chance);
|
||||
@@ -246,8 +244,8 @@ export const Tank: MessageFns<Tank> = {
|
||||
if (message.concealment_moving !== 0) {
|
||||
writer.uint32(149).float(message.concealment_moving);
|
||||
}
|
||||
if (message.concealment_factor_on_shot !== 0) {
|
||||
writer.uint32(157).float(message.concealment_factor_on_shot);
|
||||
if (message.concealment_factor_at_shot !== 0) {
|
||||
writer.uint32(157).float(message.concealment_factor_at_shot);
|
||||
}
|
||||
if (message.turret_turn_rate !== 0) {
|
||||
writer.uint32(165).float(message.turret_turn_rate);
|
||||
@@ -297,9 +295,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
if (message.brake_force !== 0) {
|
||||
writer.uint32(285).float(message.brake_force);
|
||||
}
|
||||
if (message.b_rotation_is_around_center !== false) {
|
||||
writer.uint32(288).bool(message.b_rotation_is_around_center);
|
||||
}
|
||||
return writer;
|
||||
},
|
||||
|
||||
@@ -427,7 +422,7 @@ export const Tank: MessageFns<Tank> = {
|
||||
break;
|
||||
}
|
||||
|
||||
message.health_burn_per_second = reader.float();
|
||||
message.health_burn_per_sec = reader.float();
|
||||
continue;
|
||||
}
|
||||
case 16: {
|
||||
@@ -459,7 +454,7 @@ export const Tank: MessageFns<Tank> = {
|
||||
break;
|
||||
}
|
||||
|
||||
message.concealment_factor_on_shot = reader.float();
|
||||
message.concealment_factor_at_shot = reader.float();
|
||||
continue;
|
||||
}
|
||||
case 20: {
|
||||
@@ -590,14 +585,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
message.brake_force = reader.float();
|
||||
continue;
|
||||
}
|
||||
case 36: {
|
||||
if (tag !== 288) {
|
||||
break;
|
||||
}
|
||||
|
||||
message.b_rotation_is_around_center = reader.bool();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((tag & 7) === 4 || tag === 0) {
|
||||
break;
|
||||
@@ -629,16 +616,14 @@ export const Tank: MessageFns<Tank> = {
|
||||
? object.crew_health.map((e: any) => CrewHealth.fromJSON(e))
|
||||
: [],
|
||||
max_health: globalThis.Number(assertSet("Tank.max_health", object.max_health)),
|
||||
health_burn_per_second: globalThis.Number(
|
||||
assertSet("Tank.health_burn_per_second", object.health_burn_per_second),
|
||||
),
|
||||
health_burn_per_sec: globalThis.Number(assertSet("Tank.health_burn_per_sec", object.health_burn_per_sec)),
|
||||
fire_starting_chance: globalThis.Number(assertSet("Tank.fire_starting_chance", object.fire_starting_chance)),
|
||||
concealment_stationary: globalThis.Number(
|
||||
assertSet("Tank.concealment_stationary", object.concealment_stationary),
|
||||
),
|
||||
concealment_moving: globalThis.Number(assertSet("Tank.concealment_moving", object.concealment_moving)),
|
||||
concealment_factor_on_shot: globalThis.Number(
|
||||
assertSet("Tank.concealment_factor_on_shot", object.concealment_factor_on_shot),
|
||||
concealment_factor_at_shot: globalThis.Number(
|
||||
assertSet("Tank.concealment_factor_at_shot", object.concealment_factor_at_shot),
|
||||
),
|
||||
turret_turn_rate: globalThis.Number(assertSet("Tank.turret_turn_rate", object.turret_turn_rate)),
|
||||
circular_vision_radius: globalThis.Number(
|
||||
@@ -664,9 +649,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
assertSet("Tank.terrain_resistance_hard", object.terrain_resistance_hard),
|
||||
),
|
||||
brake_force: globalThis.Number(assertSet("Tank.brake_force", object.brake_force)),
|
||||
b_rotation_is_around_center: globalThis.Boolean(
|
||||
assertSet("Tank.b_rotation_is_around_center", object.b_rotation_is_around_center),
|
||||
),
|
||||
};
|
||||
},
|
||||
|
||||
@@ -714,8 +696,8 @@ export const Tank: MessageFns<Tank> = {
|
||||
if (message.max_health !== 0) {
|
||||
obj.max_health = message.max_health;
|
||||
}
|
||||
if (message.health_burn_per_second !== 0) {
|
||||
obj.health_burn_per_second = message.health_burn_per_second;
|
||||
if (message.health_burn_per_sec !== 0) {
|
||||
obj.health_burn_per_sec = message.health_burn_per_sec;
|
||||
}
|
||||
if (message.fire_starting_chance !== 0) {
|
||||
obj.fire_starting_chance = message.fire_starting_chance;
|
||||
@@ -726,8 +708,8 @@ export const Tank: MessageFns<Tank> = {
|
||||
if (message.concealment_moving !== 0) {
|
||||
obj.concealment_moving = message.concealment_moving;
|
||||
}
|
||||
if (message.concealment_factor_on_shot !== 0) {
|
||||
obj.concealment_factor_on_shot = message.concealment_factor_on_shot;
|
||||
if (message.concealment_factor_at_shot !== 0) {
|
||||
obj.concealment_factor_at_shot = message.concealment_factor_at_shot;
|
||||
}
|
||||
if (message.turret_turn_rate !== 0) {
|
||||
obj.turret_turn_rate = message.turret_turn_rate;
|
||||
@@ -777,9 +759,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
if (message.brake_force !== 0) {
|
||||
obj.brake_force = message.brake_force;
|
||||
}
|
||||
if (message.b_rotation_is_around_center !== false) {
|
||||
obj.b_rotation_is_around_center = message.b_rotation_is_around_center;
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
|
||||
@@ -820,11 +799,11 @@ export const Tank: MessageFns<Tank> = {
|
||||
: createBaseModuleHealth();
|
||||
message.crew_health = object.crew_health?.map((e) => CrewHealth.fromPartial(e)) || [];
|
||||
message.max_health = object.max_health ?? 0;
|
||||
message.health_burn_per_second = object.health_burn_per_second ?? 0;
|
||||
message.health_burn_per_sec = object.health_burn_per_sec ?? 0;
|
||||
message.fire_starting_chance = object.fire_starting_chance ?? 0;
|
||||
message.concealment_stationary = object.concealment_stationary ?? 0;
|
||||
message.concealment_moving = object.concealment_moving ?? 0;
|
||||
message.concealment_factor_on_shot = object.concealment_factor_on_shot ?? 0;
|
||||
message.concealment_factor_at_shot = object.concealment_factor_at_shot ?? 0;
|
||||
message.turret_turn_rate = object.turret_turn_rate ?? 0;
|
||||
message.circular_vision_radius = object.circular_vision_radius ?? 0;
|
||||
message.shells = object.shells?.map((e) => Shell.fromPartial(e)) || [];
|
||||
@@ -841,7 +820,6 @@ export const Tank: MessageFns<Tank> = {
|
||||
message.rotation_speed = object.rotation_speed ?? 0;
|
||||
message.terrain_resistance_hard = object.terrain_resistance_hard ?? 0;
|
||||
message.brake_force = object.brake_force ?? 0;
|
||||
message.b_rotation_is_around_center = object.b_rotation_is_around_center ?? false;
|
||||
return message;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,112 +1,52 @@
|
||||
using Blitzkit;
|
||||
using BlitzKit.CLI.Models;
|
||||
using BlitzKit.CLI.Utils;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
using Google.Protobuf.Collections;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BlitzKit.CLI.Functions
|
||||
{
|
||||
public static class Mangler
|
||||
public class Mangler
|
||||
{
|
||||
public static void Mangle()
|
||||
{
|
||||
Tanks tanks = new();
|
||||
BlitzProvider provider = new();
|
||||
readonly Tanks tanks = new();
|
||||
readonly BlitzProvider provider = new();
|
||||
|
||||
foreach (
|
||||
var nationDir in provider.RootDirectory.GetDirectory("Blitz/Content/Tanks").Directories
|
||||
)
|
||||
public void Mangle()
|
||||
{
|
||||
var nationDirs = provider.RootDirectory.GetDirectory("Blitz/Content/Tanks").Directories;
|
||||
|
||||
foreach (var nationDir in nationDirs)
|
||||
{
|
||||
if (nationDir.Key == "TankStub")
|
||||
continue;
|
||||
|
||||
foreach (var tankDir in nationDir.Value.Directories)
|
||||
{
|
||||
var id = tankDir.Key;
|
||||
|
||||
if (id != "R90_IS_4")
|
||||
continue;
|
||||
|
||||
var attributeFileName = $"DA_{id}_Attributes.uasset";
|
||||
var hasAttributesFile = tankDir.Value.HasFile(attributeFileName);
|
||||
GameFile? attributesFile = null;
|
||||
|
||||
if (hasAttributesFile)
|
||||
{
|
||||
attributesFile = tankDir.Value.GetFile(attributeFileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
PrettyLog.Warn(
|
||||
$"No attributes file found for {nationDir.Key}/{id}, it may be misspelled; finding any attributes file..."
|
||||
);
|
||||
|
||||
foreach (var file in tankDir.Value.Files)
|
||||
{
|
||||
if (file.Key.EndsWith("_Attributes.uasset"))
|
||||
{
|
||||
attributesFile = file.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (attributesFile == null)
|
||||
{
|
||||
PrettyLog.Error(
|
||||
$"No suffixed attributes file found for {nationDir.Key}/{id}; skipping..."
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
var exports = provider.LoadAllObjects(attributesFile.Path);
|
||||
|
||||
var tankAttributesDataAsset =
|
||||
exports.First((export) => export.ExportType == "TankAttributesDataAsset")
|
||||
?? throw new Exception("TankAttributesDataAsset not found");
|
||||
var attr = JObject.FromObject(tankAttributesDataAsset);
|
||||
|
||||
if (attr["Properties"] is not JObject props || props["MaxHealth"] == null)
|
||||
{
|
||||
PrettyLog.Warn($"{nationDir.Key}/{id} has not migrated to Reforged; skipping...");
|
||||
continue;
|
||||
}
|
||||
|
||||
var tank = MangleTank(id, props);
|
||||
|
||||
tanks.Tanks_.Add(tank.Id);
|
||||
|
||||
Console.WriteLine($"Mangled {nationDir.Key}/{id}");
|
||||
}
|
||||
MangleNation(nationDir.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public static Tank MangleTank(string id, JObject props)
|
||||
void MangleNation(VfsDirectory nation)
|
||||
{
|
||||
Tank tank = new()
|
||||
foreach (var tankDir in nation.Directories)
|
||||
{
|
||||
Id = id,
|
||||
// TODO: Name
|
||||
// TODO: Set
|
||||
// TODO: Class
|
||||
// TODO: Faction
|
||||
if (tankDir.Value.Name != "R90_IS_4")
|
||||
continue;
|
||||
|
||||
TurretRotatorHealth = MangleModuleHealth((props["TurretRotatorHealth"] as JObject)!),
|
||||
SurveyingDeviceHealth = MangleModuleHealth((props["SurveyingDeviceHealth"] as JObject)!),
|
||||
GunHealth = MangleModuleHealth((props["GunHealth"] as JObject)!),
|
||||
ChassisHealth = MangleModuleHealth((props["ChassisHealth"] as JObject)!),
|
||||
AmmoBayHealth = MangleModuleHealth((props["AmmoBayHealth"] as JObject)!),
|
||||
EngineHealth = MangleModuleHealth((props["EngineHealth"] as JObject)!),
|
||||
FuelTankHealth = MangleModuleHealth((props["FuelTankHealth"] as JObject)!),
|
||||
};
|
||||
var tank = MangleTank(tankDir.Value);
|
||||
|
||||
MangleCrewHealth(tank.CrewHealth, (props["CrewHealth"] as JArray)!);
|
||||
|
||||
return tank;
|
||||
tanks.Tanks_.Add(tank.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public static Dictionary<string, CrewType> CrewTypes = new()
|
||||
Tank MangleTank(VfsDirectory tankDir)
|
||||
{
|
||||
var pdaName = $"PDA_{tankDir.Name}";
|
||||
var pda = tankDir.GetUasset($"{pdaName}.uasset").Get(pdaName);
|
||||
|
||||
Console.WriteLine(pda);
|
||||
|
||||
return new();
|
||||
}
|
||||
|
||||
Dictionary<string, CrewType> CrewTypes = new()
|
||||
{
|
||||
{ "EModuleOrTankmen::Commander", CrewType.Commander },
|
||||
{ "EModuleOrTankmen::Driver", CrewType.Driver },
|
||||
@@ -116,7 +56,7 @@ namespace BlitzKit.CLI.Functions
|
||||
{ "EModuleOrTankmen::Loader2", CrewType.Loader2 },
|
||||
};
|
||||
|
||||
public static void MangleCrewHealth(RepeatedField<CrewHealth> map, JArray array)
|
||||
void MangleCrewHealth(RepeatedField<CrewHealth> map, JArray array)
|
||||
{
|
||||
foreach (var member in array.Cast<JObject>())
|
||||
{
|
||||
@@ -138,7 +78,7 @@ namespace BlitzKit.CLI.Functions
|
||||
}
|
||||
}
|
||||
|
||||
public static ModuleHealth MangleModuleHealth(JObject obj)
|
||||
ModuleHealth MangleModuleHealth(JObject obj)
|
||||
{
|
||||
ModuleHealth moduleHealth = new()
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BlitzKit.CLI.Models
|
||||
private static readonly string LOCAL_MAPPINGS_PATH =
|
||||
"../../submodules/blitzkit-closed/blitz.usmap";
|
||||
|
||||
public readonly VfsDirectory RootDirectory = new();
|
||||
public readonly VfsDirectory RootDirectory;
|
||||
|
||||
public BlitzProvider()
|
||||
: base(
|
||||
@@ -25,6 +25,7 @@ namespace BlitzKit.CLI.Models
|
||||
versions: new(EGame.GAME_UE5_3)
|
||||
)
|
||||
{
|
||||
RootDirectory = new() { Name = "", provider = this };
|
||||
MappingsContainer = new FileUsmapTypeMappingsProvider(LOCAL_MAPPINGS_PATH);
|
||||
|
||||
Initialize();
|
||||
@@ -51,7 +52,7 @@ namespace BlitzKit.CLI.Models
|
||||
}
|
||||
else
|
||||
{
|
||||
VfsDirectory newDirectory = new();
|
||||
VfsDirectory newDirectory = new() { Name = segment, provider = this };
|
||||
directory.AddDirectory(segment, newDirectory);
|
||||
directory = newDirectory;
|
||||
}
|
||||
@@ -59,42 +60,4 @@ namespace BlitzKit.CLI.Models
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class VfsDirectory
|
||||
{
|
||||
public Dictionary<string, VfsDirectory> Directories = [];
|
||||
public Dictionary<string, GameFile> Files = [];
|
||||
|
||||
public void AddFile(string name, GameFile file) => Files.TryAdd(name, file);
|
||||
|
||||
public bool HasFile(string name) => Files.ContainsKey(name);
|
||||
|
||||
public GameFile GetFile(string name)
|
||||
{
|
||||
var directoryPath = Path.GetDirectoryName(name);
|
||||
var fileName = Path.GetFileName(name);
|
||||
var directory =
|
||||
directoryPath == null || directoryPath.Length == 0 ? this : GetDirectory(directoryPath);
|
||||
|
||||
return directory.Files[fileName];
|
||||
}
|
||||
|
||||
public bool HasDirectory(string name) => Directories.ContainsKey(name);
|
||||
|
||||
public VfsDirectory GetDirectory(string name)
|
||||
{
|
||||
var segments = name.Split('/');
|
||||
var directory = this;
|
||||
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
directory = directory.Directories[segment];
|
||||
}
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
public void AddDirectory(string name, VfsDirectory directory) =>
|
||||
Directories.Add(name, directory);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using CUE4Parse.FileProvider;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
using CUE4Parse.UE4.Assets.Exports;
|
||||
|
||||
namespace BlitzKit.CLI.Models
|
||||
{
|
||||
public class Uasset
|
||||
{
|
||||
readonly GameFile file;
|
||||
readonly Dictionary<string, UObject> objects = [];
|
||||
|
||||
public Uasset(GameFile file, AbstractFileProvider provider)
|
||||
{
|
||||
this.file = file;
|
||||
var objects = provider.LoadAllObjects(file.Path);
|
||||
|
||||
foreach (var obj in objects)
|
||||
{
|
||||
this.objects.Add(obj.Name, obj);
|
||||
}
|
||||
}
|
||||
|
||||
public UObject Get(string name) => objects[name];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using CUE4Parse.FileProvider;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
|
||||
namespace BlitzKit.CLI.Models
|
||||
{
|
||||
public class VfsDirectory
|
||||
{
|
||||
public Dictionary<string, VfsDirectory> Directories = [];
|
||||
public Dictionary<string, GameFile> Files = [];
|
||||
public required string Name;
|
||||
public required AbstractFileProvider provider;
|
||||
|
||||
public void AddFile(string name, GameFile file) => Files.TryAdd(name, file);
|
||||
|
||||
public bool HasFile(string name) => Files.ContainsKey(name);
|
||||
|
||||
public Uasset GetUasset(string name) => new(GetFile(name), provider);
|
||||
|
||||
public GameFile GetFile(string name)
|
||||
{
|
||||
var directoryPath = Path.GetDirectoryName(name);
|
||||
var fileName = Path.GetFileName(name);
|
||||
var directory =
|
||||
directoryPath == null || directoryPath.Length == 0 ? this : GetDirectory(directoryPath);
|
||||
|
||||
return directory.Files[fileName];
|
||||
}
|
||||
|
||||
public bool HasDirectory(string name) => Directories.ContainsKey(name);
|
||||
|
||||
public VfsDirectory GetDirectory(string name)
|
||||
{
|
||||
var segments = name.Split('/');
|
||||
var directory = this;
|
||||
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
directory = directory.Directories[segment];
|
||||
}
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
public void AddDirectory(string name, VfsDirectory directory) =>
|
||||
Directories.Add(name, directory);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,10 @@ namespace BlitzKit.CLI
|
||||
|
||||
case "mangle":
|
||||
{
|
||||
Mangler.Mangle();
|
||||
Mangler mangler = new();
|
||||
|
||||
mangler.Mangle();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user