Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Grim Dawn Item Stats — JavaScript SDK

Computes the real, seed-applied stats for a Grim Dawn item by replaying the game's MINSTD random stream over the item's rollable fields in the exact order the game engine draws them.

No stat/database files are bundled. You supply the raw fields you already parse from the game database; the SDK does the rolling. Zero dependencies, plain ES modules.

Install

Copy the src/ folder into your project and import from src/index.js, or reference the package directly.

Usage

import { calculate } from './src/index.js';

// field -> value, exactly as read from the item's base/prefix/suffix records.
// Values are strings; numeric fields are parsed for you, text fields (e.g. conversion damage
// types) are used as-is. Prefix and suffix are optional (pass null).
const baseStats = {
  attributeScalePercent: '30',
  characterAttackSpeedModifier: '14',
  offensiveColdModifier: '70',
  offensiveColdMin: '10',
  conversionInType: 'Physical',
  conversionOutType: 'Cold',
  conversionPercentage: '15',
};

const stats = calculate(baseStats, /* prefix */ null, /* suffix */ null, /* seed */ 63768175, /* modifier */ null);

for (const s of stats) console.log(`${s.field} = ${s.value}`);

calculate returns the rolled stats as an ordered array of { field, value } in the game's draw order. It is an array, not an object, so the sequence is preserved and the occasional repeated "chance of" proc line is not lost.

Pet bonuses

An item's base record, prefix and suffix can each carry a petBonusName field naming a pet bonus record. Those roll the "Bonus to All Pets" block, on their own stream primed with the same item seed — independent of the item's own stats — and several sources are summed per field.

import { calculatePetBonus } from './src/index.js';

const petStats = calculatePetBonus(
  {
    base: basePetRecord,     // fields of the record named by baseStats.petBonusName, or null
    prefix: prefixPetRecord, // ... by prefix.petBonusName, or null
    suffix: null,
  },
  prefix,   // the affix records themselves: their lootRandomizerJitter is the jitter used
  suffix,
  63768175,
);

Field names may keep the pet prefix the game database stores them under (petoffensiveTotalDamageModifier); they are normalized for you.

Notes

  • seed is the item's unsigned 32-bit seed. Seeds at or above 2^31 are valid and handled.
  • Only prefix/suffix affixes are modeled (no components, augments, or set bonuses).