Skip to content

Commit

Permalink
Split calc defence and only run ehp calcs on first pass of full dps (#…
Browse files Browse the repository at this point in the history
…5773)

* split calc defence and only run ehp calcs on first pass of full dps

* fix whitespace

* increment skill count only if the skill is enabled
  • Loading branch information
Regisle committed Apr 5, 2023
1 parent 02e84ae commit 5f9c384
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
12 changes: 11 additions & 1 deletion src/Modules/CalcDefence.lua
Expand Up @@ -239,7 +239,7 @@ function calcs.reducePoolsByDamage(poolTable, damageTable, actor)
}
end

-- Performs all defensive calculations
-- Performs all ingame and related defensive calculations
function calcs.defence(env, actor)
local modDB = actor.modDB
local enemyDB = actor.enemy.modDB
Expand Down Expand Up @@ -1152,6 +1152,16 @@ function calcs.defence(env, actor)
for _, ailment in ipairs(data.ailmentTypeList) do
output["Self"..ailment.."Effect"] = calcLib.mod(modDB, nil, "Self"..ailment.."Effect") * (modDB:Flag(nil, "Condition:"..ailment.."edSelf") and calcLib.mod(modDB, nil, "Enemy"..ailment.."Effect") or calcLib.mod(enemyDB, nil, "Enemy"..ailment.."Effect")) * 100
end
end

-- Performs all extra defensive calculations ( eg EHP, maxHit )
function calcs.buildDefenceEstimations(env, actor)
local modDB = actor.modDB
local enemyDB = actor.enemy.modDB
local output = actor.output
local breakdown = actor.breakdown

local condList = modDB.conditions

--Enemy damage input and modifications
do
Expand Down
12 changes: 10 additions & 2 deletions src/Modules/CalcPerform.lua
Expand Up @@ -1179,10 +1179,12 @@ end
-- 8. Processes buffs and debuffs
-- 9. Processes charges and misc buffs (doActorMisc)
-- 10. Calculates defence and offence stats (calcs.defence, calcs.offence)
function calcs.perform(env, avoidCache)
function calcs.perform(env, avoidCache, fullDPSSkipEHP)
local avoidCache = avoidCache or false
local modDB = env.modDB
local enemyDB = env.enemyDB

local fullDPSSkipEHP = fullDPSSkipEHP or false

-- Merge keystone modifiers
env.keystonesAdded = { }
Expand Down Expand Up @@ -2728,7 +2730,7 @@ function calcs.perform(env, avoidCache)

-- Make a copy of this skill so we can add new modifiers to the copy affected by Mirage Archers
local newSkill, newEnv = calcs.copyActiveSkill(env, calcMode, usedSkill)

-- Add new modifiers to new skill (which already has all the old skill's modifiers)
newSkill.skillModList:NewMod("Damage", "MORE", moreDamage, "Mirage Archer", env.player.mainSkill.ModFlags, env.player.mainSkill.KeywordFlags)
newSkill.skillModList:NewMod("Speed", "MORE", moreAttackSpeed, "Mirage Archer", env.player.mainSkill.ModFlags, env.player.mainSkill.KeywordFlags)
Expand Down Expand Up @@ -3428,13 +3430,19 @@ function calcs.perform(env, avoidCache)

-- Defence/offence calculations
calcs.defence(env, env.player)
if not fullDPSSkipEHP then
calcs.buildDefenceEstimations(env, env.player)
end
calcs.offence(env, env.player, env.player.mainSkill)

if env.minion then
doActorLifeMana(env.minion)
doActorLifeManaReservation(env.minion)

calcs.defence(env, env.minion)
if not fullDPSSkipEHP then -- main.build.calcsTab.input.showMinion and -- should be disabled unless "calcsTab.input.showMinion" is true
calcs.buildDefenceEstimations(env, env.minion)
end
calcs.offence(env, env.minion, env.minion.mainSkill)
end

Expand Down
4 changes: 2 additions & 2 deletions src/Modules/Calcs.lua
Expand Up @@ -203,9 +203,9 @@ 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 isExcludedFromFullDps(activeSkill) then
GlobalCache.numActiveSkillInFullDPS = GlobalCache.numActiveSkillInFullDPS + 1
local activeSkillCount, enabled = getActiveSkillCount(activeSkill)
if enabled then
GlobalCache.numActiveSkillInFullDPS = GlobalCache.numActiveSkillInFullDPS + 1
local cachedData = getCachedData(activeSkill, mode)
if cachedData and next(override) == nil and not GlobalCache.noCache then
usedEnv = cachedData.Env
Expand All @@ -217,7 +217,7 @@ function calcs.calcFullDPS(build, mode, override, specEnv)
GlobalCache.noCache = nil
end
fullEnv.player.mainSkill = activeSkill
calcs.perform(fullEnv, true)
calcs.perform(fullEnv, true, (GlobalCache.numActiveSkillInFullDPS ~= 1))
usedEnv = fullEnv
GlobalCache.noCache = forceCache
end
Expand Down

0 comments on commit 5f9c384

Please sign in to comment.