working
This commit is contained in:
@@ -469,7 +469,7 @@ function CalcsTabClass:PowerBuilder()
|
||||
wipeTable(node.power)
|
||||
if not node.alloc and node.modKey ~= "" and not self.mainEnv.grantedPassives[nodeId] then
|
||||
if not cache[node.modKey] then
|
||||
cache[node.modKey] = calcFunc({ addNodes = { [node] = true } })
|
||||
cache[node.modKey] = calcFunc({ addNodes = { [node] = true } }, true)
|
||||
end
|
||||
local output = cache[node.modKey]
|
||||
if self.powerStat and self.powerStat.stat and not self.powerStat.ignoreForNodes then
|
||||
@@ -514,7 +514,7 @@ function CalcsTabClass:PowerBuilder()
|
||||
wipeTable(node.power)
|
||||
if not node.alloc and node.modKey ~= "" and not self.mainEnv.grantedPassives[nodeId] then
|
||||
if not cache[node.modKey] then
|
||||
cache[node.modKey] = calcFunc({ addNodes = { [node] = true } })
|
||||
cache[node.modKey] = calcFunc({ addNodes = { [node] = true } }, true)
|
||||
end
|
||||
local output = cache[node.modKey]
|
||||
if self.powerStat and self.powerStat.stat and not self.powerStat.ignoreForNodes then
|
||||
|
||||
@@ -361,7 +361,7 @@ function GemSelectClass:Draw(viewPort)
|
||||
-- Add hovered gem to tooltip
|
||||
self:AddGemTooltip(gemInstance)
|
||||
-- Calculate with the new gem
|
||||
local output = calcFunc()
|
||||
local output = calcFunc({}, true)
|
||||
-- Put the original gem back into the list
|
||||
if oldGem then
|
||||
gemInstance.gemData = oldGem.gemData
|
||||
|
||||
@@ -571,7 +571,7 @@ function SkillsTabClass:CreateGemSlot(index)
|
||||
local tempQual = self.displayGroup.gemList[index].qualityId
|
||||
self.displayGroup.gemList[index].qualityId = hoveredQuality.type
|
||||
self:ProcessSocketGroup(self.displayGroup)
|
||||
local output = calcFunc()
|
||||
local output = calcFunc({}, true)
|
||||
self.displayGroup.gemList[index].qualityId = tempQual
|
||||
tooltip:AddSeparator(10)
|
||||
self.build:AddStatComparesToTooltip(tooltip, calcBase, output, "^7Switching to this quality variant will give you:")
|
||||
@@ -627,7 +627,7 @@ function SkillsTabClass:CreateGemSlot(index)
|
||||
local calcFunc, calcBase = self.build.calcsTab:GetMiscCalculator(self.build)
|
||||
if calcFunc then
|
||||
self.displayGroup.gemList[index].enabled = not self.displayGroup.gemList[index].enabled
|
||||
local output = calcFunc()
|
||||
local output = calcFunc({}, true)
|
||||
self.displayGroup.gemList[index].enabled = not self.displayGroup.gemList[index].enabled
|
||||
self.build:AddStatComparesToTooltip(tooltip, calcBase, output, self.displayGroup.gemList[index].enabled and "^7Disabling this gem will give you:" or "^7Enabling this gem will give you:")
|
||||
end
|
||||
|
||||
@@ -127,7 +127,7 @@ end
|
||||
-- Copy an Active Skill
|
||||
function calcs.copyActiveSkill(build, mode, skill)
|
||||
local newSkill = calcs.createActiveSkill(skill.activeEffect, skill.supportList, skill.actor, skill.socketGroup, skill.summonSkill)
|
||||
local newEnv, _, _, _ = calcs.initEnv(build, mode)
|
||||
local newEnv, _, _ = calcs.initEnv(build, mode)
|
||||
calcs.buildActiveSkillModList(newEnv, newSkill)
|
||||
return newSkill, newEnv
|
||||
end
|
||||
|
||||
@@ -170,6 +170,46 @@ function calcs.buildModListForNodeList(env, nodeList, finishJewels)
|
||||
return modList
|
||||
end
|
||||
|
||||
function wipeEnv(env)
|
||||
wipeTable(env.modDB.mods)
|
||||
wipeTable(env.modDB.conditions)
|
||||
wipeTable(env.modDB.multipliers)
|
||||
wipeTable(env.enemyDB.mods)
|
||||
wipeTable(env.enemyDB.conditions)
|
||||
wipeTable(env.enemyDB.multipliers)
|
||||
|
||||
wipeTable(env.allocNodes)
|
||||
|
||||
wipeTable(env.radiusJewelList)
|
||||
wipeTable(env.extraRadiusNodeList)
|
||||
wipeTable(env.player.itemList)
|
||||
wipeTable(env.grantedSkills)
|
||||
wipeTable(env.flasks)
|
||||
|
||||
wipeTable(env.requirementsTable)
|
||||
if env.aegisModList then
|
||||
wipeTable(env.aegisModList)
|
||||
end
|
||||
if env.theIronMass then
|
||||
wipeTable(env.theIronMass)
|
||||
end
|
||||
if env.weaponModList1 then
|
||||
wipeTable(env.weaponModList1)
|
||||
end
|
||||
|
||||
--env.modDB.multipliers.CorruptedItem
|
||||
--env.modDB.multipliers.NonCorruptedItem
|
||||
--env.modDB.multipliers.ShaperItem
|
||||
--env.modDB.multipliers.NonShaperItem
|
||||
--env.modDB.multipliers.ElderItem
|
||||
--env.modDB.multipliers.NonElderItem
|
||||
--env.modDB.multipliers.ShaperOrElderItem
|
||||
|
||||
wipeTable(env.grantedPassives)
|
||||
wipeTable(env.player.activeSkillList)
|
||||
wipeTable(env.auxSkillList)
|
||||
end
|
||||
|
||||
-- Initialise environment:
|
||||
-- 1. Initialises the player and enemy modifier databases
|
||||
-- 2. Merges modifiers for all items
|
||||
@@ -185,15 +225,67 @@ function calcs.initEnv(build, mode, override, specEnv)
|
||||
local db2 = specEnv and specEnv.db2 or nil
|
||||
local storedInfo = specEnv and specEnv.si or { }
|
||||
|
||||
local env = specEnv and specEnv.env or nil
|
||||
|
||||
-- environment variables
|
||||
local env = { }
|
||||
env.build = build
|
||||
env.data = build.data
|
||||
env.configInput = build.configTab.input
|
||||
env.calcsInput = build.calcsTab.input
|
||||
env.mode = mode
|
||||
env.spec = override.spec or build.spec
|
||||
env.classId = env.spec.curClassId
|
||||
local modDB = nil
|
||||
local enemyDB = nil
|
||||
local classStats = nil
|
||||
|
||||
if not env then
|
||||
env = { }
|
||||
env.build = build
|
||||
env.data = build.data
|
||||
env.configInput = build.configTab.input
|
||||
env.calcsInput = build.calcsTab.input
|
||||
env.mode = mode
|
||||
env.spec = override.spec or build.spec
|
||||
env.classId = env.spec.curClassId
|
||||
|
||||
modDB = new("ModDB")
|
||||
env.modDB = modDB
|
||||
enemyDB = new("ModDB")
|
||||
env.enemyDB = enemyDB
|
||||
|
||||
env.enemyLevel = m_max(1, m_min(100, env.configInput.enemyLevel and env.configInput.enemyLevel or m_min(env.build.characterLevel, data.misc.MaxEnemyLevel)))
|
||||
|
||||
-- Create player/enemy actors
|
||||
env.player = {
|
||||
modDB = env.modDB,
|
||||
level = build.characterLevel,
|
||||
}
|
||||
env.modDB.actor = env.player
|
||||
env.enemy = {
|
||||
modDB = env.enemyDB,
|
||||
level = env.enemyLevel,
|
||||
}
|
||||
enemyDB.actor = env.enemy
|
||||
env.player.enemy = env.enemy
|
||||
env.enemy.enemy = env.player
|
||||
|
||||
-- Set up requirements tracking
|
||||
env.requirementsTable = { }
|
||||
|
||||
-- Prepare item, skill, flask tables
|
||||
env.radiusJewelList = wipeTable(env.radiusJewelList)
|
||||
env.extraRadiusNodeList = wipeTable(env.extraRadiusNodeList)
|
||||
env.player.itemList = { }
|
||||
env.grantedSkills = { }
|
||||
env.flasks = { }
|
||||
|
||||
-- tree based
|
||||
env.grantedPassives = { }
|
||||
|
||||
-- skill-related
|
||||
env.player.activeSkillList = { }
|
||||
env.auxSkillList = { }
|
||||
|
||||
else
|
||||
ConPrintf(mode .. " -- wiping")
|
||||
wipeEnv(env)
|
||||
modDB = env.modDB
|
||||
enemyDB = env.enemyDB
|
||||
end
|
||||
|
||||
-- Set buff mode
|
||||
local buffMode
|
||||
@@ -219,38 +311,7 @@ function calcs.initEnv(build, mode, override, specEnv)
|
||||
env.mode_combat = false
|
||||
env.mode_effective = false
|
||||
end
|
||||
|
||||
local modDB = new("ModDB")
|
||||
env.modDB = modDB
|
||||
local enemyDB = new("ModDB")
|
||||
env.enemyDB = enemyDB
|
||||
|
||||
local classStats = env.spec.tree.characterData and env.spec.tree.characterData[env.classId] or env.spec.tree.classes[env.classId]
|
||||
env.enemyLevel = m_max(1, m_min(100, env.configInput.enemyLevel and env.configInput.enemyLevel or m_min(env.build.characterLevel, data.misc.MaxEnemyLevel)))
|
||||
|
||||
-- Create player/enemy actors
|
||||
env.player = {
|
||||
modDB = env.modDB,
|
||||
level = build.characterLevel,
|
||||
}
|
||||
env.modDB.actor = env.player
|
||||
env.enemy = {
|
||||
modDB = env.enemyDB,
|
||||
level = env.enemyLevel,
|
||||
}
|
||||
enemyDB.actor = env.enemy
|
||||
env.player.enemy = env.enemy
|
||||
env.enemy.enemy = env.player
|
||||
|
||||
-- Set up requirements tracking
|
||||
env.requirementsTable = { }
|
||||
|
||||
-- Prepare item, skill, flask tables
|
||||
env.radiusJewelList = wipeTable(env.radiusJewelList)
|
||||
env.extraRadiusNodeList = wipeTable(env.extraRadiusNodeList)
|
||||
env.player.itemList = { }
|
||||
env.grantedSkills = { }
|
||||
env.flasks = { }
|
||||
classStats = env.spec.tree.characterData and env.spec.tree.characterData[env.classId] or env.spec.tree.classes[env.classId]
|
||||
|
||||
if not db1 then
|
||||
-- Initialise modifier database with base values
|
||||
@@ -340,11 +401,11 @@ function calcs.initEnv(build, mode, override, specEnv)
|
||||
env.modDB:AddList(build.configTab.modList)
|
||||
env.enemyDB:AddList(build.configTab.enemyModList)
|
||||
|
||||
-- db1, db2 = specCopy(env)
|
||||
--else
|
||||
-- env.modDB.parent = db1
|
||||
-- env.enemyDB.parent = db2
|
||||
--end
|
||||
db1, db2 = specCopy(env)
|
||||
else
|
||||
env.modDB.parent = db1
|
||||
env.enemyDB.parent = db2
|
||||
end
|
||||
|
||||
-- Build list of passive nodes
|
||||
local nodes
|
||||
@@ -365,13 +426,11 @@ function calcs.initEnv(build, mode, override, specEnv)
|
||||
end
|
||||
env.allocNodes = nodes
|
||||
|
||||
storedInfo.allocNodes = copyTable(env.allocNodes, true)
|
||||
db1, db2 = specCopy(env)
|
||||
else
|
||||
env.modDB.parent = db1
|
||||
env.enemyDB.parent = db2
|
||||
env.allocNodes = copyTable(storedInfo.allocNodes, true)
|
||||
end
|
||||
-- db1, db2 = specCopy(env)
|
||||
--else
|
||||
-- env.modDB.parent = db1
|
||||
-- env.enemyDB.parent = db2
|
||||
--end
|
||||
|
||||
-- Build and merge item modifiers, and create list of radius jewels
|
||||
for _, slot in pairs(build.itemsTab.orderedSlots) do
|
||||
@@ -590,7 +649,6 @@ function calcs.initEnv(build, mode, override, specEnv)
|
||||
end
|
||||
|
||||
-- Add granted passives
|
||||
env.grantedPassives = { }
|
||||
for _, passive in pairs(env.modDB:List(nil, "GrantedPassive")) do
|
||||
local node = env.spec.tree.notableMap[passive]
|
||||
if node then
|
||||
@@ -704,7 +762,6 @@ function calcs.initEnv(build, mode, override, specEnv)
|
||||
end
|
||||
|
||||
-- Build list of active skills
|
||||
env.player.activeSkillList = { }
|
||||
local groupCfg = wipeTable(tempTable1)
|
||||
for index, socketGroup in pairs(build.skillsTab.socketGroupList) do
|
||||
local socketGroupSkillList = { }
|
||||
@@ -913,10 +970,9 @@ function calcs.initEnv(build, mode, override, specEnv)
|
||||
end
|
||||
|
||||
-- Build skill modifier lists
|
||||
env.auxSkillList = { }
|
||||
for _, activeSkill in pairs(env.player.activeSkillList) do
|
||||
calcs.buildActiveSkillModList(env, activeSkill)
|
||||
end
|
||||
|
||||
return env, db1, db2, storedInfo
|
||||
return env, db1, db2
|
||||
end
|
||||
|
||||
@@ -55,12 +55,12 @@ end
|
||||
-- Generate a function for calculating the effect of some modification to the environment
|
||||
local function getCalculator(build, fullInit, modFunc)
|
||||
-- Initialise environment
|
||||
local env, db1, db2, storedInfo = calcs.initEnv(build, "CALCULATOR")
|
||||
local env, db1, db2 = calcs.initEnv(build, "CALCULATOR")
|
||||
|
||||
-- Run base calculation pass
|
||||
calcs.perform(env)
|
||||
GlobalCache.dontUseCache = true
|
||||
local fullDPS = calcs.calcFullDPS(build, "CALCULATOR")
|
||||
local fullDPS = calcs.calcFullDPS(build, "CALCULATOR", {}, { db1 = db1, db2 = db2, env = nil})
|
||||
GlobalCache.dontUseCache = nil
|
||||
env.player.output.SkillDPS = fullDPS.skills
|
||||
env.player.output.FullDPS = fullDPS.combinedDPS
|
||||
@@ -83,7 +83,7 @@ local function getCalculator(build, fullInit, modFunc)
|
||||
|
||||
-- Run calculation pass
|
||||
calcs.perform(env)
|
||||
fullDPS = calcs.calcFullDPS(build, "CALCULATOR")
|
||||
fullDPS = calcs.calcFullDPS(build, "CALCULATOR", {}, { db1 = db1, db2 = db2, env = env})
|
||||
env.player.output.SkillDPS = fullDPS.skills
|
||||
env.player.output.FullDPS = fullDPS.combinedDPS
|
||||
|
||||
@@ -102,25 +102,25 @@ end
|
||||
-- Get calculator for other changes (adding/removing nodes, items, gems, etc)
|
||||
function calcs.getMiscCalculator(build)
|
||||
-- Run base calculation pass
|
||||
local env, db1, db2, storedInfo = calcs.initEnv(build, "CALCULATOR")
|
||||
local env, db1, db2 = calcs.initEnv(build, "CALCULATOR")
|
||||
calcs.perform(env)
|
||||
local fullDPS = calcs.calcFullDPS(build, "CALCULATOR")
|
||||
local fullDPS = calcs.calcFullDPS(build, "CALCULATOR", {}, { db1 = db1, db2 = db2, env = env})
|
||||
env.player.output.SkillDPS = fullDPS.skills
|
||||
env.player.output.FullDPS = fullDPS.combinedDPS
|
||||
local baseOutput = env.player.output
|
||||
|
||||
return function(override, skip)
|
||||
if skip then
|
||||
env, db1, db2, storedInfo = calcs.initEnv(build, "CALCULATOR", override, { db1 = db1, db2 = db2, si = storedInfo })
|
||||
env, db1, db2 = calcs.initEnv(build, "CALCULATOR", override, { db1 = db1, db2 = db2, env = env })
|
||||
else
|
||||
env, db1, db2, storedInfo = calcs.initEnv(build, "CALCULATOR", override)
|
||||
env, db1, db2 = calcs.initEnv(build, "CALCULATOR", override)
|
||||
end
|
||||
calcs.perform(env)
|
||||
-- prevent upcoming calculation from using Cached Data and thus forcing it to re-calculate new FullDPS roll-up
|
||||
-- without this, FullDPS increase/decrease when for node/item/gem comparison would be all 0 as it would be comparing
|
||||
-- A with A (do to cache reuse) instead of A with B
|
||||
GlobalCache.dontUseCache = true
|
||||
fullDPS = calcs.calcFullDPS(build, "CALCULATOR", override, { db1 = db1, db2 = db2, si = storedInfo })
|
||||
fullDPS = calcs.calcFullDPS(build, "CALCULATOR", override, { db1 = db1, db2 = db2, env = env })
|
||||
GlobalCache.dontUseCache = nil
|
||||
env.player.output.SkillDPS = fullDPS.skills
|
||||
env.player.output.FullDPS = fullDPS.combinedDPS
|
||||
@@ -153,7 +153,7 @@ local function getActiveSkillCount(activeSkill)
|
||||
end
|
||||
|
||||
function calcs.calcFullDPS(build, mode, override, specEnv)
|
||||
local fullEnv, _, _, _ = calcs.initEnv(build, mode, override or {}, specEnv)
|
||||
local fullEnv, db1, db2 = calcs.initEnv(build, mode, override or {}, specEnv)
|
||||
local usedEnv = nil
|
||||
|
||||
local fullDPS = { combinedDPS = 0, skills = { }, poisonDPS = 0, impaleDPS = 0, igniteDPS = 0, bleedDPS = 0, decayDPS = 0, dotDPS = 0 }
|
||||
@@ -241,7 +241,7 @@ function calcs.calcFullDPS(build, mode, override, specEnv)
|
||||
end
|
||||
end
|
||||
-- Re-Build env calculator for new run
|
||||
fullEnv, _, _, _ = calcs.initEnv(build, mode, override or {}, specEnv)
|
||||
fullEnv, _, _ = calcs.initEnv(build, mode, override or {}, { db1 = db1, db2 = db2, env = fullEnv })
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -277,7 +277,7 @@ end
|
||||
|
||||
-- Process active skill
|
||||
function calcs.buildActiveSkill(build, mode, skill, setMark)
|
||||
local fullEnv, _, _, _ = calcs.initEnv(build, mode)
|
||||
local fullEnv, _, _ = calcs.initEnv(build, mode)
|
||||
for _, activeSkill in ipairs(fullEnv.player.activeSkillList) do
|
||||
if cacheSkillUUID(activeSkill) == cacheSkillUUID(skill) then
|
||||
fullEnv.player.mainSkill = activeSkill
|
||||
@@ -291,14 +291,14 @@ end
|
||||
-- Build output for display in the side bar or calcs tab
|
||||
function calcs.buildOutput(build, mode)
|
||||
-- Build output for selected main skill
|
||||
local env, db1, db2, storedInfo = calcs.initEnv(build, mode)
|
||||
local env, db1, db2 = calcs.initEnv(build, mode)
|
||||
calcs.perform(env)
|
||||
|
||||
local output = env.player.output
|
||||
|
||||
-- Build output across all active skills
|
||||
GlobalCache.dontUseCache = true
|
||||
local fullDPS = calcs.calcFullDPS(build, "CACHE", {}, { db1 = db1, db2 = db2, si = storedInfo })
|
||||
local fullDPS = calcs.calcFullDPS(build, "CACHE", {}, { db1 = db1, db2 = db2, env = nil })
|
||||
GlobalCache.dontUseCache = nil
|
||||
|
||||
-- Add Full DPS data to main `env`
|
||||
|
||||
Reference in New Issue
Block a user