penetration

This commit is contained in:
tresabhi committed 2026-10-04 17:08:03 -05:00
1 parent bf132a7387
commit 4e1219486d
9 files changed
+90 -19

No files matched your search

@@ -0,0 +1,16 @@
import { ShellType } from "@blitzkit/protos";
import { ShellKind } from "../types";
export const blitzShellKindToBlitzkit: Record<ShellKind, ShellType> = {
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,
};
// @ts-ignore
export const blitzkitToBlitzShellKind: Record<ShellType, ShellKind> = {};
for (const [key, value] of Object.entries(blitzShellKindToBlitzkit)) {
blitzkitToBlitzShellKind[value] = key as ShellKind;
}
+1
View File
@@ -1,3 +1,4 @@
export * from "./blitzShellKindToBlitzkit";
export * from "./canSplash";
export * from "./clans";
export * from "./classes";
@@ -12,7 +12,6 @@ import {
OptionalDevices,
OptionalDeviceSlots,
ProvisionsCommon,
ShellKind,
SquadBattleTypeStylesYaml,
TankmenAvatar,
toUniqueId,
@@ -25,7 +24,6 @@ import {
CrewType,
I18nString,
ModuleType,
ShellType,
TankClass,
} from "@blitzkit/protos";
import type { extname, parse } from "node:path";
@@ -80,12 +78,6 @@ export abstract class ServerBlitzKitAPI0 extends AbstractBlitzKitAPI {
heavyTank: TankClass.TANK_CLASS_HEAVY,
mediumTank: TankClass.TANK_CLASS_MEDIUM,
};
protected blitzShellKindToBlitzkit: Record<ShellKind, ShellType> = {
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,
};
protected blitzTankFilterDefinitionCategoryToBlitzkit: Record<
BlitzTankFilterDefinitionCategory,
ConsumableTankCategoryFilterCategory
@@ -1,6 +1,7 @@
import {
BlitzCrewType,
BlitzModuleType,
blitzShellKindToBlitzkit,
BlitzTankClass,
ChassisDefinitionsList,
EngineDefinitionsList,
@@ -509,8 +510,8 @@ export abstract class ServerBlitzKitAPI1 extends ServerBlitzKitAPI0 {
.map((string) => {
const trimmed = string.trim();
if (trimmed in this.blitzShellKindToBlitzkit) {
return this.blitzShellKindToBlitzkit[trimmed as ShellKind];
if (trimmed in blitzShellKindToBlitzkit) {
return blitzShellKindToBlitzkit[trimmed as ShellKind];
}
throw new SyntaxError(`Invalid shell kind: ${trimmed}`);
@@ -614,7 +615,7 @@ export abstract class ServerBlitzKitAPI1 extends ServerBlitzKitAPI0 {
caliber: shell.caliber,
normalization: shell.normalizationAngle,
ricochet: shell.ricochetAngle,
type: this.blitzShellKindToBlitzkit[shell.kind],
type: blitzShellKindToBlitzkit[shell.kind],
explosion_radius:
shell.kind === "HIGH_EXPLOSIVE"
? (shell.explosionRadius ?? 0)
+26 -4
View File
@@ -1,3 +1,4 @@
import { blitzkitToBlitzShellKind } from "@blitzkit/core";
import {
CharacteristicType,
type Characteristic,
@@ -31,8 +32,8 @@ export const characteristics = {
if (environment.equalize) coefficient *= equalizer.damage;
script("", (script) => {
coefficient *= script.something;
script("TungstenTip", (effect) => {
coefficient *= (effect.minDamageFactor + effect.maxDamageFactor) / 2;
});
return coefficient * shell.armor_damage;
@@ -41,8 +42,29 @@ export const characteristics = {
module_damage: {
type: CharacteristicType.Number,
compute({ shell }) {
return shell.module_damage;
compute({ shell, script }) {
let coefficient = 1;
script("TungstenTip", (effect) => {
coefficient *= (effect.minDamageFactor + effect.maxDamageFactor) / 2;
});
return coefficient * shell.module_damage;
},
},
penetration: {
type: CharacteristicType.Number,
compute({ shell, script }) {
let coefficient = 1;
script("CalibratedShells", (effect) => {
coefficient *=
1 +
effect.piercingFactors![blitzkitToBlitzShellKind[shell.type]] / 100;
});
return coefficient * shell.penetration!.near;
},
},
} satisfies Record<string, Characteristic>;
@@ -76,8 +76,10 @@ export const characteristicsGroups: CharacteristicsGroup[] = [
},
},
{ name: "dpm", decimals: 0, units: "hp", localize: true },
{ name: "damage", units: "hp", localize: true },
{ name: "module_damage", units: "hp", localize: true },
{ name: "damage", decimals: 0, units: "hp", localize: true },
{ name: "damage_range", decimals: 0, units: "hp", localize: true },
{ name: "module_damage", decimals: 0, units: "hp", localize: true },
{ name: "module_damage_range", decimals: 0, units: "hp", localize: true },
{ name: "reload", decimals: 1, units: "s" },
{ name: "reloads", decimals: 1, units: "s" },
@@ -1,5 +1,7 @@
import type { BlitzEffectScript } from "@blitzkit/core/src/types/blitzEffectScript";
import { api } from "../api/dynamic";
import { characteristics } from "../config/characteristics";
import { defaultEqualizer } from "../config/equalizer";
import { Tankopedia, type TankEnvironment } from "../stores/tankopedia";
import type { TankState } from "../tankopedia/tankState";
import type {
@@ -10,6 +12,8 @@ import type {
import type { DuelSide } from "./useEquipment";
const tanks = await api.tanks();
const scripts = await api.scripts();
const equipment = await api.equipment();
export function useCharacteristics(side: DuelSide) {
const state = Tankopedia.use((state) => state[side]);
@@ -31,6 +35,27 @@ export function computeCharacteristics(
const gun = turret.guns.find((gun) => gun.id === state.gun)!;
const shell = gun.shells.find((shell) => shell.id === state.shell)!;
const equipmentPreset = equipment.presets[tank.equipment_preset];
const scriptsMap = new Map<string, BlitzEffectScript>();
for (const id of state.consumables) {
if (!(id in scripts.consumables)) continue;
const script = scripts.consumables[id];
scriptsMap.set(script["#text"], script);
}
for (const index in state.equipment) {
const choice = state.equipment[index];
const id = equipmentPreset.slots[index].options[choice];
if (!(id in scripts.equipment)) continue;
const script = scripts.equipment[id];
scriptsMap.set(script["#text"], script);
}
function characteristic(name: CharacteristicName) {
if (!computed.has(name)) {
throw new Error(`Characteristic ${name} not computed yet`);
@@ -39,10 +64,19 @@ export function computeCharacteristics(
return computed.get(name)!;
}
console.log(scriptsMap);
function script(name: string, callback: (effect: BlitzEffectScript) => void) {
if (!scriptsMap.has(name)) return;
callback(scriptsMap.get(name)!);
}
const context = {
state,
environment,
equalizer: tank.equalizer ?? defaultEqualizer,
tank,
engine,
track,
@@ -51,6 +85,7 @@ export function computeCharacteristics(
shell,
characteristic,
script,
} satisfies CharacteristicContext;
for (const name in characteristics) {
@@ -3,7 +3,6 @@ import { api } from "../../../../../api/dynamic";
import type { ThicknessRange } from "../../../../../components/StaticArmor";
import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics";
import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout";
import { TankopediaSandbox } from "../../../../../components/TankopediaSandbox";
import { defaultEqualizer } from "../../../../../config/equalizer";
import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper";
import { withLocale } from "../../../../../hocs/withLocale";
@@ -57,7 +56,7 @@ export const Page = withErrorWrapper(
</div>
<div className={styles.sandbox}>
{!skeleton && <TankopediaSandbox thicknessRange={thicknessRange} />}
{/* {!skeleton && <TankopediaSandbox thicknessRange={thicknessRange} />} */}
<TankopediaCharacteristics characteristics={characteristics} />
</div>
</div>
@@ -1,3 +1,4 @@
import type { BlitzEffectScript } from "@blitzkit/core/src/types/blitzEffectScript";
import type { Strings } from "@blitzkit/i18n";
import type {
EngineDefinition,
@@ -42,6 +43,8 @@ export interface CharacteristicContext {
characteristic(
name: CharacteristicName,
): ReturnType<Characteristic["compute"]>;
script(name: string, effect: (effect: BlitzEffectScript) => void): void;
}
export enum CharacteristicType {