feat: some healths

This commit is contained in:
tresabhi committed 2025-01-30 11:31:55 -06:00
1 parent 67f312075a
commit c6f4a13abc
6 files changed
+510 -425

No files matched your search

+1
View File
@@ -151,6 +151,7 @@
"Pyogenics", "Pyogenics",
"ratingleaderboard", "ratingleaderboard",
"raycaster", "raycaster",
"regen",
"researchable", "researchable",
"Resvg", "Resvg",
"rizz", "rizz",
+2 -2
View File
@@ -32,13 +32,13 @@
"update": "yarn upgrade --latest", "update": "yarn upgrade --latest",
"tunnel": "cloudflared tunnel --url http://localhost:3000", "tunnel": "cloudflared tunnel --url http://localhost:3000",
"discoverids": "scripts/discoverIds.ts", "discoverids": "scripts/discoverIds.ts",
"build:protos": "protoc packages/core/src/protos/*.proto --csharp_out=src/BlitzKit.CLI/Protos && bun packages/scripts/src/protos.ts", "protos": "protoc packages/core/src/protos/*.proto --csharp_out=src/BlitzKit.CLI/Protos && bun packages/scripts/src/protos.ts",
"preview:website": "cd packages/website && bun run preview", "preview:website": "cd packages/website && bun run preview",
"build:reviews": "cd packages/scripts && bun build:reviews", "build:reviews": "cd packages/scripts && bun build:reviews",
"build:ids": "cd packages/scripts && bun build:ids", "build:ids": "cd packages/scripts && bun build:ids",
"prunestrings": "cd packages/scripts && bun prunestrings", "prunestrings": "cd packages/scripts && bun prunestrings",
"dev:cli:unpack": "cd src/BlitzKit.CLI && dotnet run unpack \"C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz Playtest\" --no-overwrite", "dev:cli:unpack": "cd src/BlitzKit.CLI && dotnet run unpack \"C:/Program Files (x86)/Steam/steamapps/common/World of Tanks Blitz Playtest\" --no-overwrite",
"dev:cli:mangle": "cd src/BlitzKit.CLI && dotnet run mangle" "mangle": "cd src/BlitzKit.CLI && dotnet run mangle"
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
+28 -28
View File
@@ -9,31 +9,31 @@ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
export const protobufPackage = "blitzkit"; export const protobufPackage = "blitzkit";
export interface I18nString { export interface I18n {
locales: { [key: string]: string }; locales: { [key: string]: string };
} }
export interface I18nString_LocalesEntry { export interface I18n_LocalesEntry {
key: string; key: string;
value: string; value: string;
} }
function createBaseI18nString(): I18nString { function createBaseI18n(): I18n {
return { locales: {} }; return { locales: {} };
} }
export const I18nString: MessageFns<I18nString> = { export const I18n: MessageFns<I18n> = {
encode(message: I18nString, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { encode(message: I18n, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
Object.entries(message.locales).forEach(([key, value]) => { Object.entries(message.locales).forEach(([key, value]) => {
I18nString_LocalesEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join(); I18n_LocalesEntry.encode({ key: key as any, value }, writer.uint32(10).fork()).join();
}); });
return writer; return writer;
}, },
decode(input: BinaryReader | Uint8Array, length?: number): I18nString { decode(input: BinaryReader | Uint8Array, length?: number): I18n {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseI18nString(); const message = createBaseI18n();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@@ -42,7 +42,7 @@ export const I18nString: MessageFns<I18nString> = {
break; break;
} }
const entry1 = I18nString_LocalesEntry.decode(reader, reader.uint32()); const entry1 = I18n_LocalesEntry.decode(reader, reader.uint32());
if (entry1.value !== undefined) { if (entry1.value !== undefined) {
message.locales[entry1.key] = entry1.value; message.locales[entry1.key] = entry1.value;
} }
@@ -57,7 +57,7 @@ export const I18nString: MessageFns<I18nString> = {
return message; return message;
}, },
fromJSON(object: any): I18nString { fromJSON(object: any): I18n {
return { return {
locales: isObject(object.locales) locales: isObject(object.locales)
? Object.entries(object.locales).reduce<{ [key: string]: string }>((acc, [key, value]) => { ? Object.entries(object.locales).reduce<{ [key: string]: string }>((acc, [key, value]) => {
@@ -68,7 +68,7 @@ export const I18nString: MessageFns<I18nString> = {
}; };
}, },
toJSON(message: I18nString): unknown { toJSON(message: I18n): unknown {
const obj: any = {}; const obj: any = {};
if (message.locales) { if (message.locales) {
const entries = Object.entries(message.locales); const entries = Object.entries(message.locales);
@@ -82,11 +82,11 @@ export const I18nString: MessageFns<I18nString> = {
return obj; return obj;
}, },
create<I extends Exact<DeepPartial<I18nString>, I>>(base?: I): I18nString { create<I extends Exact<DeepPartial<I18n>, I>>(base?: I): I18n {
return I18nString.fromPartial(base ?? ({} as any)); return I18n.fromPartial(base ?? ({} as any));
}, },
fromPartial<I extends Exact<DeepPartial<I18nString>, I>>(object: I): I18nString { fromPartial<I extends Exact<DeepPartial<I18n>, I>>(object: I): I18n {
const message = createBaseI18nString(); const message = createBaseI18n();
message.locales = Object.entries(object.locales ?? {}).reduce<{ [key: string]: string }>((acc, [key, value]) => { message.locales = Object.entries(object.locales ?? {}).reduce<{ [key: string]: string }>((acc, [key, value]) => {
if (value !== undefined) { if (value !== undefined) {
acc[key] = globalThis.String(value); acc[key] = globalThis.String(value);
@@ -97,12 +97,12 @@ export const I18nString: MessageFns<I18nString> = {
}, },
}; };
function createBaseI18nString_LocalesEntry(): I18nString_LocalesEntry { function createBaseI18n_LocalesEntry(): I18n_LocalesEntry {
return { key: "", value: "" }; return { key: "", value: "" };
} }
export const I18nString_LocalesEntry: MessageFns<I18nString_LocalesEntry> = { export const I18n_LocalesEntry: MessageFns<I18n_LocalesEntry> = {
encode(message: I18nString_LocalesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter { encode(message: I18n_LocalesEntry, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.key !== undefined) { if (message.key !== undefined) {
writer.uint32(10).string(message.key); writer.uint32(10).string(message.key);
} }
@@ -112,10 +112,10 @@ export const I18nString_LocalesEntry: MessageFns<I18nString_LocalesEntry> = {
return writer; return writer;
}, },
decode(input: BinaryReader | Uint8Array, length?: number): I18nString_LocalesEntry { decode(input: BinaryReader | Uint8Array, length?: number): I18n_LocalesEntry {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input); const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
let end = length === undefined ? reader.len : reader.pos + length; let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseI18nString_LocalesEntry(); const message = createBaseI18n_LocalesEntry();
while (reader.pos < end) { while (reader.pos < end) {
const tag = reader.uint32(); const tag = reader.uint32();
switch (tag >>> 3) { switch (tag >>> 3) {
@@ -144,14 +144,14 @@ export const I18nString_LocalesEntry: MessageFns<I18nString_LocalesEntry> = {
return message; return message;
}, },
fromJSON(object: any): I18nString_LocalesEntry { fromJSON(object: any): I18n_LocalesEntry {
return { return {
key: globalThis.String(assertSet("I18nString_LocalesEntry.key", object.key)), key: globalThis.String(assertSet("I18n_LocalesEntry.key", object.key)),
value: globalThis.String(assertSet("I18nString_LocalesEntry.value", object.value)), value: globalThis.String(assertSet("I18n_LocalesEntry.value", object.value)),
}; };
}, },
toJSON(message: I18nString_LocalesEntry): unknown { toJSON(message: I18n_LocalesEntry): unknown {
const obj: any = {}; const obj: any = {};
if (message.key !== undefined) { if (message.key !== undefined) {
obj.key = message.key; obj.key = message.key;
@@ -162,11 +162,11 @@ export const I18nString_LocalesEntry: MessageFns<I18nString_LocalesEntry> = {
return obj; return obj;
}, },
create<I extends Exact<DeepPartial<I18nString_LocalesEntry>, I>>(base?: I): I18nString_LocalesEntry { create<I extends Exact<DeepPartial<I18n_LocalesEntry>, I>>(base?: I): I18n_LocalesEntry {
return I18nString_LocalesEntry.fromPartial(base ?? ({} as any)); return I18n_LocalesEntry.fromPartial(base ?? ({} as any));
}, },
fromPartial<I extends Exact<DeepPartial<I18nString_LocalesEntry>, I>>(object: I): I18nString_LocalesEntry { fromPartial<I extends Exact<DeepPartial<I18n_LocalesEntry>, I>>(object: I): I18n_LocalesEntry {
const message = createBaseI18nString_LocalesEntry(); const message = createBaseI18n_LocalesEntry();
message.key = object.key ?? ""; message.key = object.key ?? "";
message.value = object.value ?? ""; message.value = object.value ?? "";
return message; return message;
+4 -3
View File
@@ -72,11 +72,12 @@ message ModuleHealth {
required float max_regen_health = 2; required float max_regen_health = 2;
// the range from 0 to this where the module is "red" and doesn't function // the range from 0 to this where the module is "red" and doesn't function
// all the while healing; after surpassing this, the "yellow" phase is reached // all the while healing; after surpassing this, the "yellow" phase is reached
required float hysteresis_health = 3; // undefined for modules like ammo bays
optional float hysteresis_health = 3;
// the heal rate (per second); this won't apply if the health is at or above // the heal rate (per second); this won't apply if the health is at or above
// max_regen hence always leaving it in the "yellow" phase until repaired // max_regen hence always leaving it in the "yellow" phase until repaired
required float health_regen_per_second = 4; required float health_regen_per_sec = 4;
// damage received (per second) to the modules when caught on fire; this can // damage received (per second) to the modules when caught on fire; this can
// be undefined for some modules like the gun or chassis // be undefined for some modules like the gun or chassis
optional float health_burn_per_second = 5; optional float health_burn_per_sec = 5;
} }
File diff suppressed because it is too large. Load diff
+69 -12
View File
@@ -14,32 +14,33 @@ namespace BlitzKit.CLI.Functions
Tanks tanks = new(); Tanks tanks = new();
BlitzProvider provider = new(); BlitzProvider provider = new();
foreach (var nation in provider.RootDirectory.GetDirectory("Blitz/Content/Tanks").Directories) foreach (
var nationDir in provider.RootDirectory.GetDirectory("Blitz/Content/Tanks").Directories
)
{ {
if (nation.Key == "TankStub") if (nationDir.Key == "TankStub")
continue; continue;
foreach (var tank in nation.Value.Directories) foreach (var tankDir in nationDir.Value.Directories)
{ {
if (tank.Key != "R90_IS_4") if (tankDir.Key != "R90_IS_4")
continue; continue;
tanks.Tanks_.Add(tank.Key); var attributeFileName = $"DA_{tankDir.Key}_Attributes.uasset";
var attributeFileName = $"DA_{tank.Key}_Attributes.uasset"; var hasAttributesFile = tankDir.Value.HasFile(attributeFileName);
var hasAttributesFile = tank.Value.HasFile(attributeFileName);
GameFile? attributesFile = null; GameFile? attributesFile = null;
if (hasAttributesFile) if (hasAttributesFile)
{ {
attributesFile = tank.Value.GetFile(attributeFileName); attributesFile = tankDir.Value.GetFile(attributeFileName);
} }
else else
{ {
PrettyLog.Warn( PrettyLog.Warn(
$"No attributes file found for {nation.Key}/{tank.Key}, it may be misspelled; finding any attributes file..." $"No attributes file found for {nationDir.Key}/{tankDir.Key}, it may be misspelled; finding any attributes file..."
); );
foreach (var file in tank.Value.Files) foreach (var file in tankDir.Value.Files)
{ {
if (file.Key.EndsWith("_Attributes.uasset")) if (file.Key.EndsWith("_Attributes.uasset"))
{ {
@@ -51,7 +52,7 @@ namespace BlitzKit.CLI.Functions
if (attributesFile == null) if (attributesFile == null)
{ {
PrettyLog.Error( PrettyLog.Error(
$"No suffixed attributes file found for {nation.Key}/{tank.Key}; skipping..." $"No suffixed attributes file found for {nationDir.Key}/{tankDir.Key}; skipping..."
); );
continue; continue;
} }
@@ -63,12 +64,68 @@ namespace BlitzKit.CLI.Functions
exports.First((export) => export.ExportType == "TankAttributesDataAsset") exports.First((export) => export.ExportType == "TankAttributesDataAsset")
?? throw new Exception("TankAttributesDataAsset not found"); ?? throw new Exception("TankAttributesDataAsset not found");
var attr = JObject.FromObject(tankAttributesDataAsset); var attr = JObject.FromObject(tankAttributesDataAsset);
var props = attr.GetValue("Properties");
Console.WriteLine(attr); if (props == null || props["MaxHealth"] == null)
{
PrettyLog.Warn(
$"{nationDir.Key}/{tankDir.Key} has not migrated to Reforged; skipping..."
);
continue;
}
Tank tank = new()
{
Id = tankDir.Key,
// TODO: Name
// TODO: Set
// TODO: Class
// TODO: Faction
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)!),
};
tank.CrewHealth.Add("", 1);
tanks.Tanks_.Add(tank.Id);
var tankBytes = tank.ToByteArray();
Console.WriteLine($"Mangled {nationDir.Key}/{tankDir.Key}");
} }
} }
var tanksBytes = tanks.ToByteArray(); var tanksBytes = tanks.ToByteArray();
} }
public static ModuleHealth MangleModuleHealth(JObject obj)
{
ModuleHealth moduleHealth = new()
{
MaxHealth = obj["MaxHealth"]!.Value<float>(),
MaxRegenHealth = obj["MaxRegenHealth"]!.Value<float>(),
HealthRegenPerSec = obj["HealthRegenPerSec"]!.Value<float>(),
};
if (obj.TryGetValue("HysteresisHealth", out var hysteresis))
{
moduleHealth.HysteresisHealth = hysteresis.Value<float>();
}
if (obj.TryGetValue("HealthBurnPerSec", out var burn))
{
moduleHealth.HealthBurnPerSec = burn.Value<float>();
}
return moduleHealth;
}
} }
} }