Compare commits

...
5 Commits
Author SHA1 Message Date
TrèsAbhi 347523f9e7 feat: burst dpm 2025-08-22 13:38:02 -05:00
TrèsAbhi 3205630a0f feat: recoil 2025-08-22 12:44:34 -05:00
TrèsAbhi 8446e3fbbd feat: flashes 2025-08-22 12:40:26 -05:00
TrèsAbhi 6d25a97fc8 fix: dynamic sizing 2025-08-22 12:23:57 -05:00
TrèsAbhi bdbfce0e18 feat: auto reloader compatibility 2025-08-22 12:21:04 -05:00
7 changed files with 124 additions and 138 deletions

No files matched your search

+20 -5
View File
@@ -17,12 +17,27 @@ export function resolveDpm(
if (gun.gun_type!.$case === 'regular') {
dps = alpha / (reloadCoefficient * gun.gun_type!.value.reload);
} else if (gun.gun_type!.$case === 'auto_loader') {
dps =
(alpha * gun.gun_type!.value.shell_count) /
(gun.gun_type!.value.clip_reload * reloadCoefficient +
const damage = alpha * gun.gun_type!.value.shell_count;
let time = gun.gun_type!.value.clip_reload * reloadCoefficient;
if (gun.burst) {
time +=
(gun.gun_type!.value.shell_count / gun.burst.count - 1) *
gun.gun_type!.value.intra_clip *
intraClipCoefficient;
time +=
(gun.gun_type!.value.shell_count / gun.burst.count) *
(gun.burst.count - 1) *
gun.burst.interval;
} else {
time +=
(gun.gun_type!.value.shell_count - 1) *
gun.gun_type!.value.intra_clip *
intraClipCoefficient);
gun.gun_type!.value.intra_clip *
intraClipCoefficient;
}
dps = damage / time;
} else {
const mostOptimalShell = gun.gun_type!.value.shell_reloads.reduce<null | {
index: number;
+2 -2
View File
@@ -1096,8 +1096,8 @@
"dpmEffective": "Effective at 60s",
"shells": "Shells",
"mostOptimalShellIndex": "Most optimal shell",
"shellReloads": "Shell reloads",
"shellReload": "Shell reload",
"shellReloads": "Reloads",
"shellReload": "Reload",
"intraClip": "Intra-clip",
"caliber": "Caliber",
"penetration": "Penetration",
@@ -5,18 +5,9 @@ import {
resolvePenetrationCoefficient,
} from '@blitzkit/core';
import { literals } from '@blitzkit/i18n';
import {
Flex,
Heading,
IconButton,
Slider,
Text,
TextField,
Tooltip,
} from '@radix-ui/themes';
import { Flex, Heading, IconButton, Tooltip } from '@radix-ui/themes';
import { debounce } from 'lodash-es';
import { useEffect, useRef, useState } from 'react';
import { lerp } from 'three/src/math/MathUtils.js';
import { useEquipment } from '../../../../../../hooks/useEquipment';
import { useLocale } from '../../../../../../hooks/useLocale';
import { useTankModelDefinition } from '../../../../../../hooks/useTankModelDefinition';
@@ -187,73 +178,6 @@ export function Firepower({
)}
<ReloadVisualizer stats={stats} />
{typeof shell.penetration !== 'number' && (
<>
<InfoWithDelta
stats={stats}
indent
decimals={0}
name={literals(
strings.website.tools.tankopedia.characteristics.values
.at_distance,
[`${penetrationDistance}`],
)}
noRanking
value={() =>
lerp(
shell.penetration.near,
shell.penetration.far,
(penetrationDistance * penetrationLossOverDistanceCoefficient) /
500,
) * penetrationCoefficient
}
/>
<Flex align="center" gap="2" style={{ paddingLeft: 24 }}>
<Text color="gray">
{
strings.website.tools.tankopedia.characteristics.values
.at_distance_slider_label
}
</Text>
<Slider
variant="classic"
key={penetrationDistance}
min={0}
max={500}
style={{ flex: 1 }}
defaultValue={[penetrationDistance]}
onValueChange={([value]) => {
setPenetrationDistanceDebounced(value);
if (!penetrationDistanceInput.current) return;
penetrationDistanceInput.current.value = value.toString();
}}
/>
<TextField.Root
variant="classic"
style={{ width: 64 }}
ref={penetrationDistanceInput}
defaultValue={penetrationDistance}
onBlur={() => {
setPenetrationDistance(
Math.min(
parseInt(penetrationDistanceInput.current!.value),
500,
),
);
}}
onKeyDown={(event) => {
if (event.key === 'Enter') {
event.currentTarget.blur();
}
}}
>
<TextField.Slot side="right">m</TextField.Slot>
</TextField.Root>
</Flex>
</>
)}
{isExplosive(shell.type) && (
<InfoWithDelta
stats={stats}
@@ -40,7 +40,7 @@ export function Shell({ index, stats }: ShellProps & StatsAcceptorProps) {
<Box
left="50%"
position="absolute"
ml="calc(25% + 2.5rem)"
ml="40%"
width="1.25rem"
height="1.25rem"
style={{
@@ -70,11 +70,9 @@ export function Shell({ index, stats }: ShellProps & StatsAcceptorProps) {
overflow: 'hidden',
maskImage:
'url(/assets/images/tankopedia/visualizers/reload/shell.png)',
// maskComposite: 'exclude',
maskSize: 'contain',
maskRepeat: 'no-repeat',
maskPosition: 'center',
// background: 'red',
}}
>
<Box
@@ -0,0 +1,21 @@
#reload-visualizer-flash {
background: transparent;
transition-duration: 200ms;
}
#reload-visualizer-flash.go {
background: var(--white-a3);
transition: none;
}
.reload {
width: 65%;
height: 65%;
transition-duration: 200ms;
}
.reload.go {
width: 70%;
height: 70%;
transition: none;
}
@@ -1,12 +1,13 @@
import { Box, Code } from '@radix-ui/themes';
import { times } from 'lodash-es';
import { Quicklime, type QuicklimeCallback } from 'quicklime';
import { useEffect, useRef } from 'react';
import { useCallback, useEffect, useRef } from 'react';
import { Var } from '../../../../../../../core/radix/var';
import type { StatsAcceptorProps } from '../TraverseVisualizer';
import { VisualizerCard } from '../VisualizerCard';
import { Shell } from './components/Shell';
import { Target } from './components/Target';
import './index.css';
const PRECISION = 2;
@@ -23,22 +24,23 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
const reloadGlow = useRef<HTMLDivElement>(null);
const totalTime = useRef<HTMLSpanElement>(null);
const progressTime = useRef<HTMLSpanElement>(null);
const flash = useRef<HTMLDivElement>(null);
/**
* 3-shell gun example:
*
* 0-1: clip reload
* ~~~: shell shot
* 1-2: intra-clip
* ~~~: shell shot
* 2-3: intra-clip
* ~~~: shell shot & reset to 0
*
* intra-clip time = intraClip * (n - 1)
*/
const state = useRef(0);
const dpm = useRef(0);
const shotPool = useRef(new Set<number>());
const shoot = useCallback(() => {
flash.current?.classList.add('go');
reloadCircle.current?.classList.add('go');
reloadGlow.current?.classList.add('go');
void flash.current?.offsetWidth;
void reloadCircle.current?.offsetWidth;
void reloadGlow.current?.offsetWidth;
flash.current?.classList.remove('go');
reloadCircle.current?.classList.remove('go');
reloadGlow.current?.classList.remove('go');
}, []);
useEffect(() => {
let cancel = false;
@@ -46,49 +48,71 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
let lastState = state.current;
const shellArray = new Array(stats.shells);
function shoot() {
shotPool.current.add(Date.now() / 1000);
dpm.current += stats.damage;
}
function frame() {
if (!totalTime.current || !progressTime.current) return;
const reloadThreshold = stats.shellReloads
? stats.shellReloads.length
: 1;
const now = Date.now() / 1000;
const dt = now - lastT;
let reload;
let shells;
shotPool.current.forEach((t) => {
if (now - t > 60) shotPool.current.delete(t);
});
if (state.current < reloadThreshold) {
const shellReload =
reloadThreshold === 1
? stats.shellReload!
: stats.shellReloads![Math.floor(state.current)];
dpm.current = shotPool.current.size * stats.damage;
if (state.current < 1) {
state.current = Math.min(1, state.current + dt / stats.shellReload!);
reload = state.current;
state.current = Math.min(
reloadThreshold,
state.current + dt / shellReload,
);
reload = state.current % 1;
shells = shellArray.fill(reload);
totalTime.current.innerHTML = stats.shellReload!.toFixed(PRECISION);
progressTime.current.innerHTML = (
(1 - reload) *
stats.shellReload!
).toFixed(PRECISION);
if (reloadThreshold > 1) {
shells = shells.map((_, index) =>
Math.max(0, state.current - shellArray.length + index + 1),
);
}
if (state.current >= 1) shoot();
} else if (state.current < stats.shells) {
const interval =
stats.burstShells === 1
? stats.intraClip!
: Math.floor(state.current) % stats.burstShells === 0
? stats.intraClip!
: stats.burstInterShell!;
totalTime.current.innerHTML = shellReload.toFixed(PRECISION);
progressTime.current.innerHTML = ((1 - reload) * shellReload).toFixed(
PRECISION,
);
state.current = Math.min(stats.shells, state.current + dt / interval);
shells = times(stats.shells, (index) => index > state.current - 1);
if (state.current >= reloadThreshold) shoot();
} else if (state.current < stats.shells + reloadThreshold - 1) {
let interval;
if (
stats.burstShells === 1 ||
Math.floor(state.current) % stats.burstShells === 0
) {
interval = stats.intraClip!;
} else {
interval = stats.burstInterShell!;
}
state.current = Math.min(
stats.shells + reloadThreshold,
state.current + dt / interval,
);
reload = state.current % 1;
if (reloadThreshold > 1) {
shells = shellArray.map((_, index) =>
Math.max(
0,
Math.floor(index + 1 + reloadThreshold - state.current),
),
);
} else {
shells = times(stats.shells, (index) => index > state.current - 1);
}
totalTime.current.innerHTML = interval.toFixed(PRECISION);
progressTime.current.innerHTML = ((1 - reload) * interval).toFixed(
PRECISION,
@@ -159,8 +183,6 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
position="absolute"
top="50%"
left="50%"
width="12rem"
height="12rem"
className="reload"
ref={reloadGlow}
style={{
@@ -175,8 +197,6 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
position="absolute"
top="50%"
left="50%"
width="12rem"
height="12rem"
className="reload"
ref={reloadCircle}
style={{
@@ -238,7 +258,7 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
transform: 'translateX(50%)',
}}
>
6.9s
0.00
</Code>
<Code
ref={totalTime}
@@ -253,13 +273,23 @@ export function ReloadVisualizer({ stats }: StatsAcceptorProps) {
transform: 'translateX(-50%)',
}}
>
10.0s
0.00
</Code>
{stats.shells > 1 &&
times(stats.shells, (index) => (
<Shell stats={stats} index={index} key={index} />
))}
<Box
id="reload-visualizer-flash"
ref={flash}
position="absolute"
top="0"
left="0"
width="100%"
height="100%"
/>
</VisualizerCard>
);
}
@@ -87,8 +87,6 @@ export function Characteristics({ skeleton }: MaybeSkeletonComponentProps) {
modelTransformEvent.dispatch({ pitch, yaw });
}, [hasImprovedVerticalStabilizer, hasDownImprovedVerticalStabilizer]);
console.log(tank.slug, gun.burst, stats.burstShells);
return (
<Flex
gap="8"