From ce6ab17c320d3e58f2044c17c94bfbd4188c9f89 Mon Sep 17 00:00:00 2001 From: b Date: Sat, 27 Mar 2021 15:41:57 -0700 Subject: [PATCH] Fix crafted powder application formula (again) --- craft.js | 25 +++++++++++++------------ damage_calc.js | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/craft.js b/craft.js index 6ff3331..28455bb 100644 --- a/craft.js +++ b/craft.js @@ -211,18 +211,19 @@ class Craft{ powders.push(ingred.get("pid")); } } - for (const p of powders) { - /* Powders as ingredients in crafted weapons are different than powders applied to non-crafted weapons. Thanks to nbcss for showing me the math. - */ - let powder = powderStats[p]; //use min, max, and convert - let element = Math.floor((p+0.01)/6); //[0,4], the +0.01 attempts to prevent division error - let diffLow = Math.floor(nDamBaseLow * powder.convert/100); - nDamBaseLow -= diffLow; - elemDamBaseLow[element] += diffLow + Math.floor( (powder.min + powder.max) / 2 ); - let diffHigh = Math.floor(nDamBaseHigh * powder.convert/100); - nDamBaseHigh -= diffHigh; - elemDamBaseHigh[element] += diffHigh + Math.floor( (powder.min + powder.max) / 2 ); - } + // for (const p of powders) { + // /* Powders as ingredients in crafted weapons are different than powders applied to non-crafted weapons. Thanks to nbcss for showing me the math. + // */ + // let powder = powderStats[p]; //use min, max, and convert + // let element = Math.floor((p+0.01)/6); //[0,4], the +0.01 attempts to prevent division error + // let diffLow = Math.floor(nDamBaseLow * powder.convert/100); + // nDamBaseLow -= diffLow; + // elemDamBaseLow[element] += diffLow + Math.floor( (powder.min + powder.max) / 2 ); + // let diffHigh = Math.floor(nDamBaseHigh * powder.convert/100); + // nDamBaseHigh -= diffHigh; + // elemDamBaseHigh[element] += diffHigh + Math.floor( (powder.min + powder.max) / 2 ); + // } + statMap.set("ingredPowders", powders); /* I create a separate variable for each low damage range because we need one damage range to calculate damage with, and it's custom to use the maximum range of the range range. */ diff --git a/damage_calc.js b/damage_calc.js index 338cd6e..13b16f1 100644 --- a/damage_calc.js +++ b/damage_calc.js @@ -40,7 +40,7 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, //1st round - apply each as ingred, 2nd round - apply as normal if (weapon.get("tier") === "Crafted") { let damageBases = buildStats.get("damageBases").slice(); - for (const p of powders) { + for (const p of powders.concat(weapon.get("ingredPowders"))) { let powder = powderStats[p]; //use min, max, and convert let element = Math.floor((p+0.01)/6); //[0,4], the +0.01 attempts to prevent division error let diff = Math.floor(damageBases[0] * powder.convert/100);