ships.Function.shieldMassCurveMultiplier - Elite-Dangerous-Almanac/Almanac-Core GitHub Wiki

@elite-dangerous-almanac/core / ships / shieldMassCurveMultiplier

Function: shieldMassCurveMultiplier()

shieldMassCurveMultiplier(hullMass, generator): number

Defined in: src/ships/shields.ts:281

A shield generator's strength multiplier at a given hull mass.

Parameters

hullMass

number

The hull's mass, in tonnes (not the loaded ship's). Finite and non-negative.

generator

ShieldGeneratorParams

The generator's mass/multiplier curve, post-engineering. Either all six curve fields, or a record the catalogue left incomplete — see the 0 cases below.

Returns

number

The multiplier to apply to the hull's base shield strength: minMultiplier for a hull sitting exactly on maxMass, no more than maxMultiplier for a featherweight one, and 0 past maxMass — a generator cannot raise a shield around a hull heavier than it is rated for. Also 0 for a generator whose record is missing part of its curve.

Throws

If hullMass is not a finite number of zero or more, or if the generator carries all six curve fields and they are not a physical curve: every one has to be finite and non-negative, the masses strictly ordered minMass < optMass < maxMass (or all equal, for a constant curve), the multipliers strictly ordered minMultiplier < optMultiplier < maxMultiplier (or all equal), and an all-equal mass curve must have equal multipliers. A curve that is merely absent still answers 0: a catalogue record missing any of the six fields is incomplete data, not a non-physical curve, and this is the only mass-curve outcome that is not a number or a throw.

Remarks

The curve is a power law fitted through the generator's three declared points: normalize the mass into [0, 1] between maxMass and minMass, raise it to the exponent that makes the curve pass through (optMass, optMultiplier), then interpolate between minMultiplier and maxMultiplier. It is the same curve thrusterMassCurveMultiplier reads a thruster's performance off, and the two agree on every input they both accept.

Examples

import { shieldMassCurveMultiplier } from '@elite-dangerous-almanac/core/ships/shields';

// A 6A generator (opt 540 t) on a 400 t Anaconda performs slightly above spec
shieldMassCurveMultiplier(400, {
  minMass: 270, optMass: 540, maxMass: 1350,
  minMultiplier: 0.7, optMultiplier: 1.2, maxMultiplier: 1.7,
}); // -> 1.434…
import { shieldMassCurveMultiplier } from '@elite-dangerous-almanac/core/ships/shields';

// A generator whose optimal mass sits on its maximum is not a curve at all
try {
  shieldMassCurveMultiplier(400, {
    minMass: 270, optMass: 1350, maxMass: 1350,
    minMultiplier: 0.7, optMultiplier: 1.2, maxMultiplier: 1.7,
  });
} catch (error) {
  (error as Error).message;
  // -> 'shieldMassCurveMultiplier: generator: masses must be strictly ordered minMass < optMass < maxMass, or all equal'
}

// A record the catalogue left incomplete is data that is missing, not data that is wrong
shieldMassCurveMultiplier(400, { optMass: 540, optMultiplier: 1.2 }); // -> 0
⚠️ **GitHub.com Fallback** ⚠️