2024-09-30 22:35:37 -05:00
|
|
|
import {
|
|
|
|
|
Armor,
|
2025-07-31 13:44:14 -05:00
|
|
|
AssaultRanges,
|
2025-10-13 23:15:32 -05:00
|
|
|
type BlitzTankClass,
|
2024-09-30 22:35:37 -05:00
|
|
|
CamouflageDefinitions,
|
|
|
|
|
Consumable,
|
|
|
|
|
ConsumableDefinitions,
|
|
|
|
|
ConsumableTankCategoryFilterCategory,
|
|
|
|
|
Crew,
|
|
|
|
|
CrewType,
|
|
|
|
|
EquipmentDefinitions,
|
|
|
|
|
EquipmentSlot,
|
|
|
|
|
GameDefinitions,
|
|
|
|
|
GunDefinition,
|
2025-01-14 14:38:41 -06:00
|
|
|
I18nString,
|
2024-09-30 22:35:37 -05:00
|
|
|
MapDefinitions,
|
|
|
|
|
ModelDefinitions,
|
|
|
|
|
ModuleType,
|
|
|
|
|
Provision,
|
|
|
|
|
ProvisionDefinitions,
|
2024-10-05 23:20:04 -05:00
|
|
|
ResearchCost,
|
2024-09-30 22:35:37 -05:00
|
|
|
ShellType,
|
|
|
|
|
SkillDefinitions,
|
|
|
|
|
TankClass,
|
|
|
|
|
TankDefinitions,
|
|
|
|
|
TankPrice,
|
|
|
|
|
TankPriceType,
|
|
|
|
|
TankType,
|
|
|
|
|
toUniqueId,
|
|
|
|
|
Unlock,
|
|
|
|
|
Vector3,
|
2025-09-27 18:01:20 -05:00
|
|
|
} from "@blitzkit/core";
|
|
|
|
|
import { SUPPORTED_LOCALE_BLITZ_MAP } from "@blitzkit/i18n";
|
|
|
|
|
import locales from "@blitzkit/i18n/locales.json";
|
|
|
|
|
import { deburr } from "lodash-es";
|
|
|
|
|
import { parse as parsePath } from "path";
|
2025-10-13 23:15:32 -05:00
|
|
|
import type { Vector3Tuple } from "three";
|
2025-09-27 18:01:20 -05:00
|
|
|
import { parse as parseYaml } from "yaml";
|
2025-10-23 21:22:21 -05:00
|
|
|
import { AssetUploader } from "../core/github/assetUploader";
|
2025-11-26 13:07:53 -06:00
|
|
|
import { vfs } from "./constants";
|
2025-10-13 23:15:32 -05:00
|
|
|
import type { Avatar } from "./skillIcons";
|
|
|
|
|
import type { TankParameters } from "./tankIcons";
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-05-16 19:14:56 -05:00
|
|
|
const nonAlphanumericRegex = /[^a-z0-9]/g;
|
|
|
|
|
const multipleDashesRegex = /--+/g;
|
|
|
|
|
const trailingDashRegex = /-$/g;
|
|
|
|
|
const leadingDashRegex = /^-/g;
|
|
|
|
|
|
|
|
|
|
const nationSlugDiscriminators = {
|
2025-09-27 18:01:20 -05:00
|
|
|
china: "cn",
|
|
|
|
|
european: "eu",
|
|
|
|
|
france: "fr",
|
|
|
|
|
germany: "de",
|
|
|
|
|
japan: "jp",
|
|
|
|
|
other: "ot",
|
|
|
|
|
uk: "gb",
|
|
|
|
|
usa: "us",
|
|
|
|
|
ussr: "ru",
|
2025-05-16 19:14:56 -05:00
|
|
|
};
|
|
|
|
|
|
2024-10-05 23:20:04 -05:00
|
|
|
function parseResearchCost(raw: number | string) {
|
2025-09-27 18:01:20 -05:00
|
|
|
if (typeof raw === "number") {
|
2024-10-05 23:20:04 -05:00
|
|
|
return {
|
2025-09-27 18:01:20 -05:00
|
|
|
research_cost_type: { $case: "xp", value: raw },
|
2024-10-05 23:20:04 -05:00
|
|
|
} satisfies ResearchCost;
|
|
|
|
|
} else {
|
|
|
|
|
return {
|
2024-10-07 19:37:38 -05:00
|
|
|
research_cost_type: {
|
2025-09-27 18:01:20 -05:00
|
|
|
$case: "seasonal_tokens",
|
2024-10-05 23:20:04 -05:00
|
|
|
value: {
|
|
|
|
|
season: Number(/prx_season_(\d+):\d+/.exec(raw)![1]),
|
|
|
|
|
tokens: Number(/prx_season_\d+:(\d+)/.exec(raw)![1]),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
} satisfies ResearchCost;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
type BlitzTankFilterDefinitionCategory = "clip";
|
2024-09-30 22:35:37 -05:00
|
|
|
const blitzTankFilterDefinitionCategoryToBlitzkit: Record<
|
|
|
|
|
BlitzTankFilterDefinitionCategory,
|
|
|
|
|
ConsumableTankCategoryFilterCategory
|
|
|
|
|
> = {
|
2026-03-31 14:11:45 -05:00
|
|
|
clip: ConsumableTankCategoryFilterCategory.CONSUMABLE_TANK_CATEGORY_FILTER_CATEGORY_CLIP,
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
function vector3TupleToBlitzkit(tuple: Vector3Tuple) {
|
|
|
|
|
return { x: tuple[0], y: tuple[1], z: tuple[2] } satisfies Vector3;
|
|
|
|
|
}
|
|
|
|
|
const blitzTankClassToBlitzkit: Record<BlitzTankClass, TankClass> = {
|
2026-03-31 14:11:45 -05:00
|
|
|
lightTank: TankClass.TANK_CLASS_LIGHT,
|
|
|
|
|
"AT-SPG": TankClass.TANK_CLASS_TANK_DESTROYER,
|
|
|
|
|
heavyTank: TankClass.TANK_CLASS_HEAVY,
|
|
|
|
|
mediumTank: TankClass.TANK_CLASS_MEDIUM,
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
export interface BlitzStrings {
|
|
|
|
|
[key: string]: string;
|
|
|
|
|
}
|
|
|
|
|
type ShellKind =
|
2025-09-27 18:01:20 -05:00
|
|
|
| "ARMOR_PIERCING"
|
|
|
|
|
| "ARMOR_PIERCING_CR"
|
|
|
|
|
| "HIGH_EXPLOSIVE"
|
|
|
|
|
| "HOLLOW_CHARGE";
|
2024-09-30 22:35:37 -05:00
|
|
|
type ShellDefinitionsList = Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
id: number;
|
|
|
|
|
userString: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
kind: ShellKind;
|
|
|
|
|
caliber: number;
|
|
|
|
|
damage: { armor: number; devices: number };
|
2024-10-05 23:20:04 -05:00
|
|
|
normalizationAngle?: number;
|
|
|
|
|
ricochetAngle?: number;
|
2024-09-30 22:35:37 -05:00
|
|
|
explosionRadius?: number;
|
|
|
|
|
}
|
|
|
|
|
> & {
|
|
|
|
|
icons: Record<string, string>;
|
|
|
|
|
};
|
|
|
|
|
interface EngineDefinitionsList {
|
|
|
|
|
nextAvailableId: number;
|
|
|
|
|
ids: Record<string, number>;
|
|
|
|
|
shared: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
userString: string;
|
|
|
|
|
level: number;
|
|
|
|
|
fireStartingChance: number;
|
|
|
|
|
weight: number;
|
|
|
|
|
power: number;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
export interface ChassisDefinitionsList {
|
|
|
|
|
nextAvailableId: number;
|
|
|
|
|
ids: Record<string, number>;
|
|
|
|
|
}
|
|
|
|
|
type VehicleDefinitionArmor = Record<
|
|
|
|
|
string,
|
2025-09-27 18:01:20 -05:00
|
|
|
number | { vehicleDamageFactor: 0; "#text": number }
|
2024-09-30 22:35:37 -05:00
|
|
|
>;
|
|
|
|
|
interface UnlocksInner {
|
|
|
|
|
cost: number | string;
|
2025-09-27 18:01:20 -05:00
|
|
|
"#text": number;
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
|
|
|
|
type BlitzModuleType = {
|
2025-09-27 18:01:20 -05:00
|
|
|
[key in "vehicle" | "engine" | "chassis" | "turret" | "gun"]:
|
2024-09-30 22:35:37 -05:00
|
|
|
| UnlocksInner
|
|
|
|
|
| UnlocksInner[];
|
|
|
|
|
};
|
|
|
|
|
type UnlocksListing = BlitzModuleType | undefined;
|
2025-09-27 18:01:20 -05:00
|
|
|
type BlitzCrewType = "commander" | "radioman" | "gunner" | "driver" | "loader";
|
2024-09-30 22:35:37 -05:00
|
|
|
const blitzCrewTypeToBlitzkit: Record<BlitzCrewType, CrewType> = {
|
2026-03-31 14:11:45 -05:00
|
|
|
commander: CrewType.CREW_TYPE_COMMANDER,
|
|
|
|
|
driver: CrewType.CREW_TYPE_DRIVER,
|
|
|
|
|
gunner: CrewType.CREW_TYPE_GUNNER,
|
|
|
|
|
loader: CrewType.CREW_TYPE_LOADER,
|
|
|
|
|
radioman: CrewType.CREW_TYPE_RADIOMAN,
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
const blitzkitCrewTypeToBlitz: Record<CrewType, BlitzCrewType> = {
|
2026-03-31 14:11:45 -05:00
|
|
|
[CrewType.CREW_TYPE_COMMANDER]: "commander",
|
|
|
|
|
[CrewType.CREW_TYPE_DRIVER]: "driver",
|
|
|
|
|
[CrewType.CREW_TYPE_GUNNER]: "gunner",
|
|
|
|
|
[CrewType.CREW_TYPE_LOADER]: "loader",
|
|
|
|
|
[CrewType.CREW_TYPE_RADIOMAN]: "radioman",
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
interface VehicleDefinitions {
|
|
|
|
|
invisibility: {
|
|
|
|
|
moving: number;
|
|
|
|
|
still: number;
|
|
|
|
|
firePenalty: number;
|
|
|
|
|
};
|
|
|
|
|
crew: Record<BlitzCrewType, string | string[]>;
|
|
|
|
|
speedLimits: {
|
|
|
|
|
forward: number;
|
|
|
|
|
backward: number;
|
|
|
|
|
};
|
|
|
|
|
consumableSlots: number;
|
|
|
|
|
provisionSlots: number;
|
|
|
|
|
optDevicePreset: string | string[];
|
|
|
|
|
hull: {
|
|
|
|
|
armor: VehicleDefinitionArmor;
|
|
|
|
|
turretPositions: { turret: string };
|
|
|
|
|
turretInitialRotation?: { yaw: 0; pitch: 6.5; roll: 0 };
|
|
|
|
|
maxHealth: number;
|
|
|
|
|
weight: number;
|
|
|
|
|
};
|
|
|
|
|
chassis: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
unlocks: UnlocksListing;
|
|
|
|
|
weight: number;
|
|
|
|
|
terrainResistance: string;
|
|
|
|
|
rotationSpeed: number;
|
|
|
|
|
userString: string;
|
|
|
|
|
shotDispersionFactors: {
|
|
|
|
|
vehicleMovement: number;
|
|
|
|
|
vehicleRotation: number;
|
|
|
|
|
};
|
|
|
|
|
level: number;
|
|
|
|
|
hullPosition: string;
|
|
|
|
|
armor: {
|
|
|
|
|
leftTrack:
|
|
|
|
|
| number
|
|
|
|
|
| {
|
|
|
|
|
chanceToHitByProjectile: number;
|
|
|
|
|
chanceToHitByExplosion: number;
|
2025-09-27 18:01:20 -05:00
|
|
|
"#text": number;
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
rightTrack:
|
|
|
|
|
| number
|
|
|
|
|
| {
|
|
|
|
|
chanceToHitByProjectile: number;
|
|
|
|
|
chanceToHitByExplosion: number;
|
2025-09-27 18:01:20 -05:00
|
|
|
"#text": number;
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
engines: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
unlocks: UnlocksListing;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
turrets0: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
unlocks: UnlocksListing;
|
|
|
|
|
rotationSpeed: number;
|
|
|
|
|
weight: number;
|
|
|
|
|
circularVisionRadius: number;
|
|
|
|
|
maxHealth: number;
|
|
|
|
|
armor: VehicleDefinitionArmor;
|
2025-01-14 14:38:41 -06:00
|
|
|
userString: string;
|
2024-09-30 22:35:37 -05:00
|
|
|
level: number;
|
|
|
|
|
yawLimits: string | string[];
|
|
|
|
|
gunPosition: string | string[];
|
|
|
|
|
models: { undamaged: string };
|
|
|
|
|
hitTester: {
|
|
|
|
|
collisionModel: string;
|
|
|
|
|
};
|
|
|
|
|
guns: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
unlocks: UnlocksListing;
|
|
|
|
|
armor: VehicleDefinitionArmor & {
|
|
|
|
|
gun?:
|
|
|
|
|
| number
|
|
|
|
|
| {
|
|
|
|
|
chanceToHitByProjectile: number;
|
|
|
|
|
chanceToHitByExplosion: number;
|
2025-09-27 18:01:20 -05:00
|
|
|
"#text": number;
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
invisibilityFactorAtShot: number | number[];
|
|
|
|
|
reloadTime: number;
|
|
|
|
|
aimingTime?: number;
|
|
|
|
|
shotDispersionRadius: number;
|
|
|
|
|
shotDispersionFactors?: {
|
|
|
|
|
turretRotation: number;
|
|
|
|
|
afterShot: number;
|
|
|
|
|
whileGunDamaged: number;
|
|
|
|
|
};
|
|
|
|
|
maxAmmo: number;
|
|
|
|
|
extraPitchLimits?: {
|
|
|
|
|
front?: string;
|
|
|
|
|
back?: string;
|
|
|
|
|
transition?: number | number[];
|
|
|
|
|
};
|
|
|
|
|
pitchLimits?: string | string[];
|
|
|
|
|
pumpGunMode?: boolean;
|
|
|
|
|
pumpGunReloadTimes?: string;
|
|
|
|
|
clip?: { count: number; rate: number };
|
2025-08-18 12:06:14 -05:00
|
|
|
burst?: { count: number; rate: number };
|
2024-09-30 22:35:37 -05:00
|
|
|
models: { undamaged: string };
|
2025-07-31 13:40:30 -05:00
|
|
|
extras?: {
|
|
|
|
|
trayShell?: {
|
|
|
|
|
kinds: string;
|
|
|
|
|
sectors: Record<
|
|
|
|
|
string,
|
|
|
|
|
{ id: number; distance: number; factor: number }[]
|
|
|
|
|
>;
|
|
|
|
|
};
|
|
|
|
|
};
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
extras?: {
|
|
|
|
|
armorsStatesController?: {
|
|
|
|
|
state: [
|
|
|
|
|
{
|
|
|
|
|
id: 0;
|
|
|
|
|
armors: string;
|
2025-09-27 18:01:20 -05:00
|
|
|
type: "default";
|
2024-09-30 22:35:37 -05:00
|
|
|
enabled: true;
|
2025-09-27 18:01:20 -05:00
|
|
|
factorsModifiers: "";
|
|
|
|
|
default: "";
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 1;
|
|
|
|
|
armors: string;
|
2025-09-27 18:01:20 -05:00
|
|
|
type: "default";
|
2024-09-30 22:35:37 -05:00
|
|
|
enabled: false;
|
2025-09-27 18:01:20 -05:00
|
|
|
factorsModifiers: "";
|
2026-03-31 14:11:45 -05:00
|
|
|
},
|
2024-09-30 22:35:37 -05:00
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
export interface VehicleDefinitionList {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
id: number;
|
|
|
|
|
userString: string;
|
|
|
|
|
shortUserString?: string;
|
|
|
|
|
description: string;
|
2025-09-27 18:01:20 -05:00
|
|
|
price: number | { gold: ""; "#text": number };
|
|
|
|
|
sellPrice?: { gold: ""; "#text": number };
|
2024-09-30 22:35:37 -05:00
|
|
|
enrichmentPermanentCost: number;
|
|
|
|
|
notInShop?: boolean;
|
|
|
|
|
tags: string;
|
|
|
|
|
level: number;
|
|
|
|
|
combatRole?: Record<string, string>;
|
|
|
|
|
configurationModes: string;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
interface TurretDefinitionsList {
|
|
|
|
|
nextAvailableId: number;
|
|
|
|
|
ids: Record<string, number>;
|
|
|
|
|
}
|
|
|
|
|
interface GunDefinitionsList {
|
|
|
|
|
nextAvailableId: number;
|
|
|
|
|
ids: Record<string, number>;
|
|
|
|
|
shared: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
rotationSpeed: number;
|
|
|
|
|
weight: number;
|
|
|
|
|
shotDispersionFactors: {
|
|
|
|
|
turretRotation: number;
|
|
|
|
|
afterShot: number;
|
|
|
|
|
whileGunDamaged: number;
|
|
|
|
|
};
|
2024-11-09 19:16:06 -06:00
|
|
|
maxAmmo: number;
|
2024-09-30 22:35:37 -05:00
|
|
|
aimingTime: number;
|
|
|
|
|
shotDispersionRadius: number;
|
|
|
|
|
userString: string;
|
|
|
|
|
tags: string;
|
|
|
|
|
level: number;
|
|
|
|
|
pitchLimits: string;
|
|
|
|
|
burst?: { count: number; rate: number };
|
|
|
|
|
clip?: { count: number; rate: number };
|
|
|
|
|
shots: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
speed: number;
|
|
|
|
|
piercingPower: string;
|
2024-11-09 12:55:39 -06:00
|
|
|
maxDistance: number;
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface OptionalDevices {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
id: number;
|
|
|
|
|
userString: string;
|
|
|
|
|
description: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
script: unknown;
|
|
|
|
|
display_params: unknown;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface OptionalDeviceSlots {
|
|
|
|
|
presets: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
level0: OptionalDeviceSlotRow;
|
|
|
|
|
level1: OptionalDeviceSlotRow;
|
|
|
|
|
level2: OptionalDeviceSlotRow;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface OptionalDeviceSlotRow {
|
|
|
|
|
[key: string]: { device0: string; device1: string };
|
|
|
|
|
}
|
|
|
|
|
export interface ConsumablesCommon {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
id: number;
|
|
|
|
|
userString: string;
|
|
|
|
|
description: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
category: string;
|
|
|
|
|
tags: string;
|
|
|
|
|
vehicleFilter?: {
|
|
|
|
|
include: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
|
|
|
|
exclude?: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
|
|
|
|
};
|
|
|
|
|
script: {
|
2025-09-27 18:01:20 -05:00
|
|
|
"#text": string;
|
2024-09-30 22:35:37 -05:00
|
|
|
automatic?: boolean;
|
|
|
|
|
cooldown: number;
|
|
|
|
|
duration?: number;
|
|
|
|
|
shotEffect?: string;
|
|
|
|
|
bonusValues?: { [key: string]: number };
|
|
|
|
|
} & Record<string, string>;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
export interface ProvisionsCommon {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
id: number;
|
|
|
|
|
userString: string;
|
|
|
|
|
description: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
category: string;
|
|
|
|
|
tags: string;
|
|
|
|
|
vehicleFilter?: {
|
|
|
|
|
include: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
|
|
|
|
exclude?: { vehicle: ConsumablesVehicleFilter; nations?: string };
|
|
|
|
|
};
|
|
|
|
|
script: {
|
2025-09-27 18:01:20 -05:00
|
|
|
"#text": string;
|
2024-09-30 22:35:37 -05:00
|
|
|
automatic?: boolean;
|
|
|
|
|
shotEffect?: string;
|
|
|
|
|
bonusValues?: { [key: string]: number };
|
|
|
|
|
} & Record<string, string>;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CamouflagesInclude =
|
|
|
|
|
| {
|
|
|
|
|
nations?: string;
|
|
|
|
|
}
|
|
|
|
|
| {
|
|
|
|
|
vehicle?: { name?: string; minLevel?: number; maxLevel?: number };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
interface CamouflagesXML {
|
|
|
|
|
camouflages: Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
id: number;
|
|
|
|
|
userString: string;
|
|
|
|
|
description: string;
|
|
|
|
|
category: string;
|
|
|
|
|
group: string;
|
|
|
|
|
kind: string;
|
|
|
|
|
notInShop: boolean;
|
|
|
|
|
unlockCostCategory?: string;
|
|
|
|
|
vehicleFilter: {
|
|
|
|
|
include?: CamouflagesInclude | CamouflagesInclude[];
|
|
|
|
|
};
|
|
|
|
|
script: string[] | string;
|
|
|
|
|
icon?: string;
|
|
|
|
|
unlockPremium?: string;
|
|
|
|
|
unlockQuest?: string;
|
|
|
|
|
unlockClanLevel?: number;
|
|
|
|
|
unlockShopBundle?: string;
|
|
|
|
|
unlockTankRank?: number;
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CamouflagesYaml = Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
userString?: string;
|
|
|
|
|
shortUserString?: string;
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
type ConsumablesVehicleFilter =
|
|
|
|
|
| { minLevel: number; maxLevel: number }
|
|
|
|
|
| { name: string }
|
|
|
|
|
| { extendedTags: string };
|
|
|
|
|
|
|
|
|
|
export interface Maps {
|
|
|
|
|
maps: {
|
|
|
|
|
[key: string]: {
|
|
|
|
|
id: number;
|
|
|
|
|
tags?: string;
|
|
|
|
|
localName: string;
|
|
|
|
|
avaliableInTrainingRoom: boolean; // lol wg typo
|
|
|
|
|
spriteFrame: number;
|
|
|
|
|
supremacyPointsThreshold?: number;
|
|
|
|
|
availableModes: number[];
|
|
|
|
|
shadowMapsAvailable?: boolean;
|
|
|
|
|
assaultRespawnPoints: {
|
|
|
|
|
allies: MapAlly[];
|
|
|
|
|
enemies: MapAlly[];
|
|
|
|
|
};
|
|
|
|
|
levels?: number[];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface MapAlly {
|
|
|
|
|
respawnNumber: number;
|
|
|
|
|
points: Array<number[]>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface AvailableNationsYaml {
|
|
|
|
|
available_nations: string[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface SquadBattleTypeStyles {
|
|
|
|
|
Prototypes: {
|
|
|
|
|
components: {
|
|
|
|
|
UIDataLocalBindingsComponent: {
|
|
|
|
|
data: [string, string, string][];
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CombatRolesYaml = Record<
|
|
|
|
|
string,
|
|
|
|
|
{
|
|
|
|
|
id: number;
|
|
|
|
|
default_abilities: string[];
|
|
|
|
|
}
|
|
|
|
|
>;
|
|
|
|
|
|
|
|
|
|
const blitzShellKindToBlitzkit: Record<ShellKind, ShellType> = {
|
2026-03-31 14:11:45 -05:00
|
|
|
ARMOR_PIERCING: ShellType.SHELL_TYPE_AP,
|
|
|
|
|
ARMOR_PIERCING_CR: ShellType.SHELL_TYPE_APCR,
|
|
|
|
|
HIGH_EXPLOSIVE: ShellType.SHELL_TYPE_HE,
|
|
|
|
|
HOLLOW_CHARGE: ShellType.SHELL_TYPE_HEAT,
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
2025-05-16 19:14:56 -05:00
|
|
|
export const botPattern = /^.+((tutorial_bot(\d+)?)|(TU))$/;
|
2024-09-30 22:35:37 -05:00
|
|
|
const blitzModuleTypeToBlitzkit: Record<keyof BlitzModuleType, ModuleType> = {
|
2026-03-31 14:11:45 -05:00
|
|
|
chassis: ModuleType.MODULE_TYPE_TRACKS,
|
|
|
|
|
engine: ModuleType.MODULE_TYPE_ENGINE,
|
|
|
|
|
gun: ModuleType.MODULE_TYPE_GUN,
|
|
|
|
|
turret: ModuleType.MODULE_TYPE_TURRET,
|
|
|
|
|
vehicle: ModuleType.MODULE_TYPE_VEHICLE,
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
2024-09-29 22:24:35 -05:00
|
|
|
|
2024-08-27 14:40:43 -05:00
|
|
|
export async function definitions() {
|
2025-09-27 18:01:20 -05:00
|
|
|
console.log("Building definitions...");
|
2024-09-29 22:24:35 -05:00
|
|
|
|
2025-12-10 17:31:03 -06:00
|
|
|
const uploader = new AssetUploader("definitions");
|
2024-09-30 22:35:37 -05:00
|
|
|
const gameDefinitions: GameDefinitions = {
|
2025-12-10 17:31:03 -06:00
|
|
|
version: (await vfs.text("Data/version.txt")).split(" ")[0],
|
2024-09-30 22:35:37 -05:00
|
|
|
nations: (
|
2025-12-10 17:31:03 -06:00
|
|
|
await vfs.yaml<AvailableNationsYaml>("Data/available_nations.yaml")
|
2024-09-30 22:35:37 -05:00
|
|
|
).available_nations,
|
|
|
|
|
gameModes: {},
|
|
|
|
|
roles: {},
|
|
|
|
|
};
|
|
|
|
|
const tankDefinitions: TankDefinitions = { tanks: {} };
|
|
|
|
|
const camouflageDefinitions: CamouflageDefinitions = { camouflages: {} };
|
|
|
|
|
const modelDefinitions: ModelDefinitions = { models: {} };
|
|
|
|
|
const mapDefinitions: MapDefinitions = { maps: {} };
|
|
|
|
|
const equipmentDefinitions: EquipmentDefinitions = {
|
|
|
|
|
presets: {},
|
|
|
|
|
equipments: {},
|
|
|
|
|
};
|
|
|
|
|
const consumableDefinitions: ConsumableDefinitions = { consumables: {} };
|
|
|
|
|
const provisionDefinitions: ProvisionDefinitions = { provisions: {} };
|
|
|
|
|
const skillDefinitions: SkillDefinitions = {
|
|
|
|
|
classes: {
|
2026-03-31 14:11:45 -05:00
|
|
|
[TankClass.TANK_CLASS_LIGHT]: { skills: [] },
|
|
|
|
|
[TankClass.TANK_CLASS_MEDIUM]: { skills: [] },
|
|
|
|
|
[TankClass.TANK_CLASS_HEAVY]: { skills: [] },
|
|
|
|
|
[TankClass.TANK_CLASS_TANK_DESTROYER]: { skills: [] },
|
2024-09-29 22:42:15 -05:00
|
|
|
},
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
2026-04-01 21:40:15 -05:00
|
|
|
const nations = await vfs
|
2025-12-10 17:31:03 -06:00
|
|
|
.dir("Data/XML/item_defs/vehicles")
|
2026-04-01 21:40:15 -05:00
|
|
|
.then((files) => files.filter((nation) => nation !== "common"));
|
2024-09-30 22:35:37 -05:00
|
|
|
const tankStringIdMap: Record<string, number> = {};
|
2025-11-26 13:07:53 -06:00
|
|
|
const optionalDevices = await vfs.xml<{ root: OptionalDevices }>(
|
2026-03-31 14:11:45 -05:00
|
|
|
"Data/XML/item_defs/vehicles/common/optional_devices.xml",
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
2025-01-14 14:38:41 -06:00
|
|
|
const stringsI18n: Record<string, Record<string, string>> = {};
|
|
|
|
|
|
2025-01-14 19:22:41 -06:00
|
|
|
await Promise.all(
|
2025-09-27 18:01:20 -05:00
|
|
|
locales.supported.map(async ({ locale }) => {
|
2025-01-14 19:22:41 -06:00
|
|
|
const blitzLocale = SUPPORTED_LOCALE_BLITZ_MAP[locale];
|
|
|
|
|
const cache = await fetch(
|
2026-03-31 14:11:45 -05:00
|
|
|
`https://stufficons.wgcdn.co/localizations/${blitzLocale}.yaml`,
|
2025-01-14 19:22:41 -06:00
|
|
|
)
|
|
|
|
|
.then((response) => response.text())
|
|
|
|
|
.then((string) => parseYaml(string) as BlitzStrings);
|
2025-11-26 13:07:53 -06:00
|
|
|
const preInstalled = await vfs.yaml<BlitzStrings>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/Strings/${blitzLocale}.yaml`,
|
2025-01-14 19:22:41 -06:00
|
|
|
);
|
2025-01-14 14:38:41 -06:00
|
|
|
|
2025-01-14 19:22:41 -06:00
|
|
|
stringsI18n[locale] = {
|
|
|
|
|
...cache,
|
|
|
|
|
...preInstalled,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
console.log(`Loaded strings for ${locale}`);
|
2026-03-31 14:11:45 -05:00
|
|
|
}),
|
2025-01-14 19:22:41 -06:00
|
|
|
);
|
2025-01-14 14:38:41 -06:00
|
|
|
|
|
|
|
|
function getString(name: string) {
|
2025-09-27 18:01:20 -05:00
|
|
|
const collection: Record<string, string> = {
|
|
|
|
|
[locales.default]: stringsI18n[locales.default][name],
|
2025-01-14 14:38:41 -06:00
|
|
|
};
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
for (const { locale } of locales.supported) {
|
2025-01-14 14:38:41 -06:00
|
|
|
const localizedString = stringsI18n[locale][name];
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
localizedString === undefined ||
|
2025-09-27 18:01:20 -05:00
|
|
|
localizedString === collection[locales.default]
|
2025-01-14 14:38:41 -06:00
|
|
|
) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
collection[locale] = localizedString;
|
2025-01-14 14:38:41 -06:00
|
|
|
}
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
return { locales: collection } satisfies I18nString;
|
2025-01-14 14:38:41 -06:00
|
|
|
}
|
|
|
|
|
|
2025-11-26 13:07:53 -06:00
|
|
|
const optionalDeviceSlots = await vfs.xml<{
|
2024-09-30 22:35:37 -05:00
|
|
|
root: OptionalDeviceSlots;
|
2025-11-26 13:07:53 -06:00
|
|
|
}>(`Data/XML/item_defs/vehicles/common/optional_device_slots.xml`);
|
2024-09-30 22:35:37 -05:00
|
|
|
const consumables: ConsumablesCommon = {};
|
|
|
|
|
const provisions: ProvisionsCommon = {};
|
2024-09-29 22:24:35 -05:00
|
|
|
|
2024-09-30 22:35:37 -05:00
|
|
|
for (const match of (
|
2025-12-10 17:31:03 -06:00
|
|
|
await vfs.text(`Data/XML/item_defs/vehicles/common/consumables/list.xml`)
|
2024-09-30 22:35:37 -05:00
|
|
|
).matchAll(/<items path="(.+)\.xml"\/>/g)) {
|
2025-09-27 18:01:20 -05:00
|
|
|
if (match[1] === "prototypes") continue;
|
2024-09-29 22:24:35 -05:00
|
|
|
|
2024-09-30 22:35:37 -05:00
|
|
|
Object.assign(
|
|
|
|
|
consumables,
|
|
|
|
|
(
|
2025-11-26 13:07:53 -06:00
|
|
|
await vfs.xml<{ root: ConsumablesCommon }>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/XML/item_defs/vehicles/common/consumables/${match[1]}.xml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
)
|
2026-03-31 14:11:45 -05:00
|
|
|
).root,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const match of (
|
2025-12-10 17:31:03 -06:00
|
|
|
await vfs.text(`Data/XML/item_defs/vehicles/common/provisions/list.xml`)
|
2024-09-30 22:35:37 -05:00
|
|
|
).matchAll(/<items path="(.+)\.xml"\/>/g)) {
|
2025-09-27 18:01:20 -05:00
|
|
|
if (match[1] === "prototypes") continue;
|
2024-09-30 22:35:37 -05:00
|
|
|
|
|
|
|
|
Object.assign(
|
|
|
|
|
provisions,
|
|
|
|
|
(
|
2025-11-26 13:07:53 -06:00
|
|
|
await vfs.xml<{ root: ConsumablesCommon }>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/XML/item_defs/vehicles/common/provisions/${match[1]}.xml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
)
|
2026-03-31 14:11:45 -05:00
|
|
|
).root,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-26 13:07:53 -06:00
|
|
|
const avatar = await vfs.xml<{ root: Avatar }>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/XML/item_defs/tankmen/avatar.xml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
2025-11-26 13:07:53 -06:00
|
|
|
const maps = await vfs.yaml<Maps>(`Data/maps.yaml`);
|
2024-10-05 23:20:04 -05:00
|
|
|
const tankXps = new Map<number, ResearchCost>();
|
2025-11-26 13:07:53 -06:00
|
|
|
const camouflagesXml = await vfs.xml<{ root: CamouflagesXML }>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/XML/item_defs/vehicles/common/camouflages.xml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
2025-11-26 13:07:53 -06:00
|
|
|
const camouflagesYaml = await vfs.yaml<CamouflagesYaml>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/camouflages.yaml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
const camouflagesXmlEntries = Object.entries(camouflagesXml.root.camouflages);
|
2025-11-26 13:07:53 -06:00
|
|
|
const squadBattleTypeStyles = await vfs.yaml<SquadBattleTypeStyles>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/UI/Screens3/Lobby/Hangar/Squad/SquadBattleType.yaml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
2025-11-26 13:07:53 -06:00
|
|
|
const gameTypeSelectorStyles = await vfs.yaml<SquadBattleTypeStyles>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/UI/Screens/Lobby/Hangar/GameTypeSelector.yaml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
const gameModeNativeNames: Record<string, number> = {};
|
2025-11-26 13:07:53 -06:00
|
|
|
const combatRoles = await vfs.yaml<CombatRolesYaml>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/XML/item_defs/vehicles/common/combat_roles.yaml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
const consumableNativeNames: Record<string, number> = {};
|
|
|
|
|
const provisionNativeNames: Record<string, number> = {};
|
|
|
|
|
|
|
|
|
|
for (const match of squadBattleTypeStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
|
2026-03-31 14:11:45 -05:00
|
|
|
/"(\d+)" -> "(battleType\/([a-zA-Z]+))"/g,
|
2024-09-30 22:35:37 -05:00
|
|
|
)) {
|
|
|
|
|
const id = Number(match[1]);
|
2025-01-14 14:38:41 -06:00
|
|
|
const name = getString(match[2]);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
|
|
|
|
gameModeNativeNames[match[3]] = id;
|
|
|
|
|
gameDefinitions.gameModes[id] = {
|
|
|
|
|
name,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const match of gameTypeSelectorStyles.Prototypes[0].components.UIDataLocalBindingsComponent.data[1][2].matchAll(
|
2026-03-31 14:11:45 -05:00
|
|
|
/eGameMode\.([a-zA-Z]+) -> "~res:\/Gfx\/UI\/Hangar\/GameTypes\/battle-type_([^"]+)"/g,
|
2024-09-30 22:35:37 -05:00
|
|
|
)) {
|
|
|
|
|
Object.entries(gameModeNativeNames).forEach(([key, value]) => {
|
|
|
|
|
if (key.toLowerCase() === match[2].toLowerCase()) {
|
|
|
|
|
gameModeNativeNames[match[1]] = value;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
camouflagesXmlEntries.forEach(([camoKey, camo]) => {
|
|
|
|
|
const yamlEntry = camouflagesYaml[camoKey];
|
|
|
|
|
const fullName = yamlEntry.userString
|
2025-01-14 14:38:41 -06:00
|
|
|
? getString(yamlEntry.userString)
|
2024-09-30 22:35:37 -05:00
|
|
|
: undefined;
|
|
|
|
|
const shortName = yamlEntry.shortUserString
|
2025-01-14 14:38:41 -06:00
|
|
|
? getString(yamlEntry.shortUserString)
|
2024-09-30 22:35:37 -05:00
|
|
|
: undefined;
|
|
|
|
|
const resolvedTankName = shortName ?? fullName;
|
|
|
|
|
const resolvedTankNameFull =
|
|
|
|
|
resolvedTankName === fullName ? undefined : fullName;
|
|
|
|
|
|
|
|
|
|
camouflageDefinitions.camouflages[camo.id] = {
|
|
|
|
|
id: camo.id,
|
2025-01-14 14:38:41 -06:00
|
|
|
name: getString(camo.userString),
|
2024-10-07 19:37:38 -05:00
|
|
|
tank_name: resolvedTankName,
|
|
|
|
|
tank_name_full: resolvedTankNameFull,
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2025-05-16 19:14:56 -05:00
|
|
|
const slugRequesters = new Map<string, { id: number; key: string }[]>();
|
|
|
|
|
const idToNation: Record<number, string> = {};
|
|
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
for (const nation of nations) {
|
2025-11-26 13:07:53 -06:00
|
|
|
const tankList = await vfs.xml<{ root: VehicleDefinitionList }>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
2025-05-16 19:14:56 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
for (const tankKey in tankList.root) {
|
|
|
|
|
if (botPattern.test(tankKey)) continue;
|
2025-05-16 19:14:56 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
const tank = tankList.root[tankKey];
|
|
|
|
|
const tankId = toUniqueId(nation, tank.id);
|
2025-05-16 19:14:56 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
const name = (
|
|
|
|
|
(tank.shortUserString ? getString(tank.shortUserString) : undefined) ??
|
|
|
|
|
getString(tank.userString)
|
|
|
|
|
).locales.en;
|
2025-05-16 19:14:56 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
let slug = deburr(name).toLowerCase();
|
2025-09-27 18:01:20 -05:00
|
|
|
slug = slug.replaceAll(nonAlphanumericRegex, "-");
|
|
|
|
|
slug = slug.replaceAll(multipleDashesRegex, "-");
|
|
|
|
|
slug = slug.replaceAll(trailingDashRegex, "");
|
|
|
|
|
slug = slug.replaceAll(leadingDashRegex, "");
|
2025-05-16 19:14:56 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
idToNation[tankId] = nation;
|
|
|
|
|
|
|
|
|
|
if (slugRequesters.has(slug)) {
|
|
|
|
|
slugRequesters.get(slug)!.push({ id: tankId, key: tankKey });
|
|
|
|
|
} else {
|
|
|
|
|
slugRequesters.set(slug, [{ id: tankId, key: tankKey }]);
|
2025-05-16 19:14:56 -05:00
|
|
|
}
|
2025-07-31 13:40:30 -05:00
|
|
|
}
|
|
|
|
|
}
|
2025-05-16 19:14:56 -05:00
|
|
|
|
|
|
|
|
const slugs = new Map<number, string>();
|
|
|
|
|
|
|
|
|
|
slugRequesters.forEach((requesters, slug) => {
|
|
|
|
|
if (requesters.length === 1) {
|
|
|
|
|
slugs.set(requesters[0].id, slug);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.warn(
|
2025-10-23 21:22:21 -05:00
|
|
|
`Multiple tanks share slug ${slug}: ${requesters
|
|
|
|
|
.map(({ key }) => key)
|
2026-03-31 14:11:45 -05:00
|
|
|
.join(", ")}`,
|
2025-05-16 19:14:56 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (requesters.length !== 2) {
|
2025-09-27 18:01:20 -05:00
|
|
|
throw new Error("Unresolvable number of duplicates :(");
|
2025-05-16 19:14:56 -05:00
|
|
|
}
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
const nonCanonical = requesters.find(({ key }) => key.endsWith("TUR"));
|
2025-05-16 19:14:56 -05:00
|
|
|
|
|
|
|
|
if (nonCanonical === undefined) {
|
2025-09-27 18:01:20 -05:00
|
|
|
console.log("Using nations to discriminate");
|
2025-05-16 19:14:56 -05:00
|
|
|
// both are non-tutorial tanks, will have to discriminate using nation
|
|
|
|
|
|
|
|
|
|
requesters.forEach(({ id, key }) => {
|
|
|
|
|
const nation = idToNation[id];
|
|
|
|
|
const discriminator =
|
|
|
|
|
nationSlugDiscriminators[
|
|
|
|
|
nation as keyof typeof nationSlugDiscriminators
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
console.log(`Solution: ${key} -> ${slug}-${discriminator}`);
|
|
|
|
|
slugs.set(id, `${slug}-${discriminator}`);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2025-09-27 18:01:20 -05:00
|
|
|
console.log("Using tutorial bot suffix to discriminate");
|
2025-05-16 19:14:56 -05:00
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
const canonical = requesters.find(({ key }) => !key.endsWith("TUR"));
|
2025-05-16 19:14:56 -05:00
|
|
|
|
|
|
|
|
if (canonical === undefined) {
|
|
|
|
|
throw new Error(
|
2026-03-31 14:11:45 -05:00
|
|
|
"Two tutorial bots share the same slug? The world is truly broken.",
|
2025-05-16 19:14:56 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(`Solution: ${canonical.key} -> ${slug}`);
|
|
|
|
|
slugs.set(canonical.id, slug);
|
|
|
|
|
console.log(`Solution: ${nonCanonical.key} -> ${slug}-tur`);
|
|
|
|
|
slugs.set(nonCanonical.id, `${slug}-tur`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
for (const nation of nations) {
|
2025-11-26 13:07:53 -06:00
|
|
|
const tankList = await vfs.xml<{ root: VehicleDefinitionList }>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/XML/item_defs/vehicles/${nation}/list.xml`,
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
2025-11-26 13:07:53 -06:00
|
|
|
const turretList = await vfs.xml<{
|
2025-07-31 13:40:30 -05:00
|
|
|
root: TurretDefinitionsList;
|
2025-11-26 13:07:53 -06:00
|
|
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/turrets.xml`);
|
|
|
|
|
const gunList = await vfs.xml<{
|
2025-07-31 13:40:30 -05:00
|
|
|
root: GunDefinitionsList;
|
2025-11-26 13:07:53 -06:00
|
|
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/guns.xml`);
|
|
|
|
|
const shellList = await vfs.xml<{
|
2025-07-31 13:40:30 -05:00
|
|
|
root: ShellDefinitionsList;
|
2025-11-26 13:07:53 -06:00
|
|
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/shells.xml`);
|
|
|
|
|
const enginesList = await vfs.xml<{
|
2025-07-31 13:40:30 -05:00
|
|
|
root: EngineDefinitionsList;
|
2025-11-26 13:07:53 -06:00
|
|
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/engines.xml`);
|
|
|
|
|
const chassisList = await vfs.xml<{
|
2025-07-31 13:40:30 -05:00
|
|
|
root: ChassisDefinitionsList;
|
2025-11-26 13:07:53 -06:00
|
|
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/chassis.xml`);
|
2025-07-31 13:40:30 -05:00
|
|
|
|
|
|
|
|
function resolveUnlocks(unlocks?: BlitzModuleType) {
|
|
|
|
|
if (!unlocks) return [];
|
|
|
|
|
|
|
|
|
|
return Object.entries(unlocks)
|
|
|
|
|
.map(([type, list]) =>
|
|
|
|
|
(Array.isArray(list) ? list : [list]).map((item) => {
|
|
|
|
|
const typeTyped = type as keyof BlitzModuleType;
|
|
|
|
|
let rawId: number;
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
if (typeTyped === "chassis") {
|
|
|
|
|
rawId = chassisList.root.ids[item["#text"]];
|
|
|
|
|
} else if (typeTyped === "engine") {
|
|
|
|
|
rawId = enginesList.root.ids[item["#text"]];
|
|
|
|
|
} else if (typeTyped === "gun") {
|
|
|
|
|
rawId = gunList.root.ids[item["#text"]];
|
|
|
|
|
} else if (typeTyped === "turret") {
|
|
|
|
|
rawId = turretList.root.ids[item["#text"]];
|
|
|
|
|
} else if (typeTyped === "vehicle") {
|
|
|
|
|
rawId = tankList.root[item["#text"]].id;
|
2025-07-31 13:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: toUniqueId(nation, rawId!),
|
|
|
|
|
type: blitzModuleTypeToBlitzkit[typeTyped],
|
|
|
|
|
cost: {
|
|
|
|
|
type:
|
2025-09-27 18:01:20 -05:00
|
|
|
typeof item.cost === "number"
|
|
|
|
|
? "xp"
|
|
|
|
|
: item.cost.split(":")[0],
|
2025-07-31 13:40:30 -05:00
|
|
|
value:
|
2025-09-27 18:01:20 -05:00
|
|
|
typeof item.cost === "number"
|
2025-07-31 13:40:30 -05:00
|
|
|
? item.cost
|
2025-09-27 18:01:20 -05:00
|
|
|
: Number(item.cost.split(":")[1]),
|
2025-07-31 13:40:30 -05:00
|
|
|
},
|
|
|
|
|
} satisfies Unlock;
|
2026-03-31 14:11:45 -05:00
|
|
|
}),
|
2025-07-31 13:40:30 -05:00
|
|
|
)
|
|
|
|
|
.flat();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const tankKey in tankList.root) {
|
|
|
|
|
if (botPattern.test(tankKey)) continue;
|
|
|
|
|
|
|
|
|
|
const gunXps = new Map<number, ResearchCost>();
|
|
|
|
|
const turretXps = new Map<number, ResearchCost>();
|
|
|
|
|
const engineXps = new Map<number, ResearchCost>();
|
|
|
|
|
const trackXps = new Map<number, ResearchCost>();
|
|
|
|
|
const tank = tankList.root[tankKey];
|
|
|
|
|
let tankPrice: TankPrice;
|
2025-11-26 13:07:53 -06:00
|
|
|
const tankDefinition = await vfs.xml<{ root: VehicleDefinitions }>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/XML/item_defs/vehicles/${nation}/${tankKey}.xml`,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
2025-11-26 13:07:53 -06:00
|
|
|
const tankParameters = await vfs.yaml<TankParameters>(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Data/3d/Tanks/Parameters/${nation}/${tankKey}.yaml`,
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
|
|
|
|
const turretOrigin = tankDefinition.root.hull.turretPositions.turret
|
2025-09-27 18:01:20 -05:00
|
|
|
.split(" ")
|
2025-07-31 13:40:30 -05:00
|
|
|
.map(Number) as Vector3Tuple;
|
|
|
|
|
const tankId = toUniqueId(nation, tank.id);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
const tankTags = tank.tags.split(" ");
|
2025-07-31 13:40:30 -05:00
|
|
|
const hullArmor: Armor = { spaced: [], thickness: {} };
|
|
|
|
|
const equipment = tankDefinition.root.optDevicePreset;
|
|
|
|
|
tankStringIdMap[`${nation}:${tankKey}`] = tankId;
|
|
|
|
|
const slug = slugs.get(tankId);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
if (slug === undefined) {
|
|
|
|
|
throw new Error(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Could not find slug for ${nation}/${tankKey} (${tankId})`,
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
|
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
if (tank.sellPrice) {
|
|
|
|
|
tankPrice = {
|
2026-03-31 14:11:45 -05:00
|
|
|
type: TankPriceType.TANK_PRICE_TYPE_GOLD,
|
2025-09-27 18:01:20 -05:00
|
|
|
value: tank.sellPrice["#text"] * 2,
|
2025-07-31 13:40:30 -05:00
|
|
|
};
|
2025-09-27 18:01:20 -05:00
|
|
|
} else if (typeof tank.price === "number") {
|
2025-07-31 13:40:30 -05:00
|
|
|
tankPrice = {
|
2026-03-31 14:11:45 -05:00
|
|
|
type: TankPriceType.TANK_PRICE_TYPE_CREDITS,
|
2025-07-31 13:40:30 -05:00
|
|
|
value: tank.price,
|
|
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
tankPrice = {
|
2026-03-31 14:11:45 -05:00
|
|
|
type: TankPriceType.TANK_PRICE_TYPE_CREDITS,
|
2025-09-27 18:01:20 -05:00
|
|
|
value: tank.price["#text"] * 400,
|
2025-07-31 13:40:30 -05:00
|
|
|
};
|
|
|
|
|
}
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
Object.keys(tankDefinition.root.hull.armor)
|
2025-09-27 18:01:20 -05:00
|
|
|
.filter((name) => name.startsWith("armor_"))
|
2025-07-31 13:40:30 -05:00
|
|
|
.forEach((name) => {
|
|
|
|
|
const armorIdString = name.match(/armor_(\d+)/)?.[1];
|
|
|
|
|
|
|
|
|
|
if (armorIdString === undefined) {
|
|
|
|
|
throw new SyntaxError(`Invalid armor id: ${name}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const armorId = parseInt(armorIdString);
|
|
|
|
|
const armorRaw = tankDefinition.root.hull.armor[name];
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
if (typeof armorRaw === "number") {
|
2025-07-31 13:40:30 -05:00
|
|
|
hullArmor.thickness[armorId] = armorRaw;
|
|
|
|
|
} else {
|
|
|
|
|
if (!hullArmor.spaced) hullArmor.spaced = [];
|
2025-09-27 18:01:20 -05:00
|
|
|
hullArmor.thickness[armorId] = armorRaw["#text"];
|
2025-07-31 13:40:30 -05:00
|
|
|
hullArmor.spaced.push(armorId);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
const crew: Crew[] = [];
|
2025-09-27 18:01:20 -05:00
|
|
|
const fixedCamouflage = tankTags.includes("eventCamouflage_user");
|
2025-07-31 13:40:30 -05:00
|
|
|
const totalUnlocks: UnlocksListing[] = [];
|
|
|
|
|
|
|
|
|
|
Object.entries(tankDefinition.root.crew).forEach(([crewKey, value]) => {
|
|
|
|
|
let entry: Crew;
|
|
|
|
|
const index = crew.findIndex(
|
2026-03-31 14:11:45 -05:00
|
|
|
({ type }) => blitzkitCrewTypeToBlitz[type] === crewKey,
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
2025-07-31 13:40:30 -05:00
|
|
|
if (index === -1) {
|
2025-09-27 18:01:20 -05:00
|
|
|
if (crewKey === "#text") return;
|
2025-07-31 13:40:30 -05:00
|
|
|
entry = {
|
|
|
|
|
type: blitzCrewTypeToBlitzkit[crewKey as BlitzCrewType],
|
|
|
|
|
count: 0,
|
|
|
|
|
substitute: [],
|
|
|
|
|
};
|
|
|
|
|
crew.push(entry);
|
|
|
|
|
} else {
|
|
|
|
|
entry = crew[index];
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
if (typeof value === "string") {
|
2025-07-31 13:40:30 -05:00
|
|
|
entry.count++;
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
if (value !== "") {
|
2025-07-31 13:40:30 -05:00
|
|
|
entry.substitute = value.split(/\n| /).map((member) => {
|
|
|
|
|
return blitzCrewTypeToBlitzkit[member.trim() as BlitzCrewType];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (entry.count === undefined) {
|
|
|
|
|
entry.count = value.length;
|
|
|
|
|
} else {
|
|
|
|
|
entry.count += value.length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const camouflages = camouflagesXmlEntries
|
|
|
|
|
.filter(([, camo]) => {
|
|
|
|
|
if (!camo.vehicleFilter.include) return false;
|
2025-09-27 18:01:20 -05:00
|
|
|
if (camo.unlockCostCategory !== "legendary-skins-gold") return false;
|
2025-07-31 13:40:30 -05:00
|
|
|
|
|
|
|
|
const includeArray = Array.isArray(camo.vehicleFilter.include)
|
|
|
|
|
? camo.vehicleFilter.include
|
|
|
|
|
: [camo.vehicleFilter.include];
|
|
|
|
|
|
|
|
|
|
return includeArray.some((filter) => {
|
2025-09-27 18:01:20 -05:00
|
|
|
if ("vehicle" in filter && filter.vehicle?.name) {
|
2025-07-31 13:40:30 -05:00
|
|
|
return filter.vehicle.name === `${nation}:${tankKey}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.map(([, camo]) => camo.id);
|
|
|
|
|
|
|
|
|
|
tankDefinitions.tanks[tankId] = {
|
|
|
|
|
ancestors: [],
|
|
|
|
|
successors: [],
|
|
|
|
|
id: tankId,
|
2026-03-31 14:11:45 -05:00
|
|
|
dev_name: tankKey,
|
2025-07-31 13:40:30 -05:00
|
|
|
roles: {},
|
|
|
|
|
camouflages: camouflages,
|
|
|
|
|
fixed_camouflage: fixedCamouflage,
|
|
|
|
|
crew,
|
|
|
|
|
weight: tankDefinition.root.hull.weight,
|
|
|
|
|
health: tankDefinition.root.hull.maxHealth,
|
|
|
|
|
speed_forwards: tankDefinition.root.speedLimits.forward,
|
|
|
|
|
speed_backwards: tankDefinition.root.speedLimits.backward,
|
|
|
|
|
equipment_preset:
|
2025-09-27 18:01:20 -05:00
|
|
|
typeof equipment === "string" ? equipment : equipment.at(-1)!,
|
2025-07-31 13:40:30 -05:00
|
|
|
max_consumables: tankDefinition.root.consumableSlots,
|
|
|
|
|
max_provisions: tankDefinition.root.provisionSlots,
|
|
|
|
|
name:
|
|
|
|
|
(tank.shortUserString
|
|
|
|
|
? getString(tank.shortUserString)
|
|
|
|
|
: undefined) ?? getString(tank.userString),
|
|
|
|
|
slug,
|
|
|
|
|
nation,
|
2025-09-27 18:01:20 -05:00
|
|
|
type: tankTags.includes("collectible")
|
2026-03-31 14:11:45 -05:00
|
|
|
? TankType.TANK_TYPE_COLLECTOR
|
2025-09-27 18:01:20 -05:00
|
|
|
: (typeof tank.price === "number" ? false : "gold" in tank.price)
|
2026-03-31 14:11:45 -05:00
|
|
|
? TankType.TANK_TYPE_PREMIUM
|
|
|
|
|
: TankType.TANK_TYPE_RESEARCHABLE,
|
2025-07-31 13:40:30 -05:00
|
|
|
tier: tank.level,
|
|
|
|
|
class: blitzTankClassToBlitzkit[tankTags[0] as BlitzTankClass],
|
2025-09-27 18:01:20 -05:00
|
|
|
testing: tankTags.includes("testTank"),
|
|
|
|
|
deprecated: tankTags.includes("deprecated"),
|
2025-07-31 13:40:30 -05:00
|
|
|
price: tankPrice,
|
|
|
|
|
camouflage_still: tankDefinition.root.invisibility.still,
|
|
|
|
|
camouflage_moving: tankDefinition.root.invisibility.moving,
|
2026-03-31 14:11:45 -05:00
|
|
|
camouflage_on_fire: tankDefinition.root.invisibility.firePenalty,
|
2025-07-31 13:40:30 -05:00
|
|
|
turrets: [],
|
|
|
|
|
engines: [],
|
|
|
|
|
tracks: [],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (tank.combatRole) {
|
|
|
|
|
Object.entries(tank.combatRole).forEach(([gameMode, role]) => {
|
|
|
|
|
const id = Object.entries(gameModeNativeNames).find(
|
2026-03-31 14:11:45 -05:00
|
|
|
([key]) => key.toLowerCase() === gameMode.toLowerCase(),
|
2025-07-31 13:40:30 -05:00
|
|
|
)?.[1];
|
|
|
|
|
|
|
|
|
|
if (id === undefined) {
|
|
|
|
|
throw new Error(
|
2026-03-31 14:11:45 -05:00
|
|
|
`Unknown game mode in tank ${tankKey}: ${gameMode}`,
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tankDefinitions.tanks[tankId].roles[id] = combatRoles[role].id;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
modelDefinitions.models[tankId] = {
|
|
|
|
|
armor: hullArmor,
|
|
|
|
|
turret_origin: vector3TupleToBlitzkit(turretOrigin),
|
|
|
|
|
initial_turret_rotation: tankDefinition.root.hull.turretInitialRotation
|
|
|
|
|
? {
|
|
|
|
|
yaw: tankDefinition.root.hull.turretInitialRotation.yaw,
|
|
|
|
|
pitch: tankDefinition.root.hull.turretInitialRotation.pitch,
|
|
|
|
|
roll: tankDefinition.root.hull.turretInitialRotation.roll,
|
|
|
|
|
}
|
|
|
|
|
: undefined,
|
|
|
|
|
bounding_box: {
|
|
|
|
|
min: vector3TupleToBlitzkit(tankParameters.collision.hull.bbox.min),
|
|
|
|
|
max: vector3TupleToBlitzkit(tankParameters.collision.hull.bbox.max),
|
|
|
|
|
},
|
|
|
|
|
turrets: {},
|
|
|
|
|
tracks: {},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Object.keys(tankDefinition.root.chassis).forEach((key) => {
|
|
|
|
|
const track = tankDefinition.root.chassis[key];
|
|
|
|
|
const trackId = toUniqueId(nation, chassisList.root.ids[key]);
|
|
|
|
|
const terrainResistances = track.terrainResistance
|
2025-09-27 18:01:20 -05:00
|
|
|
.split(" ")
|
2025-07-31 13:40:30 -05:00
|
|
|
.map(Number);
|
|
|
|
|
const trackArmorRaw = track.armor.leftTrack;
|
|
|
|
|
const hullOrigin = track.hullPosition
|
2025-09-27 18:01:20 -05:00
|
|
|
.split(" ")
|
2024-09-30 22:35:37 -05:00
|
|
|
.map(Number) as Vector3Tuple;
|
2025-05-16 22:11:01 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
totalUnlocks.push(track.unlocks);
|
|
|
|
|
tankDefinitions.tanks[tankId].tracks.push({
|
|
|
|
|
id: trackId,
|
|
|
|
|
weight: track.weight,
|
|
|
|
|
name: getString(track.userString),
|
|
|
|
|
traverse_speed: track.rotationSpeed,
|
|
|
|
|
dispersion_move: track.shotDispersionFactors.vehicleMovement,
|
|
|
|
|
dispersion_traverse: track.shotDispersionFactors.vehicleRotation,
|
|
|
|
|
resistance_hard: terrainResistances[0],
|
|
|
|
|
resistance_medium: terrainResistances[1],
|
|
|
|
|
resistance_soft: terrainResistances[2],
|
|
|
|
|
tier: track.level,
|
|
|
|
|
unlocks: resolveUnlocks(track.unlocks),
|
2024-09-30 22:35:37 -05:00
|
|
|
});
|
|
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
modelDefinitions.models[tankId].tracks[trackId] = {
|
|
|
|
|
thickness:
|
2025-09-27 18:01:20 -05:00
|
|
|
typeof trackArmorRaw === "number"
|
2025-07-31 13:40:30 -05:00
|
|
|
? trackArmorRaw
|
2025-09-27 18:01:20 -05:00
|
|
|
: trackArmorRaw["#text"],
|
2025-07-31 13:40:30 -05:00
|
|
|
origin: vector3TupleToBlitzkit(hullOrigin),
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
2025-07-31 13:40:30 -05:00
|
|
|
});
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
Object.keys(tankDefinition.root.engines).forEach((engineKey) => {
|
|
|
|
|
const engine = tankDefinition.root.engines[engineKey];
|
|
|
|
|
const engineListEntry = enginesList.root.shared[engineKey];
|
|
|
|
|
const engineId = toUniqueId(nation, enginesList.root.ids[engineKey]);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
totalUnlocks.push(engine.unlocks);
|
|
|
|
|
tankDefinitions.tanks[tankId].engines.push({
|
|
|
|
|
id: engineId,
|
|
|
|
|
name: getString(engineListEntry.userString),
|
|
|
|
|
fire_chance: engineListEntry.fireStartingChance,
|
|
|
|
|
tier: engineListEntry.level,
|
|
|
|
|
weight: engineListEntry.weight,
|
|
|
|
|
power: engineListEntry.power,
|
|
|
|
|
unlocks: resolveUnlocks(engine.unlocks),
|
|
|
|
|
});
|
|
|
|
|
});
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
Object.keys(tankDefinition.root.turrets0).forEach(
|
|
|
|
|
(turretKey, turretIndex) => {
|
|
|
|
|
const turret = tankDefinition.root.turrets0[turretKey];
|
|
|
|
|
const turretModel = Number(
|
2026-03-31 14:11:45 -05:00
|
|
|
parsePath(turret.models.undamaged).name.split("_")[1],
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
|
|
|
|
const turretId = toUniqueId(nation, turretList.root.ids[turretKey]);
|
|
|
|
|
const turretYaw = (
|
2025-09-27 18:01:20 -05:00
|
|
|
typeof turret.yawLimits === "string"
|
2025-07-31 13:40:30 -05:00
|
|
|
? turret.yawLimits
|
|
|
|
|
: turret.yawLimits.at(-1)!
|
|
|
|
|
)
|
2025-09-27 18:01:20 -05:00
|
|
|
.split(" ")
|
2025-07-31 13:40:30 -05:00
|
|
|
.map(Number) as [number, number];
|
|
|
|
|
const gunOrigin = (
|
2025-09-27 18:01:20 -05:00
|
|
|
typeof turret.gunPosition === "string"
|
2025-07-31 13:40:30 -05:00
|
|
|
? turret.gunPosition
|
|
|
|
|
: turret.gunPosition[0]
|
|
|
|
|
)
|
2025-09-27 18:01:20 -05:00
|
|
|
.split(" ")
|
2024-09-30 22:35:37 -05:00
|
|
|
.map(Number) as Vector3Tuple;
|
2025-07-31 13:40:30 -05:00
|
|
|
const turretArmor: Armor = { thickness: {}, spaced: [] };
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
totalUnlocks.push(turret.unlocks);
|
|
|
|
|
Object.keys(turret.armor)
|
2025-09-27 18:01:20 -05:00
|
|
|
.filter((name) => name.startsWith("armor_"))
|
2025-07-31 13:40:30 -05:00
|
|
|
.forEach((name) => {
|
|
|
|
|
const armorIdString = name.match(/armor_(\d+)/)?.[1];
|
|
|
|
|
|
|
|
|
|
if (armorIdString === undefined) {
|
|
|
|
|
throw new SyntaxError(`Invalid armor id: ${name}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const armorId = parseInt(armorIdString);
|
|
|
|
|
const armorRaw = turret.armor[name];
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
if (typeof armorRaw === "number") {
|
2025-07-31 13:40:30 -05:00
|
|
|
turretArmor.thickness[armorId] = armorRaw;
|
|
|
|
|
} else {
|
|
|
|
|
if (!turretArmor.spaced) turretArmor.spaced = [];
|
2025-09-27 18:01:20 -05:00
|
|
|
turretArmor.thickness[armorId] = armorRaw["#text"];
|
2025-07-31 13:40:30 -05:00
|
|
|
turretArmor.spaced.push(armorId);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
turret.userString;
|
|
|
|
|
|
|
|
|
|
tankDefinitions.tanks[tankId].turrets.push({
|
|
|
|
|
id: turretId,
|
|
|
|
|
traverse_speed: turret.rotationSpeed,
|
|
|
|
|
name: getString(turret.userString),
|
|
|
|
|
tier: turret.level,
|
|
|
|
|
guns: [],
|
|
|
|
|
health: turret.maxHealth,
|
|
|
|
|
view_range: turret.circularVisionRadius,
|
|
|
|
|
weight: turret.weight,
|
|
|
|
|
unlocks: resolveUnlocks(turret.unlocks),
|
2024-09-30 22:35:37 -05:00
|
|
|
});
|
|
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
modelDefinitions.models[tankId].turrets[turretId] = {
|
|
|
|
|
armor: turretArmor,
|
|
|
|
|
gun_origin: vector3TupleToBlitzkit(gunOrigin),
|
|
|
|
|
model_id: turretModel,
|
|
|
|
|
yaw:
|
|
|
|
|
-turretYaw[0] + turretYaw[1] === 360
|
|
|
|
|
? undefined
|
|
|
|
|
: { min: turretYaw[0], max: turretYaw[1] },
|
|
|
|
|
guns: {},
|
|
|
|
|
bounding_box: {
|
|
|
|
|
min: vector3TupleToBlitzkit(
|
|
|
|
|
tankParameters.collision[
|
|
|
|
|
parsePath(turret.hitTester.collisionModel).name.toLowerCase()
|
2026-03-31 14:11:45 -05:00
|
|
|
].bbox.min,
|
2025-07-31 13:40:30 -05:00
|
|
|
),
|
|
|
|
|
max: vector3TupleToBlitzkit(
|
|
|
|
|
tankParameters.collision[
|
|
|
|
|
parsePath(turret.hitTester.collisionModel).name.toLowerCase()
|
2026-03-31 14:11:45 -05:00
|
|
|
].bbox.max,
|
2025-07-31 13:40:30 -05:00
|
|
|
),
|
|
|
|
|
},
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
Object.keys(turret.guns).forEach((gunKey, gunIndex) => {
|
|
|
|
|
const gun = turret.guns[gunKey];
|
|
|
|
|
const gunId = toUniqueId(nation, gunList.root.ids[gunKey]);
|
|
|
|
|
const gunListEntry = gunList.root.shared[gunKey];
|
|
|
|
|
const pitchLimitsRaw = gun.pitchLimits ?? gunListEntry.pitchLimits;
|
|
|
|
|
const gunPitch = (
|
2025-09-27 18:01:20 -05:00
|
|
|
typeof pitchLimitsRaw === "string"
|
2025-07-31 13:40:30 -05:00
|
|
|
? pitchLimitsRaw
|
|
|
|
|
: pitchLimitsRaw.at(-1)!
|
2024-09-30 22:35:37 -05:00
|
|
|
)
|
2025-09-27 18:01:20 -05:00
|
|
|
.split(" ")
|
2024-09-30 22:35:37 -05:00
|
|
|
.map(Number) as [number, number];
|
2025-07-31 13:40:30 -05:00
|
|
|
const gunModel = Number(
|
2026-03-31 14:11:45 -05:00
|
|
|
parsePath(gun.models.undamaged).name.split("_")[1],
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
|
|
|
|
const gunName = getString(gunListEntry.userString);
|
|
|
|
|
const gunType =
|
2025-09-27 18:01:20 -05:00
|
|
|
"clip" in gun
|
2025-07-31 13:40:30 -05:00
|
|
|
? gun.pumpGunMode
|
2025-09-27 18:01:20 -05:00
|
|
|
? "autoReloader"
|
|
|
|
|
: "autoLoader"
|
|
|
|
|
: "regular";
|
2025-07-31 13:40:30 -05:00
|
|
|
// const gunReload = gun.reloadTime;
|
|
|
|
|
// const shellReloads =
|
2025-09-27 18:01:20 -05:00
|
|
|
const gunClipCount = gunType === "regular" ? 1 : gun.clip!.count;
|
2025-07-31 13:40:30 -05:00
|
|
|
const front = gun.extraPitchLimits?.front
|
2025-09-27 18:01:20 -05:00
|
|
|
? gun.extraPitchLimits.front.split(" ").map(Number)
|
2025-07-31 13:40:30 -05:00
|
|
|
: undefined;
|
|
|
|
|
const back = gun.extraPitchLimits?.back
|
2025-09-27 18:01:20 -05:00
|
|
|
? gun.extraPitchLimits.back.split(" ").map(Number)
|
2025-07-31 13:40:30 -05:00
|
|
|
: undefined;
|
|
|
|
|
const transition = gun.extraPitchLimits?.transition
|
2025-09-27 18:01:20 -05:00
|
|
|
? typeof gun.extraPitchLimits.transition === "number"
|
2025-07-31 13:40:30 -05:00
|
|
|
? gun.extraPitchLimits.transition
|
|
|
|
|
: gun.extraPitchLimits.transition.at(-1)!
|
|
|
|
|
: undefined;
|
|
|
|
|
const gunArmor: Armor = { thickness: {}, spaced: [] };
|
|
|
|
|
const shotDispersionFactors =
|
|
|
|
|
gun.shotDispersionFactors ?? gunListEntry.shotDispersionFactors;
|
2025-09-27 18:01:20 -05:00
|
|
|
const maskName = `gun_${gunModel.toString().padStart(2, "0")}`;
|
2025-07-31 13:40:30 -05:00
|
|
|
const maskEnabled =
|
|
|
|
|
tankParameters.maskSlice?.[maskName]?.enabled ?? false;
|
|
|
|
|
let mask: number | undefined;
|
2025-07-31 13:44:14 -05:00
|
|
|
let assault_ranges: AssaultRanges | undefined;
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
if (gun.extras?.trayShell) {
|
2025-07-31 14:07:21 -05:00
|
|
|
const types = gun.extras.trayShell.kinds
|
2025-09-27 18:01:20 -05:00
|
|
|
.split(" ")
|
2025-07-31 13:40:30 -05:00
|
|
|
.map((string) => {
|
|
|
|
|
const trimmed = string.trim();
|
|
|
|
|
|
|
|
|
|
if (trimmed in blitzShellKindToBlitzkit) {
|
|
|
|
|
return blitzShellKindToBlitzkit[trimmed as ShellKind];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new SyntaxError(`Invalid shell kind: ${trimmed}`);
|
|
|
|
|
});
|
|
|
|
|
const sectorNames = Object.keys(gun.extras.trayShell.sectors);
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
if (sectorNames.length !== 1 || sectorNames[0] !== "sector") {
|
|
|
|
|
throw new SyntaxError("Invalid tray shell sector");
|
2025-07-31 13:40:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sector = gun.extras.trayShell.sectors.sector;
|
|
|
|
|
|
2025-07-31 13:44:14 -05:00
|
|
|
assault_ranges = {
|
2025-07-31 14:07:21 -05:00
|
|
|
types,
|
2025-07-31 13:40:30 -05:00
|
|
|
ranges: sector.map((value) => ({
|
|
|
|
|
factor: value.factor,
|
|
|
|
|
distance: value.distance,
|
|
|
|
|
})),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (maskEnabled) {
|
|
|
|
|
const maskRaw = tankParameters.maskSlice![maskName]!;
|
|
|
|
|
mask = maskRaw.planePosition[1];
|
|
|
|
|
} else {
|
|
|
|
|
mask = undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
totalUnlocks.push(gun.unlocks);
|
|
|
|
|
Object.keys(gun.armor)
|
2025-09-27 18:01:20 -05:00
|
|
|
.filter((name) => name.startsWith("armor_"))
|
2024-09-30 22:35:37 -05:00
|
|
|
.forEach((name) => {
|
|
|
|
|
const armorIdString = name.match(/armor_(\d+)/)?.[1];
|
|
|
|
|
if (armorIdString === undefined) {
|
|
|
|
|
throw new SyntaxError(`Invalid armor id: ${name}`);
|
|
|
|
|
}
|
|
|
|
|
const armorId = parseInt(armorIdString);
|
2025-07-31 13:40:30 -05:00
|
|
|
const armorRaw = gun.armor[name];
|
2025-09-27 18:01:20 -05:00
|
|
|
if (typeof armorRaw === "number") {
|
2025-07-31 13:40:30 -05:00
|
|
|
gunArmor.thickness[armorId] = armorRaw;
|
2024-09-30 22:35:37 -05:00
|
|
|
} else {
|
2025-07-31 13:40:30 -05:00
|
|
|
if (!gunArmor.spaced) gunArmor.spaced = [];
|
2025-09-27 18:01:20 -05:00
|
|
|
gunArmor.thickness[armorId] = armorRaw["#text"];
|
2025-07-31 13:40:30 -05:00
|
|
|
gunArmor.spaced.push(armorId);
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-08-18 12:06:14 -05:00
|
|
|
tankDefinitions.tanks[tankId].turrets[turretIndex].guns.push({
|
2025-07-31 13:40:30 -05:00
|
|
|
id: gunId,
|
|
|
|
|
weight: gunListEntry.weight,
|
|
|
|
|
rotation_speed: gunListEntry.rotationSpeed,
|
|
|
|
|
name: gunName,
|
|
|
|
|
tier: gunListEntry.level,
|
|
|
|
|
shells: [],
|
|
|
|
|
camouflage_loss:
|
2025-09-27 18:01:20 -05:00
|
|
|
typeof gun.invisibilityFactorAtShot === "number"
|
2025-07-31 13:40:30 -05:00
|
|
|
? gun.invisibilityFactorAtShot
|
|
|
|
|
: gun.invisibilityFactorAtShot.at(-1)!,
|
|
|
|
|
aim_time: gun.aimingTime ?? gunListEntry.aimingTime,
|
|
|
|
|
dispersion_base:
|
|
|
|
|
gun.shotDispersionRadius ?? gunListEntry.shotDispersionRadius,
|
|
|
|
|
dispersion_damaged: shotDispersionFactors.whileGunDamaged,
|
|
|
|
|
dispersion_shot: shotDispersionFactors.afterShot,
|
|
|
|
|
dispersion_traverse: shotDispersionFactors.turretRotation,
|
|
|
|
|
unlocks: resolveUnlocks(gun.unlocks),
|
|
|
|
|
shell_capacity: gun.maxAmmo ?? gunListEntry.maxAmmo,
|
2025-07-31 13:44:14 -05:00
|
|
|
assault_ranges,
|
2025-08-21 20:22:12 -05:00
|
|
|
burst:
|
|
|
|
|
gun.burst && gun.burst.count > 1
|
|
|
|
|
? {
|
|
|
|
|
count: gun.burst.count,
|
|
|
|
|
interval: 60 / gun.burst.rate,
|
|
|
|
|
}
|
|
|
|
|
: undefined,
|
2025-07-31 13:40:30 -05:00
|
|
|
gun_type:
|
2025-09-27 18:01:20 -05:00
|
|
|
gunType === "regular"
|
2025-07-31 13:40:30 -05:00
|
|
|
? {
|
2025-09-27 18:01:20 -05:00
|
|
|
$case: "regular",
|
2025-07-31 13:40:30 -05:00
|
|
|
value: {
|
2025-08-18 12:06:14 -05:00
|
|
|
reload: gun.reloadTime,
|
2025-07-31 13:40:30 -05:00
|
|
|
},
|
|
|
|
|
}
|
2025-09-27 18:01:20 -05:00
|
|
|
: gunType === "autoReloader"
|
2026-03-31 14:11:45 -05:00
|
|
|
? {
|
|
|
|
|
$case: "auto_reloader",
|
|
|
|
|
value: {
|
|
|
|
|
intra_clip: 60 / gun.clip!.rate,
|
|
|
|
|
shell_count: gunClipCount,
|
|
|
|
|
shell_reloads: gun
|
|
|
|
|
.pumpGunReloadTimes!.split(" ")
|
|
|
|
|
.map(Number),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
: {
|
|
|
|
|
$case: "auto_loader",
|
|
|
|
|
value: {
|
|
|
|
|
intra_clip: 60 / gun.clip!.rate,
|
|
|
|
|
clip_reload: gun.reloadTime,
|
|
|
|
|
shell_count: gunClipCount,
|
|
|
|
|
},
|
2025-07-31 13:40:30 -05:00
|
|
|
},
|
|
|
|
|
} satisfies GunDefinition);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
modelDefinitions.models[tankId].turrets[turretId].guns[gunId] = {
|
|
|
|
|
armor: gunArmor,
|
|
|
|
|
model_id: gunModel,
|
|
|
|
|
mask,
|
|
|
|
|
thickness:
|
|
|
|
|
gun.armor.gun === undefined
|
|
|
|
|
? 0
|
2025-09-27 18:01:20 -05:00
|
|
|
: typeof gun.armor.gun === "number"
|
2026-03-31 14:11:45 -05:00
|
|
|
? gun.armor.gun
|
|
|
|
|
: gun.armor.gun["#text"],
|
2025-07-31 13:40:30 -05:00
|
|
|
pitch: {
|
|
|
|
|
min: gunPitch[0],
|
|
|
|
|
max: gunPitch[1],
|
|
|
|
|
|
|
|
|
|
front: front
|
|
|
|
|
? {
|
|
|
|
|
min: front[0],
|
|
|
|
|
max: front[1],
|
|
|
|
|
range: front[2],
|
|
|
|
|
}
|
|
|
|
|
: undefined,
|
|
|
|
|
back: back
|
|
|
|
|
? {
|
|
|
|
|
min: back[0],
|
|
|
|
|
max: back[1],
|
|
|
|
|
range: back[2],
|
|
|
|
|
}
|
|
|
|
|
: undefined,
|
|
|
|
|
transition,
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
Object.keys(gunListEntry.shots).forEach((shellKey) => {
|
|
|
|
|
const gunShellEntry = gunListEntry.shots[shellKey];
|
|
|
|
|
const shell = shellList.root[shellKey];
|
|
|
|
|
const shellId = toUniqueId(nation, shell.id);
|
|
|
|
|
const shellName = getString(shell.userString);
|
|
|
|
|
const penetrationRaw = gunShellEntry.piercingPower
|
2025-09-27 18:01:20 -05:00
|
|
|
.split(" ")
|
|
|
|
|
.filter((penetrationString) => penetrationString !== "")
|
2025-07-31 13:40:30 -05:00
|
|
|
.map(Number);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
tankDefinitions.tanks[tankId].turrets[turretIndex].guns[
|
|
|
|
|
gunIndex
|
2025-08-18 12:06:14 -05:00
|
|
|
].shells.push({
|
2025-07-31 13:40:30 -05:00
|
|
|
id: shellId,
|
|
|
|
|
name: shellName,
|
|
|
|
|
velocity: gunShellEntry.speed,
|
|
|
|
|
armor_damage: shell.damage.armor,
|
|
|
|
|
module_damage: shell.damage.devices,
|
|
|
|
|
caliber: shell.caliber,
|
|
|
|
|
normalization: shell.normalizationAngle,
|
|
|
|
|
ricochet: shell.ricochetAngle,
|
|
|
|
|
type: blitzShellKindToBlitzkit[shell.kind],
|
|
|
|
|
explosion_radius:
|
2025-09-27 18:01:20 -05:00
|
|
|
shell.kind === "HIGH_EXPLOSIVE"
|
2026-03-31 14:11:45 -05:00
|
|
|
? (shell.explosionRadius ?? 0)
|
2024-09-30 22:35:37 -05:00
|
|
|
: undefined,
|
2025-07-31 13:40:30 -05:00
|
|
|
icon: shell.icon,
|
|
|
|
|
penetration: {
|
|
|
|
|
near: penetrationRaw[0],
|
|
|
|
|
far: penetrationRaw[1],
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2025-07-31 13:40:30 -05:00
|
|
|
range: gunShellEntry.maxDistance,
|
2024-09-30 22:35:37 -05:00
|
|
|
});
|
|
|
|
|
});
|
2025-07-31 13:40:30 -05:00
|
|
|
});
|
2026-03-31 14:11:45 -05:00
|
|
|
},
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
totalUnlocks.forEach((unlocks) => {
|
|
|
|
|
if (unlocks === undefined) return;
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
Object.entries(unlocks).forEach(([key, value]) => {
|
|
|
|
|
(Array.isArray(value) ? value : [value]).forEach((vehicle) => {
|
|
|
|
|
switch (key as keyof BlitzModuleType) {
|
2025-09-27 18:01:20 -05:00
|
|
|
case "vehicle": {
|
|
|
|
|
const tankListEntry = tankList.root[vehicle["#text"]];
|
2025-07-31 13:40:30 -05:00
|
|
|
const currentTank = tankDefinitions.tanks[tankId];
|
|
|
|
|
const successorId = toUniqueId(nation, tankListEntry.id);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
tankXps.set(successorId, parseResearchCost(vehicle.cost));
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
if (currentTank.successors === undefined) {
|
|
|
|
|
currentTank.successors = [];
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
2025-07-31 13:40:30 -05:00
|
|
|
if (!currentTank.successors!.includes(successorId)) {
|
|
|
|
|
currentTank.successors!.push(successorId);
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
2025-07-31 13:40:30 -05:00
|
|
|
break;
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
2025-07-31 13:40:30 -05:00
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
case "gun": {
|
2025-07-31 13:40:30 -05:00
|
|
|
gunXps.set(
|
2025-09-27 18:01:20 -05:00
|
|
|
toUniqueId(nation, gunList.root.ids[vehicle["#text"]]),
|
2026-03-31 14:11:45 -05:00
|
|
|
parseResearchCost(vehicle.cost),
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
case "turret": {
|
2025-07-31 13:40:30 -05:00
|
|
|
turretXps.set(
|
2025-09-27 18:01:20 -05:00
|
|
|
toUniqueId(nation, turretList.root.ids[vehicle["#text"]]),
|
2026-03-31 14:11:45 -05:00
|
|
|
parseResearchCost(vehicle.cost),
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
case "engine": {
|
2025-07-31 13:40:30 -05:00
|
|
|
engineXps.set(
|
2025-09-27 18:01:20 -05:00
|
|
|
toUniqueId(nation, enginesList.root.ids[vehicle["#text"]]),
|
2026-03-31 14:11:45 -05:00
|
|
|
parseResearchCost(vehicle.cost),
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-27 18:01:20 -05:00
|
|
|
case "chassis": {
|
2025-07-31 13:40:30 -05:00
|
|
|
trackXps.set(
|
2025-09-27 18:01:20 -05:00
|
|
|
toUniqueId(nation, chassisList.root.ids[vehicle["#text"]]),
|
2026-03-31 14:11:45 -05:00
|
|
|
parseResearchCost(vehicle.cost),
|
2025-07-31 13:40:30 -05:00
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-30 22:35:37 -05:00
|
|
|
});
|
|
|
|
|
});
|
2025-07-31 13:40:30 -05:00
|
|
|
});
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
Object.values(tankDefinitions.tanks[tankId].turrets).forEach((turret) => {
|
|
|
|
|
turret.research_cost = turretXps.get(turret.id);
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2025-07-31 13:40:30 -05:00
|
|
|
Object.values(turret.guns).forEach((gunRaw) => {
|
2025-08-18 12:06:14 -05:00
|
|
|
gunRaw.research_cost = gunXps.get(gunRaw.id);
|
2024-09-30 22:35:37 -05:00
|
|
|
});
|
2025-07-31 13:40:30 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.values(tankDefinitions.tanks[tankId].engines).forEach((engine) => {
|
|
|
|
|
engine.research_cost = engineXps.get(engine.id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.values(tankDefinitions.tanks[tankId].tracks).forEach((track) => {
|
|
|
|
|
track.research_cost = trackXps.get(track.id);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-09-30 22:35:37 -05:00
|
|
|
|
|
|
|
|
Object.values(tankDefinitions.tanks).forEach((tank) => {
|
2024-10-07 19:37:38 -05:00
|
|
|
tank.research_cost = tankXps.get(tank.id);
|
2024-09-30 22:35:37 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.values(tankDefinitions.tanks).forEach((tank) => {
|
|
|
|
|
tank.successors?.forEach((predecessorId) => {
|
|
|
|
|
if (!tankDefinitions.tanks[predecessorId].ancestors?.includes(tank.id)) {
|
|
|
|
|
tankDefinitions.tanks[predecessorId].ancestors?.push(tank.id);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.entries(optionalDevices.root).forEach(
|
|
|
|
|
([optionalDeviceKey, optionalDeviceEntry]) => {
|
2025-09-27 18:01:20 -05:00
|
|
|
if (optionalDeviceKey === "nextAvailableId") return;
|
2024-09-30 22:35:37 -05:00
|
|
|
|
|
|
|
|
equipmentDefinitions.equipments[optionalDeviceEntry.id] = {
|
2025-01-14 14:38:41 -06:00
|
|
|
name: getString(optionalDeviceEntry.userString),
|
|
|
|
|
description: getString(optionalDeviceEntry.description),
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
2026-03-31 14:11:45 -05:00
|
|
|
},
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Object.entries(optionalDeviceSlots.root.presets).forEach(
|
|
|
|
|
([optionalDeviceSlotKey, optionalDeviceSlotEntry]) => {
|
2025-09-27 18:01:20 -05:00
|
|
|
if (optionalDeviceSlotKey === "emptyPreset") return;
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2024-10-05 23:20:04 -05:00
|
|
|
equipmentDefinitions.presets[optionalDeviceSlotKey] = {
|
|
|
|
|
slots: Object.values(optionalDeviceSlotEntry)
|
|
|
|
|
.map((level) => {
|
|
|
|
|
return Object.values(level).map((options) => {
|
|
|
|
|
return {
|
|
|
|
|
left: optionalDevices.root[options.device0].id,
|
|
|
|
|
right: optionalDevices.root[options.device1].id,
|
|
|
|
|
} satisfies EquipmentSlot;
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.flat(),
|
|
|
|
|
};
|
2026-03-31 14:11:45 -05:00
|
|
|
},
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
Object.entries(consumables).forEach(([key, consumable]) => {
|
|
|
|
|
consumableNativeNames[key] = consumable.id;
|
|
|
|
|
|
|
|
|
|
const entry: Consumable = {
|
|
|
|
|
id: consumable.id,
|
2025-09-27 18:01:20 -05:00
|
|
|
game_mode_exclusive: "gameModeFilter" in consumable,
|
2024-09-30 22:35:37 -05:00
|
|
|
cooldown: consumable.script.cooldown,
|
|
|
|
|
duration: consumable.script.duration,
|
2025-01-14 14:38:41 -06:00
|
|
|
name: getString(consumable.userString),
|
2024-09-30 22:35:37 -05:00
|
|
|
exclude: [],
|
|
|
|
|
include: [],
|
|
|
|
|
};
|
|
|
|
|
consumableDefinitions.consumables[consumable.id] = entry;
|
|
|
|
|
|
|
|
|
|
const includeRaw = consumable.vehicleFilter?.include.vehicle;
|
|
|
|
|
const excludeRaw = consumable.vehicleFilter?.exclude?.vehicle;
|
|
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if (includeRaw) {
|
|
|
|
|
entry.include = [];
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if ("minLevel" in includeRaw) {
|
|
|
|
|
entry.include.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "tiers",
|
|
|
|
|
value: {
|
|
|
|
|
min: includeRaw.minLevel,
|
|
|
|
|
max: includeRaw.maxLevel,
|
2024-10-05 15:24:54 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else if ("name" in includeRaw) {
|
|
|
|
|
entry.include.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "ids",
|
|
|
|
|
value: {
|
|
|
|
|
ids: includeRaw.name.split(/ +/).map((key) => {
|
|
|
|
|
return tankStringIdMap[key];
|
|
|
|
|
}),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else throw new SyntaxError("Unhandled include type");
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if (consumable.vehicleFilter?.include.nations) {
|
|
|
|
|
entry.include.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "nations",
|
|
|
|
|
value: {
|
|
|
|
|
nations: consumable.vehicleFilter.include.nations.split(" "),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
2026-01-02 11:32:27 -06:00
|
|
|
}
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if (excludeRaw) {
|
|
|
|
|
entry.exclude = [];
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if ("name" in excludeRaw) {
|
|
|
|
|
entry.exclude!.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "ids",
|
|
|
|
|
value: {
|
|
|
|
|
ids: excludeRaw.name.split(/ +/).map((key) => {
|
|
|
|
|
return tankStringIdMap[key];
|
|
|
|
|
}),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else if ("extendedTags" in excludeRaw) {
|
|
|
|
|
entry.exclude!.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "categories",
|
|
|
|
|
value: {
|
|
|
|
|
categories: excludeRaw.extendedTags
|
|
|
|
|
.split(" ")
|
|
|
|
|
.map(
|
|
|
|
|
(item) =>
|
|
|
|
|
blitzTankFilterDefinitionCategoryToBlitzkit[
|
|
|
|
|
item as BlitzTankFilterDefinitionCategory
|
2026-03-31 14:11:45 -05:00
|
|
|
],
|
2026-01-02 11:32:27 -06:00
|
|
|
),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else throw new SyntaxError("Unhandled exclude type");
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if (consumable.vehicleFilter?.exclude?.nations) {
|
|
|
|
|
entry.exclude!.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "nations",
|
|
|
|
|
value: {
|
|
|
|
|
nations: consumable.vehicleFilter.exclude.nations.split(" "),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.entries(provisions).forEach(([key, provision]) => {
|
|
|
|
|
provisionNativeNames[key] = provision.id;
|
|
|
|
|
|
|
|
|
|
const entry: Provision = {
|
|
|
|
|
id: provision.id,
|
|
|
|
|
exclude: [],
|
|
|
|
|
include: [],
|
2025-09-27 18:01:20 -05:00
|
|
|
game_mode_exclusive: "gameModeFilter" in provision,
|
2025-01-14 14:38:41 -06:00
|
|
|
name: getString(provision.userString),
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
provisionDefinitions.provisions[provision.id] = entry;
|
|
|
|
|
|
|
|
|
|
const includeRaw = provision.vehicleFilter?.include.vehicle;
|
|
|
|
|
const excludeRaw = provision.vehicleFilter?.exclude?.vehicle;
|
|
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if (includeRaw) {
|
|
|
|
|
entry.include = [];
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if ("minLevel" in includeRaw) {
|
|
|
|
|
entry.include.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "tiers",
|
|
|
|
|
value: {
|
|
|
|
|
min: includeRaw.minLevel,
|
|
|
|
|
max: includeRaw.maxLevel,
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else if ("name" in includeRaw) {
|
|
|
|
|
entry.include.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "ids",
|
|
|
|
|
value: {
|
|
|
|
|
ids: includeRaw.name.split(/ +/).map((key) => {
|
|
|
|
|
return tankStringIdMap[key];
|
|
|
|
|
}),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else throw new SyntaxError("Unhandled include type");
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if (provision.vehicleFilter?.include.nations) {
|
|
|
|
|
entry.include.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "nations",
|
|
|
|
|
value: {
|
|
|
|
|
nations: provision.vehicleFilter.include.nations.split(" "),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
2026-01-02 11:32:27 -06:00
|
|
|
}
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if (excludeRaw) {
|
|
|
|
|
entry.exclude = [];
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if ("name" in excludeRaw) {
|
|
|
|
|
entry.exclude!.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "ids",
|
|
|
|
|
value: {
|
|
|
|
|
ids: excludeRaw.name
|
|
|
|
|
.split(/ +/)
|
|
|
|
|
.map((key) => tankStringIdMap[key]),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else if ("extendedTags" in excludeRaw) {
|
|
|
|
|
entry.exclude!.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "categories",
|
|
|
|
|
value: {
|
|
|
|
|
categories: excludeRaw.extendedTags
|
|
|
|
|
.split(" ")
|
|
|
|
|
.map(
|
|
|
|
|
(item) =>
|
|
|
|
|
blitzTankFilterDefinitionCategoryToBlitzkit[
|
|
|
|
|
item as BlitzTankFilterDefinitionCategory
|
2026-03-31 14:11:45 -05:00
|
|
|
],
|
2026-01-02 11:32:27 -06:00
|
|
|
),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
} else throw new SyntaxError("Unhandled exclude type");
|
2024-09-30 22:35:37 -05:00
|
|
|
|
2026-01-02 11:32:27 -06:00
|
|
|
if (provision.vehicleFilter?.exclude?.nations) {
|
|
|
|
|
entry.exclude!.push({
|
|
|
|
|
filter_type: {
|
|
|
|
|
$case: "nations",
|
|
|
|
|
value: {
|
|
|
|
|
nations: provision.vehicleFilter.exclude.nations.split(" "),
|
2024-09-30 22:35:37 -05:00
|
|
|
},
|
2026-01-02 11:32:27 -06:00
|
|
|
},
|
|
|
|
|
});
|
2024-09-30 22:35:37 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (provision.script.bonusValues?.crewLevelIncrease !== undefined) {
|
|
|
|
|
provisionDefinitions.provisions[provision.id].crew =
|
|
|
|
|
provision.script.bonusValues?.crewLevelIncrease;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.entries(combatRoles).forEach(([, value]) => {
|
|
|
|
|
gameDefinitions.roles[value.id] = { provisions: [], consumables: [] };
|
|
|
|
|
|
|
|
|
|
value.default_abilities.forEach((ability) => {
|
|
|
|
|
if (ability in consumableNativeNames) {
|
|
|
|
|
gameDefinitions.roles[value.id].consumables.push(
|
2026-03-31 14:11:45 -05:00
|
|
|
consumableNativeNames[ability],
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
} else if (ability in provisionNativeNames) {
|
|
|
|
|
gameDefinitions.roles[value.id].provisions.push(
|
2026-03-31 14:11:45 -05:00
|
|
|
provisionNativeNames[ability],
|
2024-09-30 22:35:37 -05:00
|
|
|
);
|
|
|
|
|
} else throw new Error(`Unknown ability ${ability}`);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.entries(avatar.root.skillsByClasses).forEach(([tankClass, skills]) => {
|
|
|
|
|
skillDefinitions.classes[
|
|
|
|
|
blitzTankClassToBlitzkit[tankClass as BlitzTankClass]
|
|
|
|
|
] = {
|
2025-09-27 18:01:20 -05:00
|
|
|
skills: skills.split(" "),
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Object.entries(maps.maps).forEach(([key, map]) => {
|
|
|
|
|
mapDefinitions.maps[map.id] = {
|
|
|
|
|
id: map.id,
|
2025-01-14 14:38:41 -06:00
|
|
|
name: getString(`#maps:${key}:${map.localName}`),
|
2024-09-30 22:35:37 -05:00
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
2025-10-23 21:22:21 -05:00
|
|
|
await uploader.add({
|
|
|
|
|
content: GameDefinitions.encode(gameDefinitions).finish(),
|
|
|
|
|
path: "definitions/game.pb",
|
|
|
|
|
});
|
|
|
|
|
await uploader.add({
|
|
|
|
|
content: TankDefinitions.encode(tankDefinitions).finish(),
|
|
|
|
|
path: "definitions/tanks.pb",
|
|
|
|
|
});
|
|
|
|
|
await uploader.add({
|
|
|
|
|
content: ModelDefinitions.encode(modelDefinitions).finish(),
|
|
|
|
|
path: "definitions/models.pb",
|
|
|
|
|
});
|
|
|
|
|
await uploader.add({
|
|
|
|
|
content: EquipmentDefinitions.encode(equipmentDefinitions).finish(),
|
|
|
|
|
path: "definitions/equipment.pb",
|
|
|
|
|
});
|
|
|
|
|
await uploader.add({
|
|
|
|
|
content: ConsumableDefinitions.encode(consumableDefinitions).finish(),
|
|
|
|
|
path: "definitions/consumables.pb",
|
|
|
|
|
});
|
|
|
|
|
await uploader.add({
|
|
|
|
|
content: ProvisionDefinitions.encode(provisionDefinitions).finish(),
|
|
|
|
|
path: "definitions/provisions.pb",
|
|
|
|
|
});
|
|
|
|
|
await uploader.add({
|
|
|
|
|
content: SkillDefinitions.encode(skillDefinitions).finish(),
|
|
|
|
|
path: "definitions/skills.pb",
|
|
|
|
|
});
|
|
|
|
|
await uploader.add({
|
|
|
|
|
content: MapDefinitions.encode(mapDefinitions).finish(),
|
|
|
|
|
path: "definitions/maps.pb",
|
|
|
|
|
});
|
|
|
|
|
await uploader.add({
|
|
|
|
|
content: CamouflageDefinitions.encode(camouflageDefinitions).finish(),
|
|
|
|
|
path: "definitions/camouflages.pb",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await uploader.flush();
|
2023-12-05 19:14:53 -06:00
|
|
|
}
|