equipment.Function.personalWeaponMetrics - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / equipment / personalWeaponMetrics

Function: personalWeaponMetrics()

personalWeaponMetrics(weapon, grade, modifiers?, options?): PersonalWeaponMetrics | null

Defined in: src/equipment/weapons.ts:258

Everything the on-foot damage arithmetic gives you for one weapon: damage per trigger pull, per second, and per second once reloads are counted.

A grade record states damage per projectile, so a shot is that damage times the projectiles a round carries times the rounds one trigger pull fires. The sustained figures then average in the reload: a magazine's worth of fire takes the shots after the first, plus the tail of the last burst, plus the reload.

damagePerShot = damage × projectiles × burstRounds
DPS           = damagePerShot × rateOfFire
SDPS          = damagePerShot × (magazine's shots / one magazine-and-reload cycle)

Parameters

weapon

PersonalWeapon

A catalogue weapon record.

grade

number

Integer grade 15.

modifiers?

readonly PersonalModifier[] = []

Fitted modification modifiers, folded per stat the way applyPersonalModifiers does. magazineSize and headshotMultiplier are the two this arithmetic reads; modifiers naming other stats are ignored. A Reload Speed modification carries no modifier at all, so it arrives through options instead. A fractional magazine is held to whole rounds, rounding up, as ships/weapons does.

options?

reloadSpeed takes the reload from reloadTime.upgraded rather than .default, because Reload Speed carries its magnitude as that pair rather than as a modifier.

reloadSpeed?

boolean

Returns

PersonalWeaponMetrics | null

The frozen PersonalWeaponMetrics, or null when the record carries no such grade — the same nullable answer getPersonalWeaponGrade gives. A magazine that modifiers empty to zero rounds or fewer reports no sustained fire.

Throws

If grade is not an integer from 1 through 5.

Example

import {
    getPersonalWeaponByName,
    personalWeaponMetrics,
} from '@elite-dangerous-almanac/core/equipment/weapons';

const shotgun = getPersonalWeaponByName('Manticore Intimidator')!;
personalWeaponMetrics(shotgun, 5)?.damagePerShot; // -> 52.15  (ten pellets of 5.215)
personalWeaponMetrics(shotgun, 5)?.damagePerSecond; // -> 65.19
personalWeaponMetrics(shotgun, 5)?.sustainedDamagePerSecond; // -> 31.6  (with the 2.5 s reload)
⚠️ **GitHub.com Fallback** ⚠️