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