From 8f20e3d85076b9bb1ff7fa105d011ce3ebfad374 Mon Sep 17 00:00:00 2001 From: Paliak <91493239+Paliak@users.noreply.github.com> Date: Wed, 27 Mar 2024 08:05:51 +0100 Subject: [PATCH] Fix calc mode issues for triggers and mirages (#7458) * FIX: Remove dead code. Fix calc mode issues. * FIX: remove vestigial exclude list * FIX: remove left over greoup table wipe --- src/Classes/GemSelectControl.lua | 1 - src/Data/Global.lua | 2 -- src/Data/Skills/sup_str.lua | 2 +- src/Modules/Build.lua | 7 ---- src/Modules/CalcMirages.lua | 38 ++++++++++---------- src/Modules/CalcPerform.lua | 10 +++--- src/Modules/CalcTriggers.lua | 62 ++++++++++++++++---------------- src/Modules/Calcs.lua | 36 +++++++------------ src/Modules/Common.lua | 48 +------------------------ 9 files changed, 67 insertions(+), 139 deletions(-) diff --git a/src/Classes/GemSelectControl.lua b/src/Classes/GemSelectControl.lua index a026bcc8d6..a643e9af75 100644 --- a/src/Classes/GemSelectControl.lua +++ b/src/Classes/GemSelectControl.lua @@ -97,7 +97,6 @@ function GemSelectClass:CalcOutputWithThisGem(calcFunc, gemData, qualityId) gemInstance.displayEffect = oldGem.displayEffect else gemList[self.index] = nil - calcFunc({ }, { allocNodes = true, requirementsItems = true }) end return output, gemInstance diff --git a/src/Data/Global.lua b/src/Data/Global.lua index e923ff7eaa..69104cab65 100644 --- a/src/Data/Global.lua +++ b/src/Data/Global.lua @@ -316,8 +316,6 @@ SkillType = { GlobalCache = { cachedData = { MAIN = {}, CALCS = {}, CALCULATOR = {}, CACHE = {}, }, - deleteGroup = { }, - excludeFullDpsList = { }, noCache = nil, useFullDPS = false, numActiveSkillInFullDPS = 0, diff --git a/src/Data/Skills/sup_str.lua b/src/Data/Skills/sup_str.lua index 4c07434f90..1a92449f69 100644 --- a/src/Data/Skills/sup_str.lua +++ b/src/Data/Skills/sup_str.lua @@ -2139,7 +2139,7 @@ skills["AvengingFlame"] = { castTime = 1, preDamageFunc = function(activeSkill, output) local uuid = activeSkill.skillData.triggerSourceUUID - local cache = uuid and GlobalCache.cachedData["CACHE"][uuid] + local cache = uuid and (GlobalCache.cachedData["MAIN"][uuid] or GlobalCache.cachedData["CALCS"][uuid]) local totemLife = cache and cache.Env.player.output.TotemLife or 0 local add = totemLife * activeSkill.skillData.lifeDealtAsFire / 100 diff --git a/src/Modules/Build.lua b/src/Modules/Build.lua index 9e1e59b038..1eb0ebabdb 100644 --- a/src/Modules/Build.lua +++ b/src/Modules/Build.lua @@ -1019,7 +1019,6 @@ function buildMode:OnFrame(inputEvents) self.controls.secondaryAscendDrop.list = {{label = "None", ascendClassId = 0}, {label = "Warden", ascendClassId = 1}, {label = "Warlock", ascendClassId = 2}, {label = "Primalist", ascendClassId = 3}} self.controls.secondaryAscendDrop:SelByValue(self.spec.curSecondaryAscendClassId, "ascendClassId") - local checkFabricatedGroups = self.buildFlag if self.buildFlag then -- Wipe Global Cache wipeGlobalCache() @@ -1046,12 +1045,6 @@ function buildMode:OnFrame(inputEvents) -- Update contents of main skill dropdowns self:RefreshSkillSelectControls(self.controls, self.mainSocketGroup, "") - -- Delete any possible fabricated groups - if checkFabricatedGroups then - deleteFabricatedGroup(self.skillsTab) - checkFabricatedGroups = false - end - -- Draw contents of current tab local sideBarWidth = 312 local tabViewPort = { diff --git a/src/Modules/CalcMirages.lua b/src/Modules/CalcMirages.lua index 23d1b4b5ae..9998630fbe 100644 --- a/src/Modules/CalcMirages.lua +++ b/src/Modules/CalcMirages.lua @@ -35,7 +35,7 @@ local function calculateMirage(env, config) end if mirageSkill then - local newSkill, newEnv = calcs.copyActiveSkill(env, env.mode == "CALCS" and "CALCS" or "MAIN", mirageSkill) + local newSkill, newEnv = calcs.copyActiveSkill(env, env.mode, mirageSkill) newSkill.skillCfg.skillCond["usedByMirage"] = true newSkill.skillData.limitedProcessing = true newSkill.skillData.mirageUses = env.player.mainSkill.skillData.storedUses @@ -122,17 +122,17 @@ function calcs.mirages(env) compareFunc = function(skill, env, config, mirageSkill) if skill ~= env.player.mainSkill and skill.skillTypes[SkillType.Attack] and not skill.skillTypes[SkillType.Totem] and not skill.skillTypes[SkillType.SummonsTotem] and band(skill.skillCfg.flags, bor(ModFlag.Sword, ModFlag.Weapon1H)) == bor(ModFlag.Sword, ModFlag.Weapon1H) and not skill.skillCfg.skillCond["usedByMirage"] then local uuid = cacheSkillUUID(skill, env) - if not GlobalCache.cachedData["CACHE"][uuid] or GlobalCache.noCache then - calcs.buildActiveSkill(env, "CACHE", skill) + if not GlobalCache.cachedData[env.mode][uuid] then + calcs.buildActiveSkill(env, env.mode, skill) end - if GlobalCache.cachedData["CACHE"][uuid] and GlobalCache.cachedData["CACHE"][uuid].CritChance and GlobalCache.cachedData["CACHE"][uuid].CritChance > 0 then + if GlobalCache.cachedData[env.mode][uuid] and GlobalCache.cachedData[env.mode][uuid].CritChance and GlobalCache.cachedData[env.mode][uuid].CritChance > 0 then if not mirageSkill then - usedSkillBestDps = GlobalCache.cachedData["CACHE"][uuid].TotalDPS - return GlobalCache.cachedData["CACHE"][uuid].ActiveSkill - elseif GlobalCache.cachedData["CACHE"][uuid].TotalDPS > usedSkillBestDps then - usedSkillBestDps = GlobalCache.cachedData["CACHE"][uuid].TotalDPS - return GlobalCache.cachedData["CACHE"][uuid].ActiveSkill + usedSkillBestDps = GlobalCache.cachedData[env.mode][uuid].TotalDPS + return GlobalCache.cachedData[env.mode][uuid].ActiveSkill + elseif GlobalCache.cachedData[env.mode][uuid].TotalDPS > usedSkillBestDps then + usedSkillBestDps = GlobalCache.cachedData[env.mode][uuid].TotalDPS + return GlobalCache.cachedData[env.mode][uuid].ActiveSkill end end end @@ -191,21 +191,21 @@ function calcs.mirages(env) local isDisabled = skill.skillFlags and skill.skillFlags.disable if skill ~= env.player.mainSkill and (skill.skillTypes[SkillType.Slam] or skill.skillTypes[SkillType.Melee]) and skill.skillTypes[SkillType.Attack] and not skill.skillTypes[SkillType.Vaal] and not isTriggered(skill) and not isDisabled and not skill.skillTypes[SkillType.Totem] and not skill.skillTypes[SkillType.SummonsTotem] and not skill.skillCfg.skillCond["usedByMirage"] then local uuid = cacheSkillUUID(skill, env) - if not GlobalCache.cachedData["CACHE"][uuid] or GlobalCache.noCache then - calcs.buildActiveSkill(env, "CACHE", skill) + if not GlobalCache.cachedData[env.mode][uuid] or env.mode == "CALCULATOR" then + calcs.buildActiveSkill(env, env.mode, skill) end - if GlobalCache.cachedData["CACHE"][uuid] then + if GlobalCache.cachedData[env.mode][uuid] then if not mirageSkill then - usedSkillBestDps = GlobalCache.cachedData["CACHE"][uuid].TotalDPS - EffectiveSourceRate = GlobalCache.cachedData["CACHE"][uuid].Speed - return GlobalCache.cachedData["CACHE"][uuid].ActiveSkill + usedSkillBestDps = GlobalCache.cachedData[env.mode][uuid].TotalDPS + EffectiveSourceRate = GlobalCache.cachedData[env.mode][uuid].Speed + return GlobalCache.cachedData[env.mode][uuid].ActiveSkill else - if GlobalCache.cachedData["CACHE"][uuid].TotalDPS > usedSkillBestDps then - usedSkillBestDps = GlobalCache.cachedData["CACHE"][uuid].TotalDPS - EffectiveSourceRate = GlobalCache.cachedData["CACHE"][uuid].Speed - return GlobalCache.cachedData["CACHE"][uuid].ActiveSkill + if GlobalCache.cachedData[env.mode][uuid].TotalDPS > usedSkillBestDps then + usedSkillBestDps = GlobalCache.cachedData[env.mode][uuid].TotalDPS + EffectiveSourceRate = GlobalCache.cachedData[env.mode][uuid].Speed + return GlobalCache.cachedData[env.mode][uuid].ActiveSkill end end end diff --git a/src/Modules/CalcPerform.lua b/src/Modules/CalcPerform.lua index 2962ed4507..1bc2ad95c9 100644 --- a/src/Modules/CalcPerform.lua +++ b/src/Modules/CalcPerform.lua @@ -925,12 +925,10 @@ end -- 8. Processes buffs and debuffs -- 9. Processes charges and misc buffs (doActorCharges, doActorMisc) -- 10. Calculates defence and offence stats (calcs.defence, calcs.offence) -function calcs.perform(env, fullDPSSkipEHP) +function calcs.perform(env, skipEHP) local modDB = env.modDB local enemyDB = env.enemyDB - local fullDPSSkipEHP = fullDPSSkipEHP or false - -- Merge keystone modifiers env.keystonesAdded = { } mergeKeystones(env) @@ -952,7 +950,7 @@ function calcs.perform(env, fullDPSSkipEHP) env.partyMembers = env.build.partyTab.actor env.player.partyMembers = env.partyMembers - local partyTabEnableExportBuffs = env.build.partyTab.enableExportBuffs + local partyTabEnableExportBuffs = env.build.partyTab.enableExportBuffs and env.mode ~= "CALCULATOR" env.minion = env.player.mainSkill.minion if env.minion then @@ -3010,7 +3008,7 @@ function calcs.perform(env, fullDPSSkipEHP) -- Defence/offence calculations calcs.defence(env, env.player) - if not fullDPSSkipEHP then + if not skipEHP then calcs.buildDefenceEstimations(env, env.player) end @@ -3021,7 +3019,7 @@ function calcs.perform(env, fullDPSSkipEHP) if env.minion then calcs.defence(env, env.minion) - if not fullDPSSkipEHP then -- main.build.calcsTab.input.showMinion and -- should be disabled unless "calcsTab.input.showMinion" is true + if not skipEHP then -- main.build.calcsTab.input.showMinion and -- should be disabled unless "calcsTab.input.showMinion" is true calcs.buildDefenceEstimations(env, env.minion) end calcs.triggers(env, env.minion) diff --git a/src/Modules/CalcTriggers.lua b/src/Modules/CalcTriggers.lua index 5985befb34..ec4464cb20 100644 --- a/src/Modules/CalcTriggers.lua +++ b/src/Modules/CalcTriggers.lua @@ -68,17 +68,17 @@ end -- Identify the trigger action skill for trigger conditions, take highest Attack Per Second local function findTriggerSkill(env, skill, source, triggerRate, comparer) local comparer = comparer or function(uuid, source, triggerRate) - local cachedSpeed = GlobalCache.cachedData["CACHE"][uuid].HitSpeed or GlobalCache.cachedData["CACHE"][uuid].Speed + local cachedSpeed = GlobalCache.cachedData[env.mode][uuid].HitSpeed or GlobalCache.cachedData[env.mode][uuid].Speed return (not source and cachedSpeed) or (cachedSpeed and cachedSpeed > (triggerRate or 0)) end local uuid = cacheSkillUUID(skill, env) - if not GlobalCache.cachedData["CACHE"][uuid] or GlobalCache.noCache then - calcs.buildActiveSkill(env, "CACHE", skill) + if not GlobalCache.cachedData[env.mode][uuid] or env.mode == "CALCULATOR" then + calcs.buildActiveSkill(env, env.mode, skill) end - if GlobalCache.cachedData["CACHE"][uuid] and comparer(uuid, source, triggerRate) and (skill.skillFlags and not skill.skillFlags.disable) and (skill.skillCfg and not skill.skillCfg.skillCond["usedByMirage"]) and not skill.skillTypes[SkillType.OtherThingUsesSkill] then - return skill, GlobalCache.cachedData["CACHE"][uuid].HitSpeed or GlobalCache.cachedData["CACHE"][uuid].Speed, uuid + if GlobalCache.cachedData[env.mode][uuid] and comparer(uuid, source, triggerRate) and (skill.skillFlags and not skill.skillFlags.disable) and (skill.skillCfg and not skill.skillCfg.skillCond["usedByMirage"]) and not skill.skillTypes[SkillType.OtherThingUsesSkill] then + return skill, GlobalCache.cachedData[env.mode][uuid].HitSpeed or GlobalCache.cachedData[env.mode][uuid].Speed, uuid end return source, triggerRate, source and cacheSkillUUID(source, env) end @@ -460,8 +460,8 @@ local function defaultTriggerHandler(env, config) actor.mainSkill.skillData.ignoresTickRate = actor.mainSkill.skillData.ignoresTickRate or (actor.mainSkill.skillData.storedUses and actor.mainSkill.skillData.storedUses > 1) --Account for source unleash - if source and GlobalCache.cachedData["CACHE"][uuid] and source.skillModList:Flag(nil, "HasSeals") and source.skillTypes[SkillType.CanRapidFire] then - local unleashDpsMult = GlobalCache.cachedData["CACHE"][uuid].ActiveSkill.skillData.dpsMultiplier or 1 + if source and GlobalCache.cachedData[env.mode][uuid] and source.skillModList:Flag(nil, "HasSeals") and source.skillTypes[SkillType.CanRapidFire] then + local unleashDpsMult = GlobalCache.cachedData[env.mode][uuid].ActiveSkill.skillData.dpsMultiplier or 1 trigRate = trigRate * unleashDpsMult actor.mainSkill.skillFlags.HasSeals = true actor.mainSkill.skillData.ignoresTickRate = true @@ -471,8 +471,8 @@ local function defaultTriggerHandler(env, config) end -- Battlemage's Cry uptime - if actor.mainSkill.skillData.triggeredByBattleMageCry and GlobalCache.cachedData["CACHE"][uuid] and source and source.skillTypes[SkillType.Melee] then - local battleMageUptime = GlobalCache.cachedData["CACHE"][uuid].Env.player.output.BattlemageUpTimeRatio or 100 + if actor.mainSkill.skillData.triggeredByBattleMageCry and GlobalCache.cachedData[env.mode][uuid] and source and source.skillTypes[SkillType.Melee] then + local battleMageUptime = GlobalCache.cachedData[env.mode][uuid].Env.player.output.BattlemageUpTimeRatio or 100 trigRate = trigRate * battleMageUptime / 100 if breakdown then t_insert(breakdown.EffectiveSourceRate, s_format("x %d%% ^8(Battlemage's Cry uptime)", battleMageUptime)) @@ -480,8 +480,8 @@ local function defaultTriggerHandler(env, config) end -- Infernal Cry uptime - if actor.mainSkill.activeEffect.grantedEffect.name == "Combust" and GlobalCache.cachedData["CACHE"][uuid] and source and source.skillTypes[SkillType.Melee] then - local InfernalUpTime = GlobalCache.cachedData["CACHE"][uuid].Env.player.output.InfernalUpTimeRatio or 100 + if actor.mainSkill.activeEffect.grantedEffect.name == "Combust" and GlobalCache.cachedData[env.mode][uuid] and source and source.skillTypes[SkillType.Melee] then + local InfernalUpTime = GlobalCache.cachedData[env.mode][uuid].Env.player.output.InfernalUpTimeRatio or 100 trigRate = trigRate * InfernalUpTime / 100 if breakdown then t_insert(breakdown.EffectiveSourceRate, s_format("x %d%% ^8(Infernal Cry uptime)", InfernalUpTime)) @@ -489,8 +489,8 @@ local function defaultTriggerHandler(env, config) end --Account for skills that can hit multiple times per use - if source and GlobalCache.cachedData["CACHE"][uuid] and source.skillPartName and source.skillPartName:match("(.*)All(.*)Projectiles(.*)") and source.skillFlags.projectile then - local multiHitDpsMult = GlobalCache.cachedData["CACHE"][uuid].Env.player.output.ProjectileCount or 1 + if source and GlobalCache.cachedData[env.mode][uuid] and source.skillPartName and source.skillPartName:match("(.*)All(.*)Projectiles(.*)") and source.skillFlags.projectile then + local multiHitDpsMult = GlobalCache.cachedData[env.mode][uuid].Env.player.output.ProjectileCount or 1 trigRate = trigRate * multiHitDpsMult if breakdown then t_insert(breakdown.EffectiveSourceRate, s_format("x %.2f ^8(%d projectiles hit)", multiHitDpsMult, multiHitDpsMult)) @@ -498,17 +498,17 @@ local function defaultTriggerHandler(env, config) end --Accuracy and crit chance - if source and (source.skillTypes[SkillType.Melee] or source.skillTypes[SkillType.Attack]) and GlobalCache.cachedData["CACHE"][uuid] and not config.triggerOnUse then - local sourceHitChance = GlobalCache.cachedData["CACHE"][uuid].HitChance + if source and (source.skillTypes[SkillType.Melee] or source.skillTypes[SkillType.Attack]) and GlobalCache.cachedData[env.mode][uuid] and not config.triggerOnUse then + local sourceHitChance = GlobalCache.cachedData[env.mode][uuid].HitChance trigRate = trigRate * (sourceHitChance or 0) / 100 if breakdown then t_insert(breakdown.EffectiveSourceRate, s_format("x %.0f%% ^8(%s hit chance)", sourceHitChance, source.activeEffect.grantedEffect.name)) end if actor.mainSkill.skillData.triggerOnCrit then - local onCritChance = actor.mainSkill.skillData.chanceToTriggerOnCrit or (GlobalCache.cachedData["CACHE"][uuid] and GlobalCache.cachedData["CACHE"][uuid].Env.player.mainSkill.skillData.chanceToTriggerOnCrit) + local onCritChance = actor.mainSkill.skillData.chanceToTriggerOnCrit or (GlobalCache.cachedData[env.mode][uuid] and GlobalCache.cachedData[env.mode][uuid].Env.player.mainSkill.skillData.chanceToTriggerOnCrit) config.triggerChance = config.triggerChance or actor.mainSkill.skillData.chanceToTriggerOnCrit or onCritChance - local sourceCritChance = GlobalCache.cachedData["CACHE"][uuid].CritChance + local sourceCritChance = GlobalCache.cachedData[env.mode][uuid].CritChance trigRate = trigRate * (sourceCritChance or 0) / 100 if breakdown then t_insert(breakdown.EffectiveSourceRate, s_format("x %.2f%% ^8(%s effective crit chance)", sourceCritChance, source.activeEffect.grantedEffect.name)) @@ -528,15 +528,14 @@ local function defaultTriggerHandler(env, config) -- Handling for mana spending rate for Manaforged Arrows Support if actor.mainSkill.skillData.triggeredByManaforged and trigRate > 0 then - local mode = env.mode == "CALCS" and "CALCS" or "MAIN" local triggeredUUID = cacheSkillUUID(actor.mainSkill, env) - if not GlobalCache.cachedData[mode][triggeredUUID] then - calcs.buildActiveSkill(env, mode, actor.mainSkill, {[triggeredUUID] = true}) + if not GlobalCache.cachedData[env.mode][triggeredUUID] then + calcs.buildActiveSkill(env, env.mode, actor.mainSkill, {[triggeredUUID] = true}) end - local triggeredManaCost = GlobalCache.cachedData[mode][triggeredUUID].Env.player.output.ManaCost or 0 + local triggeredManaCost = GlobalCache.cachedData[env.mode][triggeredUUID].Env.player.output.ManaCost or 0 if triggeredManaCost > 0 then local manaSpentThreshold = triggeredManaCost * actor.mainSkill.skillData.ManaForgedArrowsPercentThreshold - local sourceManaCost = GlobalCache.cachedData["CACHE"][uuid].Env.player.output.ManaCost or 0 + local sourceManaCost = GlobalCache.cachedData[env.mode][uuid].Env.player.output.ManaCost or 0 if sourceManaCost > 0 then if breakdown then t_insert(breakdown.EffectiveSourceRate, s_format("* %.2f ^8(Mana cost of trigger source)", sourceManaCost)) @@ -599,9 +598,9 @@ local function defaultTriggerHandler(env, config) output.TriggerRateCap = 1 / actionCooldownTickRounded end if config.triggerName == "Doom Blast" and env.build.configTab.input["doomBlastSource"] == "expiration" then - local expirationRate = 1 / GlobalCache.cachedData["CACHE"][uuid].Env.player.output.Duration + local expirationRate = 1 / GlobalCache.cachedData[env.mode][uuid].Env.player.output.Duration if breakdown and breakdown.EffectiveSourceRate then - breakdown.EffectiveSourceRate[1] = s_format("1 / %.2f ^8(source curse duration)", GlobalCache.cachedData["CACHE"][uuid].Env.player.output.Duration) + breakdown.EffectiveSourceRate[1] = s_format("1 / %.2f ^8(source curse duration)", GlobalCache.cachedData[env.mode][uuid].Env.player.output.Duration) end if expirationRate > trigRate then env.player.modDB:NewMod("UsesCurseOverlaps", "FLAG", true, "Config") @@ -1017,8 +1016,8 @@ local configTable = { return {triggerChance = env.player.modDB:Sum("BASE", nil, "KitavaTriggerChance"), triggerName = "Kitava's Thirst", comparer = function(uuid, source, triggerRate) - local cachedSpeed = GlobalCache.cachedData["CACHE"][uuid].HitSpeed or GlobalCache.cachedData["CACHE"][uuid].Speed - local cachedManaCost = GlobalCache.cachedData["CACHE"][uuid].ManaCost + local cachedSpeed = GlobalCache.cachedData[env.mode][uuid].HitSpeed or GlobalCache.cachedData[env.mode][uuid].Speed + local cachedManaCost = GlobalCache.cachedData[env.mode][uuid].ManaCost return ( (not source and cachedSpeed) or (cachedSpeed and cachedSpeed > (triggerRate or 0)) ) and ( (cachedManaCost or 0) > requiredManaCost ) end, triggerSkillCond = function(env, skill) @@ -1234,20 +1233,19 @@ local configTable = { if currentSkillSnipeIndex and currentSkillSnipeIndex <= snipeStages then local source local trigRate - local mode = env.mode == "CALCS" and "CALCS" or "MAIN" env.player.mainSkill.skillModList:NewMod("Damage", "MORE", snipeHitMulti * snipeStages , "Snipe", ModFlag.Hit, 0) env.player.mainSkill.skillModList:NewMod("Damage", "MORE", snipeAilmentMulti * snipeStages , "Snipe", ModFlag.Ailment, 0) for _, skill in ipairs(env.player.activeSkillList) do if skill.activeEffect.grantedEffect.name == "Snipe" and skill.socketGroup and skill.socketGroup.slot == env.player.mainSkill.socketGroup.slot then skill.skillData.hitTimeMultiplier = snipeStages - 0.5 local uuid = cacheSkillUUID(skill, env) - if not GlobalCache.cachedData[mode][uuid] or GlobalCache.noCache then - calcs.buildActiveSkill(env, mode, skill) + if not GlobalCache.cachedData[env.mode][uuid] or env.mode == "CALCULATOR" then + calcs.buildActiveSkill(env, env.mode, skill) end - local cachedSpeed = GlobalCache.cachedData[mode][uuid].Env.player.output.HitSpeed + local cachedSpeed = GlobalCache.cachedData[env.mode][uuid].Env.player.output.HitSpeed if (skill.skillFlags and not skill.skillFlags.disable) and (skill.skillCfg and not skill.skillCfg.skillCond["usedByMirage"]) and not skill.skillTypes[SkillType.OtherThingUsesSkill] and ((not source and cachedSpeed) or (cachedSpeed and cachedSpeed > (trigRate or 0))) then trigRate = cachedSpeed - env.player.output.ChannelTimeToTrigger = GlobalCache.cachedData[mode][uuid].Env.player.output.HitTime + env.player.output.ChannelTimeToTrigger = GlobalCache.cachedData[env.mode][uuid].Env.player.output.HitTime source = skill end end @@ -1265,7 +1263,7 @@ local configTable = { ["avenging flame"] = function(env) return {triggerSkillCond = function(env, skill) return skill.skillFlags.totem and slotMatch(env, skill) end, comparer = function(uuid, source, currentTotemLife) - local totemLife = GlobalCache.cachedData["CACHE"][uuid].Env.player.output.TotemLife + local totemLife = GlobalCache.cachedData[env.mode][uuid].Env.player.output.TotemLife return (not source and totemLife) or (totemLife and totemLife > (currentTotemLife or 0)) end, ignoreSourceRate = true} diff --git a/src/Modules/Calcs.lua b/src/Modules/Calcs.lua index 1f82b1d4c6..cb89a91e95 100644 --- a/src/Modules/Calcs.lua +++ b/src/Modules/Calcs.lua @@ -75,9 +75,7 @@ local function getCalculator(build, fullInit, modFunc) -- Run base calculation pass calcs.perform(env) - GlobalCache.noCache = true local fullDPS = calcs.calcFullDPS(build, "CALCULATOR", {}, { cachedPlayerDB = cachedPlayerDB, cachedEnemyDB = cachedEnemyDB, cachedMinionDB = cachedMinionDB, env = nil }) - GlobalCache.noCache = nil env.player.output.SkillDPS = fullDPS.skills env.player.output.FullDPS = fullDPS.combinedDPS env.player.output.FullDotDPS = fullDPS.TotalDotDPS @@ -134,7 +132,6 @@ function calcs.getMiscCalculator(build) return function(override, accelerate) local env, cachedPlayerDB, cachedEnemyDB, cachedMinionDB = calcs.initEnv(build, "CALCULATOR", override) - GlobalCache.noCache = true -- we need to preserve the override somewhere for use by possible trigger-based build-outs with overrides env.override = override calcs.perform(env) @@ -148,7 +145,6 @@ function calcs.getMiscCalculator(build) env.player.output.FullDPS = fullDPS.combinedDPS env.player.output.FullDotDPS = fullDPS.TotalDotDPS end - GlobalCache.noCache = nil return env.player.output end, baseOutput end @@ -208,7 +204,7 @@ function calcs.calcFullDPS(build, mode, override, specEnv) -- calc defences extra part should only run on the last skill of FullDPS local numActiveSkillInFullDPS = 0 for _, activeSkill in ipairs(fullEnv.player.activeSkillList) do - if activeSkill.socketGroup and activeSkill.socketGroup.includeInFullDPS and not GlobalCache.excludeFullDpsList[cacheSkillUUID(activeSkill, fullEnv)] then + if activeSkill.socketGroup and activeSkill.socketGroup.includeInFullDPS then local activeSkillCount, enabled = getActiveSkillCount(activeSkill) if enabled then numActiveSkillInFullDPS = numActiveSkillInFullDPS + 1 @@ -218,19 +214,13 @@ function calcs.calcFullDPS(build, mode, override, specEnv) GlobalCache.numActiveSkillInFullDPS = 0 for _, activeSkill in ipairs(fullEnv.player.activeSkillList) do - if activeSkill.socketGroup and activeSkill.socketGroup.includeInFullDPS and not GlobalCache.excludeFullDpsList[cacheSkillUUID(activeSkill, fullEnv)] then + if activeSkill.socketGroup and activeSkill.socketGroup.includeInFullDPS then local activeSkillCount, enabled = getActiveSkillCount(activeSkill) if enabled then GlobalCache.numActiveSkillInFullDPS = GlobalCache.numActiveSkillInFullDPS + 1 - local cachedData = GlobalCache.cachedData[mode][cacheSkillUUID(activeSkill, fullEnv)] - if cachedData and next(override) == nil and not GlobalCache.noCache then - usedEnv = cachedData.Env - activeSkill = usedEnv.player.mainSkill - else - fullEnv.player.mainSkill = activeSkill - calcs.perform(fullEnv, (GlobalCache.numActiveSkillInFullDPS ~= numActiveSkillInFullDPS)) - usedEnv = fullEnv - end + fullEnv.player.mainSkill = activeSkill + calcs.perform(fullEnv, (GlobalCache.numActiveSkillInFullDPS ~= numActiveSkillInFullDPS)) + usedEnv = fullEnv local minionName = nil if activeSkill.minion or usedEnv.minion then if usedEnv.minion.output.TotalDPS and usedEnv.minion.output.TotalDPS > 0 then @@ -417,7 +407,7 @@ function calcs.buildActiveSkill(env, mode, skill, limitedProcessingFlags) if cacheSkillUUID(activeSkill, fullEnv) == cacheSkillUUID(skill, env) then fullEnv.player.mainSkill = activeSkill fullEnv.player.mainSkill.skillData.limitedProcessing = limitedProcessingFlags and limitedProcessingFlags[cacheSkillUUID(activeSkill, fullEnv)] - calcs.perform(fullEnv) + calcs.perform(fullEnv, true) return end end @@ -433,9 +423,7 @@ function calcs.buildOutput(build, mode) local output = env.player.output -- Build output across all skills added to FullDPS skills - GlobalCache.noCache = true - local fullDPS = calcs.calcFullDPS(build, "CACHE", {}, { cachedPlayerDB = cachedPlayerDB, cachedEnemyDB = cachedEnemyDB, cachedMinionDB = cachedMinionDB, env = nil }) - GlobalCache.noCache = nil + local fullDPS = calcs.calcFullDPS(build, "CALCULATOR", {}, { cachedPlayerDB = cachedPlayerDB, cachedEnemyDB = cachedEnemyDB, cachedMinionDB = cachedMinionDB, env = nil }) -- Add Full DPS data to main `env` env.player.output.SkillDPS = fullDPS.skills @@ -445,13 +433,13 @@ function calcs.buildOutput(build, mode) if mode == "MAIN" then for _, skill in ipairs(env.player.activeSkillList) do local uuid = cacheSkillUUID(skill, env) - if not GlobalCache.cachedData["CACHE"][uuid] then - calcs.buildActiveSkill(env, "CACHE", skill) + if not GlobalCache.cachedData[mode][uuid] then + calcs.buildActiveSkill(env, mode, skill) end - if GlobalCache.cachedData["CACHE"][uuid] then + if GlobalCache.cachedData[mode][uuid] then output.EnergyShieldProtectsMana = env.modDB:Flag(nil, "EnergyShieldProtectsMana") for pool, costResource in pairs({["LifeUnreserved"] = "LifeCost", ["ManaUnreserved"] = "ManaCost", ["Rage"] = "RageCost", ["EnergyShield"] = "ESCost"}) do - local cachedCost = GlobalCache.cachedData["CACHE"][uuid].Env.player.output[costResource] + local cachedCost = GlobalCache.cachedData[mode][uuid].Env.player.output[costResource] if cachedCost then local totalPool = (output.EnergyShieldProtectsMana and costResource == "ManaCost" and output["EnergyShield"] or 0) + (output[pool] or 0) if totalPool < cachedCost then @@ -461,7 +449,7 @@ function calcs.buildOutput(build, mode) end end for pool, costResource in pairs({["LifeUnreservedPercent"] = "LifePercentCost", ["ManaUnreservedPercent"] = "ManaPercentCost"}) do - local cachedCost = GlobalCache.cachedData["CACHE"][uuid].Env.player.output[costResource] + local cachedCost = GlobalCache.cachedData[mode][uuid].Env.player.output[costResource] if cachedCost then if (output[pool] or 0) < cachedCost then output[costResource.."PercentCostWarning"] = output[costResource.."PercentCostWarning"] or {} diff --git a/src/Modules/Common.lua b/src/Modules/Common.lua index 89fefe1f91..62a8e9aae9 100644 --- a/src/Modules/Common.lua +++ b/src/Modules/Common.lua @@ -769,15 +769,7 @@ end -- Global Cache related function cacheData(uuid, env) - local mode = env.mode - if mode == "CALCULATOR" then return end - - -- If we previously had global data, we are about to over-ride it, set tables to `nil` for Lua Garbage Collection - if GlobalCache.cachedData[mode][uuid] then - GlobalCache.cachedData[mode][uuid].ActiveSkill = nil - GlobalCache.cachedData[mode][uuid].Env = nil - end - GlobalCache.cachedData[mode][uuid] = { + GlobalCache.cachedData[env.mode][uuid] = { Name = env.player.mainSkill.activeEffect.grantedEffect.name, Speed = env.player.output.Speed, HitSpeed = env.player.output.HitSpeed, @@ -795,49 +787,11 @@ function cacheData(uuid, env) } end --- Add an entry for a fabricated skill (e.g., Mirage Archers) --- to be deleted if it's not longer needed -function addDeleteGroupEntry(name) - if not GlobalCache.deleteGroup[name] then - GlobalCache.deleteGroup[name] = true - end -end - --- Remove an entry from the "to be deleted" list --- because it is still needed -function removeDeleteGroupEntry(name) - if GlobalCache.deleteGroup[name] then - GlobalCache.deleteGroup[name] = nil - end -end - --- Delete a skill-group entry from the skill list if it has --- been marked for deletion and nothing over-wrote that -function deleteFabricatedGroup(skillsTab) - for index, socketGroup in ipairs(skillsTab.controls.groupList.list) do - if GlobalCache.deleteGroup[socketGroup.label] then - t_remove(skillsTab.controls.groupList.list, index) - if skillsTab.displayGroup == socketGroup then - skillsTab:SetDisplayGroup() - end - skillsTab:AddUndoState() - skillsTab.build.buildFlag = true - skillsTab.controls.groupList.selValue = nil - wipeTable(GlobalCache.deleteGroup) - break - end - end -end - -- Wipe all the tables associated with Global Cache function wipeGlobalCache() wipeTable(GlobalCache.cachedData.MAIN) wipeTable(GlobalCache.cachedData.CALCS) wipeTable(GlobalCache.cachedData.CALCULATOR) - wipeTable(GlobalCache.cachedData.CACHE) - wipeTable(GlobalCache.excludeFullDpsList) - wipeTable(GlobalCache.deleteGroup) - GlobalCache.noCache = nil end -- Check if a specific named gem is enabled in a socket group belonging to a skill