From 5f2d35eb8a5504c1f028e468655d1bba4311530e Mon Sep 17 00:00:00 2001 From: ferricles Date: Thu, 29 Apr 2021 20:10:29 -0700 Subject: [PATCH] untested fix for custom crafted break and custom crafteds not calculating damage properly --- custom.js | 5 +++-- customizer.js | 3 +-- damage_calc.js | 7 +++++-- display.js | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/custom.js b/custom.js index 7ee1190..3a78e9b 100644 --- a/custom.js +++ b/custom.js @@ -1,11 +1,12 @@ -const ci_save_order = ["name", "lore", "tier", "set", "slots", "type", "material", "drop", "quest", "nDam", "fDam", "wDam", "aDam", "tDam", "eDam", "atkSpd", "hp", "fDef", "wDef", "aDef", "tDef", "eDef", "lvl", "classReq", "strReq", "dexReq", "intReq", "defReq", "agiReq","str", "dex", "int", "agi", "def", "id", "skillpoints", "reqs", "nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_", "majorIds", "hprPct", "mr", "sdPct", "mdPct", "ls", "ms", "xpb", "lb", "ref", "thorns", "expd", "spd", "atkTier", "poison", "hpBonus", "spRegen", "eSteal", "hprRaw", "sdRaw", "mdRaw", "fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct", "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4", "rainbowRaw", "sprint", "sprintReg", "jh", "lq", "gXp", "gSpd","durability","duration","charges"]; -const nonRolled_strings = ["name","lore", "tier","set","type","material","drop","quest","majorIds","classReq","atkSpd","displayName", "nDam", "fDam", "wDam", "aDam", "tDam", "eDam", "nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_", "durability", "duration"]; +const ci_save_order = ["name", "lore", "tier", "set", "slots", "type", "material", "drop", "quest", "nDam", "fDam", "wDam", "aDam", "tDam", "eDam", "atkSpd", "hp", "fDef", "wDef", "aDef", "tDef", "eDef", "lvl", "classReq", "strReq", "dexReq", "intReq", "defReq", "agiReq","str", "dex", "int", "agi", "def", "id", "skillpoints", "reqs", "majorIds", "hprPct", "mr", "sdPct", "mdPct", "ls", "ms", "xpb", "lb", "ref", "thorns", "expd", "spd", "atkTier", "poison", "hpBonus", "spRegen", "eSteal", "hprRaw", "sdRaw", "mdRaw", "fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct", "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4", "rainbowRaw", "sprint", "sprintReg", "jh", "lq", "gXp", "gSpd","durability","duration","charges"]; +const nonRolled_strings = ["name","lore", "tier","set","type","material","drop","quest","majorIds","classReq","atkSpd","displayName", "nDam", "fDam", "wDam", "aDam", "tDam", "eDam", "durability", "duration"]; //omitted restrict - it's always "Custom Item" //omitted displayName - either it's the same as name (repetitive) or it's "Custom Item" //omitted category - can always get this from type //omitted fixId - we will denote this early in the string. +//omitted "nDam_", "fDam_", "wDam_", "aDam_", "tDam_", "eDam_" - will be calculated on display function getCustomFromHash(hash) { let name = hash.slice(); diff --git a/customizer.js b/customizer.js index f20cb59..11a7373 100644 --- a/customizer.js +++ b/customizer.js @@ -250,7 +250,7 @@ function encodeCustom(custom, verbose) { } } } else { - let damages = ["nDam", "eDam", "tDam", "wDam", "fDam", "aDam","nDam_", "eDam_", "tDam_", "wDam_", "fDam_", "aDam_"]; + let damages = ["nDam", "eDam", "tDam", "wDam", "fDam", "aDam"]; //"nDam_", "eDam_", "tDam_", "wDam_", "fDam_", "aDam_" let val = custom.get(id); if (typeof(val) === "string" && val !== "") { @@ -305,7 +305,6 @@ function decodeCustom(custom_url_tag) { while (tag !== "") { let id = ci_save_order[Base64.toInt(tag.slice(0,2))]; let len = Base64.toInt(tag.slice(2,4)); - console.log(id); if (rolledIDs.includes(id)) { let sign = parseInt(tag.slice(4,5),10); let minRoll = Base64.toInt(tag.slice(5,5+len)); diff --git a/damage_calc.js b/damage_calc.js index 0cedd35..b179379 100644 --- a/damage_calc.js +++ b/damage_calc.js @@ -52,9 +52,12 @@ function calculateSpellDamage(stats, spellConversions, rawModifier, pctModifier, damageBases[element+1] += diff + Math.floor( (powder.min + powder.max) / 2 ); } //update all damages - for (let i = 0; i < damages.length; i++) { - damages[i] = [Math.floor(damageBases[i] * 0.9), Math.floor(damageBases[i] * 1.1)]; + if(!weapon.get("custom")) { + for (let i = 0; i < damages.length; i++) { + damages[i] = [Math.floor(damageBases[i] * 0.9), Math.floor(damageBases[i] * 1.1)]; + } } + neutralRemainingRaw = damages[0].slice(); neutralBase = damages[0].slice(); } diff --git a/display.js b/display.js index bd5c8a1..5e9b7e0 100644 --- a/display.js +++ b/display.js @@ -461,6 +461,7 @@ function displayExpandedItem(item, parent_id){ stats.set("damageBases", [item.get("nDamBaseHigh"),item.get("eDamBaseHigh"),item.get("tDamBaseHigh"),item.get("wDamBaseHigh"),item.get("fDamBaseHigh"),item.get("aDamBaseHigh")]); let results = calculateSpellDamage(stats, [100, 0, 0, 0, 0, 0], 0, 0, 0, item, [0, 0, 0, 0, 0], 1, undefined); let damages = results[2]; + console.log(damages); let total_damage_min = 0; let total_damage_max = 0; @@ -893,7 +894,7 @@ function displayExpandedItem(item, parent_id){ let base_dps_min = total_damages[0] * damage_mult; let base_dps_max = total_damages[1] * damage_mult; - base_dps_elem.textContent = "Base DPS: "+base_dps_min+"\u279c"+base_dps_max; + base_dps_elem.textContent = "Base DPS: "+base_dps_min.toFixed(3)+"\u279c"+base_dps_max.toFixed(3); } else { base_dps_elem.textContent = "Base DPS: "+(total_damages * damage_mult);