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

+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 {