From 7f796c5ec149ae2df5b5fa0f3ac05af318358ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 12 Aug 2024 21:12:07 -0500 Subject: [PATCH] fix: stat parity with game --- .../[id]/components/Characteristics/index.tsx | 43 +++++++--------- src/core/blitzkit/resolveDpm.ts | 29 ++++++----- src/core/blitzkit/tankCharacteristics.ts | 50 ++++++++----------- 3 files changed, 55 insertions(+), 67 deletions(-) diff --git a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx index 918faa699..77eb8e3f5 100644 --- a/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx +++ b/src/app/tools/tankopedia/[id]/components/Characteristics/index.tsx @@ -12,7 +12,6 @@ import { debounce } from 'lodash'; import { Fragment, use, useEffect, useRef, useState } from 'react'; import { lerp } from 'three/src/math/MathUtils'; import { Ad, AdType } from '../../../../../../components/Ad'; -import { Link } from '../../../../../../components/Link'; import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits'; import { isExplosive } from '../../../../../../core/blitz/isExplosive'; import { resolvePenetrationCoefficient } from '../../../../../../core/blitz/resolvePenetrationCoefficient'; @@ -179,27 +178,14 @@ export function Characteristics() { {stats.dpm} {gun.type === 'autoReloader' && ( - <> - - {stats.dpmMaximum!} - - - {stats.dpmEffective!} - - - What's the difference? - - } - /> - + + {stats.dpmEffective!} + )} {gun.type !== 'regular' && ( {stats.shells} @@ -477,15 +463,18 @@ export function Characteristics() { > {(member.type === 'commander' ? commanderMastery - : crewMemberMastery) * 100} + : commanderMastery * 1.1) * 100} + {member.substitute && ( - - + {member.substitute .map((sub, index) => @@ -495,7 +484,9 @@ export function Characteristics() { } - /> + > + {commanderMastery * 1.05 * 100} + )} ); diff --git a/src/core/blitzkit/resolveDpm.ts b/src/core/blitzkit/resolveDpm.ts index 028602fac..c9956f5c3 100644 --- a/src/core/blitzkit/resolveDpm.ts +++ b/src/core/blitzkit/resolveDpm.ts @@ -8,21 +8,26 @@ export function resolveDpm( intraClipCoefficient = 1, ) { const alpha = shell.damage.armor * damageCoefficient; + let dps: number; if (gun.type === 'regular') { - return (alpha / (reloadCoefficient * gun.reload)) * 60; + dps = alpha / (reloadCoefficient * gun.reload); } else if (gun.type === 'autoLoader') { - return ( - ((alpha * gun.count) / - (gun.reload + (gun.count - 1) * gun.intraClip * intraClipCoefficient)) * - 60 - ); + dps = + (alpha * gun.count) / + (gun.reload * reloadCoefficient + + (gun.count - 1) * gun.intraClip * intraClipCoefficient); } else { - return ( - ((alpha * gun.count) / - (reloadCoefficient * gun.reload.reduce((a, b) => a + b, 0) + - (gun.count - 1) * gun.intraClip * intraClipCoefficient)) * - 60 - ); + if (gun.reload[0] < gun.reload[1] + gun.intraClip) { + // first shell's the best + dps = alpha / (gun.reload[0] * reloadCoefficient); + } else { + dps = + alpha / + (gun.reload.at(-1)! * reloadCoefficient + + gun.intraClip * intraClipCoefficient); + } } + + return dps * 60; } diff --git a/src/core/blitzkit/tankCharacteristics.ts b/src/core/blitzkit/tankCharacteristics.ts index e2c9a14a3..71a14e018 100644 --- a/src/core/blitzkit/tankCharacteristics.ts +++ b/src/core/blitzkit/tankCharacteristics.ts @@ -75,6 +75,8 @@ export function tankCharacteristics( provisionDefinitions: ProvisionDefinitions; }, ) { + console.log(tank.crew); + const presetRows = equipmentDefinitions.presets[tank.equipment]; const turretModelDefinition = tankModelDefinition.turrets[turret.id]; const gunModelDefinition = turretModelDefinition.guns[gun.id]; @@ -138,8 +140,15 @@ export function tankCharacteristics( 0, ) + (hasImprovedVentilation ? 0.08 : 0); const commanderMastery = crewMastery + provisionCrewBonus; - const crewMemberMastery = commanderMastery * 1.1; - + const loaderMastery = + commanderMastery * + (tank.crew.some(({ type }) => type === 'loader') ? 1.1 : 1.05); + const gunnerMastery = + commanderMastery * + (tank.crew.some(({ type }) => type === 'gunner') ? 1.1 : 1.05); + const driverMastery = + commanderMastery * + (tank.crew.some(({ type }) => type === 'driver') ? 1.1 : 1.05); const intraClipCoefficient = coefficient([hasShellReloadBoost, -0.3]); const damageCoefficient = coefficient([hasTungsten, 0.15]) * @@ -150,7 +159,7 @@ export function tankCharacteristics( ); const reloadCoefficient = (coefficient([hasGunRammer, -0.05]) * - coefficient([true, degressiveStat(crewMemberMastery)])) / + coefficient([true, degressiveStat(loaderMastery)])) / coefficient([hasAdrenaline && gun.type === 'regular', 0.17]); const penetrationCoefficient = coefficient([ hasCalibratedShells, @@ -173,10 +182,10 @@ export function tankCharacteristics( coefficient( [hasEnhancedGunLayingDrive, -0.15], [hasReticleCalibration, -0.3], - ) * coefficient([true, degressiveStat(crewMemberMastery)]); + ) * coefficient([true, degressiveStat(gunnerMastery)]); const dispersionStillCoefficient = coefficient([hasRefinedGun, -0.15], [hasReticleCalibration, -0.3]) * - coefficient([true, degressiveStat(crewMemberMastery)]); + coefficient([true, degressiveStat(gunnerMastery)]); const dispersionDamagedCoefficient = coefficient([ hasVerticalStabilizer, -0.12, @@ -212,13 +221,13 @@ export function tankCharacteristics( ); const turretTraverseCoefficient = coefficient([hasStandardFuel, 0.03], [hasImprovedFuel, 0.1]) * - coefficient([true, progressiveStat(crewMemberMastery)]); + coefficient([true, progressiveStat(gunnerMastery)]); const hullTraverseCoefficient = coefficient( [hasImprovedControl, 0.11], [hasImprovedEnginePowerBoost, 0.01], [true, crewSkills.virtuoso / 100], - ) * coefficient([true, progressiveStat(crewMemberMastery)]); + ) * coefficient([true, progressiveStat(driverMastery)]); const resistanceHardCoefficient = coefficient([hasImprovedSuspension, -0.2]); const resistanceMediumCoefficient = coefficient([ hasImprovedSuspension, @@ -305,21 +314,13 @@ export function tankCharacteristics( reloadCoefficient, intraClipCoefficient, ); - const dpmMaximum = + const mostOptimalShellIndex = gun.type === 'autoReloader' - ? ( - gun.count > 2 - ? gun.reload.at(-1)! < gun.reload.at(-2)! - : gun.reload.at(-1)! + gun.intraClip < gun.reload.at(-2)! - ) - ? ((damageCoefficient * shell.damage.armor) / - (gun.reload.at(-1)! * reloadCoefficient + - gun.intraClip * intraClipCoefficient)) * - 60 - : ((damageCoefficient * shell.damage.armor) / - (gun.reload[0] * reloadCoefficient)) * - 60 + ? gun.reload[0] + gun.intraClip < gun.reload[1] + ? 1 + : gun.reload.length : undefined; + const damage = shell.damage.armor * damageCoefficient; const dpmEffective = gun.type === 'autoReloader' ? gun.reload.at(-1)! < gun.reload.at(-2)! @@ -343,13 +344,6 @@ export function tankCharacteristics( damageCoefficient * shell.damage.armor * gun.reload.slice(1).length : undefined; const shells = gun.type === 'regular' ? 1 : gun.count; - console.log(gun.reload); - const mostOptimalShellIndex = - gun.type === 'autoReloader' - ? gun.reload[0] + gun.intraClip < gun.reload[1] - ? 1 - : gun.reload.length - : undefined; const shellReloads = gun.type === 'autoReloader' ? gun.reload.map((reload) => reload * reloadCoefficient) @@ -361,7 +355,6 @@ export function tankCharacteristics( const caliber = shell.caliber; const penetration = resolveNearPenetration(shell.penetration) * penetrationCoefficient; - const damage = shell.damage.armor * damageCoefficient; const clipDamage = gun.type === 'regular' ? undefined : gun.count * damage; const moduleDamage = shell.damage.module * damageCoefficient; const explosionRadius = shell.explosionRadius; @@ -471,7 +464,6 @@ export function tankCharacteristics( shellNormalization, shellRicochet, dpm, - dpmMaximum, dpmEffective, shells, mostOptimalShellIndex,