fix: stat parity with game

This commit is contained in:
TrèsAbhi committed 2024-08-12 21:12:07 -05:00
1 parent 8d32c7ce23
commit 7f796c5ec1
3 files changed
+55 -67

No files matched your search

@@ -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}
</InfoWithDelta>
{gun.type === 'autoReloader' && (
<>
<InfoWithDelta decimals={0} indent name="Maximum" unit="hp / min">
{stats.dpmMaximum!}
</InfoWithDelta>
<InfoWithDelta
decimals={0}
indent
name="Effective at 60s"
unit="hp / min"
>
{stats.dpmEffective!}
</InfoWithDelta>
<Info
indent
name={
<Link target="_blank" href="/docs/guide/dpm">
What's the difference?
</Link>
}
/>
</>
<InfoWithDelta
decimals={0}
indent
name="Effective at 60s"
unit="hp / min"
>
{stats.dpmEffective!}
</InfoWithDelta>
)}
{gun.type !== 'regular' && (
<InfoWithDelta name="Shells">{stats.shells}</InfoWithDelta>
@@ -477,15 +463,18 @@ export function Characteristics() {
>
{(member.type === 'commander'
? commanderMastery
: crewMemberMastery) * 100}
: commanderMastery * 1.1) * 100}
</InfoWithDelta>
{member.substitute && (
<Info
<InfoWithDelta
key={`${member.type}-substitute`}
decimals={0}
unit="%"
indent
name={
<>
<Flex align="center" gap="1">
<Flex align="center" gap="1" display="inline-flex">
<AccessibilityIcon />
{member.substitute
.map((sub, index) =>
@@ -495,7 +484,9 @@ export function Characteristics() {
</Flex>
</>
}
/>
>
{commanderMastery * 1.05 * 100}
</InfoWithDelta>
)}
</Fragment>
);
+17 -12
View File
@@ -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;
}
+21 -29
View File
@@ -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,